Index: trunk/minix/commands/i386/Makefile
===================================================================
--- trunk/minix/commands/i386/Makefile	(revision 9)
+++ 	(revision )
@@ -1,27 +1,0 @@
-# Makefile for commands/i386.
-
-CFLAGS	= -D_MINIX -D_POSIX_SOURCE
-CCLD	= $(CC) -i $(CFLAGS)
-MAKE	= exec make -$(MAKEFLAGS)
-CC = exec cc
-
-all::	acd
-
-acd:	acd.c
-	$(CCLD) -o $@ -DARCH=\"`arch`\" -DDESCR=\"/usr/lib/descr\" $?
-	install -S 50kw $@
-
-install::	/usr/bin/acd /usr/bin/cc /usr/bin/m2 /usr/bin/pc
-
-/usr/bin/acd:	acd
-	install -cs -o bin $? $@
-
-/usr/bin/cc /usr/bin/m2 /usr/bin/pc:	/usr/bin/acd
-	install -l $? $@
-
-clean::
-	rm -rf a.out core acd
-
-all install clean::
-	cd asmconv && $(MAKE) $@
-	cd mtools-3.9.7 && $(MAKE) $@
Index: trunk/minix/commands/i386/acd.c
===================================================================
--- trunk/minix/commands/i386/acd.c	(revision 9)
+++ 	(revision )
@@ -1,2701 +1,0 @@
-/*	acd 1.10 - A compiler driver			Author: Kees J. Bot
- *								7 Jan 1993
- * Needs about 25kw heap + stack.
- */
-char version[] = "1.9";
-
-#define nil 0
-#define _POSIX_SOURCE	1
-#include <sys/types.h>
-#include <stdio.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <signal.h>
-#include <errno.h>
-#include <ctype.h>
-#include <assert.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-
-#ifndef LIB
-#define LIB	"/usr/lib"	/* Default library directory. */
-#endif
-
-#define arraysize(a)	(sizeof(a) / sizeof((a)[0]))
-#define arraylimit(a)	((a) + arraysize(a))
-
-char *program;		/* Call name. */
-
-int verbose= 0;		/* -v0: Silent.
-			 * -v1: Show abbreviated pass names.
-			 * -v2: Show executed UNIX commands.
-			 * -v3: Show executed ACD commands.
-			 * -v4: Show descr file as it is read.
-			 */
-
-int action= 2;		/*   0: An error occured, don't do anything anymore.
-			 *   1: (-vn) Do not execute, play-act.
-			 *   2: Execute UNIX commands.
-			 */
-
-void report(char *label)
-{
-	if (label == nil || label[0] == 0) {
-		fprintf(stderr, "%s: %s\n", program, strerror(errno));
-	} else {
-		fprintf(stderr, "%s: %s: %s\n",
-					program, label, strerror(errno));
-	}
-	action= 0;
-}
-
-void quit(int exit_code);
-
-void fatal(char *label)
-{
-	report(label);
-	quit(-1);
-}
-
-size_t heap_chunks= 0;
-
-void *allocate(void *mem, size_t size)
-/* Safe malloc/realloc.  (I have heard that one can call realloc with a
- * null first argument with the effect below, but that is of course to
- * ridiculous to believe.)
- */
-{
-	assert(size > 0);
-
-	if (mem != nil) {
-		mem= realloc(mem, size);
-	} else {
-		mem= malloc(size);
-		heap_chunks++;
-	}
-	if (mem == nil) fatal(nil);
-	return mem;
-}
-
-void deallocate(void *mem)
-{
-	if (mem != nil) {
-		free(mem);
-		heap_chunks--;
-	}
-}
-
-char *copystr(const char *s)
-{
-	char *c;
-	c= allocate(nil, (strlen(s)+1) * sizeof(*c));
-	strcpy(c, s);
-	return c;
-}
-
-/* Every object, list, letter, or variable, is made with cells. */
-typedef struct cell {
-	unsigned short	refc;		/* Reference count. */
-	char		type;		/* Type of object. */
-	unsigned char	letter;		/* Simply a letter. */
-	char		*name;		/* Name of a word. */
-	struct cell	*hash;		/* Hash chain. */
-	struct cell	*car, *cdr;	/* To form lists. */
-
-/* For a word: */
-#	define	value	car		/* Value of a variable. */
-#	define	base	cdr		/* Base-name in transformations. */
-#	define	suffix	cdr		/* Suffix in a treat-as. */
-#	define	flags	letter		/* Special flags. */
-
-/* A substitution: */
-#	define	subst	car
-
-} cell_t;
-
-typedef enum type {
-	CELL,		/* A list cell. */
-	STRING,		/* To make a list of characters and substs. */
-	SUBST,		/* Variable to substitute. */
-	/* Unique objects. */
-	LETTER,		/* A letter. */
-	WORD,		/* A string collapses to a word. */
-	EQUALS,		/* = operator, etc. */
-	OPEN,
-	CLOSE,
-	PLUS,
-	MINUS,
-	STAR,
-	INPUT,
-	OUTPUT,
-	WHITE,
-	COMMENT,
-	SEMI,
-	EOLN,
-	N_TYPES		/* number of different types */
-} type_t;
-
-#define is_unique(type) ((type) >= LETTER)
-
-/* Flags on a word. */
-#define W_SET		0x01	/* Not undefined, e.g. assigned to. */
-#define W_RDONLY	0x02	/* Read only. */
-#define W_LOCAL		0x04	/* Local variable, immediate substitution. */
-#define W_TEMP		0x08	/* Name of a temporary file, delete on quit. */
-#define W_SUFF		0x10	/* Has a suffix set on it. */
-
-void princhar(int c)
-/* Print a character, escaped if important to the shell *within* quotes. */
-{
-	if (strchr("\\'\"<>();~$^&*|{}[]?", c) != nil) fputc('\\', stdout);
-	putchar(c);
-}
-
-void prinstr(char *s)
-/* Print a string, in quotes if the shell might not like it. */
-{
-	int q= 0;
-	char *s2= s;
-
-	while (*s2 != 0)
-		if (strchr("~`$^&*()=\\|[]{};'\"<>?", *s2++) != nil) q= 1;
-
-	if (q) fputc('"', stdout);
-	while (*s != 0) princhar(*s++);
-	if (q) fputc('"', stdout);
-}
-
-void prin2(cell_t *p);
-
-void prin1(cell_t *p)
-/* Print a cell structure for debugging purposes. */
-{
-	if (p == nil) {
-		printf("(\b(\b()\b)\b)");
-		return;
-	}
-
-	switch (p->type) {
-	case CELL:
-		printf("(\b(\b(");
-		prin2(p);
-		printf(")\b)\b)");
-		break;
-	case STRING:
-		printf("\"\b\"\b\"");
-		prin2(p);
-		printf("\"\b\"\b\"");
-		break;
-	case SUBST:
-		printf("$\b$\b${%s}", p->subst->name);
-		break;
-	case LETTER:
-		princhar(p->letter);
-		break;
-	case WORD:
-		prinstr(p->name);
-		break;
-	case EQUALS:
-		printf("=\b=\b=");
-		break;
-	case PLUS:
-		printf("+\b+\b+");
-		break;
-	case MINUS:
-		printf("-\b-\b-");
-		break;
-	case STAR:
-		printf("*\b*\b*");
-		break;
-	case INPUT:
-		printf(verbose >= 3 ? "<\b<\b<" : "<");
-		break;
-	case OUTPUT:
-		printf(verbose >= 3 ? ">\b>\b>" : ">");
-		break;
-	default:
-		assert(0);
-	}
-}
-
-void prin2(cell_t *p)
-/* Print a list for debugging purposes. */
-{
-	while (p != nil && p->type <= STRING) {
-		prin1(p->car);
-
-		if (p->type == CELL && p->cdr != nil) fputc(' ', stdout);
-
-		p= p->cdr;
-	}
-	if (p != nil) prin1(p);		/* Dotted pair? */
-}
-
-void prin1n(cell_t *p) { prin1(p); fputc('\n', stdout); }
-
-void prin2n(cell_t *p) { prin2(p); fputc('\n', stdout); }
-
-/* A program is consists of a series of lists at a certain indentation level. */
-typedef struct program {
-	struct program	*next;
-	cell_t		*file;		/* Associated description file. */
-	unsigned	indent;		/* Line indentation level. */
-	unsigned	lineno;		/* Line number where this is found. */
-	cell_t		*line;		/* One line of tokens. */
-} program_t;
-
-program_t *pc;		/* Program Counter (what else?) */
-program_t *nextpc;	/* Next line to execute. */
-
-cell_t *oldcells;	/* Keep a list of old cells, don't deallocate. */
-
-cell_t *newcell(void)
-/* Make a new empty cell. */
-{
-	cell_t *p;
-
-	if (oldcells != nil) {
-		p= oldcells;
-		oldcells= p->cdr;
-		heap_chunks++;
-	} else {
-		p= allocate(nil, sizeof(*p));
-	}
-
-	p->refc= 0;
-	p->type= CELL;
-	p->letter= 0;
-	p->name= nil;
-	p->car= nil;
-	p->cdr= nil;
-	return p;
-}
-
-#define N_CHARS		(1 + (unsigned char) -1)
-#define HASHDENSE	0x400
-
-cell_t *oblist[HASHDENSE + N_CHARS + N_TYPES];
-
-unsigned hashfun(cell_t *p)
-/* Use a blender on a cell. */
-{
-	unsigned h;
-	char *name;
-
-	switch (p->type) {
-	case WORD:
-		h= 0;
-		name= p->name;
-		while (*name != 0) h= (h * 0x1111) + *name++;
-		return h % HASHDENSE;
-	case LETTER:
-		return HASHDENSE + p->letter;
-	default:
-		return HASHDENSE + N_CHARS + p->type;
-	}
-}
-
-cell_t *search(cell_t *p, cell_t ***hook)
-/* Search for *p, return the one found.  *hook may be used to insert or
- * delete.
- */
-{
-	cell_t *sp;
-
-	sp= *(*hook= &oblist[hashfun(p)]);
-
-	if (p->type == WORD) {
-		/* More than one name per hash slot. */
-		int cmp= 0;
-
-		while (sp != nil && (cmp= strcmp(p->name, sp->name)) > 0)
-			sp= *(*hook= &sp->hash);
-
-		if (cmp != 0) sp= nil;
-	}
-	return sp;
-}
-
-void dec(cell_t *p)
-/* Decrease the number of references to p, if zero delete and recurse. */
-{
-	if (p == nil || --p->refc > 0) return;
-
-	if (is_unique(p->type)) {
-		/* Remove p from the oblist. */
-		cell_t *o, **hook;
-
-		o= search(p, &hook);
-
-		if (o == p) {
-			/* It's there, remove it. */
-			*hook= p->hash;
-			p->hash= nil;
-		}
-
-		if (p->type == WORD && (p->flags & W_TEMP)) {
-			/* A filename to remove. */
-			if (verbose >= 2) {
-				printf("rm -f ");
-				prinstr(p->name);
-				fputc('\n', stdout);
-			}
-			if (unlink(p->name) < 0 && errno != ENOENT)
-				report(p->name);
-		}
-	}
-	deallocate(p->name);
-	dec(p->car);
-	dec(p->cdr);
-	p->cdr= oldcells;
-	oldcells= p;
-	heap_chunks--;
-}
-
-cell_t *inc(cell_t *p)
-/* Increase the number of references to p. */
-{
-	cell_t *o, **hook;
-
-	if (p == nil) return nil;
-
-	if (++p->refc > 1 || !is_unique(p->type)) return p;
-
-	/* First appearance, put p on the oblist. */
-	o= search(p, &hook);
-
-	if (o == nil) {
-		/* Not there yet, add it. */
-		p->hash= *hook;
-		*hook= p;
-	} else {
-		/* There is another object already there with the same info. */
-		o->refc++;
-		dec(p);
-		p= o;
-	}
-	return p;
-}
-
-cell_t *go(cell_t *p, cell_t *field)
-/* Often happening: You've got p, you want p->field. */
-{
-	field= inc(field);
-	dec(p);
-	return field;
-}
-
-cell_t *cons(type_t type, cell_t *p)
-/* P is to be added to a list (or a string). */
-{
-	cell_t *l= newcell();
-	l->type= type;
-	l->refc++;
-	l->car= p;
-	return l;
-}
-
-cell_t *append(type_t type, cell_t *p)
-/* P is to be appended to a list (or a string). */
-{
-	return p == nil || p->type == type ? p : cons(type, p);
-}
-
-cell_t *findnword(char *name, size_t n)
-/* Find the word with the given name of length n. */
-{
-	cell_t *w= newcell();
-	w->type= WORD;
-	w->name= allocate(nil, (n+1) * sizeof(*w->name));
-	memcpy(w->name, name, n);
-	w->name[n]= 0;
-	return inc(w);
-}
-
-cell_t *findword(char *name)
-/* Find the word with the given null-terminated name. */
-{
-	return findnword(name, strlen(name));
-}
-
-void quit(int exstat)
-/* Remove all temporary names, then exit. */
-{
-	cell_t **op, *p, *v, *b;
-	size_t chunks;
-
-	/* Remove cycles, like X = X. */
-	for (op= oblist; op < oblist + HASHDENSE; op++) {
-		p= *op;
-		while (p != nil) {
-			if (p->value != nil || p->base != nil) {
-				v= p->value;
-				b= p->base;
-				p->value= nil;
-				p->base= nil;
-				p= *op;
-				dec(v);
-				dec(b);
-			} else {
-				p= p->hash;
-			}
-		}
-	}
-	chunks= heap_chunks;
-
-	/* Something may remain on an early quit: tempfiles. */
-	for (op= oblist; op < oblist + HASHDENSE; op++) {
-
-		while (*op != nil) { (*op)->refc= 1; dec(*op); }
-	}
-
-	if (exstat != -1 && chunks > 0) {
-		fprintf(stderr,
-			"%s: internal fault: %d chunks still on the heap\n",
-						program, chunks);
-	}
-	exit(exstat);
-}
-
-void interrupt(int sig)
-{
-	signal(sig, interrupt);
-	if (verbose >= 2) write(1, "# interrupt\n", 12);
-	action= 0;
-}
-
-int extalnum(int c)
-/* Uppercase, lowercase, digit, underscore or anything non-American. */
-{
-	return isalnum(c) || c == '_' || c >= 0200;
-}
-
-char *descr;		/* Name of current description file. */
-FILE *dfp;		/* Open description file. */
-int dch;		/* Input character. */
-unsigned lineno;	/* Line number in file. */
-unsigned indent;	/* Indentation level. */
-
-void getdesc(void)
-{
-	if (dch == EOF) return;
-
-	if (dch == '\n') { lineno++; indent= 0; }
-
-	if ((dch = getc(dfp)) == EOF && ferror(dfp)) fatal(descr);
-
-	if (dch == 0) {
-		fprintf(stderr, "%s: %s is a binary file.\n", program, descr);
-		quit(-1);
-	}
-}
-
-#define E_BASH		0x01	/* Escaped by backslash. */
-#define E_QUOTE		0x02	/* Escaped by double quote. */
-#define E_SIMPLE	0x04	/* More simple characters? */
-
-cell_t *get_token(void)
-/* Read one token from the description file. */
-{
-	int whitetype= 0;
-	static int escape= 0;
-	cell_t *tok;
-	char *name;
-	int n, i;
-
-	if (escape & E_SIMPLE) {
-		/* More simple characters?  (Note: performance hack.) */
-		if (isalnum(dch)) {
-			tok= newcell();
-			tok->type= LETTER;
-			tok->letter= dch;
-			getdesc();
-			return inc(tok);
-		}
-		escape&= ~E_SIMPLE;
-	}
-
-	/* Gather whitespace. */
-	for (;;) {
-		if (dch == '\\' && whitetype == 0) {
-			getdesc();
-			if (isspace(dch)) {
-				/* \ whitespace: remove. */
-				do {
-					getdesc();
-					if (dch == '#' && !(escape & E_QUOTE)) {
-						/* \ # comment */
-						do
-							getdesc();
-						while (dch != '\n'
-								&& dch != EOF);
-					}
-				} while (isspace(dch));
-				continue;
-			}
-			escape|= E_BASH;	/* Escaped character. */
-		}
-
-		if (escape != 0) break;
-
-		if (dch == '#' && (indent == 0 || whitetype != 0)) {
-			/* # Comment. */
-			do getdesc(); while (dch != '\n' && dch != EOF);
-			whitetype= COMMENT;
-			break;
-		}
-
-		if (!isspace(dch) || dch == '\n' || dch == EOF) break;
-
-		whitetype= WHITE;
-
-		indent++;
-		if (dch == '\t') indent= (indent + 7) & ~7;
-
-		getdesc();
-	}
-
-	if (dch == EOF) return nil;
-
-	/* Make a token. */
-	tok= newcell();
-
-	if (whitetype != 0) {
-		tok->type= whitetype;
-		return inc(tok);
-	}
-
-	if (!(escape & E_BASH) && dch == '"') {
-		getdesc();
-		if (!(escape & E_QUOTE)) {
-			/* Start of a string, signal this with a string cell. */
-			escape|= E_QUOTE;
-			tok->type= STRING;
-			return inc(tok);
-		} else {
-			/* End of a string, back to normal mode. */
-			escape&= ~E_QUOTE;
-			deallocate(tok);
-			return get_token();
-		}
-	}
-
-	if (escape & E_BASH
-		|| strchr(escape & E_QUOTE ? "$" : "$=()+-*<>;\n", dch) == nil
-	) {
-		if (dch == '\n') {
-			fprintf(stderr,
-				"\"%s\", line %u: missing closing quote\n",
-				descr, lineno);
-			escape&= ~E_QUOTE;
-			action= 0;
-		}
-		if (escape & E_BASH && dch == 'n') dch= '\n';
-		escape&= ~E_BASH;
-
-		/* A simple character. */
-		tok->type= LETTER;
-		tok->letter= dch;
-		getdesc();
-		escape|= E_SIMPLE;
-		return inc(tok);
-	}
-
-	if (dch != '$') {
-		/* Single character token. */
-		switch (dch) {
-		case '=':	tok->type= EQUALS;	break;
-		case '(':	tok->type= OPEN;	break;
-		case ')':	tok->type= CLOSE;	break;
-		case '+':	tok->type= PLUS;	break;
-		case '-':	tok->type= MINUS;	break;
-		case '*':	tok->type= STAR;	break;
-		case '<':	tok->type= INPUT;	break;
-		case '>':	tok->type= OUTPUT;	break;
-		case ';':	tok->type= SEMI;	break;
-		case '\n':	tok->type= EOLN;	break;
-		}
-		getdesc();
-		return inc(tok);
-	}
-
-	/* Substitution. */
-	getdesc();
-	if (dch == EOF || isspace(dch)) {
-		fprintf(stderr, "\"%s\", line %u: Word expected after '$'\n",
-			descr, lineno);
-		action= 0;
-		deallocate(tok);
-		return get_token();
-	}
-
-	name= allocate(nil, (n= 16) * sizeof(*name));
-	i= 0;
-
-	if (dch == '{' || dch == '('  /* )} */ ) {
-		/* $(X), ${X} */
-		int lpar= dch;		/* ( */
-		int rpar= lpar == '{' ? '}' : ')';
-
-		for (;;) {
-			getdesc();
-			if (dch == rpar) { getdesc(); break; }
-			if (isspace(dch) || dch == EOF) {
-				fprintf(stderr,
-				"\"%s\", line %u: $%c unmatched, no '%c'\n",
-					descr, lineno, lpar, rpar);
-				action= 0;
-				break;
-			}
-			name[i++]= dch;
-			if (i == n)
-				name= allocate(name, (n*= 2) * sizeof(char));
-		}
-	} else
-	if (extalnum(dch)) {
-		/* $X */
-		do {
-			name[i++]= dch;
-			if (i == n)
-				name= allocate(name, (n*= 2) * sizeof(char));
-			getdesc();
-		} while (extalnum(dch));
-	} else {
-		/* $* */
-		name[i++]= dch;
-		getdesc();
-	}
-	name[i++]= 0;
-	name= allocate(name, i * sizeof(char));
-	tok->type= SUBST;
-	tok->subst= newcell();
-	tok->subst->type= WORD;
-	tok->subst->name= name;
-	tok->subst= inc(tok->subst);
-	return inc(tok);
-}
-
-typedef enum how { SUPERFICIAL, PARTIAL, FULL, EXPLODE, IMPLODE } how_t;
-
-cell_t *explode(cell_t *p, how_t how);
-
-cell_t *get_string(cell_t **pp)
-/* Get a string: A series of letters and substs.  Special tokens '=', '+', '-'
- * and '*' are also recognized if on their own.  A finished string is "exploded"
- * to a word if it consists of letters only.
- */
-{
-	cell_t *p= *pp, *s= nil, **ps= &s;
-	int quoted= 0;
-
-	while (p != nil) {
-		switch (p->type) {
-		case STRING:
-			quoted= 1;
-			dec(p);
-			break;
-		case EQUALS:
-		case PLUS:
-		case MINUS:
-		case STAR:
-		case SUBST:
-		case LETTER:
-			*ps= cons(STRING, p);
-			ps= &(*ps)->cdr;
-			break;
-		default:
-			goto got_string;
-		}
-		p= get_token();
-	}
-    got_string:
-	*pp= p;
-
-	/* A single special token must be folded up. */
-	if (!quoted && s != nil && s->cdr == nil) {
-		switch (s->car->type) {
-		case EQUALS:
-		case PLUS:
-		case MINUS:
-		case STAR:
-		case SUBST:
-			return go(s, s->car);
-		}
-	}
-
-	/* Go over the string changing '=', '+', '-', '*' to letters. */
-	for (p= s; p != nil; p= p->cdr) {
-		int c= 0;
-
-		switch (p->car->type) {
-		case EQUALS:
-			c= '='; break;
-		case PLUS:
-			c= '+'; break;
-		case MINUS:
-			c= '-'; break;
-		case STAR:
-			c= '*'; break;
-		}
-		if (c != 0) {
-			dec(p->car);
-			p->car= newcell();
-			p->car->type= LETTER;
-			p->car->letter= c;
-			p->car= inc(p->car);
-		}
-	}
-	return explode(s, SUPERFICIAL);
-}
-
-cell_t *get_list(cell_t **pp, type_t stop)
-/* Read a series of tokens upto a token of type "stop". */
-{
-	cell_t *p= *pp, *l= nil, **pl= &l;
-
-	while (p != nil && p->type != stop
-				&& !(stop == EOLN && p->type == SEMI)) {
-		switch (p->type) {
-		case WHITE:
-		case COMMENT:
-		case SEMI:
-		case EOLN:
-			dec(p);
-			p= get_token();
-			break;
-		case OPEN:
-			/* '(' words ')'. */
-			dec(p);
-			p= get_token();
-			*pl= cons(CELL, get_list(&p, CLOSE));
-			pl= &(*pl)->cdr;
-			dec(p);
-			p= get_token();
-			break;
-		case CLOSE:
-			/* Unexpected closing parenthesis. (*/
-			fprintf(stderr, "\"%s\", line %u: unmatched ')'\n",
-				descr, lineno);
-			action= 0;
-			dec(p);
-			p= get_token();
-			break;
-		case INPUT:
-		case OUTPUT:
-			*pl= cons(CELL, p);
-			pl= &(*pl)->cdr;
-			p= get_token();
-			break;
-		case STRING:
-		case EQUALS:
-		case PLUS:
-		case MINUS:
-		case STAR:
-		case LETTER:
-		case SUBST:
-			*pl= cons(CELL, get_string(&p));
-			pl= &(*pl)->cdr;
-			break;
-		default:
-			assert(0);
-		}
-	}
-
-	if (p == nil && stop == CLOSE) {
-		/* Couldn't get the closing parenthesis. */
-		fprintf(stderr, "\"%s\", lines %u-%u: unmatched '('\n",	/*)*/
-			descr, pc->lineno, lineno);
-		action= 0;
-	}
-	*pp= p;
-	return l;
-}
-
-program_t *get_line(cell_t *file)
-{
-	program_t *l;
-	cell_t *p;
-	static keep_indent= 0;
-	static unsigned old_indent= 0;
-
-	/* Skip leading whitespace to determine the indentation level. */
-	indent= 0;
-	while ((p= get_token()) != nil && p->type == WHITE) dec(p);
-
-	if (p == nil) return nil;		/* EOF */
-
-	if (p->type == EOLN) indent= old_indent;	/* Empty line. */
-
-	/* Make a program line. */
-	pc= l= allocate(nil, sizeof(*l));
-
-	l->next= nil;
-	l->file= inc(file);
-	l->indent= keep_indent ? old_indent : indent;
-	l->lineno= lineno;
-
-	l->line= get_list(&p, EOLN);
-
-	/* If the line ended in a semicolon then keep the indentation level. */
-	keep_indent= (p != nil && p->type == SEMI);
-	old_indent= l->indent;
-
-	dec(p);
-
-	if (verbose >= 4) {
-		if (l->line == nil)
-			fputc('\n', stdout);
-		else {
-			printf("%*s", (int) l->indent, "");
-			prin2n(l->line);
-		}
-	}
-	return l;
-}
-
-program_t *get_prog(void)
-/* Read the description file into core. */
-{
-	cell_t *file;
-	program_t *prog, **ppg= &prog;
-
-	descr= copystr(descr);
-
-	if (descr[0] == '-' && descr[1] == 0) {
-		/* -descr -: Read from standard input. */
-		deallocate(descr);
-		descr= copystr("stdin");
-		dfp= stdin;
-	} else {
-		char *d= descr;
-
-		if (*d == '.' && *++d == '.') d++;
-		if (*d != '/') {
-			/* -descr name: Read /usr/lib/<name>/descr. */
-
-			d= allocate(nil, sizeof(LIB) +
-					(strlen(descr) + 7) * sizeof(*d));
-			sprintf(d, "%s/%s/descr", LIB, descr);
-			deallocate(descr);
-			descr= d;
-		}
-		if ((dfp= fopen(descr, "r")) == nil) fatal(descr);
-	}
-	file= findword(descr);
-	deallocate(descr);
-	descr= file->name;
-
-	/* Preread the first character. */
-	dch= 0;
-	lineno= 1;
-	indent= 0;
-	getdesc();
-
-	while ((*ppg= get_line(file)) != nil) ppg= &(*ppg)->next;
-
-	if (dfp != stdin) (void) fclose(dfp);
-	dec(file);
-
-	return prog;
-}
-
-void makenames(cell_t ***ppr, cell_t *s, char **name, size_t i, size_t *n)
-/* Turn a string of letters and lists into words.  A list denotes a choice
- * between several paths, like a search on $PATH.
- */
-{
-	cell_t *p, *q;
-	size_t len;
-
-	/* Simply add letters, skip empty lists. */
-	while (s != nil && (s->car == nil || s->car->type == LETTER)) {
-		if (s->car != nil) {
-			if (i == *n) *name= allocate(*name,
-						(*n *= 2) * sizeof(**name));
-			(*name)[i++]= s->car->letter;
-		}
-		s= s->cdr;
-	}
-
-	/* If the end is reached then make a word out of the result. */
-	if (s == nil) {
-		**ppr= cons(CELL, findnword(*name, i));
-		*ppr= &(**ppr)->cdr;
-		return;
-	}
-
-	/* Elements of a list must be tried one by one. */
-	p= s->car;
-	s= s->cdr;
-
-	while (p != nil) {
-		if (p->type == WORD) {
-			q= p; p= nil;
-		} else {
-			assert(p->type == CELL);
-			q= p->car; p= p->cdr;
-			assert(q != nil);
-			assert(q->type == WORD);
-		}
-		len= strlen(q->name);
-		if (i + len > *n) *name= allocate(*name,
-					(*n += i + len) * sizeof(**name));
-		memcpy(*name + i, q->name, len);
-
-		makenames(ppr, s, name, i+len, n);
-	}
-}
-
-int constant(cell_t *p)
-/* See if a string has been partially evaluated to a constant so that it
- * can be imploded to a word.
- */
-{
-	while (p != nil) {
-		switch (p->type) {
-		case CELL:
-		case STRING:
-			if (!constant(p->car)) return 0;
-			p= p->cdr;
-			break;
-		case SUBST:
-			return 0;
-		default:
-			return 1;
-		}
-	}
-	return 1;
-}
-
-cell_t *evaluate(cell_t *p, how_t how);
-
-cell_t *explode(cell_t *s, how_t how)
-/* Explode a string with several choices to just one list of choices. */
-{
-	cell_t *t, *r= nil, **pr= &r;
-	size_t i, n;
-	char *name;
-	struct stat st;
-
-	if (how >= PARTIAL) {
-		/* Evaluate the string, expanding substitutions. */
-		while (s != nil) {
-			assert(s->type == STRING);
-			t= inc(s->car);
-			s= go(s, s->cdr);
-
-			t= evaluate(t, how == IMPLODE ? EXPLODE : how);
-
-			/* A list of one element becomes that element. */
-			if (t != nil && t->type == CELL && t->cdr == nil)
-				t= go(t, t->car);
-
-			/* Append the result, trying to flatten it. */
-			*pr= t;
-
-			/* Find the end of what has just been added. */
-			while ((*pr) != nil) {
-				*pr= append(STRING, *pr);
-				pr= &(*pr)->cdr;
-			}
-		}
-		s= r;
-	}
-
-	/* Is the result a simple string of constants? */
-	if (how <= PARTIAL && !constant(s)) return s;
-
-	/* Explode the string to all possible choices, by now the string is
-	 * a series of characters, words and lists of words.
-	 */
-	r= nil; pr= &r;
-	name= allocate(nil, (n= 16) * sizeof(char));
-	i= 0;
-
-	makenames(&pr, s, &name, i, &n);
-	deallocate(name);
-	assert(r != nil);
-	dec(s);
-	s= r;
-
-	/* "How" may specify that a choice must be made. */
-	if (how == IMPLODE) {
-		if (s->cdr != nil) {
-			/* More than one choice, find the file. */
-			do {
-				assert(s->car->type == WORD);
-				if (stat(s->car->name, &st) >= 0)
-					return go(r, s->car);	/* Found. */
-			} while ((s= s->cdr) != nil);
-		}
-		/* The first name is the default if nothing is found. */
-		return go(r, r->car);
-	}
-
-	/* If the result is a list of one word then return that word, otherwise
-	 * turn it into a string again unless this explode has been called
-	 * by another explode.  (Exploding a string inside a string, the joys
-	 * of recursion.)
-	 */
-	if (s->cdr == nil) return go(s, s->car);
-
-	return how >= EXPLODE ? s : cons(STRING, s);
-}
-
-void modify(cell_t **pp, cell_t *p, type_t mode)
-/* Add or remove the element p from the list *pp. */
-{
-	while (*pp != nil) {
-		*pp= append(CELL, *pp);
-
-		if ((*pp)->car == p) {
-			/* Found it, if adding then exit, else remove. */
-			if (mode == PLUS) break;
-			*pp= go(*pp, (*pp)->cdr);
-		} else
-			pp= &(*pp)->cdr;
-	}
-
-	if (*pp == nil && mode == PLUS) {
-		/* Not found, add it. */
-		*pp= cons(CELL, p);
-	} else
-		dec(p);
-}
-
-int tainted(cell_t *p)
-/* A variable is tainted (must be substituted) if either it is marked as a
- * local variable, or some subst in its value is.
- */
-{
-	if (p == nil) return 0;
-
-	switch (p->type) {
-	case CELL:
-	case STRING:
-		return tainted(p->car) || tainted(p->cdr);
-	case SUBST:
-		return p->subst->flags & W_LOCAL || tainted(p->subst->value);
-	default:
-		return 0;
-	}
-}
-
-cell_t *evaluate(cell_t *p, how_t how)
-/* Evaluate an expression, usually the right hand side of an assignment. */
-{
-	cell_t *q, *t, *r= nil, **pr= &r;
-	type_t mode;
-
-	if (p == nil) return nil;
-
-	switch (p->type) {
-	case CELL:
-		break;	/* see below */
-	case STRING:
-		return explode(p, how);
-	case SUBST:
-		if (how >= FULL || tainted(p))
-			p= evaluate(go(p, p->subst->value), how);
-		return p;
-	case EQUALS:
-		fprintf(stderr,
-			"\"%s\", line %u: Can't do nested assignments\n",
-			descr, pc->lineno);
-		action= 0;
-		dec(p);
-		return nil;
-	case LETTER:
-	case WORD:
-	case INPUT:
-	case OUTPUT:
-	case PLUS:
-	case MINUS:
-		return p;
-	default:
-		assert(0);
-	}
-
-	/* It's a list, see if there is a '*' there forcing a full expansion,
-	 * or a '+' or '-' forcing an implosive expansion.  (Yeah, right.)
-	 * Otherwise evaluate each element.
-	 */
-	q = inc(p);
-	while (p != nil) {
-		if ((t= p->car) != nil) {
-			if (t->type == STAR) {
-				if (how < FULL) how= FULL;
-				dec(q);
-				*pr= evaluate(go(p, p->cdr), how);
-				return r;
-			}
-			if (how>=FULL && (t->type == PLUS || t->type == MINUS))
-				break;
-		}
-
-		t= evaluate(inc(t), how);
-		assert(p->type == CELL);
-		p= go(p, p->cdr);
-
-		if (how >= FULL) {
-			/* Flatten the list. */
-			*pr= t;
-		} else {
-			/* Keep the nested list structure. */
-			*pr= cons(CELL, t);
-		}
-
-		/* Find the end of what has just been added. */
-		while ((*pr) != nil) {
-			*pr= append(CELL, *pr);
-			pr= &(*pr)->cdr;
-		}
-	}
-
-	if (p == nil) {
-		/* No PLUS or MINUS: done. */
-		dec(q);
-		return r;
-	}
-
-	/* A PLUS or MINUS, reevaluate the original list implosively. */
-	if (how < IMPLODE) {
-		dec(r);
-		dec(p);
-		return evaluate(q, IMPLODE);
-	}
-	dec(q);
-
-	/* Execute the PLUSes and MINUSes. */
-	while (p != nil) {
-		t= inc(p->car);
-		p= go(p, p->cdr);
-
-		if (t != nil && (t->type == PLUS || t->type == MINUS)) {
-			/* Change the add/subtract mode. */
-			mode= t->type;
-			dec(t);
-			continue;
-		}
-
-		t= evaluate(t, IMPLODE);
-
-		/* Add or remove all elements of t to/from r. */
-		while (t != nil) {
-			if (t->type == CELL) {
-				modify(&r, inc(t->car), mode);
-			} else {
-				modify(&r, t, mode);
-				break;
-			}
-			t= go(t, t->cdr);
-		}
-	}
-	return r;
-}
-
-/* An ACD program can be in three phases: Initialization (the first run
- * of the program), argument scanning, and compilation.
- */
-typedef enum phase { INIT, SCAN, COMPILE } phase_t;
-
-phase_t phase;
-
-typedef struct rule {		/* Transformation rule. */
-	struct rule	*next;
-	char		type;		/* arg, transform, combine */
-	char		flags;
-	unsigned short	npaths;		/* Number of paths running through. */
-#	define	match	from		/* Arg matching strings. */
-	cell_t		*from;		/* Transformation source suffixe(s) */
-	cell_t		*to;		/* Destination suffix. */
-	cell_t		*wait;		/* Files waiting to be transformed. */
-	program_t	*prog;		/* Program to execute. */
-	struct rule	*path;		/* Transformation path. */
-} rule_t;
-
-typedef enum ruletype { ARG, PREFER, TRANSFORM, COMBINE } ruletype_t;
-
-#define R_PREFER	0x01		/* A preferred transformation. */
-
-rule_t *rules= nil;
-
-void newrule(ruletype_t type, cell_t *from, cell_t *to)
-/* Make a new rule cell. */
-{
-	rule_t *r= nil, **pr= &rules;
-
-	/* See if there is a rule with the same suffixes, probably a matching
-	 * transform and prefer, or a re-execution of the same arg command.
-	 */
-	while ((r= *pr) != nil) {
-		if (r->from == from && r->to == to) break;
-		pr= &r->next;
-	}
-
-	if (*pr == nil) {
-		/* Add a new rule. */
-		*pr= r= allocate(nil, sizeof(*r));
-
-		r->next= nil;
-		r->type= type;
-		r->flags= 0;
-		r->from= r->to= r->wait= nil;
-		r->path= nil;
-	}
-	if (type == TRANSFORM) r->type= TRANSFORM;
-	if (type == PREFER) r->flags|= R_PREFER;
-	if (type != PREFER) r->prog= pc;
-	dec(r->from); r->from= from;
-	dec(r->to); r->to= to;
-}
-
-int talk(void)
-/* True if verbose and if so indent what is to come. */
-{
-	if (verbose < 3) return 0;
-	printf("%*s", (int) pc->indent, "");
-	return 1;
-}
-
-void unix_exec(cell_t *c)
-/* Execute the list of words p as a UNIX command. */
-{
-	cell_t *v, *a;
-	int fd[2];
-	int *pf;
-	char **argv;
-	int i, n;
-	int r, pid, status;
-
-	if (action == 0) return;	/* Error mode. */
-
-	if (talk() || verbose >= 2) prin2n(c);
-
-	fd[0]= fd[1]= -1;
-
-	argv= allocate(nil, (n= 16) * sizeof(*argv));
-	i= 0;
-
-	/* Gather argv[] and scan for I/O redirection. */
-	for (v= c; v != nil; v= v->cdr) {
-		a= v->car;
-		pf= nil;
-		if (a->type == INPUT) pf= &fd[0];
-		if (a->type == OUTPUT) pf= &fd[1];
-
-		if (pf == nil) {
-			/* An argument. */
-			argv[i++]= a->name;
-			if (i==n) argv= allocate(argv, (n*= 2) * sizeof(*argv));
-			continue;
-		}
-		/* I/O redirection. */
-		if ((v= v->cdr) == nil || (a= v->car)->type != WORD) {
-			fprintf(stderr,
-			"\"%s\", line %u: I/O redirection without a file\n",
-				descr, pc->lineno);
-			action= 0;
-			if (v == nil) break;
-		}
-		if (*pf >= 0) close(*pf);
-
-		if (action >= 2
-			&& (*pf= open(a->name, pf == &fd[0] ? O_RDONLY
-				: O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0
-		) {
-			report(a->name);
-			action= 0;
-		}
-	}
-	argv[i]= nil;
-
-	if (i >= 0 && action > 0 && verbose == 1) {
-		char *name= strrchr(argv[0], '/');
-
-		if (name == nil) name= argv[0]; else name++;
-
-		printf("%s\n", name);
-	}
-	if (i >= 0 && action >= 2) {
-		/* Really execute the command. */
-		fflush(stdout);
-		switch (pid= fork()) {
-		case -1:
-			fatal("fork()");
-		case 0:
-			if (fd[0] >= 0) { dup2(fd[0], 0); close(fd[0]); }
-			if (fd[1] >= 0) { dup2(fd[1], 1); close(fd[1]); }
-			execvp(argv[0], argv);
-			report(argv[0]);
-			exit(-1);
-		}
-	}
-	if (fd[0] >= 0) close(fd[0]);
-	if (fd[1] >= 0) close(fd[1]);
-
-	if (i >= 0 && action >= 2) {
-		/* Wait for the command to terminate. */
-		while ((r= wait(&status)) != pid && (r >= 0 || errno == EINTR));
-
-		if (status != 0) {
-			int sig= WTERMSIG(status);
-
-			if (!WIFEXITED(status)
-					&& sig != SIGINT && sig != SIGPIPE) {
-				fprintf(stderr, "%s: %s: Signal %d%s\n",
-					program, argv[0], sig,
-					status & 0x80 ? " - core dumped" : "");
-			}
-			action= 0;
-		}
-	}
-	deallocate(argv);
-}
-
-/* Special read-only variables ($*) and lists. */
-cell_t *V_star, **pV_star;
-cell_t *L_files, **pL_files= &L_files;
-cell_t *V_in, *V_out, *V_stop, *L_args, *L_predef;
-
-typedef enum exec { DOIT, DONT } exec_t;
-
-void execute(exec_t how, unsigned indent);
-
-int equal(cell_t *p, cell_t *q)
-/* Two lists are equal if they contain each others elements. */
-{
-	cell_t *t, *m1, *m2;
-
-	t= inc(newcell());
-	t->cdr= inc(newcell());
-	t->cdr->cdr= inc(newcell());
-	t->cdr->car= newcell();
-	t->cdr->car->type= MINUS;
-	t->cdr->car= inc(t->cdr->car);
-
-	/* Compute p - q. */
-	t->car= inc(p);
-	t->cdr->cdr->car= inc(q);
-	m1= evaluate(inc(t), IMPLODE);
-	dec(m1);
-
-	/* Compute q - p. */
-	t->car= q;
-	t->cdr->cdr->car= p;
-	m2= evaluate(t, IMPLODE);
-	dec(m2);
-
-	/* Both results must be empty. */
-	return m1 == nil && m2 == nil;
-}
-
-int wordlist(cell_t **pw, int atom)
-/* Check if p is a list of words, typically an imploded list.  Return
- * the number of words seen, -1 if they are not words (INPUT/OUTPUT?).
- * If atom is true than a list of one word is turned into a word.
- */
-{
-	int n= 0;
-	cell_t *p, **pp= pw;
-
-	while (*pp != nil) {
-		*pp= append(CELL, *pp);
-		p= (*pp)->car;
-		n= n >= 0 && p != nil && p->type == WORD ? n+1 : -1;
-		pp= &(*pp)->cdr;
-	}
-	if (atom && n == 1) *pw= go(*pw, (*pw)->car);
-	return n;
-}
-
-char *template;		/* Current name of a temporary file. */
-static char *tp;	/* Current place withing the tempfile. */
-
-char *maketemp(void)
-/* Return a name that can be used as a temporary filename. */
-{
-	int i= 0;
-
-	if (tp == nil) {
-		size_t len= strlen(template);
-
-		template= allocate(template, (len+20) * sizeof(*template));
-		sprintf(template+len, "/acd%d", getpid());
-		tp= template + strlen(template);
-	}
-
-	for (;;) {
-		switch (tp[i]) {
-		case 0:		tp[i]= 'a';
-				tp[i+1]= 0;	return template;
-		case 'z':	tp[i++]= 'a';	break;
-		default:	tp[i]++;	return template;
-		}
-	}
-}
-
-void inittemp(char *tmpdir)
-/* Initialize the temporary filename generator. */
-{
-	template= allocate(nil, (strlen(tmpdir)+20) * sizeof(*template));
-	sprintf(template, "%s/acd%d", tmpdir, getpid());
-	tp= template + strlen(template);
-
-	/* Create a directory within tempdir that we can safely play in. */
-	while (action != 1 && mkdir(template, 0700) < 0) {
-		if (errno == EEXIST) {
-			(void) maketemp();
-		} else {
-			report(template);
-			action= 0;
-		}
-	}
-	if (verbose >= 2) printf("mkdir %s\n", template);
-	while (*tp != 0) tp++;
-	*tp++= '/';
-	*tp= 0;
-}
-
-void deltemp(void)
-/* Remove our temporary temporaries directory. */
-{
-	while (*--tp != '/') {}
-	*tp = 0;
-	if (rmdir(template) < 0 && errno != ENOENT) report(template);
-	if (verbose >= 2) printf("rmdir %s\n", template);
-	deallocate(template);
-}
-
-cell_t *splitenv(char *env)
-/* Split a string from the environment into several words at whitespace
- * and colons.  Two colons (::) become a dot.
- */
-{
-	cell_t *r= nil, **pr= &r;
-	char *p;
-
-	do {
-		while (*env != 0 && isspace(*env)) env++;
-
-		if (*env == 0) break;
-
-		p= env;
-		while (*p != 0 && !isspace(*p) && *p != ':') p++;
-
-		*pr= cons(CELL,
-			p == env ? findword(".") : findnword(env, p-env));
-		pr= &(*pr)->cdr;
-		env= p;
-	} while (*env++ != 0);
-	return r;
-}
-
-void key_usage(char *how)
-{
-	fprintf(stderr, "\"%s\", line %u: Usage: %s %s\n",
-		descr, pc->lineno, pc->line->car->name, how);
-	action= 0;
-}
-
-void inappropriate(void)
-{
-	fprintf(stderr, "\"%s\", line %u: wrong execution phase for '%s'\n",
-		descr, pc->lineno, pc->line->car->name);
-	action= 0;
-}
-
-int readonly(cell_t *v)
-{
-	if (v->flags & W_RDONLY) {
-		fprintf(stderr, "\"%s\", line %u: %s is read-only\n",
-			descr, pc->lineno, v->name);
-		action= 0;
-		return 1;
-	}
-	return 0;
-}
-
-void complain(cell_t *err)
-/* acd: err ... */
-{
-	cell_t *w;
-
-	fprintf(stderr, "%s:", program);
-
-	while (err != nil) {
-		if (err->type == CELL) {
-			w= err->car; err= err->cdr;
-		} else {
-			w= err; err= nil;
-		}
-		fprintf(stderr, " %s", w->name);
-	}
-	action= 0;
-}
-
-int keyword(char *name)
-/* True if the current line is headed by the given keyword. */
-{
-	cell_t *t;
-
-	return (t= pc->line) != nil && t->type == CELL
-		&& (t= t->car) != nil && t->type == WORD
-		&& strcmp(t->name, name) == 0;
-}
-
-cell_t *getvar(cell_t *v)
-/* Return a word or the word referenced by a subst. */
-{
-	if (v == nil) return nil;
-	if (v->type == WORD) return v;
-	if (v->type == SUBST) return v->subst;
-	return nil;
-}
-
-void argscan(void), compile(void);
-void transform(rule_t *);
-
-void exec_one(void)
-/* Execute one line of the program. */
-{
-	cell_t *v, *p, *q, *r, *t;
-	unsigned n= 0;
-	static int last_if= 1;
-
-	/* Description file this line came from. */
-	descr= pc->file->name;
-
-	for (p= pc->line; p != nil; p= p->cdr) n++;
-
-	if (n == 0) return;	/* Null statement. */
-
-	p= pc->line;
-	q= p->cdr;
-	r= q == nil ? nil : q->cdr;
-
-	/* Try one by one all the different commands. */
-
-	if (n >= 2 && q->car != nil && q->car->type == EQUALS) {
-		/* An assignment. */
-		int flags;
-
-		if ((v= getvar(p->car)) == nil) {
-			fprintf(stderr,
-				"\"%s\", line %u: Usage: <var> = expr ...\n",
-				descr, pc->lineno);
-			action= 0;
-			return;
-		}
-
-		if (readonly(v)) return;
-
-		flags= v->flags;
-		v->flags|= W_LOCAL|W_RDONLY;
-		t= evaluate(inc(r), PARTIAL);
-		dec(v->value);
-		v->value= t;
-		v->flags= flags | W_SET;
-		if (talk()) {
-			printf("%s =\b=\b= ", v->name);
-			prin2n(t);
-		}
-	} else
-	if (keyword("unset")) {
-		/* Set a variable to "undefined". */
-
-		if (n != 2 || (v= getvar(q->car)) == nil) {
-			key_usage("<var>");
-			return;
-		}
-		if (readonly(v)) return;
-
-		if (talk()) prin2n(p);
-
-		dec(v->value);
-		v->value= nil;
-		v->flags&= ~W_SET;
-	} else
-	if (keyword("import")) {
-		/* Import a variable from the UNIX environment. */
-		char *env;
-
-		if (n != 2 || (v= getvar(q->car)) == nil) {
-			key_usage("<var>");
-			return;
-		}
-		if (readonly(v)) return;
-
-		if ((env= getenv(v->name)) == nil) return;
-
-		if (talk()) printf("import %s=%s\n", v->name, env);
-
-		t= splitenv(env);
-		dec(v->value);
-		v->value= t;
-		v->flags|= W_SET;
-	} else
-	if (keyword("mktemp")) {
-		/* Assign a variable the name of a temporary file. */
-		char *tmp, *suff;
-
-		r= evaluate(inc(r), IMPLODE);
-		if (n == 3 && wordlist(&r, 1) != 1) n= 0;
-
-		if ((n != 2 && n != 3) || (v= getvar(q->car)) == nil) {
-			dec(r);
-			key_usage("<var> [<suffix>]");
-			return;
-		}
-		if (readonly(v)) { dec(r); return; }
-
-		tmp= maketemp();
-		suff= r == nil ? "" : r->name;
-
-		t= newcell();
-		t->type= WORD;
-		t->name= allocate(nil,
-			(strlen(tmp) + strlen(suff) + 1) * sizeof(*t->name));
-		strcpy(t->name, tmp);
-		strcat(t->name, suff);
-		t= inc(t);
-		dec(r);
-		dec(v->value);
-		v->value= t;
-		v->flags|= W_SET;
-		t->flags|= W_TEMP;
-		if (talk()) printf("mktemp %s=%s\n", v->name, t->name);
-	} else
-	if (keyword("temporary")) {
-		/* Mark a word as a temporary file. */
-		cell_t *tmp;
-
-		tmp= evaluate(inc(q), IMPLODE);
-
-		if (wordlist(&tmp, 1) < 0) {
-			dec(tmp);
-			key_usage("<word>");
-			return;
-		}
-		if (talk()) printf("temporary %s\n", tmp->name);
-
-		tmp->flags|= W_TEMP;
-		dec(tmp);
-	} else
-	if (keyword("stop")) {
-		/* Set the suffix to stop the transformation on. */
-		cell_t *suff;
-
-		if (phase > SCAN) { inappropriate(); return; }
-
-		suff= evaluate(inc(q), IMPLODE);
-
-		if (wordlist(&suff, 1) != 1) {
-			dec(suff);
-			key_usage("<suffix>");
-			return;
-		}
-		dec(V_stop);
-		V_stop= suff;
-		if (talk()) printf("stop %s\n", suff->name);
-	} else
-	if (keyword("numeric")) {
-		/* Check if a string denotes a number, like $n in -O$n. */
-		cell_t *num;
-		char *pn;
-
-		num= evaluate(inc(q), IMPLODE);
-
-		if (wordlist(&num, 1) != 1) {
-			dec(num);
-			key_usage("<arg>");
-			return;
-		}
-		if (talk()) printf("numeric %s\n", num->name);
-
-		(void) strtoul(num->name, &pn, 10);
-		if (*pn != 0) {
-			complain(phase == SCAN ? V_star->value : nil);
-			if (phase == SCAN) fputc(':', stderr);
-			fprintf(stderr, " '%s' is not a number\n", num->name);
-		}
-		dec(num);
-	} else
-	if (keyword("error")) {
-		/* Signal an error. */
-		cell_t *err;
-
-		err= evaluate(inc(q), IMPLODE);
-
-		if (wordlist(&err, 0) < 1) {
-			dec(err);
-			key_usage("expr ...");
-			return;
-		}
-
-		if (talk()) { printf("error "); prin2n(err); }
-
-		complain(err);
-		fputc('\n', stderr);
-		dec(err);
-	} else
-	if (keyword("if")) {
-		/* if (list) = (list) using set comparison. */
-		int eq;
-
-		if (n != 4 || r->car == nil || r->car->type != EQUALS) {
-			key_usage("<expr> = <expr>");
-			execute(DONT, pc->indent+1);
-			last_if= 1;
-			return;
-		}
-		q= q->car;
-		r= r->cdr->car;
-		if (talk()) {
-			printf("if ");
-			prin1(t= evaluate(inc(q), IMPLODE));
-			dec(t);
-			printf(" = ");
-			prin1n(t= evaluate(inc(r), IMPLODE));
-			dec(t);
-		}
-		eq= equal(q, r);
-		execute(eq ? DOIT : DONT, pc->indent+1);
-		last_if= eq;
-	} else
-	if (keyword("ifdef") || keyword("ifndef")) {
-		/* Is a variable defined or undefined? */
-		int doit;
-
-		if (n != 2 || (v= getvar(q->car)) == nil) {
-			key_usage("<var>");
-			execute(DONT, pc->indent+1);
-			last_if= 1;
-			return;
-		}
-		if (talk()) prin2n(p);
-
-		doit= ((v->flags & W_SET) != 0) ^ (p->car->name[2] == 'n');
-		execute(doit ? DOIT : DONT, pc->indent+1);
-		last_if= doit;
-	} else
-	if (keyword("iftemp") || keyword("ifhash")) {
-		/* Is a file a temporary file? */
-		/* Does a file need preprocessing? */
-		cell_t *file;
-		int doit= 0;
-
-		file= evaluate(inc(q), IMPLODE);
-
-		if (wordlist(&file, 1) != 1) {
-			dec(file);
-			key_usage("<arg>");
-			return;
-		}
-		if (talk()) printf("%s %s\n", p->car->name, file->name);
-
-		if (p->car->name[2] == 't') {
-			/* iftemp file */
-			if (file->flags & W_TEMP) doit= 1;
-		} else {
-			/* ifhash file */
-			int fd;
-			char hash;
-
-			if ((fd= open(file->name, O_RDONLY)) >= 0) {
-				if (read(fd, &hash, 1) == 1 && hash == '#')
-					doit= 1;
-				close(fd);
-			}
-		}
-		dec(file);
-
-		execute(doit ? DOIT : DONT, pc->indent+1);
-		last_if= doit;
-	} else
-	if (keyword("else")) {
-		/* Else clause for an if, ifdef, or ifndef. */
-		if (n != 1) {
-			key_usage("");
-			execute(DONT, pc->indent+1);
-			return;
-		}
-		if (talk()) prin2n(p);
-
-		execute(!last_if ? DOIT : DONT, pc->indent+1);
-	} else
-	if (keyword("treat")) {
-		/* Treat a file as having a certain suffix. */
-
-		if (phase > SCAN) { inappropriate(); return; }
-
-		if (n == 3) {
-			q= evaluate(inc(q->car), IMPLODE);
-			r= evaluate(inc(r->car), IMPLODE);
-		}
-		if (n != 3 || wordlist(&q, 1) != 1 || wordlist(&r, 1) != 1) {
-			if (n == 3) { dec(q); dec(r); }
-			key_usage("<file> <suffix>");
-			return;
-		}
-		if (talk()) printf("treat %s %s\n", q->name, r->name);
-
-		dec(q->suffix);
-		q->suffix= r;
-		q->flags|= W_SUFF;
-		dec(q);
-	} else
-	if (keyword("apply")) {
-		/* Apply a transformation rule to the current input file. */
-		rule_t *rule, *sav_path;
-		cell_t *sav_wait, *sav_in, *sav_out;
-		program_t *sav_next;
-
-		if (phase != COMPILE) { inappropriate(); return; }
-
-		if (V_star->value->cdr != nil) {
-			fprintf(stderr, "\"%s\", line %u: $* is not one file\n",
-				descr, pc->lineno);
-			action= 0;
-			return;
-		}
-		if (n == 3) {
-			q= evaluate(inc(q->car), IMPLODE);
-			r= evaluate(inc(r->car), IMPLODE);
-		}
-		if (n != 3 || wordlist(&q, 1) != 1 || wordlist(&r, 1) != 1) {
-			if (n == 3) { dec(q); dec(r); }
-			key_usage("<file> <suffix>");
-			return;
-		}
-		if (talk()) printf("apply %s %s\n", q->name, r->name);
-
-		/* Find a rule */
-		for (rule= rules; rule != nil; rule= rule->next) {
-			if (rule->type == TRANSFORM
-				&& rule->from == q && rule->to == r) break;
-		}
-		if (rule == nil) {
-			fprintf(stderr,
-				"\"%s\", line %u: no %s %s transformation\n",
-				descr, pc->lineno, q->name, r->name);
-			action= 0;
-		}
-		dec(q);
-		dec(r);
-		if (rule == nil) return;
-
-		/* Save the world. */
-		sav_path= rule->path;
-		sav_wait= rule->wait;
-		sav_in= V_in->value;
-		sav_out= V_out->value;
-		sav_next= nextpc;
-
-		/* Isolate the rule and give it new input. */
-		rule->path= rule;
-		rule->wait= V_star->value;
-		V_star->value= nil;
-		V_in->value= nil;
-		V_out->value= nil;
-
-		transform(rule);
-
-		/* Retrieve the new $* and repair. */
-		V_star->value= rule->wait;
-		rule->path= sav_path;
-		rule->wait= sav_wait;
-		V_in->value= sav_in;
-		V_out->value= sav_out;
-		V_out->flags= W_SET|W_LOCAL;
-		nextpc= sav_next;
-	} else
-	if (keyword("include")) {
-		/* Include another description file into this program. */
-		cell_t *file;
-		program_t *incl, *prog, **ppg= &prog;
-
-		file= evaluate(inc(q), IMPLODE);
-
-		if (wordlist(&file, 1) != 1) {
-			dec(file);
-			key_usage("<file>");
-			return;
-		}
-		if (talk()) printf("include %s\n", file->name);
-		descr= file->name;
-		incl= pc;
-		prog= get_prog();
-		dec(file);
-
-		/* Raise the program to the include's indent level. */
-		while (*ppg != nil) {
-			(*ppg)->indent += incl->indent;
-			ppg= &(*ppg)->next;
-		}
-
-		/* Kill the include and splice the included program in. */
-		dec(incl->line);
-		incl->line= nil;
-		*ppg= incl->next;
-		incl->next= prog;
-		pc= incl;
-		nextpc= prog;
-	} else
-	if (keyword("arg")) {
-		/* An argument scanning rule. */
-
-		if (phase > SCAN) { inappropriate(); return; }
-
-		if (n < 2) {
-			key_usage("<string> ...");
-			execute(DONT, pc->indent+1);
-			return;
-		}
-		if (talk()) prin2n(p);
-
-		newrule(ARG, inc(q), nil);
-
-		/* Always skip the body, it comes later. */
-		execute(DONT, pc->indent+1);
-	} else
-	if (keyword("transform")) {
-		/* A file transformation rule. */
-
-		if (phase > SCAN) { inappropriate(); return; }
-
-		if (n == 3) {
-			q= evaluate(inc(q->car), IMPLODE);
-			r= evaluate(inc(r->car), IMPLODE);
-		}
-		if (n != 3 || wordlist(&q, 1) != 1 || wordlist(&r, 1) != 1) {
-			if (n == 3) { dec(q); dec(r); }
-			key_usage("<suffix1> <suffix2>");
-			execute(DONT, pc->indent+1);
-			return;
-		}
-		if (talk()) printf("transform %s %s\n", q->name, r->name);
-
-		newrule(TRANSFORM, q, r);
-
-		/* Body comes later. */
-		execute(DONT, pc->indent+1);
-	} else
-	if (keyword("prefer")) {
-		/* Prefer a transformation over others. */
-
-		if (phase > SCAN) { inappropriate(); return; }
-
-		if (n == 3) {
-			q= evaluate(inc(q->car), IMPLODE);
-			r= evaluate(inc(r->car), IMPLODE);
-		}
-		if (n != 3 || wordlist(&q, 1) != 1 || wordlist(&r, 1) != 1) {
-			if (n == 3) { dec(q); dec(r); }
-			key_usage("<suffix1> <suffix2>");
-			return;
-		}
-		if (talk()) printf("prefer %s %s\n", q->name, r->name);
-
-		newrule(PREFER, q, r);
-	} else
-	if (keyword("combine")) {
-		/* A file combination (loader) rule. */
-
-		if (phase > SCAN) { inappropriate(); return; }
-
-		if (n == 3) {
-			q= evaluate(inc(q->car), IMPLODE);
-			r= evaluate(inc(r->car), IMPLODE);
-		}
-		if (n != 3 || wordlist(&q, 0) < 1 || wordlist(&r, 1) != 1) {
-			if (n == 3) { dec(q); dec(r); }
-			key_usage("<suffix-list> <suffix>");
-			execute(DONT, pc->indent+1);
-			return;
-		}
-		if (talk()) {
-			printf("combine ");
-			prin1(q);
-			printf(" %s\n", r->name);
-		}
-
-		newrule(COMBINE, q, r);
-
-		/* Body comes later. */
-		execute(DONT, pc->indent+1);
-	} else
-	if (keyword("scan") || keyword("compile")) {
-		program_t *next= nextpc;
-
-		if (n != 1) { key_usage(""); return; }
-		if (phase != INIT) { inappropriate(); return; }
-
-		if (talk()) prin2n(p);
-
-		argscan();
-		if (p->car->name[0] == 'c') compile();
-		nextpc= next;
-	} else {
-		/* A UNIX command. */
-		t= evaluate(inc(pc->line), IMPLODE);
-		unix_exec(t);
-		dec(t);
-	}
-}
-
-void execute(exec_t how, unsigned indent)
-/* Execute (or skip) all lines with at least the given indent. */
-{
-	int work= 0;	/* Need to execute at least one line. */
-	unsigned firstline;
-	unsigned nice_indent= 0;	/* 0 = Don't know what's nice yet. */
-
-	if (pc == nil) return;	/* End of program. */
-
-	firstline= pc->lineno;
-
-	if (how == DONT) {
-		/* Skipping a body, but is there another guard? */
-		pc= pc->next;
-		if (pc != nil && pc->indent < indent && pc->line != nil) {
-			/* There is one!  Bail out, then it get's executed. */
-			return;
-		}
-	} else {
-		/* Skip lines with a lesser indentation, they are guards for
-		 * the same substatements.  Don't go past empty lines.
-		 */
-		while (pc != nil && pc->indent < indent && pc->line != nil)
-			pc= pc->next;
-	}
-
-	/* Execute all lines with an indentation of at least "indent". */
-	while (pc != nil && pc->indent >= indent) {
-		if (pc->indent != nice_indent && how == DOIT) {
-			if (nice_indent != 0) {
-				fprintf(stderr,
-			"\"%s\", line %u: (warning) sudden indentation shift\n",
-					descr, pc->lineno);
-			}
-			nice_indent= pc->indent;
-		}
-		nextpc= pc->next;
-		if (how == DOIT) exec_one();
-		pc= nextpc;
-		work= 1;
-	}
-
-	if (indent > 0 && !work) {
-		fprintf(stderr, "\"%s\", line %u: empty body, no statements\n",
-			descr, firstline);
-		action= 0;
-	}
-}
-
-int argmatch(int shift, cell_t *match, cell_t *match1, char *arg1)
-/* Try to match an arg rule to the input file list L_args.  Execute the arg
- * body (pc is set to it) on success.
- */
-{
-	cell_t *oldval, *v;
-	int m, oldflags;
-	size_t i, len;
-	int minus= 0;
-
-	if (shift) {
-		/* An argument has been accepted and may be shifted to $*. */
-		cell_t **oldpstar= pV_star;
-		*pV_star= L_args;
-		L_args= *(pV_star= &L_args->cdr);
-		*pV_star= nil;
-
-		if (argmatch(0, match->cdr, nil, nil)) return 1;
-
-		/* Undo the damage. */
-		*pV_star= L_args;
-		L_args= *(pV_star= oldpstar);
-		*pV_star= nil;
-		return 0;
-	}
-
-	if (match == nil) {
-		/* A full match, execute the arg body. */
-
-		/* Enable $>. */
-		V_out->flags= W_SET|W_LOCAL;
-
-		if (verbose >= 3) {
-			prin2(pc->line);
-			printf(" =\b=\b= ");
-			prin2n(V_star->value);
-		}
-		execute(DOIT, pc->indent+1);
-
-		/* Append $> to the file list. */
-		if (V_out->value != nil) {
-			*pL_files= cons(CELL, V_out->value);
-			pL_files= &(*pL_files)->cdr;
-		}
-
-		/* Disable $>. */
-		V_out->value= nil;
-		V_out->flags= W_SET|W_LOCAL|W_RDONLY;
-
-		return 1;
-	}
-
-	if (L_args == nil) return 0;	/* Out of arguments to match. */
-
-	/* Match is a list of words, substs and strings containing letters and
-	 * substs.  Match1 is the current element of the first element of match.
-	 * Arg1 is the current character of the first element of L_args.
-	 */
-	if (match1 == nil) {
-		/* match1 is at the end of a string, then arg1 must also. */
-		if (arg1 != nil) {
-			if (*arg1 != 0) return 0;
-			return argmatch(1, match, nil, nil);
-		}
-		/* If both are nil: Initialize. */
-		match1= match->car;
-		arg1= L_args->car->name;
-
-		/* A subst may not match a leading '-'. */
-		if (arg1[0] == '-') minus= 1;
-	}
-
-	if (match1->type == WORD && strcmp(match1->name, arg1) == 0) {
-		/* A simple match of an argument. */
-
-		return argmatch(1, match, nil, nil);
-	}
-
-	if (match1->type == SUBST && !minus) {
-		/* A simple match of a subst. */
-
-		/* The variable gets the first of the arguments as its value. */
-		v= match1->subst;
-		if (v->flags & W_RDONLY) return 0;	/* ouch */
-		oldflags= v->flags;
-		v->flags= W_SET|W_LOCAL|W_RDONLY;
-		oldval= v->value;
-		v->value= inc(L_args->car);
-
-		m= argmatch(1, match, nil, nil);
-
-		/* Recover the value of the variable. */
-		dec(v->value);
-		v->flags= oldflags;
-		v->value= oldval;
-		return m;
-	}
-	if (match1->type != STRING) return 0;
-
-	/* Match the first item in the string. */
-	if (match1->car == nil) return 0;
-
-	if (match1->car->type == LETTER
-			&& match1->car->letter == (unsigned char) *arg1) {
-		/* A letter matches, try the rest of the string. */
-
-		return argmatch(0, match, match1->cdr, arg1+1);
-	}
-
-	/* It can only be a subst in a string now. */
-	len= strlen(arg1);
-	if (match1->car->type != SUBST || minus || len == 0) return 0;
-
-	/* The variable can match from 1 character to all of the argument.
-	 * Matching as few characters as possible happens to be the Right Thing.
-	 */
-	v= match1->car->subst;
-	if (v->flags & W_RDONLY) return 0;	/* ouch */
-	oldflags= v->flags;
-	v->flags= W_SET|W_LOCAL|W_RDONLY;
-	oldval= v->value;
-
-	m= 0;
-	for (i= match1->cdr == nil ? len : 1; !m && i <= len; i++) {
-		v->value= findnword(arg1, i);
-
-		m= argmatch(0, match, match1->cdr, arg1+i);
-
-		dec(v->value);
-	}
-	/* Recover the value of the variable. */
-	v->flags= oldflags;
-	v->value= oldval;
-	return m;
-}
-
-void argscan(void)
-/* Match all the arguments to the arg rules, those that don't match are
- * used as files for transformation.
- */
-{
-	rule_t *rule;
-	int m;
-
-	phase= SCAN;
-
-	/* Process all the arguments. */
-	while (L_args != nil) {
-		pV_star= &V_star->value;
-
-		/* Try all the arg rules. */
-		m= 0;
-		for (rule= rules; !m && rule != nil; rule= rule->next) {
-			if (rule->type != ARG) continue;
-
-			pc= rule->prog;
-
-			m= argmatch(0, rule->match, nil, nil);
-		}
-		dec(V_star->value);
-		V_star->value= nil;
-
-		/* On failure, add the first argument to the list of files. */
-		if (!m) {
-			*pL_files= L_args;
-			L_args= *(pL_files= &L_args->cdr);
-			*pL_files= nil;
-		}
-	}
-	phase= INIT;
-}
-
-int member(cell_t *p, cell_t *l)
-/* True if p is a member of list l. */
-{
-	while (l != nil && l->type == CELL) {
-		if (p == l->car) return 1;
-		l= l->cdr;
-	}
-	return p == l;
-}
-
-long basefind(cell_t *f, cell_t *l)
-/* See if f has a suffix in list l + set the base name of f.
- * -1 if not found, preference number for a short basename otherwise. */
-{
-	cell_t *suff;
-	size_t blen, slen;
-	char *base;
-
-	/* Determine base name of f, with suffix. */
-	if ((base= strrchr(f->name, '/')) == nil) base= f->name; else base++;
-	blen= strlen(base);
-
-	/* Try suffixes. */
-	while (l != nil) {
-		if (l->type == CELL) {
-			suff= l->car; l= l->cdr;
-		} else {
-			suff= l; l= nil;
-		}
-		if (f->flags & W_SUFF) {
-			/* F has a suffix imposed on it. */
-			if (f->suffix == suff) return 0;
-			continue;
-		}
-		slen= strlen(suff->name);
-		if (slen < blen && strcmp(base+blen-slen, suff->name) == 0) {
-			/* Got it! */
-			dec(f->base);
-			f->base= findnword(base, blen-slen);
-			return 10000L * (blen - slen);
-		}
-	}
-	return -1;
-}
-
-#define NO_PATH		2000000000	/* No path found yet. */
-
-long shortest;		/* Length of the shortest path as yet. */
-
-rule_t *findpath(long depth, int seek, cell_t *file, rule_t *start)
-/* Find the path of the shortest transformation to the stop suffix. */
-{
-	rule_t *rule;
-
-	if (action == 0) return nil;
-
-	if (start == nil) {
-		/* No starting point defined, find one using "file". */
-
-		for (rule= rules; rule != nil; rule= rule->next) {
-			if (rule->type < TRANSFORM) continue;
-
-			if ((depth= basefind(file, rule->from)) >= 0) {
-				if (findpath(depth, seek, nil, rule) != nil)
-					return rule;
-			}
-		}
-		return nil;
-	}
-
-	/* Cycle? */
-	if (start->path != nil) {
-		/* We can't have cycles through combines. */
-		if (start->type == COMBINE) {
-			fprintf(stderr,
-				"\"%s\": contains a combine-combine cycle\n",
-				descr);
-			action= 0;
-		}
-		return nil;
-	}
-
-	/* Preferred transformations are cheap. */
-	if (start->flags & R_PREFER) depth-= 100;
-
-	/* Try to go from start closer to the stop suffix. */
-	for (rule= rules; rule != nil; rule= rule->next) {
-		if (rule->type < TRANSFORM) continue;
-
-		if (member(start->to, rule->from)) {
-			start->path= rule;
-			rule->npaths++;
-			if (findpath(depth+1, seek, nil, rule) != nil)
-				return start;
-			start->path= nil;
-			rule->npaths--;
-		}
-	}
-
-	if (V_stop == nil) {
-		fprintf(stderr, "\"%s\": no stop suffix has been defined\n",
-			descr);
-		action= 0;
-		return nil;
-	}
-
-	/* End of the line? */
-	if (start->to == V_stop) {
-		/* Got it. */
-		if (seek) {
-			/* Second hunt, do we find the shortest? */
-			if (depth == shortest) return start;
-		} else {
-			/* Is this path shorter than the last one? */
-			if (depth < shortest) shortest= depth;
-		}
-	}
-	return nil;	/* Fail. */
-}
-
-void transform(rule_t *rule)
-/* Transform the file(s) connected to the rule according to the rule. */
-{
-	cell_t *file, *in, *out;
-	char *base;
-
-	/* Let $* be the list of input files. */
-	while (rule->wait != nil) {
-		file= rule->wait;
-		rule->wait= file->cdr;
-		file->cdr= V_star->value;
-		V_star->value= file;
-	}
-
-	/* Set $< to the basename of the first input file. */
-	file= file->car;
-	V_in->value= in= inc(file->flags & W_SUFF ? file : file->base);
-	file->flags&= ~W_SUFF;
-
-	/* Set $> to the output file name of the transformation. */
-	out= newcell();
-	out->type= WORD;
-	base= rule->path == nil ? in->name : maketemp();
-	out->name= allocate(nil,
-		(strlen(base)+strlen(rule->to->name)+1) * sizeof(*out->name));
-	strcpy(out->name, base);
-	if (rule->path == nil || strchr(rule->to->name, '/') == nil)
-		strcat(out->name, rule->to->name);
-	out= inc(out);
-	if (rule->path != nil) out->flags|= W_TEMP;
-
-	V_out->value= out;
-	V_out->flags= W_SET|W_LOCAL;
-
-	/* Do a transformation.  (Finally) */
-	if (verbose >= 3) {
-		printf("%s ", rule->type==TRANSFORM ? "transform" : "combine");
-		prin2(V_star->value);
-		printf(" %s\n", out->name);
-	}
-	pc= rule->prog;
-	execute(DOIT, pc->indent+1);
-
-	/* Hand $> over to the next rule, it must be a single word. */
-	out= evaluate(V_out->value, IMPLODE);
-	if (wordlist(&out, 1) != 1) {
-		fprintf(stderr,
-		"\"%s\", line %u: $> should be returned as a single word\n",
-			descr, rule->prog->lineno);
-		action= 0;
-	}
-
-	if ((rule= rule->path) != nil) {
-		/* There is a next rule. */
-		dec(out->base);
-		out->base= in;		/* Basename of input file. */
-		file= inc(newcell());
-		file->car= out;
-		file->cdr= rule->wait;
-		rule->wait= file;
-	} else {
-		dec(in);
-		dec(out);
-	}
-
-	/* Undo the damage to $*, $<, and $>. */
-	dec(V_star->value);
-	V_star->value= nil;
-	V_in->value= nil;
-	V_out->value= nil;
-	V_out->flags= W_SET|W_LOCAL|W_RDONLY;
-}
-
-void compile(void)
-{
-	rule_t *rule;
-	cell_t *file, *t;
-
-	phase= COMPILE;
-
-	/* Implode the files list. */
-	L_files= evaluate(L_files, IMPLODE);
-	if (wordlist(&L_files, 0) < 0) {
-		fprintf(stderr, "\"%s\": An assignment to $> contained junk\n",
-			descr);
-		action= 0;
-	}
-
-	while (action != 0 && L_files != nil) {
-		file= L_files->car;
-
-		/* Initialize. */
-		shortest= NO_PATH;
-		for (rule= rules; rule != nil; rule= rule->next)
-			rule->path= nil;
-
-		/* Try all possible transformation paths. */
-		(void) findpath(0L, 0, file, nil);
-
-		if (shortest == NO_PATH) {	/* Can't match the file. */
-			fprintf(stderr,
-			"%s: %s: can't compile, no transformation applies\n",
-				program, file->name);
-			action= 0;
-			return;
-		}
-
-		/* Find the first short path. */
-		if ((rule= findpath(0L, 1, file, nil)) == nil) return;
-
-		/* Transform the file until you hit a combine. */
-		t= inc(newcell());
-		t->car= inc(file);
-		L_files= go(L_files, L_files->cdr);
-		t->cdr= rule->wait;
-		rule->wait= t;
-		while (action != 0 && rule != nil && rule->type != COMBINE) {
-			transform(rule);
-			rule= rule->path;
-		}
-	}
-
-	/* All input files have been transformed to combine rule(s).  Now
-	 * we need to find the combine rule with the least number of paths
-	 * running through it (this combine may be followed by another) and
-	 * transform from there.
-	 */
-	while (action != 0) {
-		int least;
-		rule_t *comb= nil;
-
-		for (rule= rules; rule != nil; rule= rule->next) {
-			rule->path= nil;
-
-			if (rule->type != COMBINE || rule->wait == nil)
-				continue;
-
-			if (comb == nil || rule->npaths < least) {
-				least= rule->npaths;
-				comb= rule;
-			}
-		}
-
-		/* No combine?  Then we're done. */
-		if (comb == nil) break;
-
-		/* Initialize. */
-		shortest= NO_PATH;
-
-		/* Try all possible transformation paths. */
-		(void) findpath(0L, 0, nil, comb);
-
-		if (shortest == NO_PATH) break;
-
-		/* Find the first short path. */
-		if ((rule= findpath(0L, 1, nil, comb)) == nil) return;
-
-		/* Transform until you hit another combine. */
-		do {
-			transform(rule);
-			rule= rule->path;
-		} while (action != 0 && rule != nil && rule->type != COMBINE);
-	}
-	phase= INIT;
-}
-
-cell_t *predef(char *var, char *val)
-/* A predefined variable var with value val, or a special variable. */
-{
-	cell_t *p, *t;
-
-	p= findword(var);
-	if (val != nil) {	/* Predefined. */
-		t= findword(val);
-		dec(p->value);
-		p->value= t;
-		p->flags|= W_SET;
-		if (verbose >= 3) {
-			prin1(p);
-			printf(" =\b=\b= ");
-			prin2n(t);
-		}
-	} else {		/* Special: $* and such. */
-		p->flags= W_SET|W_LOCAL|W_RDONLY;
-	}
-	t= inc(newcell());
-	t->car= p;
-	t->cdr= L_predef;
-	L_predef= t;
-	return p;
-}
-
-void usage(void)
-{
-	fprintf(stderr,
-	"Usage: %s -v<n> -vn<n> -name <name> -descr <descr> -T <dir> ...\n",
-		program);
-	exit(-1);
-}
-
-int main(int argc, char **argv)
-{
-	char *tmpdir;
-	program_t *prog;
-	cell_t **pa;
-	int i;
-
-	/* Call name of the program, decides which description to use. */
-	if ((program= strrchr(argv[0], '/')) == nil)
-		program= argv[0];
-	else
-		program++;
-
-	/* Directory for temporary files. */
-	if ((tmpdir= getenv("TMPDIR")) == nil || *tmpdir == 0)
-		tmpdir= "/tmp";
-
-	/* Transform arguments to a list, processing the few ACD options. */
-	pa= &L_args;
-	for (i= 1; i < argc; i++) {
-		if (argv[i][0] == '-' && argv[i][1] == 'v') {
-			char *a= argv[i]+2;
-
-			if (*a == 'n') { a++; action= 1; }
-			verbose= 2;
-
-			if (*a != 0) {
-				verbose= strtoul(a, &a, 10);
-				if (*a != 0) usage();
-			}
-		} else
-		if (strcmp(argv[i], "-name") == 0) {
-			if (++i == argc) usage();
-			program= argv[i];
-		} else
-		if (strcmp(argv[i], "-descr") == 0) {
-			if (++i == argc) usage();
-			descr= argv[i];
-		} else
-		if (argv[i][0] == '-' && argv[i][1] == 'T') {
-			if (argv[i][2] == 0) {
-				if (++i == argc) usage();
-				tmpdir= argv[i];
-			} else
-				tmpdir= argv[i]+2;
-		} else {
-			/* Any other argument must be processed. */
-			*pa= cons(CELL, findword(argv[i]));
-			pa= &(*pa)->cdr;
-		}
-	}
-#ifndef DESCR
-	/* Default description file is based on the program name. */
-	if (descr == nil) descr= program;
-#else
-	/* Default description file is predefined. */
-	if (descr == nil) descr= DESCR;
-#endif
-
-	inittemp(tmpdir);
-
-	/* Catch user signals. */
-	if (signal(SIGHUP, SIG_IGN) != SIG_IGN) signal(SIGHUP, interrupt);
-	if (signal(SIGINT, SIG_IGN) != SIG_IGN) signal(SIGINT, interrupt);
-	if (signal(SIGTERM, SIG_IGN) != SIG_IGN) signal(SIGTERM, interrupt);
-
-	/* Predefined or special variables. */
-	predef("PROGRAM", program);
-	predef("VERSION", version);
-#ifdef ARCH
-	predef("ARCH", ARCH);		/* Cross-compilers like this. */
-#endif
-	V_star= predef("*", nil);
-	V_in= predef("<", nil);
-	V_out= predef(">", nil);
-
-	/* Read the description file. */
-	if (verbose >= 3) printf("include %s\n", descr);
-	prog= get_prog();
-
-	phase= INIT;
-	pc= prog;
-	execute(DOIT, 0);
-
-	argscan();
-	compile();
-
-	/* Delete all allocated data to test inc/dec balance. */
-	while (prog != nil) {
-		program_t *junk= prog;
-		prog= junk->next;
-		dec(junk->file);
-		dec(junk->line);
-		deallocate(junk);
-	}
-	while (rules != nil) {
-		rule_t *junk= rules;
-		rules= junk->next;
-		dec(junk->from);
-		dec(junk->to);
-		dec(junk->wait);
-		deallocate(junk);
-	}
-	deltemp();
-	dec(V_stop);
-	dec(L_args);
-	dec(L_files);
-	dec(L_predef);
-
-	quit(action == 0 ? 1 : 0);
-}
Index: trunk/minix/commands/i386/asmconv/Makefile
===================================================================
--- trunk/minix/commands/i386/asmconv/Makefile	(revision 9)
+++ 	(revision )
@@ -1,32 +1,0 @@
-# Makefile for asmconv.
-
-CFLAGS=		$(OPT)
-LDFLAGS=	-i
-CC = exec cc
-
-all:	asmconv
-
-OBJ=	asm86.o asmconv.o parse_ack.o parse_gnu.o parse_bas.o \
-	tokenize.o emit_ack.o emit_gnu.o
-
-asmconv:	$(OBJ)
-	$(CC) $(LDFLAGS) -o $@ $(OBJ)
-	install -S 8kw $@
-
-install:	/usr/lib/asmconv
-
-/usr/lib/asmconv:	asmconv
-	install -cs -o bin asmconv $@
-
-clean:
-	rm -f $(OBJ) asmconv core
-
-# Dependencies.
-asm86.o:	asm86.h asmconv.h token.h
-asmconv.o:	asmconv.h languages.h asm86.h
-parse_ack.o:	asmconv.h languages.h token.h asm86.h
-parse_gnu.o:	asmconv.h languages.h token.h asm86.h
-parse_bas.o:	asmconv.h languages.h token.h asm86.h
-tokenize.o:	asmconv.h token.h
-emit_ack.o:	asmconv.h languages.h token.h asm86.h
-emit_gnu.o:	asmconv.h languages.h token.h asm86.h
Index: trunk/minix/commands/i386/asmconv/asm86.c
===================================================================
--- trunk/minix/commands/i386/asmconv/asm86.c	(revision 9)
+++ 	(revision )
@@ -1,85 +1,0 @@
-/*	asm86.c - 80X86 assembly intermediate		Author: Kees J. Bot
- *								24 Dec 1993
- */
-#define nil 0
-#include <stddef.h>
-#include <string.h>
-#include <assert.h>
-#include "asm86.h"
-#include "asmconv.h"
-#include "token.h"
-
-expression_t *new_expr(void)
-/* Make a new cell to build an expression. */
-{
-	expression_t *e;
-
-	e= allocate(nil, sizeof(*e));
-	e->operator= -1;
-	e->left= e->middle= e->right= nil;
-	e->name= nil;
-	e->magic= 31624;
-	return e;
-}
-
-void del_expr(expression_t *e)
-/* Delete an expression tree. */
-{
-	if (e != nil) {
-		assert(e->magic == 31624);
-		e->magic= 0;
-		deallocate(e->name);
-		del_expr(e->left);
-		del_expr(e->middle);
-		del_expr(e->right);
-		deallocate(e);
-	}
-}
-
-asm86_t *new_asm86(void)
-/* Make a new cell to hold an 80X86 instruction. */
-{
-	asm86_t *a;
-
-	a= allocate(nil, sizeof(*a));
-	a->opcode= -1;
-	get_file(&a->file, &a->line);
-	a->optype= -1;
-	a->oaz= 0;
-	a->rep= ONCE;
-	a->seg= DEFSEG;
-	a->args= nil;
-	a->magic= 37937;
-	return a;
-}
-
-void del_asm86(asm86_t *a)
-/* Delete an 80X86 instruction. */
-{
-	assert(a != nil);
-	assert(a->magic == 37937);
-	a->magic= 0;
-	del_expr(a->args);
-	deallocate(a);
-}
-
-int isregister(const char *name)
-/* True if the string is a register name.  Return its size. */
-{
-	static char *regs[] = {
-		"al", "bl", "cl", "dl", "ah", "bh", "ch", "dh",
-		"ax", "bx", "cx", "dx", "si", "di", "bp", "sp",
-		"cs", "ds", "es", "fs", "gs", "ss",
-		"eax", "ebx", "ecx", "edx", "esi", "edi", "ebp", "esp",
-		"cr0", "cr1", "cr2", "cr3",
-		"st",
-	};
-	int reg;
-
-	for (reg= 0; reg < arraysize(regs); reg++) {
-		if (strcmp(name, regs[reg]) == 0) {
-			return reg < 8 ? 1 : reg < 22 ? 2 : 4;
-		}
-	}
-	return 0;
-}
Index: trunk/minix/commands/i386/asmconv/asm86.h
===================================================================
--- trunk/minix/commands/i386/asmconv/asm86.h	(revision 9)
+++ 	(revision )
@@ -1,250 +1,0 @@
-/*	asm86.h - 80X86 assembly intermediate		Author: Kees J. Bot
- *								27 Jun 1993
- */
-
-typedef enum opcode {	/* 80486 opcodes, from the i486 reference manual.
-			 * Synonyms left out, some new words invented.
-			 */
-	DOT_ALIGN,
-	DOT_ASCII,	DOT_ASCIZ,
-	DOT_ASSERT,			/* Pseudo's invented */
-	DOT_BASE,
-	DOT_COMM,	DOT_LCOMM,
-	DOT_DATA1,
-	DOT_DATA2,
-	DOT_DATA4,
-	DOT_DEFINE,	DOT_EXTERN,
-	DOT_EQU,
-	DOT_FILE,	DOT_LINE,
-	DOT_LABEL,
-	DOT_LIST,	DOT_NOLIST,
-	DOT_SPACE,
-	DOT_SYMB,
-	DOT_TEXT,	DOT_ROM,	DOT_DATA,	DOT_BSS,	DOT_END,
-	DOT_USE16,	DOT_USE32,
-	AAA,
-	AAD,
-	AAM,
-	AAS,
-	ADC,
-	ADD,
-	AND,
-	ARPL,
-	BOUND,
-	BSF,
-	BSR,
-	BSWAP,
-	BT,
-	BTC,
-	BTR,
-	BTS,
-	CALL,	CALLF,			/* CALLF added */
-	CBW,
-	CLC,
-	CLD,
-	CLI,
-	CLTS,
-	CMC,
-	CMP,
-	CMPS,
-	CMPXCHG,
-	CWD,
-	DAA,
-	DAS,
-	DEC,
-	DIV,
-	ENTER,
-	F2XM1,
-	FABS,
-	FADD,	FADDD,	FADDS,	FADDP,	FIADDL,	FIADDS,
-	FBLD,
-	FBSTP,
-	FCHS,
-	FCLEX,
-	FCOMD,	FCOMS,	FCOMPD,	FCOMPS,	FCOMPP,
-	FCOS,
-	FDECSTP,
-	FDIVD,	FDIVS,	FDIVP,	FIDIVL,	FIDIVS,
-	FDIVRD,	FDIVRS,	FDIVRP,	FIDIVRL,	FIDIVRS,
-	FFREE,
-	FICOM,	FICOMP,
-	FILDQ,	FILDL,	FILDS,
-	FINCSTP,
-	FINIT,
-	FISTL,	FISTS,	FISTP,
-	FLDX,	FLDD,	FLDS,
-	FLD1,	FLDL2T,	FLDL2E,	FLDPI,	FLDLG2,	FLDLN2,	FLDZ,
-	FLDCW,
-	FLDENV,
-	FMULD,	FMULS,	FMULP,	FIMULL,	FIMULS,
-	FNOP,
-	FPATAN,
-	FPREM,
-	FPREM1,
-	FPTAN,
-	FRNDINT,
-	FRSTOR,
-	FSAVE,
-	FSCALE,
-	FSIN,
-	FSINCOS,
-	FSQRT,
-	FSTD,	FSTS,	FSTPX,	FSTPD,	FSTPS,
-	FSTCW,
-	FSTENV,
-	FSTSW,
-	FSUBD,	FSUBS,	FSUBP,	FISUBL,	FISUBS,
-	FSUBRD,	FSUBRS,	FSUBPR,	FISUBRL, FISUBRS,
-	FTST,
-	FUCOM,	FUCOMP,	FUCOMPP,
-	FXAM,
-	FXCH,
-	FXTRACT,
-	FYL2X,
-	FYL2XP1,
-	HLT,
-	IDIV,
-	IMUL,
-	IN,
-	INC,
-	INS,
-	INT,	INTO,
-	INVD,
-	INVLPG,
-	IRET,	IRETD,
-	JA,	JAE,	JB,	JBE,	JCXZ,	JE,	JG,	JGE,	JL,
-	JLE,	JNE,	JNO,	JNP,	JNS,	JO,	JP,	JS,
-	JMP,	JMPF,			/* JMPF added */
-	LAHF,
-	LAR,
-	LEA,
-	LEAVE,
-	LGDT,	LIDT,
-	LGS,	LSS,	LDS,	LES,	LFS,
-	LLDT,
-	LMSW,
-	LOCK,
-	LODS,
-	LOOP,	LOOPE,	LOOPNE,
-	LSL,
-	LTR,
-	MOV,
-	MOVS,
-	MOVSX,
-	MOVSXB,
-	MOVZX,
-	MOVZXB,
-	MUL,
-	NEG,
-	NOP,
-	NOT,
-	OR,
-	OUT,
-	OUTS,
-	POP,
-	POPA,
-	POPF,
-	PUSH,
-	PUSHA,
-	PUSHF,
-	RCL,	RCR,	ROL,	ROR,
-	RET,	RETF,			/* RETF added */
-	SAHF,
-	SAL,	SAR,	SHL,	SHR,
-	SBB,
-	SCAS,
-	SETA,	SETAE,	SETB,	SETBE,	SETE,	SETG,	SETGE,	SETL,
-	SETLE,	SETNE,	SETNO,	SETNP,	SETNS,	SETO,	SETP,	SETS,
-	SGDT,	SIDT,
-	SHLD,
-	SHRD,
-	SLDT,
-	SMSW,
-	STC,
-	STD,
-	STI,
-	STOS,
-	STR,
-	SUB,
-	TEST,
-	VERR,	VERW,
-	WAIT,
-	WBINVD,
-	XADD,
-	XCHG,
-	XLAT,
-	XOR
-} opcode_t;
-
-#define is_pseudo(o)	((o) <= DOT_USE32)
-#define N_OPCODES	((int) XOR + 1)
-
-#define OPZ	0x01		/* Operand size prefix. */
-#define ADZ	0x02		/* Address size prefix. */
-
-typedef enum optype {
-	PSEUDO,	JUMP,	BYTE,	WORD,	OWORD		/* Ordered list! */
-} optype_t;
-
-typedef enum repeat {
-	ONCE,	REP,	REPE,	REPNE
-} repeat_t;
-
-typedef enum segment {
-	DEFSEG,	CSEG,	DSEG,	ESEG,	FSEG,	GSEG,	SSEG
-} segment_t;
-
-typedef struct expression {
-	int		operator;
-	struct expression *left, *middle, *right;
-	char		*name;
-	size_t		len;
-	unsigned	magic;
-} expression_t;
-
-typedef struct asm86 {
-	opcode_t	opcode;		/* DOT_TEXT, MOV, ... */
-	char		*file;		/* Name of the file it is found in. */
-	long		line;		/* Line number. */
-	optype_t	optype;		/* Type of operands: byte, word... */
-	int		oaz;		/* Operand/address size prefix? */
-	repeat_t	rep;		/* Repeat prefix used on this instr. */
-	segment_t	seg;		/* Segment override. */
-	expression_t	*args;		/* Arguments in ACK order. */
-	unsigned	magic;
-} asm86_t;
-
-expression_t *new_expr(void);
-void del_expr(expression_t *a);
-asm86_t *new_asm86(void);
-void del_asm86(asm86_t *a);
-int isregister(const char *name);
-
-/*
- * Format of the arguments of the asm86_t structure:
- *
- *
- * ACK assembly operands	expression_t cell:
- * or part of operand:		{operator, left, middle, right, name, len}
- *
- * [expr]			{'[', nil, expr, nil}
- * word				{'W', nil, nil, nil, word}
- * "string"			{'S', nil, nil, nil, "string", strlen("string")}
- * label = expr			{'=', nil, expr, nil, label}
- * expr * expr			{'*', expr, nil, expr}
- * - expr			{'-', nil, expr, nil}
- * (memory)			{'(', nil, memory, nil}
- * offset(base)(index*n)	{'O', offset, base, index*n}
- * base				{'B', nil, nil, nil, base}
- * index*4			{'4', nil, nil, nil, index}
- * operand, oplist		{',', operand, nil, oplist}
- * label :			{':', nil, nil, nil, label}
- *
- * The precedence of operators is ignored.  The expression is simply copied
- * as is, including parentheses.  Problems like missing operators in the
- * target language will have to be handled by rewriting the source language.
- * 16-bit or 32-bit registers must be used where they are required by the
- * target assembler even though ACK makes no difference between 'ax' and
- * 'eax'.  Asmconv is smart enough to transform compiler output.  Human made
- * assembly can be fixed up to be transformable.
- */
Index: trunk/minix/commands/i386/asmconv/asmconv.c
===================================================================
--- trunk/minix/commands/i386/asmconv/asmconv.c	(revision 9)
+++ 	(revision )
@@ -1,157 +1,0 @@
-/*	asmconv 1.11 - convert 80X86 assembly		Author: Kees J. Bot
- *								24 Dec 1993
- */
-static char version[] = "1.11";
-
-#define nil 0
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <assert.h>
-#include "asmconv.h"
-#include "asm86.h"
-#include "languages.h"
-
-void fatal(char *label)
-{
-	fprintf(stderr, "asmconv: %s: %s\n", label, strerror(errno));
-	exit(EXIT_FAILURE);
-}
-
-void *allocate(void *mem, size_t size)
-/* A checked malloc/realloc().  Yes, I know ISO C allows realloc(NULL, size). */
-{
-	mem= mem == nil ? malloc(size) : realloc(mem, size);
-	if (mem == nil) fatal("malloc()");
-	return mem;
-}
-
-void deallocate(void *mem)
-/* Free a malloc()d cell.  (Yes I know ISO C allows free(NULL) */
-{
-	if (mem != nil) free(mem);
-}
-
-char *copystr(const char *s)
-{
-	char *c;
-
-	c= allocate(nil, (strlen(s) + 1) * sizeof(s[0]));
-	strcpy(c, s);
-	return c;
-}
-
-int isanumber(const char *s)
-/* True if s can be turned into a number. */
-{
-	char *end;
-
-	(void) strtol(s, &end, 0);
-	return end != s && *end == 0;
-}
-
-/* "Invisible" globals. */
-int asm_mode32= (sizeof(int) == 4);
-int err_code= EXIT_SUCCESS;
-
-int main(int argc, char **argv)
-{
-	void (*parse_init)(char *file);
-	asm86_t *(*get_instruction)(void);
-	void (*emit_init)(char *file, const char *banner);
-	void (*emit_instruction)(asm86_t *instr);
-	char *lang_parse, *lang_emit, *input_file, *output_file;
-	asm86_t *instr;
-	char banner[80];
-
-	if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'm') {
-		if (strcmp(argv[1], "-mi86") == 0) {
-			set_use16();
-		} else
-		if (strcmp(argv[1], "-mi386") == 0) {
-			set_use32();
-		} else {
-			fprintf(stderr, "asmconv: '%s': unknown machine\n",
-				argv[1]+2);
-		}
-		argc--;
-		argv++;
-	}
-
-	if (argc < 3 || argc > 5) {
-		fprintf(stderr,
-"Usage: asmconv <input-type> <output-type> [input-file [output-file]]\n");
-		exit(EXIT_FAILURE);
-	}
-
-	lang_parse= argv[1];
-	lang_emit= argv[2];
-	input_file= argc < 4 ? nil : argv[3];
-	output_file= argc < 5 ? nil : argv[4];
-
-	/* Choose the parsing routines. */
-	if (strcmp(lang_parse, "ack") == 0) {
-		/* Standard ACK. */
-		parse_init= ack_parse_init;
-		get_instruction= ack_get_instruction;
-	} else
-	if (strcmp(lang_parse, "ncc") == 0) {
-		/* ACK Xenix assembly, a black sheep among ACK assemblies. */
-		parse_init= ncc_parse_init;
-		get_instruction= ncc_get_instruction;
-	} else
-	if (strcmp(lang_parse, "gnu") == 0) {
-		/* GNU assembly.  Parser by R.S. Veldema. */
-		parse_init= gnu_parse_init;
-		get_instruction= gnu_get_instruction;
-	} else
-	if (strcmp(lang_parse, "bas") == 0) {
-		/* Bruce Evans' assembler. */
-		parse_init= bas_parse_init;
-		get_instruction= bas_get_instruction;
-	} else {
-		fprintf(stderr, "asmconv: '%s': unknown input language\n",
-			lang_parse);
-		exit(EXIT_FAILURE);
-	}
-
-	/* Choose the output language. */
-	if (strcmp(lang_emit, "ack") == 0) {
-		/* Standard ACK. */
-		emit_init= ack_emit_init;
-		emit_instruction= ack_emit_instruction;
-	} else
-	if (strcmp(lang_emit, "ncc") == 0) {
-		/* ACK Xenix assembly, can be read by BAS and the 8086 ACK
-		 * ANSI C compiler.  (Allows us to compile the Boot Monitor.)
-		 */
-		emit_init= ncc_emit_init;
-		emit_instruction= ncc_emit_instruction;
-	} else
-	if (strcmp(lang_emit, "gnu") == 0) {
-		/* GNU assembler.  So we can assemble the ACK stuff among the
-		 * kernel sources and in the library.
-		 */
-		emit_init= gnu_emit_init;
-		emit_instruction= gnu_emit_instruction;
-	} else {
-		fprintf(stderr, "asmconv: '%s': unknown output language\n",
-			lang_emit);
-		exit(EXIT_FAILURE);
-	}
-
-	sprintf(banner, "Translated from %s to %s by asmconv %s",
-					lang_parse, lang_emit, version);
-
-	(*parse_init)(input_file);
-	(*emit_init)(output_file, banner);
-	for (;;) {
-		instr= (*get_instruction)();
-		(*emit_instruction)(instr);
-		if (instr == nil) break;
-		del_asm86(instr);
-	}
-	exit(err_code);
-}
Index: trunk/minix/commands/i386/asmconv/asmconv.h
===================================================================
--- trunk/minix/commands/i386/asmconv/asmconv.h	(revision 9)
+++ 	(revision )
@@ -1,24 +1,0 @@
-/*	asmconv.h - shared functions			Author: Kees J. Bot
- *								19 Dec 1993
- */
-
-#define arraysize(a)	(sizeof(a)/sizeof((a)[0]))
-#define arraylimit(a)	((a) + arraysize(a))
-#define between(a, c, z)	\
-			((unsigned)((c) - (a)) <= (unsigned)((z) - (a)))
-
-void *allocate(void *mem, size_t size);
-void deallocate(void *mem);
-void fatal(char *label);
-char *copystr(const char *s);
-int isanumber(const char *s);
-
-extern int asm_mode32;	/* In 32 bit mode if true. */
-
-#define use16()		(!asm_mode32)
-#define use32()		((int) asm_mode32)
-#define set_use16()	((void) (asm_mode32= 0))
-#define set_use32()	((void) (asm_mode32= 1))
-
-extern int err_code;	/* Exit code. */
-#define set_error()	((void) (err_code= EXIT_FAILURE))
Index: trunk/minix/commands/i386/asmconv/build
===================================================================
--- trunk/minix/commands/i386/asmconv/build	(revision 9)
+++ 	(revision )
@@ -1,3 +1,0 @@
-#!/bin/sh
-make clean
-make && make install
Index: trunk/minix/commands/i386/asmconv/emit_ack.c
===================================================================
--- trunk/minix/commands/i386/asmconv/emit_ack.c	(revision 9)
+++ 	(revision )
@@ -1,621 +1,0 @@
-/*	emit_ack.c - emit ACK assembly			Author: Kees J. Bot
- *		     emit NCC assembly				27 Dec 1993
- */
-#define nil 0
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <assert.h>
-#include "asmconv.h"
-#include "token.h"
-#include "asm86.h"
-#include "languages.h"
-
-typedef struct mnemonic {	/* ACK as86 mnemonics translation table. */
-	opcode_t	opcode;
-	char		*name;
-} mnemonic_t;
-
-static mnemonic_t mnemtab[] = {
-	{ AAA,		"aaa"		},
-	{ AAD,		"aad"		},
-	{ AAM,		"aam"		},
-	{ AAS,		"aas"		},
-	{ ADC,		"adc%"		},
-	{ ADD,		"add%"		},
-	{ AND,		"and%"		},
-	{ ARPL,		"arpl"		},
-	{ BOUND,	"bound"		},
-	{ BSF,		"bsf"		},
-	{ BSR,		"bsr"		},
-	{ BSWAP,	"bswap"		},
-	{ BT,		"bt"		},
-	{ BTC,		"btc"		},
-	{ BTR,		"btr"		},
-	{ BTS,		"bts"		},
-	{ CALL,		"call"		},
-	{ CALLF,	"callf"		},
-	{ CBW,		"cbw"		},
-	{ CLC,		"clc"		},
-	{ CLD,		"cld"		},
-	{ CLI,		"cli"		},
-	{ CLTS,		"clts"		},
-	{ CMC,		"cmc"		},
-	{ CMP,		"cmp%"		},
-	{ CMPS,		"cmps%"		},
-	{ CMPXCHG,	"cmpxchg"	},
-	{ CWD,		"cwd"		},
-	{ DAA,		"daa"		},
-	{ DAS,		"das"		},
-	{ DEC,		"dec%"		},
-	{ DIV,		"div%"		},
-	{ DOT_ALIGN,	".align"	},
-	{ DOT_ASCII,	".ascii"	},
-	{ DOT_ASCIZ,	".asciz"	},
-	{ DOT_ASSERT,	".assert"	},
-	{ DOT_BASE,	".base"		},
-	{ DOT_BSS,	".sect .bss"	},
-	{ DOT_COMM,	".comm"		},
-	{ DOT_DATA,	".sect .data"	},
-	{ DOT_DATA1,	".data1"	},
-	{ DOT_DATA2,	".data2"	},
-	{ DOT_DATA4,	".data4"	},
-	{ DOT_DEFINE,	".define"	},
-	{ DOT_END,	".sect .end"	},
-	{ DOT_EXTERN,	".extern"	},
-	{ DOT_FILE,	".file"		},
-	{ DOT_LCOMM,	".comm"		},
-	{ DOT_LINE,	".line"		},
-	{ DOT_LIST,	".list"		},
-	{ DOT_NOLIST,	".nolist"	},
-	{ DOT_ROM,	".sect .rom"	},
-	{ DOT_SPACE,	".space"	},
-	{ DOT_SYMB,	".symb"		},
-	{ DOT_TEXT,	".sect .text"	},
-	{ DOT_USE16,	".use16"	},
-	{ DOT_USE32,	".use32"	},
-	{ ENTER,	"enter"		},
-	{ F2XM1,	"f2xm1"		},
-	{ FABS,		"fabs"		},
-	{ FADD,		"fadd"		},
-	{ FADDD,	"faddd"		},
-	{ FADDP,	"faddp"		},
-	{ FADDS,	"fadds"		},
-	{ FBLD,		"fbld"		},
-	{ FBSTP,	"fbstp"		},
-	{ FCHS,		"fchs"		},
-	{ FCLEX,	"fclex"		},
-	{ FCOMD,	"fcomd"		},
-	{ FCOMPD,	"fcompd"	},
-	{ FCOMPP,	"fcompp"	},
-	{ FCOMPS,	"fcomps"	},
-	{ FCOMS,	"fcoms"		},
-	{ FCOS,		"fcos"		},
-	{ FDECSTP,	"fdecstp"	},
-	{ FDIVD,	"fdivd"		},
-	{ FDIVP,	"fdivp"		},
-	{ FDIVRD,	"fdivrd"	},
-	{ FDIVRP,	"fdivrp"	},
-	{ FDIVRS,	"fdivrs"	},
-	{ FDIVS,	"fdivs"		},
-	{ FFREE,	"ffree"		},
-	{ FIADDL,	"fiaddl"	},
-	{ FIADDS,	"fiadds"	},
-	{ FICOM,	"ficom"		},
-	{ FICOMP,	"ficomp"	},
-	{ FIDIVL,	"fidivl"	},
-	{ FIDIVRL,	"fidivrl"	},
-	{ FIDIVRS,	"fidivrs"	},
-	{ FIDIVS,	"fidivs"	},
-	{ FILDL,	"fildl"		},
-	{ FILDQ,	"fildq"		},
-	{ FILDS,	"filds"		},
-	{ FIMULL,	"fimull"	},
-	{ FIMULS,	"fimuls"	},
-	{ FINCSTP,	"fincstp"	},
-	{ FINIT,	"finit"		},
-	{ FISTL,	"fistl"		},
-	{ FISTP,	"fistp"		},
-	{ FISTS,	"fists"		},
-	{ FISUBL,	"fisubl"	},
-	{ FISUBRL,	"fisubrl"	},
-	{ FISUBRS,	"fisubrs"	},
-	{ FISUBS,	"fisubs"	},
-	{ FLD1,		"fld1"		},
-	{ FLDCW,	"fldcw"		},
-	{ FLDD,		"fldd"		},
-	{ FLDENV,	"fldenv"	},
-	{ FLDL2E,	"fldl2e"	},
-	{ FLDL2T,	"fldl2t"	},
-	{ FLDLG2,	"fldlg2"	},
-	{ FLDLN2,	"fldln2"	},
-	{ FLDPI,	"fldpi"		},
-	{ FLDS,		"flds"		},
-	{ FLDX,		"fldx"		},
-	{ FLDZ,		"fldz"		},
-	{ FMULD,	"fmuld"		},
-	{ FMULP,	"fmulp"		},
-	{ FMULS,	"fmuls"		},
-	{ FNOP,		"fnop"		},
-	{ FPATAN,	"fpatan"	},
-	{ FPREM,	"fprem"		},
-	{ FPREM1,	"fprem1"	},
-	{ FPTAN,	"fptan"		},
-	{ FRNDINT,	"frndint"	},
-	{ FRSTOR,	"frstor"	},
-	{ FSAVE,	"fsave"		},
-	{ FSCALE,	"fscale"	},
-	{ FSIN,		"fsin"		},
-	{ FSINCOS,	"fsincos"	},
-	{ FSQRT,	"fsqrt"		},
-	{ FSTCW,	"fstcw"		},
-	{ FSTD,		"fstd"		},
-	{ FSTENV,	"fstenv"	},
-	{ FSTPD,	"fstpd"		},
-	{ FSTPS,	"fstps"		},
-	{ FSTPX,	"fstpx"		},
-	{ FSTS,		"fsts"		},
-	{ FSTSW,	"fstsw"		},
-	{ FSUBD,	"fsubd"		},
-	{ FSUBP,	"fsubp"		},
-	{ FSUBPR,	"fsubpr"	},
-	{ FSUBRD,	"fsubrd"	},
-	{ FSUBRS,	"fsubrs"	},
-	{ FSUBS,	"fsubs"		},
-	{ FTST,		"ftst"		},
-	{ FUCOM,	"fucom"		},
-	{ FUCOMP,	"fucomp"	},
-	{ FUCOMPP,	"fucompp"	},
-	{ FXAM,		"fxam"		},
-	{ FXCH,		"fxch"		},
-	{ FXTRACT,	"fxtract"	},
-	{ FYL2X,	"fyl2x"		},
-	{ FYL2XP1,	"fyl2xp1"	},
-	{ HLT,		"hlt"		},
-	{ IDIV,		"idiv%"		},
-	{ IMUL,		"imul%"		},
-	{ IN,		"in%"		},
-	{ INC,		"inc%"		},
-	{ INS,		"ins%"		},
-	{ INT,		"int"		},
-	{ INTO,		"into"		},
-	{ INVD,		"invd"		},
-	{ INVLPG,	"invlpg"	},
-	{ IRET,		"iret"		},
-	{ IRETD,	"iretd"		},
-	{ JA,		"ja"		},
-	{ JAE,		"jae"		},
-	{ JB,		"jb"		},
-	{ JBE,		"jbe"		},
-	{ JCXZ,		"jcxz"		},
-	{ JE,		"je"		},
-	{ JG,		"jg"		},
-	{ JGE,		"jge"		},
-	{ JL,		"jl"		},
-	{ JLE,		"jle"		},
-	{ JMP,		"jmp"		},
-	{ JMPF,		"jmpf"		},
-	{ JNE,		"jne"		},
-	{ JNO,		"jno"		},
-	{ JNP,		"jnp"		},
-	{ JNS,		"jns"		},
-	{ JO,		"jo"		},
-	{ JP,		"jp"		},
-	{ JS,		"js"		},
-	{ LAHF,		"lahf"		},
-	{ LAR,		"lar"		},
-	{ LDS,		"lds"		},
-	{ LEA,		"lea"		},
-	{ LEAVE,	"leave"		},
-	{ LES,		"les"		},
-	{ LFS,		"lfs"		},
-	{ LGDT,		"lgdt"		},
-	{ LGS,		"lgs"		},
-	{ LIDT,		"lidt"		},
-	{ LLDT,		"lldt"		},
-	{ LMSW,		"lmsw"		},
-	{ LOCK,		"lock"		},
-	{ LODS,		"lods%"		},
-	{ LOOP,		"loop"		},
-	{ LOOPE,	"loope"		},
-	{ LOOPNE,	"loopne"	},
-	{ LSL,		"lsl"		},
-	{ LSS,		"lss"		},
-	{ LTR,		"ltr"		},
-	{ MOV,		"mov%"		},
-	{ MOVS,		"movs%"		},
-	{ MOVSX,	"movsx"		},
-	{ MOVSXB,	"movsxb"	},
-	{ MOVZX,	"movzx"		},
-	{ MOVZXB,	"movzxb"	},
-	{ MUL,		"mul%"		},
-	{ NEG,		"neg%"		},
-	{ NOP,		"nop"		},
-	{ NOT,		"not%"		},
-	{ OR,		"or%"		},
-	{ OUT,		"out%"		},
-	{ OUTS,		"outs%"		},
-	{ POP,		"pop"		},
-	{ POPA,		"popa"		},
-	{ POPF,		"popf"		},
-	{ PUSH,		"push"		},
-	{ PUSHA,	"pusha"		},
-	{ PUSHF,	"pushf"		},
-	{ RCL,		"rcl%"		},
-	{ RCR,		"rcr%"		},
-	{ RET,		"ret"		},
-	{ RETF,		"retf"		},
-	{ ROL,		"rol%"		},
-	{ ROR,		"ror%"		},
-	{ SAHF,		"sahf"		},
-	{ SAL,		"sal%"		},
-	{ SAR,		"sar%"		},
-	{ SBB,		"sbb%"		},
-	{ SCAS,		"scas%"		},
-	{ SETA,		"seta"		},
-	{ SETAE,	"setae"		},
-	{ SETB,		"setb"		},
-	{ SETBE,	"setbe"		},
-	{ SETE,		"sete"		},
-	{ SETG,		"setg"		},
-	{ SETGE,	"setge"		},
-	{ SETL,		"setl"		},
-	{ SETLE,	"setle"		},
-	{ SETNE,	"setne"		},
-	{ SETNO,	"setno"		},
-	{ SETNP,	"setnp"		},
-	{ SETNS,	"setns"		},
-	{ SETO,		"seto"		},
-	{ SETP,		"setp"		},
-	{ SETS,		"sets"		},
-	{ SGDT,		"sgdt"		},
-	{ SHL,		"shl%"		},
-	{ SHLD,		"shld"		},
-	{ SHR,		"shr%"		},
-	{ SHRD,		"shrd"		},
-	{ SIDT,		"sidt"		},
-	{ SLDT,		"sldt"		},
-	{ SMSW,		"smsw"		},
-	{ STC,		"stc"		},
-	{ STD,		"std"		},
-	{ STI,		"sti"		},
-	{ STOS,		"stos%"		},
-	{ STR,		"str"		},
-	{ SUB,		"sub%"		},
-	{ TEST,		"test%"		},
-	{ VERR,		"verr"		},
-	{ VERW,		"verw"		},
-	{ WAIT,		"wait"		},
-	{ WBINVD,	"wbinvd"	},
-	{ XADD,		"xadd"		},
-	{ XCHG,		"xchg%"		},
-	{ XLAT,		"xlat"		},
-	{ XOR,		"xor%"		},
-};
-
-#define farjmp(o)	((o) == JMPF || (o) == CALLF)
-
-static FILE *ef;
-static long eline= 1;
-static char *efile;
-static char *orig_efile;
-static char *opcode2name_tab[N_OPCODES];
-static enum dialect { ACK, NCC } dialect= ACK;
-
-static void ack_putchar(int c)
-/* LOOK, this programmer checks the return code of putc!  What an idiot, noone
- * does that!
- */
-{
-	if (putc(c, ef) == EOF) fatal(orig_efile);
-}
-
-static void ack_printf(const char *fmt, ...)
-{
-	va_list ap;
-
-	va_start(ap, fmt);
-	if (vfprintf(ef, fmt, ap) == EOF) fatal(orig_efile);
-	va_end(ap);
-}
-
-void ack_emit_init(char *file, const char *banner)
-/* Prepare producing an ACK assembly file. */
-{
-	mnemonic_t *mp;
-
-	if (file == nil) {
-		file= "stdout";
-		ef= stdout;
-	} else {
-		if ((ef= fopen(file, "w")) == nil) fatal(file);
-	}
-	orig_efile= file;
-	efile= file;
-	ack_printf("! %s", banner);
-	if (dialect == ACK) {
-		/* Declare the four sections used under Minix. */
-		ack_printf(
-	"\n.sect .text; .sect .rom; .sect .data; .sect .bss\n.sect .text");
-	}
-
-	/* Initialize the opcode to mnemonic translation table. */
-	for (mp= mnemtab; mp < arraylimit(mnemtab); mp++) {
-		assert(opcode2name_tab[mp->opcode] == nil);
-		opcode2name_tab[mp->opcode]= mp->name;
-	}
-}
-
-#define opcode2name(op)		(opcode2name_tab[op] + 0)
-
-static void ack_put_string(const char *s, size_t n)
-/* Emit a string with weird characters quoted. */
-{
-	while (n > 0) {
-		int c= *s;
-
-		if (c < ' ' || c > 0177) {
-			ack_printf("\\%03o", c & 0xFF);
-		} else
-		if (c == '"' || c == '\\') {
-			ack_printf("\\%c", c);
-		} else {
-			ack_putchar(c);
-		}
-		s++;
-		n--;
-	}
-}
-
-static void ack_put_expression(asm86_t *a, expression_t *e, int deref)
-/* Send an expression, i.e. instruction operands, to the output file.  Deref
- * is true when the rewrite for the ncc dialect may be made.
- */
-{
-	assert(e != nil);
-
-	switch (e->operator) {
-	case ',':
-		if (dialect == NCC && farjmp(a->opcode)) {
-			/* ACK jmpf seg:off  ->  NCC jmpf off,seg */
-			ack_put_expression(a, e->right, deref);
-			ack_printf(", ");
-			ack_put_expression(a, e->left, deref);
-		} else {
-			ack_put_expression(a, e->left, deref);
-			ack_printf(farjmp(a->opcode) ? ":" : ", ");
-			ack_put_expression(a, e->right, deref);
-		}
-		break;
-	case 'O':
-		if (deref && a->optype == JUMP) ack_putchar('@');
-		if (e->left != nil) ack_put_expression(a, e->left, 0);
-		if (e->middle != nil) ack_put_expression(a, e->middle, 0);
-		if (e->right != nil) ack_put_expression(a, e->right, 0);
-		break;
-	case '(':
-		if (deref && a->optype == JUMP) ack_putchar('@');
-		if (!deref) ack_putchar('(');
-		ack_put_expression(a, e->middle, 0);
-		if (!deref) ack_putchar(')');
-		break;
-	case 'B':
-		ack_printf("(%s)", e->name);
-		break;
-	case '1':
-	case '2':
-	case '4':
-	case '8':
-		ack_printf((use16() && e->operator == '1')
-				? "(%s)" : "(%s*%c)", e->name, e->operator);
-		break;
-	case '+':
-	case '-':
-	case '~':
-		if (e->middle != nil) {
-			if (deref && a->optype != JUMP) ack_putchar('#');
-			ack_putchar(e->operator);
-			ack_put_expression(a, e->middle, 0);
-			break;
-		}
-		/*FALL THROUGH*/
-	case '*':
-	case '/':
-	case '%':
-	case '&':
-	case '|':
-	case '^':
-	case S_LEFTSHIFT:
-	case S_RIGHTSHIFT:
-		if (deref && a->optype != JUMP) ack_putchar('#');
-		ack_put_expression(a, e->left, 0);
-		if (e->operator == S_LEFTSHIFT) {
-			ack_printf("<<");
-		} else
-		if (e->operator == S_RIGHTSHIFT) {
-			ack_printf(">>");
-		} else {
-			ack_putchar(e->operator);
-		}
-		ack_put_expression(a, e->right, 0);
-		break;
-	case '[':
-		if (deref && a->optype != JUMP) ack_putchar('#');
-		ack_putchar('[');
-		ack_put_expression(a, e->middle, 0);
-		ack_putchar(']');
-		break;
-	case 'W':
-		if (deref && a->optype == JUMP && isregister(e->name))
-		{
-			ack_printf("(%s)", e->name);
-			break;
-		}
-		if (deref && a->optype != JUMP && !isregister(e->name)) {
-			ack_putchar('#');
-		}
-		ack_printf("%s", e->name);
-		break;
-	case 'S':
-		ack_putchar('"');
-		ack_put_string(e->name, e->len);
-		ack_putchar('"');
-		break;
-	default:
-		fprintf(stderr,
-		"asmconv: internal error, unknown expression operator '%d'\n",
-			e->operator);
-		exit(EXIT_FAILURE);
-	}
-}
-
-void ack_emit_instruction(asm86_t *a)
-/* Output one instruction and its operands. */
-{
-	int same= 0;
-	char *p;
-	static int high_seg;
-	int deref;
-
-	if (a == nil) {
-		/* Last call */
-		ack_putchar('\n');
-		return;
-	}
-
-	/* Make sure the line number of the line to be emitted is ok. */
-	if ((a->file != efile && strcmp(a->file, efile) != 0)
-				|| a->line < eline || a->line > eline+10) {
-		ack_putchar('\n');
-		ack_printf("# %ld \"%s\"\n", a->line, a->file);
-		efile= a->file;
-		eline= a->line;
-	} else {
-		if (a->line == eline) {
-			ack_printf("; ");
-			same= 1;
-		}
-		while (eline < a->line) {
-			ack_putchar('\n');
-			eline++;
-		}
-	}
-
-	if (a->opcode == DOT_LABEL) {
-		assert(a->args->operator == ':');
-		ack_printf("%s:", a->args->name);
-	} else
-	if (a->opcode == DOT_EQU) {
-		assert(a->args->operator == '=');
-		ack_printf("\t%s = ", a->args->name);
-		ack_put_expression(a, a->args->middle, 0);
-	} else
-	if ((p= opcode2name(a->opcode)) != nil) {
-		char *sep= dialect == ACK ? "" : ";";
-
-		if (!is_pseudo(a->opcode) && !same) ack_putchar('\t');
-
-		switch (a->rep) {
-		case ONCE:	break;
-		case REP:	ack_printf("rep");	break;
-		case REPE:	ack_printf("repe");	break;
-		case REPNE:	ack_printf("repne");	break;
-		default:	assert(0);
-		}
-		if (a->rep != ONCE) {
-			ack_printf(dialect == ACK ? " " : "; ");
-		}
-		switch (a->seg) {
-		case DEFSEG:	break;
-		case CSEG:	ack_printf("cseg");	break;
-		case DSEG:	ack_printf("dseg");	break;
-		case ESEG:	ack_printf("eseg");	break;
-		case FSEG:	ack_printf("fseg");	break;
-		case GSEG:	ack_printf("gseg");	break;
-		case SSEG:	ack_printf("sseg");	break;
-		default:	assert(0);
-		}
-		if (a->seg != DEFSEG) {
-			ack_printf(dialect == ACK ? " " : "; ");
-		}
-		if (a->oaz & OPZ) ack_printf(use16() ? "o32 " : "o16 ");
-		if (a->oaz & ADZ) ack_printf(use16() ? "a32 " : "a16 ");
-
-		if (a->opcode == CBW) {
-			p= !(a->oaz & OPZ) == use16() ? "cbw" : "cwde";
-		}
-
-		if (a->opcode == CWD) {
-			p= !(a->oaz & OPZ) == use16() ? "cwd" : "cdq";
-		}
-
-		if (a->opcode == DOT_COMM && a->args != nil
-			&& a->args->operator == ','
-			&& a->args->left->operator == 'W'
-		) {
-			ack_printf(".define\t%s; ", a->args->left->name);
-		}
-		while (*p != 0) {
-			if (*p == '%') {
-				if (a->optype == BYTE) ack_putchar('b');
-			} else {
-				ack_putchar(*p);
-			}
-			p++;
-		}
-		if (a->args != nil) {
-			ack_putchar('\t');
-			switch (a->opcode) {
-			case IN:
-			case OUT:
-			case INT:
-				deref= 0;
-				break;
-			default:
-				deref= (dialect == NCC && a->optype != PSEUDO);
-			}
-			ack_put_expression(a, a->args, deref);
-		}
-		if (a->opcode == DOT_USE16) set_use16();
-		if (a->opcode == DOT_USE32) set_use32();
-	} else {
-		fprintf(stderr,
-			"asmconv: internal error, unknown opcode '%d'\n",
-			a->opcode);
-		exit(EXIT_FAILURE);
-	}
-}
-
-/* A few ncc mnemonics are different. */
-static mnemonic_t ncc_mnemtab[] = {
-	{ DOT_BSS,	".bss"		},
-	{ DOT_DATA,	".data"		},
-	{ DOT_END,	".end"		},
-	{ DOT_ROM,	".rom"		},
-	{ DOT_TEXT,	".text"		},
-};
-
-void ncc_emit_init(char *file, const char *banner)
-/* The assembly produced by the Minix ACK ANSI C compiler for the 8086 is
- * different from the normal ACK assembly, and different from the old K&R
- * assembler.  This brings us endless joy.  (It was supposed to make
- * translation of the assembly used by the old K&R assembler easier by
- * not deviating too much from that dialect.)
- */
-{
-	mnemonic_t *mp;
-
-	dialect= NCC;
-	ack_emit_init(file, banner);
-
-	/* Replace a few mnemonics. */
-	for (mp= ncc_mnemtab; mp < arraylimit(ncc_mnemtab); mp++) {
-		opcode2name_tab[mp->opcode]= mp->name;
-	}
-}
-
-void ncc_emit_instruction(asm86_t *a)
-{
-	ack_emit_instruction(a);
-}
Index: trunk/minix/commands/i386/asmconv/emit_gnu.c
===================================================================
--- trunk/minix/commands/i386/asmconv/emit_gnu.c	(revision 9)
+++ 	(revision )
@@ -1,674 +1,0 @@
-/*	emit_gnu.c - emit GNU assembly			Author: Kees J. Bot
- *								28 Dec 1993
- */
-#define nil 0
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <assert.h>
-#include "asmconv.h"
-#include "token.h"
-#include "asm86.h"
-#include "languages.h"
-
-typedef struct mnemonic {	/* GNU as386 mnemonics translation table. */
-	opcode_t	opcode;
-	char		*name;
-} mnemonic_t;
-
-static mnemonic_t mnemtab[] = {
-	{ AAA,		"aaa"		},
-	{ AAD,		"aad"		},
-	{ AAM,		"aam"		},
-	{ AAS,		"aas"		},
-	{ ADC,		"adc%"		},
-	{ ADD,		"add%"		},
-	{ AND,		"and%"		},
-	{ ARPL,		"arpl"		},
-	{ BOUND,	"bound%"	},
-	{ BSF,		"bsf%"		},
-	{ BSR,		"bsr%"		},
-	{ BSWAP,	"bswap"		},
-	{ BT,		"bt%"		},
-	{ BTC,		"btc%"		},
-	{ BTR,		"btr%"		},
-	{ BTS,		"bts%"		},
-	{ CALL,		"call"		},
-	{ CALLF,	"lcall"		},
-	{ CBW,		"cbtw"		},
-	{ CLC,		"clc"		},
-	{ CLD,		"cld"		},
-	{ CLI,		"cli"		},
-	{ CLTS,		"clts"		},
-	{ CMC,		"cmc"		},
-	{ CMP,		"cmp%"		},
-	{ CMPS,		"cmps%"		},
-	{ CMPXCHG,	"cmpxchg"	},
-	{ CWD,		"cwtd"		},
-	{ DAA,		"daa"		},
-	{ DAS,		"das"		},
-	{ DEC,		"dec%"		},
-	{ DIV,		"div%"		},
-	{ DOT_ALIGN,	".align"	},
-	{ DOT_ASCII,	".ascii"	},
-	{ DOT_ASCIZ,	".asciz"	},
-	{ DOT_ASSERT,	".assert"	},
-	{ DOT_BASE,	".base"		},
-	{ DOT_BSS,	".bss"		},
-	{ DOT_COMM,	".comm"		},
-	{ DOT_DATA,	".data"		},
-	{ DOT_DATA1,	".byte"		},
-	{ DOT_DATA2,	".short"	},
-	{ DOT_DATA4,	".long"		},
-	{ DOT_DEFINE,	".globl"	},
-	{ DOT_EXTERN,	".globl"	},
-	{ DOT_FILE,	".file"		},
-	{ DOT_LCOMM,	".lcomm"	},
-	{ DOT_LINE,	".line"		},
-	{ DOT_LIST,	".list"		},
-	{ DOT_NOLIST,	".nolist"	},
-	{ DOT_ROM,	".data"		},	/* Minix -- separate I&D. */
-	{ DOT_SPACE,	".space"	},
-	{ DOT_SYMB,	".symb"		},
-	{ DOT_TEXT,	".text"		},
-	{ DOT_USE16,	".use16"	},
-	{ DOT_USE32,	".use32"	},
-	{ ENTER,	"enter"		},
-	{ F2XM1,	"f2xm1"		},
-	{ FABS,		"fabs"		},
-	{ FADD,		"fadd"		},
-	{ FADDD,	"faddl"		},
-	{ FADDP,	"faddp"		},
-	{ FADDS,	"fadds"		},
-	{ FBLD,		"fbld"		},
-	{ FBSTP,	"fbstp"		},
-	{ FCHS,		"fchs"		},
-	{ FCLEX,	"fnclex"	},
-	{ FCOMD,	"fcoml"		},
-	{ FCOMPD,	"fcompl"	},
-	{ FCOMPP,	"fcompp"	},
-	{ FCOMPS,	"fcomps"	},
-	{ FCOMS,	"fcoms"		},
-	{ FCOS,		"fcos"		},
-	{ FDECSTP,	"fdecstp"	},
-	{ FDIVD,	"fdivl"		},
-	{ FDIVP,	"fdivp"		},
-	{ FDIVRD,	"fdivrl"	},
-	{ FDIVRP,	"fdivrp"	},
-	{ FDIVRS,	"fdivrs"	},
-	{ FDIVS,	"fdivs"		},
-	{ FFREE,	"ffree"		},
-	{ FIADDL,	"fiaddl"	},
-	{ FIADDS,	"fiadds"	},
-	{ FICOM,	"ficom"		},
-	{ FICOMP,	"ficomp"	},
-	{ FIDIVL,	"fidivl"	},
-	{ FIDIVRL,	"fidivrl"	},
-	{ FIDIVRS,	"fidivrs"	},
-	{ FIDIVS,	"fidivs"	},
-	{ FILDL,	"fildl"		},
-	{ FILDQ,	"fildq"		},
-	{ FILDS,	"filds"		},
-	{ FIMULL,	"fimull"	},
-	{ FIMULS,	"fimuls"	},
-	{ FINCSTP,	"fincstp"	},
-	{ FINIT,	"fninit"	},
-	{ FISTL,	"fistl"		},
-	{ FISTP,	"fistp"		},
-	{ FISTS,	"fists"		},
-	{ FISUBL,	"fisubl"	},
-	{ FISUBRL,	"fisubrl"	},
-	{ FISUBRS,	"fisubrs"	},
-	{ FISUBS,	"fisubs"	},
-	{ FLD1,		"fld1"		},
-	{ FLDCW,	"fldcw"		},
-	{ FLDD,		"fldl"		},
-	{ FLDENV,	"fldenv"	},
-	{ FLDL2E,	"fldl2e"	},
-	{ FLDL2T,	"fldl2t"	},
-	{ FLDLG2,	"fldlg2"	},
-	{ FLDLN2,	"fldln2"	},
-	{ FLDPI,	"fldpi"		},
-	{ FLDS,		"flds"		},
-	{ FLDX,		"fldt"		},
-	{ FLDZ,		"fldz"		},
-	{ FMULD,	"fmull"		},
-	{ FMULP,	"fmulp"		},
-	{ FMULS,	"fmuls"		},
-	{ FNOP,		"fnop"		},
-	{ FPATAN,	"fpatan"	},
-	{ FPREM,	"fprem"		},
-	{ FPREM1,	"fprem1"	},
-	{ FPTAN,	"fptan"		},
-	{ FRNDINT,	"frndint"	},
-	{ FRSTOR,	"frstor"	},
-	{ FSAVE,	"fnsave"	},
-	{ FSCALE,	"fscale"	},
-	{ FSIN,		"fsin"		},
-	{ FSINCOS,	"fsincos"	},
-	{ FSQRT,	"fsqrt"		},
-	{ FSTCW,	"fnstcw"	},
-	{ FSTD,		"fstl"		},
-	{ FSTENV,	"fnstenv"	},
-	{ FSTPD,	"fstpl"		},
-	{ FSTPS,	"fstps"		},
-	{ FSTPX,	"fstpt"		},
-	{ FSTS,		"fsts"		},
-	{ FSTSW,	"fstsw"		},
-	{ FSUBD,	"fsubl"		},
-	{ FSUBP,	"fsubp"		},
-	{ FSUBPR,	"fsubpr"	},
-	{ FSUBRD,	"fsubrl"	},
-	{ FSUBRS,	"fsubrs"	},
-	{ FSUBS,	"fsubs"		},
-	{ FTST,		"ftst"		},
-	{ FUCOM,	"fucom"		},
-	{ FUCOMP,	"fucomp"	},
-	{ FUCOMPP,	"fucompp"	},
-	{ FXAM,		"fxam"		},
-	{ FXCH,		"fxch"		},
-	{ FXTRACT,	"fxtract"	},
-	{ FYL2X,	"fyl2x"		},
-	{ FYL2XP1,	"fyl2xp1"	},
-	{ HLT,		"hlt"		},
-	{ IDIV,		"idiv%"		},
-	{ IMUL,		"imul%"		},
-	{ IN,		"in%"		},
-	{ INC,		"inc%"		},
-	{ INS,		"ins%"		},
-	{ INT,		"int"		},
-	{ INTO,		"into"		},
-	{ INVD,		"invd"		},
-	{ INVLPG,	"invlpg"	},
-	{ IRET,		"iret"		},
-	{ IRETD,	"iret"		},
-	{ JA,		"ja"		},
-	{ JAE,		"jae"		},
-	{ JB,		"jb"		},
-	{ JBE,		"jbe"		},
-	{ JCXZ,		"jcxz"		},
-	{ JE,		"je"		},
-	{ JG,		"jg"		},
-	{ JGE,		"jge"		},
-	{ JL,		"jl"		},
-	{ JLE,		"jle"		},
-	{ JMP,		"jmp"		},
-	{ JMPF,		"ljmp"		},
-	{ JNE,		"jne"		},
-	{ JNO,		"jno"		},
-	{ JNP,		"jnp"		},
-	{ JNS,		"jns"		},
-	{ JO,		"jo"		},
-	{ JP,		"jp"		},
-	{ JS,		"js"		},
-	{ LAHF,		"lahf"		},
-	{ LAR,		"lar"		},
-	{ LDS,		"lds"		},
-	{ LEA,		"lea%"		},
-	{ LEAVE,	"leave"		},
-	{ LES,		"les"		},
-	{ LFS,		"lfs"		},
-	{ LGDT,		"lgdt"		},
-	{ LGS,		"lgs"		},
-	{ LIDT,		"lidt"		},
-	{ LLDT,		"lldt"		},
-	{ LMSW,		"lmsw"		},
-	{ LOCK,		"lock"		},
-	{ LODS,		"lods%"		},
-	{ LOOP,		"loop"		},
-	{ LOOPE,	"loope"		},
-	{ LOOPNE,	"loopne"	},
-	{ LSL,		"lsl"		},
-	{ LSS,		"lss"		},
-	{ LTR,		"ltr"		},
-	{ MOV,		"mov%"		},
-	{ MOVS,		"movs%"		},
-	{ MOVSX,	"movswl"	},
-	{ MOVSXB,	"movsb%"	},
-	{ MOVZX,	"movzwl"	},
-	{ MOVZXB,	"movzb%"	},
-	{ MUL,		"mul%"		},
-	{ NEG,		"neg%"		},
-	{ NOP,		"nop"		},
-	{ NOT,		"not%"		},
-	{ OR,		"or%"		},
-	{ OUT,		"out%"		},
-	{ OUTS,		"outs%"		},
-	{ POP,		"pop%"		},
-	{ POPA,		"popa%"		},
-	{ POPF,		"popf%"		},
-	{ PUSH,		"push%"		},
-	{ PUSHA,	"pusha%"	},
-	{ PUSHF,	"pushf%"	},
-	{ RCL,		"rcl%"		},
-	{ RCR,		"rcr%"		},
-	{ RET,		"ret"		},
-	{ RETF,		"lret"		},
-	{ ROL,		"rol%"		},
-	{ ROR,		"ror%"		},
-	{ SAHF,		"sahf"		},
-	{ SAL,		"sal%"		},
-	{ SAR,		"sar%"		},
-	{ SBB,		"sbb%"		},
-	{ SCAS,		"scas%"		},
-	{ SETA,		"setab"		},
-	{ SETAE,	"setaeb"	},
-	{ SETB,		"setbb"		},
-	{ SETBE,	"setbeb"	},
-	{ SETE,		"seteb"		},
-	{ SETG,		"setgb"		},
-	{ SETGE,	"setgeb"	},
-	{ SETL,		"setlb"		},
-	{ SETLE,	"setleb"	},
-	{ SETNE,	"setneb"	},
-	{ SETNO,	"setnob"	},
-	{ SETNP,	"setnpb"	},
-	{ SETNS,	"setnsb"	},
-	{ SETO,		"setob"		},
-	{ SETP,		"setpb"		},
-	{ SETS,		"setsb"		},
-	{ SGDT,		"sgdt"		},
-	{ SHL,		"shl%"		},
-	{ SHLD,		"shld%"		},
-	{ SHR,		"shr%"		},
-	{ SHRD,		"shrd%"		},
-	{ SIDT,		"sidt"		},
-	{ SLDT,		"sldt"		},
-	{ SMSW,		"smsw"		},
-	{ STC,		"stc"		},
-	{ STD,		"std"		},
-	{ STI,		"sti"		},
-	{ STOS,		"stos%"		},
-	{ STR,		"str"		},
-	{ SUB,		"sub%"		},
-	{ TEST,		"test%"		},
-	{ VERR,		"verr"		},
-	{ VERW,		"verw"		},
-	{ WAIT,		"wait"		},
-	{ WBINVD,	"wbinvd"	},
-	{ XADD,		"xadd"		},
-	{ XCHG,		"xchg%"		},
-	{ XLAT,		"xlat"		},
-	{ XOR,		"xor%"		},
-};
-
-static FILE *ef;
-static long eline= 1;
-static char *efile;
-static char *orig_efile;
-static char *opcode2name_tab[N_OPCODES];
-
-static void gnu_putchar(int c)
-/* LOOK, this programmer checks the return code of putc!  What an idiot, noone
- * does that!
- */
-{
-	if (putc(c, ef) == EOF) fatal(orig_efile);
-}
-
-static void gnu_printf(const char *fmt, ...)
-{
-	va_list ap;
-
-	va_start(ap, fmt);
-	if (vfprintf(ef, fmt, ap) == EOF) fatal(orig_efile);
-	va_end(ap);
-}
-
-void gnu_emit_init(char *file, const char *banner)
-/* Prepare producing a GNU assembly file. */
-{
-	mnemonic_t *mp;
-
-	if (file == nil) {
-		file= "stdout";
-		ef= stdout;
-	} else {
-		if ((ef= fopen(file, "w")) == nil) fatal(file);
-	}
-	orig_efile= file;
-	efile= file;
-	gnu_printf("/ %s", banner);
-
-	/* Initialize the opcode to mnemonic translation table. */
-	for (mp= mnemtab; mp < arraylimit(mnemtab); mp++) {
-		assert(opcode2name_tab[mp->opcode] == nil);
-		opcode2name_tab[mp->opcode]= mp->name;
-	}
-}
-
-#define opcode2name(op)		(opcode2name_tab[op] + 0)
-
-static void gnu_put_string(const char *s, size_t n)
-/* Emit a string with weird characters quoted. */
-{
-	while (n > 0) {
-		int c= *s;
-
-		if (c < ' ' || c > 0177) {
-			gnu_printf("\\%03o", c);
-		} else
-		if (c == '"' || c == '\\') {
-			gnu_printf("\\%c", c & 0xFF);
-		} else {
-			gnu_putchar(c);
-		}
-		s++;
-		n--;
-	}
-}
-
-static void gnu_put_expression(asm86_t *a, expression_t *e, int deref)
-/* Send an expression, i.e. instruction operands, to the output file.  Deref
- * is true when the rewrite of "x" -> "#x" or "(x)" -> "x" may be made.
- */
-{
-	assert(e != nil);
-
-	switch (e->operator) {
-	case ',':
-		if (is_pseudo(a->opcode)) {
-			/* Pseudo's are normal. */
-			gnu_put_expression(a, e->left, deref);
-			gnu_printf(", ");
-			gnu_put_expression(a, e->right, deref);
-		} else {
-			/* He who invented GNU assembly has seen one VAX too
-			 * many, operands are given in the wrong order.  This
-			 * makes coding from an Intel databook a real delight.
-			 * A good thing this program allows us to write the
-			 * more normal ACK assembly.
-			 */
-			gnu_put_expression(a, e->right, deref);
-			gnu_printf(", ");
-			gnu_put_expression(a, e->left, deref);
-		}
-		break;
-	case 'O':
-		if (deref && a->optype == JUMP) gnu_putchar('*');
-		if (e->left != nil) gnu_put_expression(a, e->left, 0);
-		gnu_putchar('(');
-		if (e->middle != nil) gnu_put_expression(a, e->middle, 0);
-		if (e->right != nil) {
-			gnu_putchar(',');
-			gnu_put_expression(a, e->right, 0);
-		}
-		gnu_putchar(')');
-		break;
-	case '(':
-		if (!deref) gnu_putchar('(');
-		if (deref && a->optype == JUMP) gnu_putchar('*');
-		gnu_put_expression(a, e->middle, 0);
-		if (!deref) gnu_putchar(')');
-		break;
-	case 'B':
-		gnu_printf("%%%s", e->name);
-		break;
-	case '1':
-	case '2':
-	case '4':
-	case '8':
-		gnu_printf("%%%s,%c", e->name, e->operator);
-		break;
-	case '+':
-	case '-':
-	case '~':
-		if (e->middle != nil) {
-			if (deref && a->optype >= BYTE) gnu_putchar('$');
-			gnu_putchar(e->operator);
-			gnu_put_expression(a, e->middle, 0);
-			break;
-		}
-		/*FALL THROUGH*/
-	case '*':
-	case '/':
-	case '%':
-	case '&':
-	case '|':
-	case '^':
-	case S_LEFTSHIFT:
-	case S_RIGHTSHIFT:
-		if (deref && a->optype >= BYTE) gnu_putchar('$');
-		gnu_put_expression(a, e->left, 0);
-		if (e->operator == S_LEFTSHIFT) {
-			gnu_printf("<<");
-		} else
-		if (e->operator == S_RIGHTSHIFT) {
-			gnu_printf(">>");
-		} else {
-			gnu_putchar(e->operator);
-		}
-		gnu_put_expression(a, e->right, 0);
-		break;
-	case '[':
-		if (deref && a->optype >= BYTE) gnu_putchar('$');
-		gnu_putchar('(');
-		gnu_put_expression(a, e->middle, 0);
-		gnu_putchar(')');
-		break;
-	case 'W':
-		if (isregister(e->name)) {
-			if (a->optype == JUMP) gnu_putchar('*');
-			gnu_printf("%%%s", e->name);
-		} else {
-			if (deref && a->optype >= BYTE) gnu_putchar('$');
-			gnu_printf("%s", e->name);
-		}
-		break;
-	case 'S':
-		gnu_putchar('"');
-		gnu_put_string(e->name, e->len);
-		gnu_putchar('"');
-		break;
-	default:
-		fprintf(stderr,
-		"asmconv: internal error, unknown expression operator '%d'\n",
-			e->operator);
-		exit(EXIT_FAILURE);
-	}
-}
-
-void gnu_emit_instruction(asm86_t *a)
-/* Output one instruction and its operands. */
-{
-	int same= 0;
-	char *p;
-
-	if (a == nil) {
-		/* Last call */
-		gnu_putchar('\n');
-		return;
-	}
-
-	if (use16()) {
-		fprintf(stderr,
-		"asmconv: the GNU assembler can't translate 8086 code\n");
-		exit(EXIT_FAILURE);
-	}
-
-	/* Make sure the line number of the line to be emitted is ok. */
-	if ((a->file != efile && strcmp(a->file, efile) != 0)
-				|| a->line < eline || a->line > eline+10) {
-		gnu_putchar('\n');
-		gnu_printf("# %ld \"%s\"\n", a->line, a->file);
-		efile= a->file;
-		eline= a->line;
-	} else {
-		if (a->line == eline) {
-			gnu_printf("; ");
-			same= 1;
-		}
-		while (eline < a->line) {
-			gnu_putchar('\n');
-			eline++;
-		}
-	}
-
-	if (a->opcode == DOT_LABEL) {
-		assert(a->args->operator == ':');
-		gnu_printf("%s:", a->args->name);
-	} else
-	if (a->opcode == DOT_EQU) {
-		assert(a->args->operator == '=');
-		gnu_printf("\t%s = ", a->args->name);
-		gnu_put_expression(a, a->args->middle, 0);
-	} else
-	if (a->opcode == DOT_ALIGN) {
-		/* GNU .align thinks in powers of two. */
-		unsigned long n;
-		unsigned s;
-
-		assert(a->args->operator == 'W' && isanumber(a->args->name));
-		n= strtoul(a->args->name, nil, 0);
-		for (s= 0; s <= 4 && (1 << s) < n; s++) {}
-		gnu_printf(".align\t%u", s);
-	} else
-	if ((p= opcode2name(a->opcode)) != nil) {
-		if (!is_pseudo(a->opcode) && !same) gnu_putchar('\t');
-
-		switch (a->rep) {
-		case ONCE:	break;
-		case REP:	gnu_printf("rep; ");	break;
-		case REPE:	gnu_printf("repe; ");	break;
-		case REPNE:	gnu_printf("repne; ");	break;
-		default:	assert(0);
-		}
-		switch (a->seg) {
-		/* Kludge to avoid knowing where to put the "%es:" */
-		case DEFSEG:	break;
-		case CSEG:	gnu_printf(".byte 0x2e; ");	break;
-		case DSEG:	gnu_printf(".byte 0x3e; ");	break;
-		case ESEG:	gnu_printf(".byte 0x26; ");	break;
-		case FSEG:	gnu_printf(".byte 0x64; ");	break;
-		case GSEG:	gnu_printf(".byte 0x65; ");	break;
-		case SSEG:	gnu_printf(".byte 0x36; ");	break;
-		default:	assert(0);
-		}
-
-		/* Exceptions, exceptions... */
-		if (a->opcode == CBW) {
-			if (!(a->oaz & OPZ)) p= "cwtl";
-			a->oaz&= ~OPZ;
-		}
-		if (a->opcode == CWD) {
-			if (!(a->oaz & OPZ)) p= "cltd";
-			a->oaz&= ~OPZ;
-		}
-
-		if (a->opcode == RET || a->opcode == RETF) {
-			/* Argument of RET needs a '$'. */
-			a->optype= WORD;
-		}
-
-		if (a->opcode == MUL && a->args != nil
-						&& a->args->operator == ',') {
-			/* Two operand MUL is an IMUL? */
-			p="imul%";
-		}
-
-		/* GAS doesn't understand the interesting combinations. */
-		if (a->oaz & ADZ) gnu_printf(".byte 0x67; ");
-		if (a->oaz & OPZ && strchr(p, '%') == nil)
-			gnu_printf(".byte 0x66; ");
-
-		/* Unsupported instructions that Minix code needs. */
-		if (a->opcode == JMPF && a->args != nil
-					&& a->args->operator == ',') {
-			/* JMPF seg:off. */
-			gnu_printf(".byte 0xEA; .long ");
-			gnu_put_expression(a, a->args->right, 0);
-			gnu_printf("; .short ");
-			gnu_put_expression(a, a->args->left, 0);
-			return;
-		}
-		if (a->opcode == JMPF && a->args != nil
-			&& a->args->operator == 'O'
-			&& a->args->left != nil
-			&& a->args->right == nil
-			&& a->args->middle != nil
-			&& a->args->middle->operator == 'B'
-			&& strcmp(a->args->middle->name, "esp") == 0
-		) {
-			/* JMPF offset(ESP). */
-			gnu_printf(".byte 0xFF,0x6C,0x24,");
-			gnu_put_expression(a, a->args->left, 0);
-			return;
-		}
-		if (a->opcode == MOV && a->args != nil
-			&& a->args->operator == ','
-			&& a->args->left != nil
-			&& a->args->left->operator == 'W'
-			&& (strcmp(a->args->left->name, "ds") == 0
-				|| strcmp(a->args->left->name, "es") == 0)
-			&& a->args->right->operator == 'O'
-			&& a->args->right->left != nil
-			&& a->args->right->right == nil
-			&& a->args->right->middle != nil
-			&& a->args->right->middle->operator == 'B'
-			&& strcmp(a->args->right->middle->name, "esp") == 0
-		) {
-			/* MOV DS, offset(ESP); MOV ES, offset(ESP) */
-			gnu_printf(".byte 0x8E,0x%02X,0x24,",
-				a->args->left->name[0] == 'd' ? 0x5C : 0x44);
-			gnu_put_expression(a, a->args->right->left, 0);
-			return;
-		}
-		if (a->opcode == MOV && a->args != nil
-			&& a->args->operator == ','
-			&& a->args->left != nil
-			&& a->args->left->operator == 'W'
-			&& (strcmp(a->args->left->name, "ds") == 0
-				|| strcmp(a->args->left->name, "es") == 0)
-			&& a->args->right->operator == '('
-			&& a->args->right->middle != nil
-		) {
-			/* MOV DS, (memory); MOV ES, (memory) */
-			gnu_printf(".byte 0x8E,0x%02X; .long ",
-				a->args->left->name[0] == 'd' ? 0x1D : 0x05);
-			gnu_put_expression(a, a->args->right->middle, 0);
-			return;
-		}
-
-		while (*p != 0) {
-			if (*p == '%') {
-				if (a->optype == BYTE) {
-					gnu_putchar('b');
-				} else
-				if (a->optype == WORD) {
-					gnu_putchar((a->oaz & OPZ) ? 'w' : 'l');
-				} else {
-					assert(0);
-				}
-			} else {
-				gnu_putchar(*p);
-			}
-			p++;
-		}
-
-		if (a->args != nil) {
-			static char *aregs[] = { "al", "ax", "eax" };
-
-			gnu_putchar('\t');
-			switch (a->opcode) {
-			case IN:
-				gnu_put_expression(a, a->args, 1);
-				gnu_printf(", %%%s", aregs[a->optype - BYTE]);
-				break;
-			case OUT:
-				gnu_printf("%%%s, ", aregs[a->optype - BYTE]);
-				gnu_put_expression(a, a->args, 1);
-				break;
-			default:
-				gnu_put_expression(a, a->args, 1);
-			}
-		}
-		if (a->opcode == DOT_USE16) set_use16();
-		if (a->opcode == DOT_USE32) set_use32();
-	} else {
-		fprintf(stderr,
-			"asmconv: internal error, unknown opcode '%d'\n",
-			a->opcode);
-		exit(EXIT_FAILURE);
-	}
-}
Index: trunk/minix/commands/i386/asmconv/languages.h
===================================================================
--- trunk/minix/commands/i386/asmconv/languages.h	(revision 9)
+++ 	(revision )
@@ -1,25 +1,0 @@
-/*	languages.h - functions that parse or emit assembly
- *							Author: Kees J. Bot
- *								27 Dec 1993
- */
-
-void ack_parse_init(char *file);
-asm86_t *ack_get_instruction(void);
-
-void ncc_parse_init(char *file);
-asm86_t *ncc_get_instruction(void);
-
-void gnu_parse_init(char *file);
-asm86_t *gnu_get_instruction(void);
-
-void bas_parse_init(char *file);
-asm86_t *bas_get_instruction(void);
-
-void ack_emit_init(char *file, const char *banner);
-void ack_emit_instruction(asm86_t *instr);
-
-void ncc_emit_init(char *file, const char *banner);
-void ncc_emit_instruction(asm86_t *instr);
-
-void gnu_emit_init(char *file, const char *banner);
-void gnu_emit_instruction(asm86_t *instr);
Index: trunk/minix/commands/i386/asmconv/parse_ack.c
===================================================================
--- trunk/minix/commands/i386/asmconv/parse_ack.c	(revision 9)
+++ 	(revision )
@@ -1,910 +1,0 @@
-/*	parse_ack.c - parse ACK assembly		Author: Kees J. Bot
- *		      parse NCC assembly			18 Dec 1993
- */
-#define nil 0
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include "asmconv.h"
-#include "token.h"
-#include "asm86.h"
-#include "languages.h"
-
-typedef struct mnemonic {	/* ACK as86 mnemonics translation table. */
-	char		*name;
-	opcode_t	opcode;
-	optype_t	optype;
-} mnemonic_t;
-
-static mnemonic_t mnemtab[] = {			/* This array is sorted. */
-	{ ".align",	DOT_ALIGN,	PSEUDO },
-	{ ".ascii",	DOT_ASCII,	PSEUDO },
-	{ ".asciz",	DOT_ASCIZ,	PSEUDO },
-	{ ".assert",	DOT_ASSERT,	PSEUDO },
-	{ ".base",	DOT_BASE,	PSEUDO },
-	{ ".bss",	DOT_BSS,	PSEUDO },
-	{ ".comm",	DOT_LCOMM,	PSEUDO },
-	{ ".data",	DOT_DATA,	PSEUDO },
-	{ ".data1",	DOT_DATA1,	PSEUDO },
-	{ ".data2",	DOT_DATA2,	PSEUDO },
-	{ ".data4",	DOT_DATA4,	PSEUDO },
-	{ ".define",	DOT_DEFINE,	PSEUDO },
-	{ ".end",	DOT_END,	PSEUDO },
-	{ ".extern",	DOT_EXTERN,	PSEUDO },
-	{ ".file",	DOT_FILE,	PSEUDO },
-	{ ".line",	DOT_LINE,	PSEUDO },
-	{ ".list",	DOT_LIST,	PSEUDO },
-	{ ".nolist",	DOT_NOLIST,	PSEUDO },
-	{ ".rom",	DOT_ROM,	PSEUDO },
-	{ ".space",	DOT_SPACE,	PSEUDO },
-	{ ".symb",	DOT_SYMB,	PSEUDO },
-	{ ".text",	DOT_TEXT,	PSEUDO },
-	{ ".use16",	DOT_USE16,	PSEUDO },
-	{ ".use32",	DOT_USE32,	PSEUDO },
-	{ "aaa",	AAA,		WORD },
-	{ "aad",	AAD,		WORD },
-	{ "aam",	AAM,		WORD },
-	{ "aas",	AAS,		WORD },
-	{ "adc",	ADC,		WORD },
-	{ "adcb",	ADC,		BYTE },
-	{ "add",	ADD,		WORD },
-	{ "addb",	ADD,		BYTE },
-	{ "and",	AND,		WORD },
-	{ "andb",	AND,		BYTE },
-	{ "arpl",	ARPL,		WORD },
-	{ "bound",	BOUND,		WORD },
-	{ "bsf",	BSF,		WORD },
-	{ "bsr",	BSR,		WORD },
-	{ "bswap",	BSWAP,		WORD },
-	{ "bt",		BT,		WORD },
-	{ "btc",	BTC,		WORD },
-	{ "btr",	BTR,		WORD },
-	{ "bts",	BTS,		WORD },
-	{ "call",	CALL,		JUMP },
-	{ "callf",	CALLF,		JUMP },
-	{ "cbw",	CBW,		WORD },
-	{ "cdq",	CWD,		WORD },
-	{ "clc",	CLC,		WORD },
-	{ "cld",	CLD,		WORD },
-	{ "cli",	CLI,		WORD },
-	{ "clts",	CLTS,		WORD },
-	{ "cmc",	CMC,		WORD },
-	{ "cmp",	CMP,		WORD },
-	{ "cmpb",	CMP,		BYTE },
-	{ "cmps",	CMPS,		WORD },
-	{ "cmpsb",	CMPS,		BYTE },
-	{ "cmpxchg",	CMPXCHG,	WORD },
-	{ "cwd",	CWD,		WORD },
-	{ "cwde",	CBW,		WORD },
-	{ "daa",	DAA,		WORD },
-	{ "das",	DAS,		WORD },
-	{ "dec",	DEC,		WORD },
-	{ "decb",	DEC,		BYTE },
-	{ "div",	DIV,		WORD },
-	{ "divb",	DIV,		BYTE },
-	{ "enter",	ENTER,		WORD },
-	{ "f2xm1",	F2XM1,		WORD },
-	{ "fabs",	FABS,		WORD },
-	{ "fadd",	FADD,		WORD },
-	{ "faddd",	FADDD,		WORD },
-	{ "faddp",	FADDP,		WORD },
-	{ "fadds",	FADDS,		WORD },
-	{ "fbld",	FBLD,		WORD },
-	{ "fbstp",	FBSTP,		WORD },
-	{ "fchs",	FCHS,		WORD },
-	{ "fclex",	FCLEX,		WORD },
-	{ "fcomd",	FCOMD,		WORD },
-	{ "fcompd",	FCOMPD,		WORD },
-	{ "fcompp",	FCOMPP,		WORD },
-	{ "fcomps",	FCOMPS,		WORD },
-	{ "fcoms",	FCOMS,		WORD },
-	{ "fcos",	FCOS,		WORD },
-	{ "fdecstp",	FDECSTP,	WORD },
-	{ "fdivd",	FDIVD,		WORD },
-	{ "fdivp",	FDIVP,		WORD },
-	{ "fdivrd",	FDIVRD,		WORD },
-	{ "fdivrp",	FDIVRP,		WORD },
-	{ "fdivrs",	FDIVRS,		WORD },
-	{ "fdivs",	FDIVS,		WORD },
-	{ "ffree",	FFREE,		WORD },
-	{ "fiaddl",	FIADDL,		WORD },
-	{ "fiadds",	FIADDS,		WORD },
-	{ "ficom",	FICOM,		WORD },
-	{ "ficomp",	FICOMP,		WORD },
-	{ "fidivl",	FIDIVL,		WORD },
-	{ "fidivrl",	FIDIVRL,	WORD },
-	{ "fidivrs",	FIDIVRS,	WORD },
-	{ "fidivs",	FIDIVS,		WORD },
-	{ "fildl",	FILDL,		WORD },
-	{ "fildq",	FILDQ,		WORD },
-	{ "filds",	FILDS,		WORD },
-	{ "fimull",	FIMULL,		WORD },
-	{ "fimuls",	FIMULS,		WORD },
-	{ "fincstp",	FINCSTP,	WORD },
-	{ "finit",	FINIT,		WORD },
-	{ "fistl",	FISTL,		WORD },
-	{ "fistp",	FISTP,		WORD },
-	{ "fists",	FISTS,		WORD },
-	{ "fisubl",	FISUBL,		WORD },
-	{ "fisubrl",	FISUBRL,	WORD },
-	{ "fisubrs",	FISUBRS,	WORD },
-	{ "fisubs",	FISUBS,		WORD },
-	{ "fld1",	FLD1,		WORD },
-	{ "fldcw",	FLDCW,		WORD },
-	{ "fldd",	FLDD,		WORD },
-	{ "fldenv",	FLDENV,		WORD },
-	{ "fldl2e",	FLDL2E,		WORD },
-	{ "fldl2t",	FLDL2T,		WORD },
-	{ "fldlg2",	FLDLG2,		WORD },
-	{ "fldln2",	FLDLN2,		WORD },
-	{ "fldpi",	FLDPI,		WORD },
-	{ "flds",	FLDS,		WORD },
-	{ "fldx",	FLDX,		WORD },
-	{ "fldz",	FLDZ,		WORD },
-	{ "fmuld",	FMULD,		WORD },
-	{ "fmulp",	FMULP,		WORD },
-	{ "fmuls",	FMULS,		WORD },
-	{ "fnop",	FNOP,		WORD },
-	{ "fpatan",	FPATAN,		WORD },
-	{ "fprem",	FPREM,		WORD },
-	{ "fprem1",	FPREM1,		WORD },
-	{ "fptan",	FPTAN,		WORD },
-	{ "frndint",	FRNDINT,	WORD },
-	{ "frstor",	FRSTOR,		WORD },
-	{ "fsave",	FSAVE,		WORD },
-	{ "fscale",	FSCALE,		WORD },
-	{ "fsin",	FSIN,		WORD },
-	{ "fsincos",	FSINCOS,	WORD },
-	{ "fsqrt",	FSQRT,		WORD },
-	{ "fstcw",	FSTCW,		WORD },
-	{ "fstd",	FSTD,		WORD },
-	{ "fstenv",	FSTENV,		WORD },
-	{ "fstpd",	FSTPD,		WORD },
-	{ "fstps",	FSTPS,		WORD },
-	{ "fstpx",	FSTPX,		WORD },
-	{ "fsts",	FSTS,		WORD },
-	{ "fstsw",	FSTSW,		WORD },
-	{ "fsubd",	FSUBD,		WORD },
-	{ "fsubp",	FSUBP,		WORD },
-	{ "fsubpr",	FSUBPR,		WORD },
-	{ "fsubrd",	FSUBRD,		WORD },
-	{ "fsubrs",	FSUBRS,		WORD },
-	{ "fsubs",	FSUBS,		WORD },
-	{ "ftst",	FTST,		WORD },
-	{ "fucom",	FUCOM,		WORD },
-	{ "fucomp",	FUCOMP,		WORD },
-	{ "fucompp",	FUCOMPP,	WORD },
-	{ "fxam",	FXAM,		WORD },
-	{ "fxch",	FXCH,		WORD },
-	{ "fxtract",	FXTRACT,	WORD },
-	{ "fyl2x",	FYL2X,		WORD },
-	{ "fyl2xp1",	FYL2XP1,	WORD },
-	{ "hlt",	HLT,		WORD },
-	{ "idiv",	IDIV,		WORD },
-	{ "idivb",	IDIV,		BYTE },
-	{ "imul",	IMUL,		WORD },
-	{ "imulb",	IMUL,		BYTE },
-	{ "in",		IN,		WORD },
-	{ "inb",	IN,		BYTE },
-	{ "inc",	INC,		WORD },
-	{ "incb",	INC,		BYTE },
-	{ "ins",	INS,		WORD },
-	{ "insb",	INS,		BYTE },
-	{ "int",	INT,		WORD },
-	{ "into",	INTO,		JUMP },
-	{ "invd",	INVD,		WORD },
-	{ "invlpg",	INVLPG,		WORD },
-	{ "iret",	IRET,		JUMP },
-	{ "iretd",	IRETD,		JUMP },
-	{ "ja",		JA,		JUMP },
-	{ "jae",	JAE,		JUMP },
-	{ "jb",		JB,		JUMP },
-	{ "jbe",	JBE,		JUMP },
-	{ "jc",		JB,		JUMP },
-	{ "jcxz",	JCXZ,		JUMP },
-	{ "je",		JE,		JUMP },
-	{ "jecxz",	JCXZ,		JUMP },
-	{ "jg",		JG,		JUMP },
-	{ "jge",	JGE,		JUMP },
-	{ "jl",		JL,		JUMP },
-	{ "jle",	JLE,		JUMP },
-	{ "jmp",	JMP,		JUMP },
-	{ "jmpf",	JMPF,		JUMP },
-	{ "jna",	JBE,		JUMP },
-	{ "jnae",	JB,		JUMP },
-	{ "jnb",	JAE,		JUMP },
-	{ "jnbe",	JA,		JUMP },
-	{ "jnc",	JAE,		JUMP },
-	{ "jne",	JNE,		JUMP },
-	{ "jng",	JLE,		JUMP },
-	{ "jnge",	JL,		JUMP },
-	{ "jnl",	JGE,		JUMP },
-	{ "jnle",	JG,		JUMP },
-	{ "jno",	JNO,		JUMP },
-	{ "jnp",	JNP,		JUMP },
-	{ "jns",	JNS,		JUMP },
-	{ "jnz",	JNE,		JUMP },
-	{ "jo",		JO,		JUMP },
-	{ "jp",		JP,		JUMP },
-	{ "js",		JS,		JUMP },
-	{ "jz",		JE,		JUMP },
-	{ "lahf",	LAHF,		WORD },
-	{ "lar",	LAR,		WORD },
-	{ "lds",	LDS,		WORD },
-	{ "lea",	LEA,		WORD },
-	{ "leave",	LEAVE,		WORD },
-	{ "les",	LES,		WORD },
-	{ "lfs",	LFS,		WORD },
-	{ "lgdt",	LGDT,		WORD },
-	{ "lgs",	LGS,		WORD },
-	{ "lidt",	LIDT,		WORD },
-	{ "lldt",	LLDT,		WORD },
-	{ "lmsw",	LMSW,		WORD },
-	{ "lock",	LOCK,		WORD },
-	{ "lods",	LODS,		WORD },
-	{ "lodsb",	LODS,		BYTE },
-	{ "loop",	LOOP,		JUMP },
-	{ "loope",	LOOPE,		JUMP },
-	{ "loopne",	LOOPNE,		JUMP },
-	{ "loopnz",	LOOPNE,		JUMP },
-	{ "loopz",	LOOPE,		JUMP },
-	{ "lsl",	LSL,		WORD },
-	{ "lss",	LSS,		WORD },
-	{ "ltr",	LTR,		WORD },
-	{ "mov",	MOV,		WORD },
-	{ "movb",	MOV,		BYTE },
-	{ "movs",	MOVS,		WORD },
-	{ "movsb",	MOVS,		BYTE },
-	{ "movsx",	MOVSX,		WORD },
-	{ "movsxb",	MOVSXB,		WORD },
-	{ "movzx",	MOVZX,		WORD },
-	{ "movzxb",	MOVZXB,		WORD },
-	{ "mul",	MUL,		WORD },
-	{ "mulb",	MUL,		BYTE },
-	{ "neg",	NEG,		WORD },
-	{ "negb",	NEG,		BYTE },
-	{ "nop",	NOP,		WORD },
-	{ "not",	NOT,		WORD },
-	{ "notb",	NOT,		BYTE },
-	{ "or",		OR,		WORD },
-	{ "orb",	OR,		BYTE },
-	{ "out",	OUT,		WORD },
-	{ "outb",	OUT,		BYTE },
-	{ "outs",	OUTS,		WORD },
-	{ "outsb",	OUTS,		BYTE },
-	{ "pop",	POP,		WORD },
-	{ "popa",	POPA,		WORD },
-	{ "popad",	POPA,		WORD },
-	{ "popf",	POPF,		WORD },
-	{ "push",	PUSH,		WORD },
-	{ "pusha",	PUSHA,		WORD },
-	{ "pushad",	PUSHA,		WORD },
-	{ "pushf",	PUSHF,		WORD },
-	{ "rcl",	RCL,		WORD },
-	{ "rclb",	RCL,		BYTE },
-	{ "rcr",	RCR,		WORD },
-	{ "rcrb",	RCR,		BYTE },
-	{ "ret",	RET,		JUMP },
-	{ "retf",	RETF,		JUMP },
-	{ "rol",	ROL,		WORD },
-	{ "rolb",	ROL,		BYTE },
-	{ "ror",	ROR,		WORD },
-	{ "rorb",	ROR,		BYTE },
-	{ "sahf",	SAHF,		WORD },
-	{ "sal",	SAL,		WORD },
-	{ "salb",	SAL,		BYTE },
-	{ "sar",	SAR,		WORD },
-	{ "sarb",	SAR,		BYTE },
-	{ "sbb",	SBB,		WORD },
-	{ "sbbb",	SBB,		BYTE },
-	{ "scas",	SCAS,		WORD },
-	{ "scasb",	SCAS,		BYTE },
-	{ "seta",	SETA,		BYTE },
-	{ "setae",	SETAE,		BYTE },
-	{ "setb",	SETB,		BYTE },
-	{ "setbe",	SETBE,		BYTE },
-	{ "sete",	SETE,		BYTE },
-	{ "setg",	SETG,		BYTE },
-	{ "setge",	SETGE,		BYTE },
-	{ "setl",	SETL,		BYTE },
-	{ "setna",	SETBE,		BYTE },
-	{ "setnae",	SETB,		BYTE },
-	{ "setnb",	SETAE,		BYTE },
-	{ "setnbe",	SETA,		BYTE },
-	{ "setne",	SETNE,		BYTE },
-	{ "setng",	SETLE,		BYTE },
-	{ "setnge",	SETL,		BYTE },
-	{ "setnl",	SETGE,		BYTE },
-	{ "setnle",	SETG,		BYTE },
-	{ "setno",	SETNO,		BYTE },
-	{ "setnp",	SETNP,		BYTE },
-	{ "setns",	SETNS,		BYTE },
-	{ "seto",	SETO,		BYTE },
-	{ "setp",	SETP,		BYTE },
-	{ "sets",	SETS,		BYTE },
-	{ "setz",	SETE,		BYTE },
-	{ "sgdt",	SGDT,		WORD },
-	{ "shl",	SHL,		WORD },
-	{ "shlb",	SHL,		BYTE },
-	{ "shld",	SHLD,		WORD },
-	{ "shr",	SHR,		WORD },
-	{ "shrb",	SHR,		BYTE },
-	{ "shrd",	SHRD,		WORD },
-	{ "sidt",	SIDT,		WORD },
-	{ "sldt",	SLDT,		WORD },
-	{ "smsw",	SMSW,		WORD },
-	{ "stc",	STC,		WORD },
-	{ "std",	STD,		WORD },
-	{ "sti",	STI,		WORD },
-	{ "stos",	STOS,		WORD },
-	{ "stosb",	STOS,		BYTE },
-	{ "str",	STR,		WORD },
-	{ "sub",	SUB,		WORD },
-	{ "subb",	SUB,		BYTE },
-	{ "test",	TEST,		WORD },
-	{ "testb",	TEST,		BYTE },
-	{ "verr",	VERR,		WORD },
-	{ "verw",	VERW,		WORD },
-	{ "wait",	WAIT,		WORD },
-	{ "wbinvd",	WBINVD,		WORD },
-	{ "xadd",	XADD,		WORD },
-	{ "xchg",	XCHG,		WORD },
-	{ "xchgb",	XCHG,		BYTE },
-	{ "xlat",	XLAT,		WORD },
-	{ "xor",	XOR,		WORD },
-	{ "xorb",	XOR,		BYTE },
-};
-
-static enum dialect { ACK, NCC } dialect= ACK;
-
-void ack_parse_init(char *file)
-/* Prepare parsing of an ACK assembly file. */
-{
-	tok_init(file, '!');
-}
-
-void ncc_parse_init(char *file)
-/* Prepare parsing of an ACK Xenix assembly file.  See emit_ack.c for comments
- * on this fine assembly dialect.
- */
-{
-	dialect= NCC;
-	ack_parse_init(file);
-}
-
-static void zap(void)
-/* An error, zap the rest of the line. */
-{
-	token_t *t;
-
-	while ((t= get_token(0))->type != T_EOF && t->symbol != ';')
-		skip_token(1);
-}
-
-static mnemonic_t *search_mnem(char *name)
-/* Binary search for a mnemonic.  (That's why the table is sorted.) */
-{
-	int low, mid, high;
-	int cmp;
-	mnemonic_t *m;
-
-	low= 0;
-	high= arraysize(mnemtab)-1;
-	while (low <= high) {
-		mid= (low + high) / 2;
-		m= &mnemtab[mid];
-
-		if ((cmp= strcmp(name, m->name)) == 0) return m;
-
-		if (cmp < 0) high= mid-1; else low= mid+1;
-	}
-	return nil;
-}
-
-static expression_t *ack_get_C_expression(int *pn)
-/* Read a "C-like" expression.  Note that we don't worry about precedence,
- * the expression is printed later like it is read.  If the target language
- * does not have all the operators (like ~) then this has to be repaired by
- * changing the source file.  (No problem, you still have one source file
- * to maintain, not two.)
- */
-{
-	expression_t *e, *a1, *a2;
-	token_t *t;
-
-	if ((t= get_token(*pn))->symbol == '[') {
-		/* [ expr ]: grouping. */
-		(*pn)++;
-		if ((a1= ack_get_C_expression(pn)) == nil) return nil;
-		if (get_token(*pn)->symbol != ']') {
-			parse_err(1, t, "missing ]\n");
-			del_expr(a1);
-			return nil;
-		}
-		(*pn)++;
-		e= new_expr();
-		e->operator= '[';
-		e->middle= a1;
-	} else
-	if (t->type == T_WORD || t->type == T_STRING) {
-		/* Label, number, or string. */
-		e= new_expr();
-		e->operator= t->type == T_WORD ? 'W' : 'S';
-		e->name= allocate(nil, (t->len+1) * sizeof(e->name[0]));
-		memcpy(e->name, t->name, t->len+1);
-		e->len= t->len;
-		(*pn)++;
-	} else
-	if (t->symbol == '+' || t->symbol == '-' || t->symbol == '~') {
-		/* Unary operator. */
-		(*pn)++;
-		if ((a1= ack_get_C_expression(pn)) == nil) return nil;
-		e= new_expr();
-		e->operator= t->symbol;
-		e->middle= a1;
-	} else {
-		parse_err(1, t, "expression syntax error\n");
-		return nil;
-	}
-
-	switch ((t= get_token(*pn))->symbol) {
-	case '+':
-	case '-':
-	case '*':
-	case '/':
-	case '%':
-	case '&':
-	case '|':
-	case '^':
-	case S_LEFTSHIFT:
-	case S_RIGHTSHIFT:
-		(*pn)++;
-		a1= e;
-		if ((a2= ack_get_C_expression(pn)) == nil) {
-			del_expr(a1);
-			return nil;
-		}
-		e= new_expr();
-		e->operator= t->symbol;
-		e->left= a1;
-		e->right= a2;
-	}
-	return e;
-}
-
-static expression_t *ack_get_operand(int *pn, int deref)
-/* Get something like: (memory), offset(base)(index*scale), or simpler. */
-{
-	expression_t *e, *offset, *base, *index;
-	token_t *t;
-	int c;
-
-	/* Is it (memory)? */
-	if (get_token(*pn)->symbol == '('
-		&& ((t= get_token(*pn + 1))->type != T_WORD
-			|| !isregister(t->name))
-	) {
-		/* A memory dereference. */
-		(*pn)++;
-		if ((offset= ack_get_C_expression(pn)) == nil) return nil;
-		if (get_token(*pn)->symbol != ')') {
-			parse_err(1, t, "operand syntax error\n");
-			del_expr(offset);
-			return nil;
-		}
-		(*pn)++;
-		e= new_expr();
-		e->operator= '(';
-		e->middle= offset;
-		return e;
-	}
-
-	/* #constant? */
-	if (dialect == NCC && deref
-			&& ((c= get_token(*pn)->symbol) == '#' || c == '*')) {
-		/* NCC: mov ax,#constant  ->  ACK: mov ax,constant */
-		(*pn)++;
-		return ack_get_C_expression(pn);
-	}
-
-	/* @address? */
-	if (dialect == NCC && get_token(*pn)->symbol == '@') {
-		/* NCC: jmp @address  ->  ACK: jmp (address) */
-		(*pn)++;
-		if ((offset= ack_get_operand(pn, deref)) == nil) return nil;
-		e= new_expr();
-		e->operator= '(';
-		e->middle= offset;
-		return e;
-	}
-
-	/* Offset? */
-	if (get_token(*pn)->symbol != '(') {
-		/* There is an offset. */
-		if ((offset= ack_get_C_expression(pn)) == nil) return nil;
-	} else {
-		/* No offset. */
-		offset= nil;
-	}
-
-	/* (base)? */
-	if (get_token(*pn)->symbol == '('
-		&& (t= get_token(*pn + 1))->type == T_WORD
-		&& isregister(t->name)
-		&& get_token(*pn + 2)->symbol == ')'
-	) {
-		/* A base register expression. */
-		base= new_expr();
-		base->operator= 'B';
-		base->name= copystr(t->name);
-		(*pn)+= 3;
-	} else {
-		/* No base register expression. */
-		base= nil;
-	}
-
-	/* (index*scale)? */
-	if (get_token(*pn)->symbol == '(') {
-		/* An index most likely. */
-		token_t *m= nil;
-
-		if (!(		/* This must be true: */
-			(t= get_token(*pn + 1))->type == T_WORD
-			&& isregister(t->name)
-			&& (get_token(*pn + 2)->symbol == ')' || (
-				get_token(*pn + 2)->symbol == '*'
-				&& (m= get_token(*pn + 3))->type == T_WORD
-				&& strchr("1248", m->name[0]) != nil
-				&& m->name[1] == 0
-				&& get_token(*pn + 4)->symbol == ')'
-			))
-		)) {
-			/* Alas it isn't */
-			parse_err(1, t, "operand syntax error\n");
-			del_expr(offset);
-			del_expr(base);
-			return nil;
-		}
-		/* Found an index. */
-		index= new_expr();
-		index->operator= m == nil ? '1' : m->name[0];
-		index->name= copystr(t->name);
-		(*pn)+= (m == nil ? 3 : 5);
-	} else {
-		/* No index. */
-		index= nil;
-	}
-
-	if (dialect == NCC && deref && base == nil && index == nil
-		&& !(offset != nil && offset->operator == 'W'
-					&& isregister(offset->name))
-	) {
-		/* NCC: mov ax,thing  ->  ACK mov ax,(thing) */
-		e= new_expr();
-		e->operator= '(';
-		e->middle= offset;
-		return e;
-	}
-
-	if (base == nil && index == nil) {
-		/* Return a lone offset as is. */
-		e= offset;
-	} else {
-		e= new_expr();
-		e->operator= 'O';
-		e->left= offset;
-		e->middle= base;
-		e->right= index;
-	}
-	return e;
-}
-
-static expression_t *ack_get_oplist(int *pn, int deref)
-/* Get a comma (or colon for jmpf and callf) separated list of instruction
- * operands.
- */
-{
-	expression_t *e, *o1, *o2;
-	token_t *t;
-
-	if ((e= ack_get_operand(pn, deref)) == nil) return nil;
-
-	if ((t= get_token(*pn))->symbol == ',' || t->symbol == ':') {
-		o1= e;
-		(*pn)++;
-		if ((o2= ack_get_oplist(pn, deref)) == nil) {
-			del_expr(o1);
-			return nil;
-		}
-		e= new_expr();
-		e->operator= ',';
-		e->left= o1;
-		e->right= o2;
-	}
-	return e;
-}
-
-static asm86_t *ack_get_statement(void)
-/* Get a pseudo op or machine instruction with arguments. */
-{
-	token_t *t= get_token(0);
-	asm86_t *a;
-	mnemonic_t *m;
-	int n;
-	int prefix_seen;
-	int oaz_prefix;
-	int deref;
-
-	assert(t->type == T_WORD);
-
-	if (strcmp(t->name, ".sect") == 0) {
-		/* .sect .text etc.  Accept only four segment names. */
-		skip_token(1);
-		t= get_token(0);
-		if (t->type != T_WORD || (
-			strcmp(t->name, ".text") != 0
-			&& strcmp(t->name, ".rom") != 0
-			&& strcmp(t->name, ".data") != 0
-			&& strcmp(t->name, ".bss") != 0
-			&& strcmp(t->name, ".end") != 0
-		)) {
-			parse_err(1, t, "weird section name to .sect\n");
-			return nil;
-		}
-	}
-	a= new_asm86();
-
-	/* Process instruction prefixes. */
-	oaz_prefix= 0;
-	for (prefix_seen= 0;; prefix_seen= 1) {
-		if (strcmp(t->name, "o16") == 0) {
-			if (use16()) {
-				parse_err(1, t, "o16 in an 8086 section\n");
-			}
-			oaz_prefix|= OPZ;
-		} else
-		if (strcmp(t->name, "o32") == 0) {
-			if (use32()) {
-				parse_err(1, t, "o32 in an 80386 section\n");
-			}
-			oaz_prefix|= OPZ;
-		} else
-		if (strcmp(t->name, "a16") == 0) {
-			if (use16()) {
-				parse_err(1, t, "a16 in an 8086 section\n");
-			}
-			oaz_prefix|= ADZ;
-		} else
-		if (strcmp(t->name, "a32") == 0) {
-			if (use32()) {
-				parse_err(1, t, "a32 in an 80386 section\n");
-			}
-			oaz_prefix|= ADZ;
-		} else
-		if (strcmp(t->name, "rep") == 0
-			|| strcmp(t->name, "repe") == 0
-			|| strcmp(t->name, "repne") == 0
-			|| strcmp(t->name, "repz") == 0
-			|| strcmp(t->name, "repnz") == 0
-		) {
-			if (a->rep != ONCE) {
-				parse_err(1, t,
-					"can't have more than one rep\n");
-			}
-			switch (t->name[3]) {
-			case 0:		a->rep= REP;	break;
-			case 'e':
-			case 'z':	a->rep= REPE;	break;
-			case 'n':	a->rep= REPNE;	break;
-			}
-		} else
-		if (strchr("cdefgs", t->name[0]) != nil
-					&& strcmp(t->name+1, "seg") == 0) {
-			if (a->seg != DEFSEG) {
-				parse_err(1, t,
-				"can't have more than one segment prefix\n");
-			}
-			switch (t->name[0]) {
-			case 'c':	a->seg= CSEG;	break;
-			case 'd':	a->seg= DSEG;	break;
-			case 'e':	a->seg= ESEG;	break;
-			case 'f':	a->seg= FSEG;	break;
-			case 'g':	a->seg= GSEG;	break;
-			case 's':	a->seg= SSEG;	break;
-			}
-		} else
-		if (!prefix_seen) {
-			/* No prefix here, get out! */
-			break;
-		} else {
-			/* No more prefixes, next must be an instruction. */
-			if (t->type != T_WORD
-				|| (m= search_mnem(t->name)) == nil
-				|| m->optype == PSEUDO
-			) {
-				parse_err(1, t,
-		"machine instruction expected after instruction prefix\n");
-				del_asm86(a);
-				return nil;
-			}
-			if (oaz_prefix != 0 && m->optype != JUMP
-						&& m->optype != WORD) {
-				parse_err(1, t,
-			"'%s' can't have an operand size prefix\n", m->name);
-			}
-			break;
-		}
-
-		/* Skip the prefix and extra newlines. */
-		do {
-			skip_token(1);
-		} while ((t= get_token(0))->symbol == ';');
-	}
-
-	/* All the readahead being done upsets the line counter. */
-	a->line= t->line;
-
-	/* Read a machine instruction or pseudo op. */
-	if ((m= search_mnem(t->name)) == nil) {
-		parse_err(1, t, "unknown instruction '%s'\n", t->name);
-		del_asm86(a);
-		return nil;
-	}
-	a->opcode= m->opcode;
-	a->optype= m->optype;
-	a->oaz= oaz_prefix;
-
-	switch (a->opcode) {
-	case IN:
-	case OUT:
-	case INT:
-		deref= 0;
-		break;
-	default:
-		deref= (a->optype >= BYTE);
-	}
-	n= 1;
-	if (get_token(1)->symbol != ';'
-			&& (a->args= ack_get_oplist(&n, deref)) == nil) {
-		del_asm86(a);
-		return nil;
-	}
-	if (get_token(n)->symbol != ';') {
-		parse_err(1, t, "garbage at end of instruction\n");
-		del_asm86(a);
-		return nil;
-	}
-	switch (a->opcode) {
-	case DOT_ALIGN:
-		/* Restrict .align to have a single numeric argument, some
-		 * assemblers think of the argument as a power of two, so
-		 * we need to be able to change the value.
-		 */
-		if (a->args == nil || a->args->operator != 'W'
-					|| !isanumber(a->args->name)) {
-			parse_err(1, t,
-			  ".align is restricted to one numeric argument\n");
-			del_asm86(a);
-			return nil;
-		}
-		break;
-	case JMPF:
-	case CALLF:
-		/* NCC jmpf off,seg  ->  ACK jmpf seg:off */
-		if (dialect == NCC && a->args != nil
-						&& a->args->operator == ',') {
-			expression_t *t;
-
-			t= a->args->left;
-			a->args->left= a->args->right;
-			a->args->right= t;
-			break;
-		}
-		/*FALL THROUGH*/
-	case JMP:
-	case CALL:
-		/* NCC jmp @(reg)  ->  ACK jmp (reg) */
-		if (dialect == NCC && a->args != nil && (
-			(a->args->operator == '('
-				&& a->args->middle != nil
-				&& a->args->middle->operator == 'O')
-			|| (a->args->operator == 'O'
-				&& a->args->left == nil
-				&& a->args->middle != nil
-				&& a->args->right == nil)
-		)) {
-			expression_t *t;
-
-			t= a->args;
-			a->args= a->args->middle;
-			t->middle= nil;
-			del_expr(t);
-			if (a->args->operator == 'B') a->args->operator= 'W';
-		}
-		break;
-	default:;
-	}
-	skip_token(n+1);
-	return a;
-}
-
-asm86_t *ack_get_instruction(void)
-{
-	asm86_t *a= nil;
-	expression_t *e;
-	token_t *t;
-
-	while ((t= get_token(0))->symbol == ';')
-		skip_token(1);
-
-	if (t->type == T_EOF) return nil;
-
-	if (t->symbol == '#') {
-		/* Preprocessor line and file change. */
-
-		if ((t= get_token(1))->type != T_WORD || !isanumber(t->name)
-			|| get_token(2)->type != T_STRING
-		) {
-			parse_err(1, t, "file not preprocessed?\n");
-			zap();
-		} else {
-			set_file(get_token(2)->name,
-				strtol(get_token(1)->name, nil, 0) - 1);
-
-			/* GNU CPP adds extra cruft, simply zap the line. */
-			zap();
-		}
-		a= ack_get_instruction();
-	} else
-	if (t->type == T_WORD && get_token(1)->symbol == ':') {
-		/* A label definition. */
-		a= new_asm86();
-		a->line= t->line;
-		a->opcode= DOT_LABEL;
-		a->optype= PSEUDO;
-		a->args= e= new_expr();
-		e->operator= ':';
-		e->name= copystr(t->name);
-		skip_token(2);
-	} else
-	if (t->type == T_WORD && get_token(1)->symbol == '=') {
-		int n= 2;
-
-		if ((e= ack_get_C_expression(&n)) == nil) {
-			zap();
-			a= ack_get_instruction();
-		} else
-		if (get_token(n)->symbol != ';') {
-			parse_err(1, t, "garbage after assignment\n");
-			zap();
-			a= ack_get_instruction();
-		} else {
-			a= new_asm86();
-			a->line= t->line;
-			a->opcode= DOT_EQU;
-			a->optype= PSEUDO;
-			a->args= new_expr();
-			a->args->operator= '=';
-			a->args->name= copystr(t->name);
-			a->args->middle= e;
-			skip_token(n+1);
-		}
-	} else
-	if (t->type == T_WORD) {
-		if ((a= ack_get_statement()) == nil) {
-			zap();
-			a= ack_get_instruction();
-		}
-	} else {
-		parse_err(1, t, "syntax error\n");
-		zap();
-		a= ack_get_instruction();
-	}
-	return a;
-}
-
-asm86_t *ncc_get_instruction(void)
-{
-	return ack_get_instruction();
-}
Index: trunk/minix/commands/i386/asmconv/parse_bas.c
===================================================================
--- trunk/minix/commands/i386/asmconv/parse_bas.c	(revision 9)
+++ 	(revision )
@@ -1,940 +1,0 @@
-/*	parse_bas.c - parse BCC AS assembly		Author: Kees J. Bot
- *								13 Nov 1994
- */
-#define nil 0
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include "asmconv.h"
-#include "token.h"
-#include "asm86.h"
-#include "languages.h"
-
-typedef struct mnemonic {	/* BAS mnemonics translation table. */
-	char		*name;
-	opcode_t	opcode;
-	optype_t	optype;
-} mnemonic_t;
-
-static mnemonic_t mnemtab[] = {			/* This array is sorted. */
-	{ ".align",	DOT_ALIGN,	PSEUDO },
-	{ ".ascii",	DOT_ASCII,	PSEUDO },
-	{ ".asciz",	DOT_ASCIZ,	PSEUDO },
-	{ ".assert",	DOT_ASSERT,	PSEUDO },
-	{ ".base",	DOT_BASE,	PSEUDO },
-	{ ".blkb",	DOT_SPACE,	PSEUDO },
-	{ ".bss",	DOT_BSS,	PSEUDO },
-	{ ".byte",	DOT_DATA1,	PSEUDO },
-	{ ".comm",	DOT_COMM,	PSEUDO },
-	{ ".data",	DOT_DATA,	PSEUDO },
-	{ ".define",	DOT_DEFINE,	PSEUDO },
-	{ ".end",	DOT_END,	PSEUDO },
-	{ ".even",	DOT_ALIGN,	PSEUDO },
-	{ ".extern",	DOT_EXTERN,	PSEUDO },
-	{ ".file",	DOT_FILE,	PSEUDO },
-	{ ".globl",	DOT_DEFINE,	PSEUDO },
-	{ ".lcomm",	DOT_LCOMM,	PSEUDO },
-	{ ".line",	DOT_LINE,	PSEUDO },
-	{ ".list",	DOT_LIST,	PSEUDO },
-	{ ".long",	DOT_DATA4,	PSEUDO },
-	{ ".nolist",	DOT_NOLIST,	PSEUDO },
-	{ ".rom",	DOT_ROM,	PSEUDO },
-	{ ".space",	DOT_SPACE,	PSEUDO },
-	{ ".symb",	DOT_SYMB,	PSEUDO },
-	{ ".text",	DOT_TEXT,	PSEUDO },
-	{ ".use16",	DOT_USE16,	PSEUDO },
-	{ ".use32",	DOT_USE32,	PSEUDO },
-	{ ".word",	DOT_DATA2,	PSEUDO },
-	{ ".zerob",	DOT_SPACE,	PSEUDO },
-	{ ".zerow",	DOT_SPACE,	PSEUDO },
-	{ "aaa",	AAA,		WORD },
-	{ "aad",	AAD,		WORD },
-	{ "aam",	AAM,		WORD },
-	{ "aas",	AAS,		WORD },
-	{ "adc",	ADC,		WORD },
-	{ "add",	ADD,		WORD },
-	{ "and",	AND,		WORD },
-	{ "arpl",	ARPL,		WORD },
-	{ "bc",		JB,		JUMP },
-	{ "beq",	JE,		JUMP },
-	{ "bge",	JGE,		JUMP },
-	{ "bgt",	JG,		JUMP },
-	{ "bhi",	JA,		JUMP },
-	{ "bhis",	JAE,		JUMP },
-	{ "ble",	JLE,		JUMP },
-	{ "blo",	JB,		JUMP },
-	{ "blos",	JBE,		JUMP },
-	{ "blt",	JL,		JUMP },
-	{ "bnc",	JAE,		JUMP },
-	{ "bne",	JNE,		JUMP },
-	{ "bound",	BOUND,		WORD },
-	{ "br",		JMP,		JUMP },
-	{ "bsf",	BSF,		WORD },
-	{ "bsr",	BSR,		WORD },
-	{ "bswap",	BSWAP,		WORD },
-	{ "bt",		BT,		WORD },
-	{ "btc",	BTC,		WORD },
-	{ "btr",	BTR,		WORD },
-	{ "bts",	BTS,		WORD },
-	{ "bz",		JE,		JUMP },
-	{ "call",	CALL,		JUMP },
-	{ "callf",	CALLF,		JUMP },
-	{ "cbw",	CBW,		WORD },
-	{ "cdq",	CWD,		WORD },
-	{ "clc",	CLC,		WORD },
-	{ "cld",	CLD,		WORD },
-	{ "cli",	CLI,		WORD },
-	{ "clts",	CLTS,		WORD },
-	{ "cmc",	CMC,		WORD },
-	{ "cmp",	CMP,		WORD },
-	{ "cmps",	CMPS,		WORD },
-	{ "cmpsb",	CMPS,		BYTE },
-	{ "cmpxchg",	CMPXCHG,	WORD },
-	{ "cwd",	CWD,		WORD },
-	{ "cwde",	CBW,		WORD },
-	{ "daa",	DAA,		WORD },
-	{ "das",	DAS,		WORD },
-	{ "dd",		DOT_DATA4,	PSEUDO },
-	{ "dec",	DEC,		WORD },
-	{ "div",	DIV,		WORD },
-	{ "enter",	ENTER,		WORD },
-	{ "export",	DOT_DEFINE,	PSEUDO },
-	{ "f2xm1",	F2XM1,		WORD },
-	{ "fabs",	FABS,		WORD },
-	{ "fadd",	FADD,		WORD },
-	{ "faddd",	FADDD,		WORD },
-	{ "faddp",	FADDP,		WORD },
-	{ "fadds",	FADDS,		WORD },
-	{ "fbld",	FBLD,		WORD },
-	{ "fbstp",	FBSTP,		WORD },
-	{ "fchs",	FCHS,		WORD },
-	{ "fclex",	FCLEX,		WORD },
-	{ "fcomd",	FCOMD,		WORD },
-	{ "fcompd",	FCOMPD,		WORD },
-	{ "fcompp",	FCOMPP,		WORD },
-	{ "fcomps",	FCOMPS,		WORD },
-	{ "fcoms",	FCOMS,		WORD },
-	{ "fcos",	FCOS,		WORD },
-	{ "fdecstp",	FDECSTP,	WORD },
-	{ "fdivd",	FDIVD,		WORD },
-	{ "fdivp",	FDIVP,		WORD },
-	{ "fdivrd",	FDIVRD,		WORD },
-	{ "fdivrp",	FDIVRP,		WORD },
-	{ "fdivrs",	FDIVRS,		WORD },
-	{ "fdivs",	FDIVS,		WORD },
-	{ "ffree",	FFREE,		WORD },
-	{ "fiaddl",	FIADDL,		WORD },
-	{ "fiadds",	FIADDS,		WORD },
-	{ "ficom",	FICOM,		WORD },
-	{ "ficomp",	FICOMP,		WORD },
-	{ "fidivl",	FIDIVL,		WORD },
-	{ "fidivrl",	FIDIVRL,	WORD },
-	{ "fidivrs",	FIDIVRS,	WORD },
-	{ "fidivs",	FIDIVS,		WORD },
-	{ "fildl",	FILDL,		WORD },
-	{ "fildq",	FILDQ,		WORD },
-	{ "filds",	FILDS,		WORD },
-	{ "fimull",	FIMULL,		WORD },
-	{ "fimuls",	FIMULS,		WORD },
-	{ "fincstp",	FINCSTP,	WORD },
-	{ "finit",	FINIT,		WORD },
-	{ "fistl",	FISTL,		WORD },
-	{ "fistp",	FISTP,		WORD },
-	{ "fists",	FISTS,		WORD },
-	{ "fisubl",	FISUBL,		WORD },
-	{ "fisubrl",	FISUBRL,	WORD },
-	{ "fisubrs",	FISUBRS,	WORD },
-	{ "fisubs",	FISUBS,		WORD },
-	{ "fld1",	FLD1,		WORD },
-	{ "fldcw",	FLDCW,		WORD },
-	{ "fldd",	FLDD,		WORD },
-	{ "fldenv",	FLDENV,		WORD },
-	{ "fldl2e",	FLDL2E,		WORD },
-	{ "fldl2t",	FLDL2T,		WORD },
-	{ "fldlg2",	FLDLG2,		WORD },
-	{ "fldln2",	FLDLN2,		WORD },
-	{ "fldpi",	FLDPI,		WORD },
-	{ "flds",	FLDS,		WORD },
-	{ "fldx",	FLDX,		WORD },
-	{ "fldz",	FLDZ,		WORD },
-	{ "fmuld",	FMULD,		WORD },
-	{ "fmulp",	FMULP,		WORD },
-	{ "fmuls",	FMULS,		WORD },
-	{ "fnop",	FNOP,		WORD },
-	{ "fpatan",	FPATAN,		WORD },
-	{ "fprem",	FPREM,		WORD },
-	{ "fprem1",	FPREM1,		WORD },
-	{ "fptan",	FPTAN,		WORD },
-	{ "frndint",	FRNDINT,	WORD },
-	{ "frstor",	FRSTOR,		WORD },
-	{ "fsave",	FSAVE,		WORD },
-	{ "fscale",	FSCALE,		WORD },
-	{ "fsin",	FSIN,		WORD },
-	{ "fsincos",	FSINCOS,	WORD },
-	{ "fsqrt",	FSQRT,		WORD },
-	{ "fstcw",	FSTCW,		WORD },
-	{ "fstd",	FSTD,		WORD },
-	{ "fstenv",	FSTENV,		WORD },
-	{ "fstpd",	FSTPD,		WORD },
-	{ "fstps",	FSTPS,		WORD },
-	{ "fstpx",	FSTPX,		WORD },
-	{ "fsts",	FSTS,		WORD },
-	{ "fstsw",	FSTSW,		WORD },
-	{ "fsubd",	FSUBD,		WORD },
-	{ "fsubp",	FSUBP,		WORD },
-	{ "fsubpr",	FSUBPR,		WORD },
-	{ "fsubrd",	FSUBRD,		WORD },
-	{ "fsubrs",	FSUBRS,		WORD },
-	{ "fsubs",	FSUBS,		WORD },
-	{ "ftst",	FTST,		WORD },
-	{ "fucom",	FUCOM,		WORD },
-	{ "fucomp",	FUCOMP,		WORD },
-	{ "fucompp",	FUCOMPP,	WORD },
-	{ "fxam",	FXAM,		WORD },
-	{ "fxch",	FXCH,		WORD },
-	{ "fxtract",	FXTRACT,	WORD },
-	{ "fyl2x",	FYL2X,		WORD },
-	{ "fyl2xp1",	FYL2XP1,	WORD },
-	{ "hlt",	HLT,		WORD },
-	{ "idiv",	IDIV,		WORD },
-	{ "imul",	IMUL,		WORD },
-	{ "in",		IN,		WORD },
-	{ "inb",	IN,		BYTE },
-	{ "inc",	INC,		WORD },
-	{ "ins",	INS,		WORD },
-	{ "insb",	INS,		BYTE },
-	{ "int",	INT,		WORD },
-	{ "into",	INTO,		JUMP },
-	{ "invd",	INVD,		WORD },
-	{ "invlpg",	INVLPG,		WORD },
-	{ "iret",	IRET,		JUMP },
-	{ "iretd",	IRETD,		JUMP },
-	{ "j",		JMP,		JUMP },
-	{ "ja",		JA,		JUMP },
-	{ "jae",	JAE,		JUMP },
-	{ "jb",		JB,		JUMP },
-	{ "jbe",	JBE,		JUMP },
-	{ "jc",		JB,		JUMP },
-	{ "jcxz",	JCXZ,		JUMP },
-	{ "je",		JE,		JUMP },
-	{ "jecxz",	JCXZ,		JUMP },
-	{ "jeq",	JE,		JUMP },
-	{ "jg",		JG,		JUMP },
-	{ "jge",	JGE,		JUMP },
-	{ "jgt",	JG,		JUMP },
-	{ "jhi",	JA,		JUMP },
-	{ "jhis",	JAE,		JUMP },
-	{ "jl",		JL,		JUMP },
-	{ "jle",	JLE,		JUMP },
-	{ "jlo",	JB,		JUMP },
-	{ "jlos",	JBE,		JUMP },
-	{ "jlt",	JL,		JUMP },
-	{ "jmp",	JMP,		JUMP },
-	{ "jmpf",	JMPF,		JUMP },
-	{ "jna",	JBE,		JUMP },
-	{ "jnae",	JB,		JUMP },
-	{ "jnb",	JAE,		JUMP },
-	{ "jnbe",	JA,		JUMP },
-	{ "jnc",	JAE,		JUMP },
-	{ "jne",	JNE,		JUMP },
-	{ "jng",	JLE,		JUMP },
-	{ "jnge",	JL,		JUMP },
-	{ "jnl",	JGE,		JUMP },
-	{ "jnle",	JG,		JUMP },
-	{ "jno",	JNO,		JUMP },
-	{ "jnp",	JNP,		JUMP },
-	{ "jns",	JNS,		JUMP },
-	{ "jnz",	JNE,		JUMP },
-	{ "jo",		JO,		JUMP },
-	{ "jp",		JP,		JUMP },
-	{ "js",		JS,		JUMP },
-	{ "jz",		JE,		JUMP },
-	{ "lahf",	LAHF,		WORD },
-	{ "lar",	LAR,		WORD },
-	{ "lds",	LDS,		WORD },
-	{ "lea",	LEA,		WORD },
-	{ "leave",	LEAVE,		WORD },
-	{ "les",	LES,		WORD },
-	{ "lfs",	LFS,		WORD },
-	{ "lgdt",	LGDT,		WORD },
-	{ "lgs",	LGS,		WORD },
-	{ "lidt",	LIDT,		WORD },
-	{ "lldt",	LLDT,		WORD },
-	{ "lmsw",	LMSW,		WORD },
-	{ "lock",	LOCK,		WORD },
-	{ "lods",	LODS,		WORD },
-	{ "lodsb",	LODS,		BYTE },
-	{ "loop",	LOOP,		JUMP },
-	{ "loope",	LOOPE,		JUMP },
-	{ "loopne",	LOOPNE,		JUMP },
-	{ "loopnz",	LOOPNE,		JUMP },
-	{ "loopz",	LOOPE,		JUMP },
-	{ "lsl",	LSL,		WORD },
-	{ "lss",	LSS,		WORD },
-	{ "ltr",	LTR,		WORD },
-	{ "mov",	MOV,		WORD },
-	{ "movs",	MOVS,		WORD },
-	{ "movsb",	MOVS,		BYTE },
-	{ "movsx",	MOVSX,		WORD },
-	{ "movzx",	MOVZX,		WORD },
-	{ "mul",	MUL,		WORD },
-	{ "neg",	NEG,		WORD },
-	{ "nop",	NOP,		WORD },
-	{ "not",	NOT,		WORD },
-	{ "or",		OR,		WORD },
-	{ "out",	OUT,		WORD },
-	{ "outb",	OUT,		BYTE },
-	{ "outs",	OUTS,		WORD },
-	{ "outsb",	OUTS,		BYTE },
-	{ "pop",	POP,		WORD },
-	{ "popa",	POPA,		WORD },
-	{ "popad",	POPA,		WORD },
-	{ "popf",	POPF,		WORD },
-	{ "popfd",	POPF,		WORD },
-	{ "push",	PUSH,		WORD },
-	{ "pusha",	PUSHA,		WORD },
-	{ "pushad",	PUSHA,		WORD },
-	{ "pushf",	PUSHF,		WORD },
-	{ "pushfd",	PUSHF,		WORD },
-	{ "rcl",	RCL,		WORD },
-	{ "rcr",	RCR,		WORD },
-	{ "ret",	RET,		JUMP },
-	{ "retf",	RETF,		JUMP },
-	{ "rol",	ROL,		WORD },
-	{ "ror",	ROR,		WORD },
-	{ "sahf",	SAHF,		WORD },
-	{ "sal",	SAL,		WORD },
-	{ "sar",	SAR,		WORD },
-	{ "sbb",	SBB,		WORD },
-	{ "scas",	SCAS,		WORD },
-	{ "seta",	SETA,		BYTE },
-	{ "setae",	SETAE,		BYTE },
-	{ "setb",	SETB,		BYTE },
-	{ "setbe",	SETBE,		BYTE },
-	{ "sete",	SETE,		BYTE },
-	{ "setg",	SETG,		BYTE },
-	{ "setge",	SETGE,		BYTE },
-	{ "setl",	SETL,		BYTE },
-	{ "setna",	SETBE,		BYTE },
-	{ "setnae",	SETB,		BYTE },
-	{ "setnb",	SETAE,		BYTE },
-	{ "setnbe",	SETA,		BYTE },
-	{ "setne",	SETNE,		BYTE },
-	{ "setng",	SETLE,		BYTE },
-	{ "setnge",	SETL,		BYTE },
-	{ "setnl",	SETGE,		BYTE },
-	{ "setnle",	SETG,		BYTE },
-	{ "setno",	SETNO,		BYTE },
-	{ "setnp",	SETNP,		BYTE },
-	{ "setns",	SETNS,		BYTE },
-	{ "seto",	SETO,		BYTE },
-	{ "setp",	SETP,		BYTE },
-	{ "sets",	SETS,		BYTE },
-	{ "setz",	SETE,		BYTE },
-	{ "sgdt",	SGDT,		WORD },
-	{ "shl",	SHL,		WORD },
-	{ "shld",	SHLD,		WORD },
-	{ "shr",	SHR,		WORD },
-	{ "shrd",	SHRD,		WORD },
-	{ "sidt",	SIDT,		WORD },
-	{ "sldt",	SLDT,		WORD },
-	{ "smsw",	SMSW,		WORD },
-	{ "stc",	STC,		WORD },
-	{ "std",	STD,		WORD },
-	{ "sti",	STI,		WORD },
-	{ "stos",	STOS,		WORD },
-	{ "stosb",	STOS,		BYTE },
-	{ "str",	STR,		WORD },
-	{ "sub",	SUB,		WORD },
-	{ "test",	TEST,		WORD },
-	{ "verr",	VERR,		WORD },
-	{ "verw",	VERW,		WORD },
-	{ "wait",	WAIT,		WORD },
-	{ "wbinvd",	WBINVD,		WORD },
-	{ "xadd",	XADD,		WORD },
-	{ "xchg",	XCHG,		WORD },
-	{ "xlat",	XLAT,		WORD },
-	{ "xor",	XOR,		WORD },
-};
-
-void bas_parse_init(char *file)
-/* Prepare parsing of an BAS assembly file. */
-{
-	tok_init(file, '!');
-}
-
-static void zap(void)
-/* An error, zap the rest of the line. */
-{
-	token_t *t;
-
-	while ((t= get_token(0))->type != T_EOF && t->symbol != ';')
-		skip_token(1);
-}
-
-static mnemonic_t *search_mnem(char *name)
-/* Binary search for a mnemonic.  (That's why the table is sorted.) */
-{
-	int low, mid, high;
-	int cmp;
-	mnemonic_t *m;
-
-	low= 0;
-	high= arraysize(mnemtab)-1;
-	while (low <= high) {
-		mid= (low + high) / 2;
-		m= &mnemtab[mid];
-
-		if ((cmp= strcmp(name, m->name)) == 0) return m;
-
-		if (cmp < 0) high= mid-1; else low= mid+1;
-	}
-	return nil;
-}
-
-static expression_t *bas_get_C_expression(int *pn)
-/* Read a "C-like" expression.  Note that we don't worry about precedence,
- * the expression is printed later like it is read.  If the target language
- * does not have all the operators (like ~) then this has to be repaired by
- * changing the source file.  (No problem, you still have one source file
- * to maintain, not two.)
- */
-{
-	expression_t *e, *a1, *a2;
-	token_t *t;
-
-	if ((t= get_token(*pn))->symbol == '(') {
-		/* ( expr ): grouping. */
-		(*pn)++;
-		if ((a1= bas_get_C_expression(pn)) == nil) return nil;
-		if (get_token(*pn)->symbol != ')') {
-			parse_err(1, t, "missing )\n");
-			del_expr(a1);
-			return nil;
-		}
-		(*pn)++;
-		e= new_expr();
-		e->operator= '[';
-		e->middle= a1;
-	} else
-	if (t->type == T_WORD || t->type == T_STRING) {
-		/* Label, number, or string. */
-		e= new_expr();
-		e->operator= t->type == T_WORD ? 'W' : 'S';
-		e->name= allocate(nil, (t->len+1) * sizeof(e->name[0]));
-		memcpy(e->name, t->name, t->len+1);
-		e->len= t->len;
-		(*pn)++;
-	} else
-	if (t->symbol == '+' || t->symbol == '-' || t->symbol == '~') {
-		/* Unary operator. */
-		(*pn)++;
-		if ((a1= bas_get_C_expression(pn)) == nil) return nil;
-		e= new_expr();
-		e->operator= t->symbol;
-		e->middle= a1;
-	} else
-	if (t->symbol == '$' && get_token(*pn + 1)->type == T_WORD) {
-		/* A hexadecimal number. */
-		t= get_token(*pn + 1);
-		e= new_expr();
-		e->operator= 'W';
-		e->name= allocate(nil, (t->len+3) * sizeof(e->name[0]));
-		strcpy(e->name, "0x");
-		memcpy(e->name+2, t->name, t->len+1);
-		e->len= t->len+2;
-		(*pn)+= 2;
-	} else {
-		parse_err(1, t, "expression syntax error\n");
-		return nil;
-	}
-
-	switch ((t= get_token(*pn))->symbol) {
-	case '+':
-	case '-':
-	case '*':
-	case '/':
-	case '%':
-	case '&':
-	case '|':
-	case '^':
-	case S_LEFTSHIFT:
-	case S_RIGHTSHIFT:
-		(*pn)++;
-		a1= e;
-		if ((a2= bas_get_C_expression(pn)) == nil) {
-			del_expr(a1);
-			return nil;
-		}
-		e= new_expr();
-		e->operator= t->symbol;
-		e->left= a1;
-		e->right= a2;
-	}
-	return e;
-}
-
-/* We want to know the sizes of the first two operands. */
-static optype_t optypes[2];
-static int op_idx;
-
-static expression_t *bas_get_operand(int *pn)
-/* Get something like: [memory], offset[base+index*scale], or simpler. */
-{
-	expression_t *e, *offset, *base, *index;
-	token_t *t;
-	int c;
-	optype_t optype;
-
-	/* Prefixed by 'byte', 'word' or 'dword'? */
-	if ((t= get_token(*pn))->type == T_WORD && (
-		strcmp(t->name, "byte") == 0
-		|| strcmp(t->name, "word") == 0
-		|| strcmp(t->name, "dword") == 0)
-	) {
-		switch (t->name[0]) {
-		case 'b':	optype= BYTE; break;
-		case 'w':	optype= use16() ? WORD : OWORD; break;
-		case 'd':	optype= use32() ? WORD : OWORD; break;
-		}
-		if (op_idx < arraysize(optypes)) optypes[op_idx++]= optype;
-		(*pn)++;
-
-		/* It may even be "byte ptr"... */
-		if ((t= get_token(*pn))->type == T_WORD
-					&& strcmp(t->name, "ptr") == 0) {
-			(*pn)++;
-		}
-	}
-
-	/* Is it [memory]? */
-	if (get_token(*pn)->symbol == '['
-		&& ((t= get_token(*pn + 1))->type != T_WORD
-			|| !isregister(t->name))
-	) {
-		/* A memory dereference. */
-		(*pn)++;
-		if ((offset= bas_get_C_expression(pn)) == nil) return nil;
-		if (get_token(*pn)->symbol != ']') {
-			parse_err(1, t, "operand syntax error\n");
-			del_expr(offset);
-			return nil;
-		}
-		(*pn)++;
-		e= new_expr();
-		e->operator= '(';
-		e->middle= offset;
-		return e;
-	}
-
-	/* #something? *something? */
-	if ((c= get_token(*pn)->symbol) == '#' || c == '*') {
-		/* '#' and '*' are often used to introduce some constant. */
-		(*pn)++;
-	}
-
-	/* Offset? */
-	if (get_token(*pn)->symbol != '[') {
-		/* There is an offset. */
-		if ((offset= bas_get_C_expression(pn)) == nil) return nil;
-	} else {
-		/* No offset. */
-		offset= nil;
-	}
-
-	/* [base]? [base+? base-? */
-	c= 0;
-	if (get_token(*pn)->symbol == '['
-		&& (t= get_token(*pn + 1))->type == T_WORD
-		&& isregister(t->name)
-		&& ((c= get_token(*pn + 2)->symbol) == ']' || c=='+' || c=='-')
-	) {
-		/* A base register expression. */
-		base= new_expr();
-		base->operator= 'B';
-		base->name= copystr(t->name);
-		(*pn)+= c == ']' ? 3 : 2;
-	} else {
-		/* No base register expression. */
-		base= nil;
-	}
-
-	/* +offset]? -offset]? */
-	if (offset == nil
-		&& (c == '+' || c == '-')
-		&& (t= get_token(*pn + 1))->type == T_WORD
-		&& !isregister(t->name)
-	) {
-		(*pn)++;
-		if ((offset= bas_get_C_expression(pn)) == nil) return nil;
-		if (get_token(*pn)->symbol != ']') {
-			parse_err(1, t, "operand syntax error\n");
-			del_expr(offset);
-			del_expr(base);
-			return nil;
-		}
-		(*pn)++;
-		c= 0;
-	}
-
-	/* [index*scale]? +index*scale]? */
-	if (c == '+' || get_token(*pn)->symbol == '[') {
-		/* An index most likely. */
-		token_t *m= nil;
-
-		if (!(		/* This must be true: */
-			(t= get_token(*pn + 1))->type == T_WORD
-			&& isregister(t->name)
-			&& (get_token(*pn + 2)->symbol == ']' || (
-				get_token(*pn + 2)->symbol == '*'
-				&& (m= get_token(*pn + 3))->type == T_WORD
-				&& strchr("1248", m->name[0]) != nil
-				&& m->name[1] == 0
-				&& get_token(*pn + 4)->symbol == ']'
-			))
-		)) {
-			/* Alas it isn't */
-			parse_err(1, t, "operand syntax error\n");
-			del_expr(offset);
-			del_expr(base);
-			return nil;
-		}
-		/* Found an index. */
-		index= new_expr();
-		index->operator= m == nil ? '1' : m->name[0];
-		index->name= copystr(t->name);
-		(*pn)+= (m == nil ? 3 : 5);
-	} else {
-		/* No index. */
-		index= nil;
-	}
-
-	if (base == nil && index == nil) {
-		/* Return a lone offset as is. */
-		e= offset;
-
-		/* Lone registers tell operand size. */
-		if (offset->operator == 'W' && isregister(offset->name)) {
-			switch (isregister(offset->name)) {
-			case 1:	optype= BYTE; break;
-			case 2:	optype= use16() ? WORD : OWORD; break;
-			case 4:	optype= use32() ? WORD : OWORD; break;
-			}
-			if (op_idx < arraysize(optypes))
-				optypes[op_idx++]= optype;
-		}
-	} else {
-		e= new_expr();
-		e->operator= 'O';
-		e->left= offset;
-		e->middle= base;
-		e->right= index;
-	}
-	return e;
-}
-
-static expression_t *bas_get_oplist(int *pn)
-/* Get a comma (or colon for jmpf and callf) separated list of instruction
- * operands.
- */
-{
-	expression_t *e, *o1, *o2;
-	token_t *t;
-
-	if ((e= bas_get_operand(pn)) == nil) return nil;
-
-	if ((t= get_token(*pn))->symbol == ',' || t->symbol == ':') {
-		o1= e;
-		(*pn)++;
-		if ((o2= bas_get_oplist(pn)) == nil) {
-			del_expr(o1);
-			return nil;
-		}
-		e= new_expr();
-		e->operator= ',';
-		e->left= o1;
-		e->right= o2;
-	}
-	return e;
-}
-
-static asm86_t *bas_get_statement(void)
-/* Get a pseudo op or machine instruction with arguments. */
-{
-	token_t *t= get_token(0);
-	asm86_t *a;
-	mnemonic_t *m;
-	int n;
-	int prefix_seen;
-
-
-	assert(t->type == T_WORD);
-
-	if (strcmp(t->name, ".sect") == 0) {
-		/* .sect .text etc.  Accept only four segment names. */
-		skip_token(1);
-		t= get_token(0);
-		if (t->type != T_WORD || (
-			strcmp(t->name, ".text") != 0
-			&& strcmp(t->name, ".rom") != 0
-			&& strcmp(t->name, ".data") != 0
-			&& strcmp(t->name, ".bss") != 0
-			&& strcmp(t->name, ".end") != 0
-		)) {
-			parse_err(1, t, "weird section name to .sect\n");
-			return nil;
-		}
-	}
-	a= new_asm86();
-
-	/* Process instruction prefixes. */
-	for (prefix_seen= 0;; prefix_seen= 1) {
-		if (strcmp(t->name, "rep") == 0
-			|| strcmp(t->name, "repe") == 0
-			|| strcmp(t->name, "repne") == 0
-			|| strcmp(t->name, "repz") == 0
-			|| strcmp(t->name, "repnz") == 0
-		) {
-			if (a->rep != ONCE) {
-				parse_err(1, t,
-					"can't have more than one rep\n");
-			}
-			switch (t->name[3]) {
-			case 0:		a->rep= REP;	break;
-			case 'e':
-			case 'z':	a->rep= REPE;	break;
-			case 'n':	a->rep= REPNE;	break;
-			}
-		} else
-		if (strcmp(t->name, "seg") == 0
-					&& get_token(1)->type == T_WORD) {
-			if (a->seg != DEFSEG) {
-				parse_err(1, t,
-				"can't have more than one segment prefix\n");
-			}
-			switch (get_token(1)->name[0]) {
-			case 'c':	a->seg= CSEG;	break;
-			case 'd':	a->seg= DSEG;	break;
-			case 'e':	a->seg= ESEG;	break;
-			case 'f':	a->seg= FSEG;	break;
-			case 'g':	a->seg= GSEG;	break;
-			case 's':	a->seg= SSEG;	break;
-			}
-			skip_token(1);
-		} else
-		if (!prefix_seen) {
-			/* No prefix here, get out! */
-			break;
-		} else {
-			/* No more prefixes, next must be an instruction. */
-			if (t->type != T_WORD
-				|| (m= search_mnem(t->name)) == nil
-				|| m->optype == PSEUDO
-			) {
-				parse_err(1, t,
-		"machine instruction expected after instruction prefix\n");
-				del_asm86(a);
-				return nil;
-			}
-			break;
-		}
-
-		/* Skip the prefix and extra newlines. */
-		do {
-			skip_token(1);
-		} while ((t= get_token(0))->symbol == ';');
-	}
-
-	/* All the readahead being done upsets the line counter. */
-	a->line= t->line;
-
-	/* Read a machine instruction or pseudo op. */
-	if ((m= search_mnem(t->name)) == nil) {
-		parse_err(1, t, "unknown instruction '%s'\n", t->name);
-		del_asm86(a);
-		return nil;
-	}
-	a->opcode= m->opcode;
-	a->optype= m->optype;
-	if (a->opcode == CBW || a->opcode == CWD) {
-		a->optype= (strcmp(t->name, "cbw") == 0
-		    || strcmp(t->name, "cwd") == 0) == use16() ? WORD : OWORD;
-	}
-	for (op_idx= 0; op_idx < arraysize(optypes); op_idx++)
-		optypes[op_idx]= m->optype;
-	op_idx= 0;
-
-	n= 1;
-	if (get_token(1)->symbol != ';'
-				&& (a->args= bas_get_oplist(&n)) == nil) {
-		del_asm86(a);
-		return nil;
-	}
-
-	if (m->optype == WORD) {
-		/* Does one of the operands overide the optype? */
-		for (op_idx= 0; op_idx < arraysize(optypes); op_idx++) {
-			if (optypes[op_idx] != m->optype)
-				a->optype= optypes[op_idx];
-		}
-	}
-
-	if (get_token(n)->symbol != ';') {
-		parse_err(1, t, "garbage at end of instruction\n");
-		del_asm86(a);
-		return nil;
-	}
-	switch (a->opcode) {
-	case DOT_ALIGN:
-		/* Restrict .align to have a single numeric argument, some
-		 * assemblers think of the argument as a power of two, so
-		 * we need to be able to change the value.
-		 */
-		if (strcmp(t->name, ".even") == 0 && a->args == nil) {
-			/* .even becomes .align 2. */
-			expression_t *e;
-			a->args= e= new_expr();
-			e->operator= 'W';
-			e->name= copystr("2");
-			e->len= 2;
-		}
-		if (a->args == nil || a->args->operator != 'W'
-					|| !isanumber(a->args->name)) {
-			parse_err(1, t,
-			  ".align is restricted to one numeric argument\n");
-			del_asm86(a);
-			return nil;
-		}
-		break;
-	case MOVSX:
-	case MOVZX:
-		/* Types of both operands tell the instruction type. */
-		a->optype= optypes[0];
-		if (optypes[1] == BYTE) {
-			a->opcode= a->opcode == MOVSX ? MOVSXB : MOVZXB;
-		}
-		break;
-	case SAL:
-	case SAR:
-	case SHL:
-	case SHR:
-	case RCL:
-	case RCR:
-	case ROL:
-	case ROR:
-		/* Only the first operand tells the operand size. */
-		a->optype= optypes[0];
-		break;
-	default:;
-	}
-	skip_token(n+1);
-	return a;
-}
-
-asm86_t *bas_get_instruction(void)
-{
-	asm86_t *a= nil;
-	expression_t *e;
-	token_t *t;
-
-	while ((t= get_token(0))->symbol == ';')
-		skip_token(1);
-
-	if (t->type == T_EOF) return nil;
-
-	if (t->symbol == '#') {
-		/* Preprocessor line and file change. */
-
-		if ((t= get_token(1))->type != T_WORD || !isanumber(t->name)
-			|| get_token(2)->type != T_STRING
-		) {
-			parse_err(1, t, "file not preprocessed?\n");
-			zap();
-		} else {
-			set_file(get_token(2)->name,
-				strtol(get_token(1)->name, nil, 0) - 1);
-
-			/* GNU CPP adds extra cruft, simply zap the line. */
-			zap();
-		}
-		a= bas_get_instruction();
-	} else
-	if (t->type == T_WORD && get_token(1)->symbol == ':') {
-		/* A label definition. */
-		a= new_asm86();
-		a->line= t->line;
-		a->opcode= DOT_LABEL;
-		a->optype= PSEUDO;
-		a->args= e= new_expr();
-		e->operator= ':';
-		e->name= copystr(t->name);
-		skip_token(2);
-	} else
-	if (t->type == T_WORD && get_token(1)->symbol == '=') {
-		int n= 2;
-
-		if ((e= bas_get_C_expression(&n)) == nil) {
-			zap();
-			a= bas_get_instruction();
-		} else
-		if (get_token(n)->symbol != ';') {
-			parse_err(1, t, "garbage after assignment\n");
-			zap();
-			a= bas_get_instruction();
-		} else {
-			a= new_asm86();
-			a->line= t->line;
-			a->opcode= DOT_EQU;
-			a->optype= PSEUDO;
-			a->args= new_expr();
-			a->args->operator= '=';
-			a->args->name= copystr(t->name);
-			a->args->middle= e;
-			skip_token(n+1);
-		}
-	} else
-	if (t->type == T_WORD && get_token(1)->type == T_WORD
-				&& strcmp(get_token(1)->name, "lcomm") == 0) {
-		/* Local common block definition. */
-		int n= 2;
-
-		if ((e= bas_get_C_expression(&n)) == nil) {
-			zap();
-			a= bas_get_instruction();
-		} else
-		if (get_token(n)->symbol != ';') {
-			parse_err(1, t, "garbage after lcomm\n");
-			zap();
-			a= bas_get_instruction();
-		} else {
-			a= new_asm86();
-			a->line= t->line;
-			a->opcode= DOT_LCOMM;
-			a->optype= PSEUDO;
-			a->args= new_expr();
-			a->args->operator= ',';
-			a->args->right= e;
-			a->args->left= e= new_expr();
-			e->operator= 'W';
-			e->name= copystr(t->name);
-			e->len= strlen(e->name)+1;
-			skip_token(n+1);
-		}
-	} else
-	if (t->type == T_WORD) {
-		if ((a= bas_get_statement()) == nil) {
-			zap();
-			a= bas_get_instruction();
-		}
-	} else {
-		parse_err(1, t, "syntax error\n");
-		zap();
-		a= bas_get_instruction();
-	}
-	if (a->optype == OWORD) {
-		a->optype= WORD;
-		a->oaz|= OPZ;
-	}
-	return a;
-}
Index: trunk/minix/commands/i386/asmconv/parse_gnu.c
===================================================================
--- trunk/minix/commands/i386/asmconv/parse_gnu.c	(revision 9)
+++ 	(revision )
@@ -1,879 +1,0 @@
-/*	parse_ack.c - parse GNU assembly		Author: R.S. Veldema
- *							 <rveldema@cs.vu.nl>
- *								26 Aug 1996
- */
-#define nil 0
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <assert.h>
-#include "asmconv.h"
-#include "token.h"
-#include "asm86.h"
-#include "languages.h"
-
-typedef struct mnemonic {	/* GNU as86 mnemonics translation table. */
-	char		*name;
-	opcode_t	opcode;
-	optype_t	optype;
-} mnemonic_t;
-
-static mnemonic_t mnemtab[] = {			/* This array is sorted. */
-	{ ".align",	DOT_ALIGN,	PSEUDO },
-	{ ".ascii",	DOT_ASCII,	PSEUDO },
-	{ ".asciz",	DOT_ASCIZ,	PSEUDO },
-	{ ".assert",	DOT_ASSERT,	PSEUDO },
-	{ ".base",	DOT_BASE,	PSEUDO },
-	{ ".bss",	DOT_BSS,	PSEUDO },
-	{ ".byte",	DOT_DATA1,	PSEUDO },
-	{ ".comm",	DOT_COMM,	PSEUDO },
-	{ ".data",	DOT_DATA,	PSEUDO },
-	{ ".data1",	DOT_DATA1,	PSEUDO },
-	{ ".data2",	DOT_DATA2,	PSEUDO },
-	{ ".data4",	DOT_DATA4,	PSEUDO },
-	{ ".end",	DOT_END,	PSEUDO },
-	{ ".extern",	DOT_EXTERN,	PSEUDO },
-	{ ".file",	DOT_FILE,	PSEUDO },
-	{ ".globl",	DOT_DEFINE,	PSEUDO },
-	{ ".lcomm",	DOT_LCOMM,	PSEUDO },
-	{ ".line",	DOT_LINE,	PSEUDO },
-	{ ".list",	DOT_LIST,	PSEUDO },
-	{ ".long",	DOT_DATA4,	PSEUDO },
-	{ ".nolist",	DOT_NOLIST,	PSEUDO },
-	{ ".rom",	DOT_ROM,	PSEUDO },
-	{ ".space",	DOT_SPACE,	PSEUDO },
-	{ ".symb",	DOT_SYMB,	PSEUDO },
-	{ ".text",	DOT_TEXT,	PSEUDO },
-	{ ".word",	DOT_DATA2,	PSEUDO },
-	{ "aaa",	AAA,		WORD },
-	{ "aad",	AAD,		WORD },
-	{ "aam",	AAM,		WORD },
-	{ "aas",	AAS,		WORD },
-	{ "adcb",	ADC,		BYTE },
-	{ "adcl",	ADC,		WORD },
-	{ "adcw",	ADC,		OWORD },
-	{ "addb",	ADD,		BYTE },
-	{ "addl",	ADD,		WORD },
-	{ "addw",	ADD,		OWORD },
-	{ "andb",	AND,		BYTE },
-	{ "andl",	AND,		WORD },
-	{ "andw",	AND,		OWORD },
-	{ "arpl",	ARPL,		WORD },
-	{ "bound",	BOUND,		WORD },
-	{ "bsf",	BSF,		WORD },
-	{ "bsr",	BSR,		WORD },
-	{ "bswap",	BSWAP,		WORD },
-	{ "btc",	BTC,		WORD },
-	{ "btl",	BT,		WORD },
-	{ "btr",	BTR,		WORD },
-	{ "bts",	BTS,		WORD },
-	{ "btw",	BT,		OWORD },
-	{ "call",	CALL,		JUMP },
-	{ "callf",	CALLF,		JUMP },
-	{ "cbtw",	CBW,		OWORD },
-	{ "cbw",	CBW,		WORD },
-	{ "cdq",	CWD,		WORD },
-	{ "clc",	CLC,		WORD },
-	{ "cld",	CLD,		WORD },
-	{ "cli",	CLI,		WORD },
-	{ "cltd",	CWD,		WORD },
-	{ "clts",	CLTS,		WORD },
-	{ "cmc",	CMC,		WORD },
-	{ "cmpb",	CMP,		BYTE },
-	{ "cmpl",	CMP,		WORD },
-	{ "cmps",	CMPS,		WORD },
-	{ "cmpsb",	CMPS,		BYTE },
-	{ "cmpw",	CMP,		OWORD },
-	{ "cmpxchg",	CMPXCHG,	WORD },
-	{ "cwd",	CWD,		WORD },
-	{ "cwde",	CBW,		WORD },
-	{ "cwtd",	CWD,		OWORD },
-	{ "cwtl",	CBW,		WORD },
-	{ "daa",	DAA,		WORD },
-	{ "das",	DAS,		WORD },
-	{ "decb",	DEC,		BYTE },
-	{ "decl",	DEC,		WORD },
-	{ "decw",	DEC,		OWORD },
-	{ "divb",	DIV,		BYTE },
-	{ "divl",	DIV,		WORD },
-	{ "divw",	DIV,		OWORD },
-	{ "enter",	ENTER,		WORD },
-	{ "f2xm1",	F2XM1,		WORD },
-	{ "fabs",	FABS,		WORD },
-	{ "fadd",	FADD,		WORD },
-	{ "faddd",	FADDD,		WORD },
-	{ "faddp",	FADDP,		WORD },
-	{ "fadds",	FADDS,		WORD },
-	{ "fbld",	FBLD,		WORD },
-	{ "fbstp",	FBSTP,		WORD },
-	{ "fchs",	FCHS,		WORD },
-	{ "fcomd",	FCOMD,		WORD },
-	{ "fcompd",	FCOMPD,		WORD },
-	{ "fcompp",	FCOMPP,		WORD },
-	{ "fcomps",	FCOMPS,		WORD },
-	{ "fcoms",	FCOMS,		WORD },
-	{ "fcos",	FCOS,		WORD },
-	{ "fdecstp",	FDECSTP,	WORD },
-	{ "fdivd",	FDIVD,		WORD },
-	{ "fdivp",	FDIVP,		WORD },
-	{ "fdivrd",	FDIVRD,		WORD },
-	{ "fdivrp",	FDIVRP,		WORD },
-	{ "fdivrs",	FDIVRS,		WORD },
-	{ "fdivs",	FDIVS,		WORD },
-	{ "ffree",	FFREE,		WORD },
-	{ "fiaddl",	FIADDL,		WORD },
-	{ "fiadds",	FIADDS,		WORD },
-	{ "ficom",	FICOM,		WORD },
-	{ "ficomp",	FICOMP,		WORD },
-	{ "fidivl",	FIDIVL,		WORD },
-	{ "fidivrl",	FIDIVRL,	WORD },
-	{ "fidivrs",	FIDIVRS,	WORD },
-	{ "fidivs",	FIDIVS,		WORD },
-	{ "fildl",	FILDL,		WORD },
-	{ "fildq",	FILDQ,		WORD },
-	{ "filds",	FILDS,		WORD },
-	{ "fimull",	FIMULL,		WORD },
-	{ "fimuls",	FIMULS,		WORD },
-	{ "fincstp",	FINCSTP,	WORD },
-	{ "fistl",	FISTL,		WORD },
-	{ "fistp",	FISTP,		WORD },
-	{ "fists",	FISTS,		WORD },
-	{ "fisubl",	FISUBL,		WORD },
-	{ "fisubrl",	FISUBRL,	WORD },
-	{ "fisubrs",	FISUBRS,	WORD },
-	{ "fisubs",	FISUBS,		WORD },
-	{ "fld1",	FLD1,		WORD },
-	{ "fldcw",	FLDCW,		WORD },
-	{ "fldd",	FLDD,		WORD },
-	{ "fldenv",	FLDENV,		WORD },
-	{ "fldl2e",	FLDL2E,		WORD },
-	{ "fldl2t",	FLDL2T,		WORD },
-	{ "fldlg2",	FLDLG2,		WORD },
-	{ "fldln2",	FLDLN2,		WORD },
-	{ "fldpi",	FLDPI,		WORD },
-	{ "flds",	FLDS,		WORD },
-	{ "fldx",	FLDX,		WORD },
-	{ "fldz",	FLDZ,		WORD },
-	{ "fmuld",	FMULD,		WORD },
-	{ "fmulp",	FMULP,		WORD },
-	{ "fmuls",	FMULS,		WORD },
-	{ "fnclex",	FCLEX,		WORD },
-	{ "fninit",	FINIT,		WORD },
-	{ "fnop",	FNOP,		WORD },
-	{ "fnsave",	FSAVE,		WORD },
-	{ "fnstcw",	FSTCW,		WORD },
-	{ "fnstenv",	FSTENV,		WORD },
-	{ "fpatan",	FPATAN,		WORD },
-	{ "fprem",	FPREM,		WORD },
-	{ "fprem1",	FPREM1,		WORD },
-	{ "fptan",	FPTAN,		WORD },
-	{ "frndint",	FRNDINT,	WORD },
-	{ "frstor",	FRSTOR,		WORD },
-	{ "fscale",	FSCALE,		WORD },
-	{ "fsin",	FSIN,		WORD },
-	{ "fsincos",	FSINCOS,	WORD },
-	{ "fsqrt",	FSQRT,		WORD },
-	{ "fstd",	FSTD,		WORD },
-	{ "fstpd",	FSTPD,		WORD },
-	{ "fstps",	FSTPS,		WORD },
-	{ "fstpx",	FSTPX,		WORD },
-	{ "fsts",	FSTS,		WORD },
-	{ "fstsw",	FSTSW,		WORD },
-	{ "fsubd",	FSUBD,		WORD },
-	{ "fsubp",	FSUBP,		WORD },
-	{ "fsubpr",	FSUBPR,		WORD },
-	{ "fsubrd",	FSUBRD,		WORD },
-	{ "fsubrs",	FSUBRS,		WORD },
-	{ "fsubs",	FSUBS,		WORD },
-	{ "ftst",	FTST,		WORD },
-	{ "fucom",	FUCOM,		WORD },
-	{ "fucomp",	FUCOMP,		WORD },
-	{ "fucompp",	FUCOMPP,	WORD },
-	{ "fxam",	FXAM,		WORD },
-	{ "fxch",	FXCH,		WORD },
-	{ "fxtract",	FXTRACT,	WORD },
-	{ "fyl2x",	FYL2X,		WORD },
-	{ "fyl2xp1",	FYL2XP1,	WORD },
-	{ "hlt",	HLT,		WORD },
-	{ "idivb",	IDIV,		BYTE },
-	{ "idivl",	IDIV,		WORD },
-	{ "idivw",	IDIV,		OWORD },
-	{ "imulb",	IMUL,		BYTE },
-	{ "imull",	IMUL,		WORD },
-	{ "imulw",	IMUL,		OWORD },
-	{ "inb",	IN,		BYTE },
-	{ "incb",	INC,		BYTE },
-	{ "incl",	INC,		WORD },
-	{ "incw",	INC,		OWORD },
-	{ "inl",	IN,		WORD },
-	{ "insb",	INS,		BYTE },
-	{ "insl",	INS,		WORD },
-	{ "insw",	INS,		OWORD },
-	{ "int",	INT,		WORD },
-	{ "into",	INTO,		JUMP },
-	{ "invd",	INVD,		WORD },
-	{ "invlpg",	INVLPG,		WORD },
-	{ "inw",	IN,		OWORD },
-	{ "iret",	IRET,		JUMP },
-	{ "iretd",	IRETD,		JUMP },
-	{ "ja",		JA,		JUMP },
-	{ "jae",	JAE,		JUMP },
-	{ "jb",		JB,		JUMP },
-	{ "jbe",	JBE,		JUMP },
-	{ "jc",		JB,		JUMP },
-	{ "jcxz",	JCXZ,		JUMP },
-	{ "je",		JE,		JUMP },
-	{ "jecxz",	JCXZ,		JUMP },
-	{ "jg",		JG,		JUMP },
-	{ "jge",	JGE,		JUMP },
-	{ "jl",		JL,		JUMP },
-	{ "jle",	JLE,		JUMP },
-	{ "jmp",	JMP,		JUMP },
-	{ "jmpf",	JMPF,		JUMP },
-	{ "jna",	JBE,		JUMP },
-	{ "jnae",	JB,		JUMP },
-	{ "jnb",	JAE,		JUMP },
-	{ "jnbe",	JA,		JUMP },
-	{ "jnc",	JAE,		JUMP },
-	{ "jne",	JNE,		JUMP },
-	{ "jng",	JLE,		JUMP },
-	{ "jnge",	JL,		JUMP },
-	{ "jnl",	JGE,		JUMP },
-	{ "jnle",	JG,		JUMP },
-	{ "jno",	JNO,		JUMP },
-	{ "jnp",	JNP,		JUMP },
-	{ "jns",	JNS,		JUMP },
-	{ "jnz",	JNE,		JUMP },
-	{ "jo",		JO,		JUMP },
-	{ "jp",		JP,		JUMP },
-	{ "js",		JS,		JUMP },
-	{ "jz",		JE,		JUMP },
-	{ "lahf",	LAHF,		WORD },
-	{ "lar",	LAR,		WORD },
-	{ "lds",	LDS,		WORD },
-	{ "leal",	LEA,		WORD },
-	{ "leave",	LEAVE,		WORD },
-	{ "leaw",	LEA,		OWORD },
-	{ "les",	LES,		WORD },
-	{ "lfs",	LFS,		WORD },
-	{ "lgdt",	LGDT,		WORD },
-	{ "lgs",	LGS,		WORD },
-	{ "lidt",	LIDT,		WORD },
-	{ "lldt",	LLDT,		WORD },
-	{ "lmsw",	LMSW,		WORD },
-	{ "lock",	LOCK,		WORD },
-	{ "lods",	LODS,		WORD },
-	{ "lodsb",	LODS,		BYTE },
-	{ "loop",	LOOP,		JUMP },
-	{ "loope",	LOOPE,		JUMP },
-	{ "loopne",	LOOPNE,		JUMP },
-	{ "loopnz",	LOOPNE,		JUMP },
-	{ "loopz",	LOOPE,		JUMP },
-	{ "lsl",	LSL,		WORD },
-	{ "lss",	LSS,		WORD },
-	{ "ltr",	LTR,		WORD },
-	{ "movb",	MOV,		BYTE },
-	{ "movl",	MOV,		WORD },
-	{ "movsb",	MOVS,		BYTE },
-	{ "movsbl",	MOVSXB,		WORD },
-	{ "movsbw",	MOVSXB,		OWORD },
-	{ "movsl",	MOVS,		WORD },
-	{ "movsw",	MOVS,		OWORD },
-	{ "movswl",	MOVSX,		WORD },
-	{ "movw",	MOV,		OWORD },
-	{ "movzbl",	MOVZXB,		WORD },
-	{ "movzbw",	MOVZXB,		OWORD },
-	{ "movzwl",	MOVZX,		WORD },
-	{ "mulb",	MUL,		BYTE },
-	{ "mull",	MUL,		WORD },
-	{ "mulw",	MUL,		OWORD },
-	{ "negb",	NEG,		BYTE },
-	{ "negl",	NEG,		WORD },
-	{ "negw",	NEG,		OWORD },
-	{ "nop",	NOP,		WORD },
-	{ "notb",	NOT,		BYTE },
-	{ "notl",	NOT,		WORD },
-	{ "notw",	NOT,		OWORD },
-	{ "orb",	OR,		BYTE },
-	{ "orl",	OR,		WORD },
-	{ "orw",	OR,		OWORD },
-	{ "outb",	OUT,		BYTE },
-	{ "outl",	OUT,		WORD },
-	{ "outsb",	OUTS,		BYTE },
-	{ "outsl",	OUTS,		WORD },
-	{ "outsw",	OUTS,		OWORD },
-	{ "outw",	OUT,		OWORD },
-	{ "pop",	POP,		WORD },
-	{ "popa",	POPA,		WORD },
-	{ "popad",	POPA,		WORD },
-	{ "popf",	POPF,		WORD },
-	{ "popl",	POP,		WORD },
-	{ "push",	PUSH,		WORD },
-	{ "pusha",	PUSHA,		WORD },
-	{ "pushad",	PUSHA,		WORD },
-	{ "pushf",	PUSHF,		WORD },
-	{ "pushl",	PUSH,		WORD },
-	{ "rclb",	RCL,		BYTE },
-	{ "rcll",	RCL,		WORD },
-	{ "rclw",	RCL,		OWORD },
-	{ "rcrb",	RCR,		BYTE },
-	{ "rcrl",	RCR,		WORD },
-	{ "rcrw",	RCR,		OWORD },
-	{ "ret",	RET,		JUMP },
-	{ "retf",	RETF,		JUMP },
-	{ "rolb",	ROL,		BYTE },
-	{ "roll",	ROL,		WORD },
-	{ "rolw",	ROL,		OWORD },
-	{ "rorb",	ROR,		BYTE },
-	{ "rorl",	ROR,		WORD },
-	{ "rorw",	ROR,		OWORD },
-	{ "sahf",	SAHF,		WORD },
-	{ "salb",	SAL,		BYTE },
-	{ "sall",	SAL,		WORD },
-	{ "salw",	SAL,		OWORD },
-	{ "sarb",	SAR,		BYTE },
-	{ "sarl",	SAR,		WORD },
-	{ "sarw",	SAR,		OWORD },
-	{ "sbbb",	SBB,		BYTE },
-	{ "sbbl",	SBB,		WORD },
-	{ "sbbw",	SBB,		OWORD },
-	{ "scasb",	SCAS,		BYTE },
-	{ "scasl",	SCAS,		WORD },
-	{ "scasw",	SCAS,		OWORD },
-	{ "seta",	SETA,		BYTE },
-	{ "setae",	SETAE,		BYTE },
-	{ "setb",	SETB,		BYTE },
-	{ "setbe",	SETBE,		BYTE },
-	{ "sete",	SETE,		BYTE },
-	{ "setg",	SETG,		BYTE },
-	{ "setge",	SETGE,		BYTE },
-	{ "setl",	SETL,		BYTE },
-	{ "setna",	SETBE,		BYTE },
-	{ "setnae",	SETB,		BYTE },
-	{ "setnb",	SETAE,		BYTE },
-	{ "setnbe",	SETA,		BYTE },
-	{ "setne",	SETNE,		BYTE },
-	{ "setng",	SETLE,		BYTE },
-	{ "setnge",	SETL,		BYTE },
-	{ "setnl",	SETGE,		BYTE },
-	{ "setnle",	SETG,		BYTE },
-	{ "setno",	SETNO,		BYTE },
-	{ "setnp",	SETNP,		BYTE },
-	{ "setns",	SETNS,		BYTE },
-	{ "seto",	SETO,		BYTE },
-	{ "setp",	SETP,		BYTE },
-	{ "sets",	SETS,		BYTE },
-	{ "setz",	SETE,		BYTE },
-	{ "sgdt",	SGDT,		WORD },
-	{ "shlb",	SHL,		BYTE },
-	{ "shldl",	SHLD,		WORD },
-	{ "shll",	SHL,		WORD },
-	{ "shlw",	SHL,		OWORD },
-	{ "shrb",	SHR,		BYTE },
-	{ "shrdl",	SHRD,		WORD },
-	{ "shrl",	SHR,		WORD },
-	{ "shrw",	SHR,		OWORD },
-	{ "sidt",	SIDT,		WORD },
-	{ "sldt",	SLDT,		WORD },
-	{ "smsw",	SMSW,		WORD },
-	{ "stc",	STC,		WORD },
-	{ "std",	STD,		WORD },
-	{ "sti",	STI,		WORD },
-	{ "stosb",	STOS,		BYTE },
-	{ "stosl",	STOS,		WORD },
-	{ "stosw",	STOS,		OWORD },
-	{ "str",	STR,		WORD },
-	{ "subb",	SUB,		BYTE },
-	{ "subl",	SUB,		WORD },
-	{ "subw",	SUB,		OWORD },
-	{ "testb",	TEST,		BYTE },
-	{ "testl",	TEST,		WORD },
-	{ "testw",	TEST,		OWORD },
-	{ "verr",	VERR,		WORD },
-	{ "verw",	VERW,		WORD },
-	{ "wait",	WAIT,		WORD },
-	{ "wbinvd",	WBINVD,		WORD },
-	{ "xadd",	XADD,		WORD },
-	{ "xchgb",	XCHG,		BYTE },
-	{ "xchgl",	XCHG,		WORD },
-	{ "xchgw",	XCHG,		OWORD },
-	{ "xlat",	XLAT,		WORD },
-	{ "xorb",	XOR,		BYTE },
-	{ "xorl",	XOR,		WORD },
-	{ "xorw",	XOR,		OWORD },
-};
-
-void gnu_parse_init(char *file)
-/* Prepare parsing of an GNU assembly file. */
-{
-	tok_init(file, '#');
-}
-
-static void zap(void)
-/* An error, zap the rest of the line. */
-{
-	token_t *t;
-
-	while ((t= get_token(0))->type != T_EOF && t->symbol != ';')
-		skip_token(1);
-}
-
-static mnemonic_t *search_mnem(char *name)
-/* Binary search for a mnemonic.  (That's why the table is sorted.) */
-{
-	int low, mid, high;
-	int cmp;
-	mnemonic_t *m;
-
-	low= 0;
-	high= arraysize(mnemtab)-1;
-	while (low <= high) {
-		mid= (low + high) / 2;
-		m= &mnemtab[mid];
-
-		if ((cmp= strcmp(name, m->name)) == 0) return m;
-
-		if (cmp < 0) high= mid-1; else low= mid+1;
-	}
-	return nil;
-}
-
-static expression_t *gnu_get_C_expression(int *pn)
-/* Read a "C-like" expression.  Note that we don't worry about precedence,
- * the expression is printed later like it is read.  If the target language
- * does not have all the operators (like ~) then this has to be repaired by
- * changing the source file.  (No problem, you still have one source file
- * to maintain, not two.)
- */
-{
-	expression_t *e, *a1, *a2;
-	token_t *t;
-
-	if ((t= get_token(*pn))->symbol == '(') {
-		/* ( expr ): grouping. */
-		(*pn)++;
-		if ((a1= gnu_get_C_expression(pn)) == nil) return nil;
-		if (get_token(*pn)->symbol != ')') {
-			parse_err(1, t, "missing )\n");
-			del_expr(a1);
-			return nil;
-		}
-		(*pn)++;
-		e= new_expr();
-		e->operator= '[';
-		e->middle= a1;
-	} else
-	if (t->type == T_WORD || t->type == T_STRING) {
-		/* Label, number, or string. */
-		e= new_expr();
-		e->operator= t->type == T_WORD ? 'W' : 'S';
-		e->name= allocate(nil, (t->len+1) * sizeof(e->name[0]));
-		memcpy(e->name, t->name , t->len+1);
-		e->len= t->len;
-		(*pn)++;
-	} else
-	if (t->symbol == '+' || t->symbol == '-' || t->symbol == '~') {
-		/* Unary operator. */
-		(*pn)++;
-		if ((a1= gnu_get_C_expression(pn)) == nil) return nil;
-		e= new_expr();
-		e->operator= t->symbol;
-		e->middle= a1;
-	} else {
-		parse_err(1, t, "expression syntax error\n");
-		return nil;
-	}
-
-	switch ((t= get_token(*pn))->symbol) {
-	case '%': 
-	case '+':
-	case '-':
-	case '*':
-	case '/':
-	case '&':
-	case '|':
-	case '^':
-	case S_LEFTSHIFT:
-	case S_RIGHTSHIFT:
-		(*pn)++;
-		a1= e;
-		if ((a2= gnu_get_C_expression(pn)) == nil) {
-			del_expr(a1);
-			return nil;
-		}
-		e= new_expr();
-		e->operator= t->symbol;
-		e->left= a1;
-		e->right= a2;
-	}
-	return e;
-}
-
-static expression_t *gnu_get_operand(int *pn, int deref)
-/* Get something like: $immed, memory, offset(%base,%index,scale), or simpler. */
-{
-	expression_t *e, *offset, *base, *index;
-	token_t *t;
-	int c;
-
-	if (get_token(*pn)->symbol == '$') {
-		/* An immediate value. */
-		(*pn)++;
-		return gnu_get_C_expression(pn);
-	}
-
-	if (get_token(*pn)->symbol == '*') {
-		/* Indirection. */
-		(*pn)++;
-		if ((offset= gnu_get_operand(pn, deref)) == nil) return nil;
-		e= new_expr();
-		e->operator= '(';
-		e->middle= offset;
-		return e;
-	}
-
-	if ((get_token(*pn)->symbol == '%')
-		&& (t= get_token(*pn + 1))->type == T_WORD
-		&& isregister(t->name)
-	) {
-		/* A register operand. */
-		(*pn)+= 2;
-		e= new_expr();
-		e->operator= 'W';
-		e->name= copystr(t->name);
-		return e;
-	}
-
-	/* Offset? */
-	if (get_token(*pn)->symbol != '('
-				|| get_token(*pn + 1)->symbol != '%') {
-		/* There is an offset. */
-		if ((offset= gnu_get_C_expression(pn)) == nil) return nil;
-	} else {
-		/* No offset. */
-		offset= nil;
-	}
-
-	/* (%base,%index,scale) ? */
-	base= index= nil;
-	if (get_token(*pn)->symbol == '(') {
-		(*pn)++;
-
-		/* %base ? */
-		if (get_token(*pn)->symbol == '%'
-			&& (t= get_token(*pn + 1))->type == T_WORD
-			&& isregister(t->name)
-		) {
-			/* A base register expression. */
-			base= new_expr();
-			base->operator= 'B';
-			base->name= copystr(t->name);
-			(*pn)+= 2;
-		}
-
-		if (get_token(*pn)->symbol == ',') (*pn)++;
-
-		/* %index ? */
-		if (get_token(*pn)->symbol == '%'
-			&& (t= get_token(*pn + 1))->type == T_WORD
-			&& isregister(t->name)
-		) {
-			/* A index register expression. */
-			index= new_expr();
-			index->operator= '1';		/* for now */
-			index->name= copystr(t->name);
-			(*pn)+= 2;
-		}
-
-		if (get_token(*pn)->symbol == ',') (*pn)++;
-
-		/* scale ? */
-		if ((base != nil || index != nil)
-			&& (t= get_token(*pn))->type == T_WORD
-			&& strchr("1248", t->name[0]) != nil
-			&& t->name[1] == 0
-		) {		
-			if (index == nil) {
-				/* Base is really an index register. */
-				index= base;
-				base= nil;
-			}
-			index->operator= t->name[0];
-			(*pn)++;
-		}
-
-		if (get_token(*pn)->symbol == ')') {
-			/* Ending paren. */
-			(*pn)++;
-		} else {
-			/* Alas. */
-			parse_err(1, t, "operand syntax error\n");
-			del_expr(offset);
-			del_expr(base);
-			del_expr(index);
-			return nil;
-		}
-	}
-
-	if (base == nil && index == nil) {
-		if (deref) {
-			/* Return a lone offset as (offset). */
-			e= new_expr();
-			e->operator= '(';
-			e->middle= offset;
-		} else {
-			/* Return a lone offset as is. */
-			e= offset;
-		}
-	} else {
-		e= new_expr();
-		e->operator= 'O';
-		e->left= offset;
-
-		e->middle= base;
-		e->right= index;
-	}
-	return e;
-}
-
-static expression_t *gnu_get_oplist(int *pn, int deref)
-/* Get a comma (or colon for jmpf and callf) separated list of instruction
- * operands.
- */
-{
-	expression_t *e, *o1, *o2;
-	token_t *t;
-
-	if ((e= gnu_get_operand(pn, deref)) == nil) return nil;
-
-	if ((t= get_token(*pn))->symbol == ',' || t->symbol == ':') {
-		o1= e;
-		(*pn)++;
-		if ((o2= gnu_get_oplist(pn, deref)) == nil) {
-			del_expr(o1);
-			return nil;
-		}
-		e= new_expr();
-		e->operator= ',';
-		e->left= o1;
-		e->right= o2;
-	}
-	return e;
-}
-
-
-static asm86_t *gnu_get_statement(void)
-/* Get a pseudo op or machine instruction with arguments. */
-{
-	token_t *t= get_token(0);
-	asm86_t *a;
-	mnemonic_t *m;
-	int n;
-	int prefix_seen;
-	int deref;
-
-	assert(t->type == T_WORD);
-
-	a= new_asm86();
-
-	/* Process instruction prefixes. */
-	for (prefix_seen= 0;; prefix_seen= 1) {
-		if (strcmp(t->name, "rep") == 0
-			|| strcmp(t->name, "repe") == 0
-			|| strcmp(t->name, "repne") == 0
-			|| strcmp(t->name, "repz") == 0
-			|| strcmp(t->name, "repnz") == 0
-		) {
-			if (a->rep != ONCE) {
-				parse_err(1, t,
-					"can't have more than one rep\n");
-			}
-			switch (t->name[3]) {
-			case 0:		a->rep= REP;	break;
-			case 'e':
-			case 'z':	a->rep= REPE;	break;
-			case 'n':	a->rep= REPNE;	break;
-			}
-		} else
-		if (!prefix_seen) {
-			/* No prefix here, get out! */
-			break;
-		} else {
-			/* No more prefixes, next must be an instruction. */
-			if (t->type != T_WORD
-				|| (m= search_mnem(t->name)) == nil
-				|| m->optype == PSEUDO
-			) {
-				parse_err(1, t,
-		"machine instruction expected after instruction prefix\n");
-				del_asm86(a);
-				return nil;
-			}
-			break;
-		}
-
-		/* Skip the prefix and extra newlines. */
-		do {
-			skip_token(1);
-		} while ((t= get_token(0))->symbol == ';');
-	}
-
-	/* All the readahead being done upsets the line counter. */
-	a->line= t->line;
-
-	/* Read a machine instruction or pseudo op. */
-	if ((m= search_mnem(t->name)) == nil) {
-		parse_err(1, t, "unknown instruction '%s'\n", t->name);
-		del_asm86(a);
-		return nil;
-	}
-	a->opcode= m->opcode;
-	a->optype= m->optype;
-	a->oaz= 0;
-	if (a->optype == OWORD) {
-		a->oaz|= OPZ;
-		a->optype= WORD;
-	}
-
-	switch (a->opcode) {
-	case IN:
-	case OUT:
-	case INT:
-		deref= 0;
-		break;
-	default:
-		deref= (a->optype >= BYTE);
-	}
-	n= 1;
-	if (get_token(1)->symbol != ';'
-			&& (a->args= gnu_get_oplist(&n, deref)) == nil) {
-		del_asm86(a);
-		return nil;
-	}
-	if (get_token(n)->symbol != ';') {
-		parse_err(1, t, "garbage at end of instruction\n");
-		del_asm86(a);
-		return nil;
-	}
-	if (!is_pseudo(a->opcode)) {
-		/* GNU operand order is the other way around. */
-		expression_t *e, *t;
-
-		e= a->args;
-		while (e != nil && e->operator == ',') {
-			t= e->right; e->right= e->left; e->left= t;
-			e= e->left;
-		}
-	}
-	switch (a->opcode) {
-	case DOT_ALIGN:
-		/* Delete two argument .align, because ACK can't do it.
-		 * Raise 2 to the power of .align's argument.
-		 */
-		if (a->args == nil || a->args->operator != 'W') {	
-			del_asm86(a);
-			return nil;
-		}
-		if (a->args != nil && a->args->operator == 'W'
-			&& isanumber(a->args->name)
-		) {	
-			unsigned n;
-			char num[sizeof(int) * CHAR_BIT / 3 + 1];
-
-			n= 1 << strtoul(a->args->name, nil, 0);
-			sprintf(num, "%u", n);
-			deallocate(a->args->name);
-			a->args->name= copystr(num);
-		}
-		break;
-	case JMPF:
-	case CALLF:
-		/*FALL THROUGH*/
-	case JMP:
-	case CALL:
-		break;
-	default:;
-	}
-	skip_token(n+1);
-	return a;
-}
-
-
-asm86_t *gnu_get_instruction(void)
-{
-	asm86_t *a= nil;
-	expression_t *e;
-	token_t *t;
-
-	while ((t= get_token(0))->symbol == ';' || t->symbol == '/') {
-		zap();		/* if a comment started by a '/' */
-		skip_token(1);
-	}
-
-	if (t->type == T_EOF) return nil;
-
-	if (t->symbol == '#') {
-		/* Preprocessor line and file change. */
-
-		if ((t= get_token(1))->type != T_WORD || !isanumber(t->name)
-			|| get_token(2)->type != T_STRING
-		) {
-			parse_err(1, t, "file not preprocessed?\n");
-			zap();
-		} else {
-			set_file(get_token(2)->name,
-				strtol(get_token(1)->name, nil, 0) - 1);
-
-			/* GNU CPP adds extra cruft, simply zap the line. */
-			zap();
-		}
-		a= gnu_get_instruction();
-	} else
-	if (t->type == T_WORD && get_token(1)->symbol == ':') {
-		/* A label definition. */
-
-		a= new_asm86();
-		a->line= t->line;
-		a->opcode= DOT_LABEL;
-		a->optype= PSEUDO;
-		a->args= e= new_expr();
-		e->operator= ':';
-		e->name= copystr(t->name);
-		skip_token(2);
-	} else
-	if (t->type == T_WORD && get_token(1)->symbol == '=') {
-		int n= 2;
-
-		if ((e= gnu_get_C_expression(&n)) == nil) {
-			zap();
-			a= gnu_get_instruction();
-		} else
-		if (get_token(n)->symbol != ';') {
-			parse_err(1, t, "garbage after assignment\n");
-			zap();
-			a= gnu_get_instruction();
-		} else {
-			a= new_asm86();
-			a->line= t->line;
-			a->opcode= DOT_EQU;
-			a->optype= PSEUDO;
-			a->args= new_expr();
-			a->args->operator= '=';
-			a->args->name= copystr(t->name);
-			a->args->middle= e;
-			skip_token(n+1);
-		}
-	} else
-	if (t->type == T_WORD) {
-		if ((a= gnu_get_statement()) == nil) {
-			zap();
-			a= gnu_get_instruction();
-		}
-	} else {
-		parse_err(1, t, "syntax error\n");
-		zap();
-		a= gnu_get_instruction();
-	}
-	return a;
-}
Index: trunk/minix/commands/i386/asmconv/syntax.ack
===================================================================
--- trunk/minix/commands/i386/asmconv/syntax.ack	(revision 9)
+++ 	(revision )
@@ -1,107 +1,0 @@
-asmprog:
-	comment ?
-	statement
-	asmprog ; asmprog
-	asmprog comment ? \n asmprog
-
-letter:
-	[._a-zA-Z]
-
-digit:
-	[0-9]
-
-identifier:
-	letter (letter | digit)*
-	digit [bf]
-
-string:
-	'C-like string sequence'
-	"C-like string sequence"
-
-number:
-	C-like number
-
-comment:
-	! .*
-
-statement:
-	label-definition statement
-	empty
-	assignment
-	instruction
-	pseudo-instruction
-
-label-definition:
-	identifier :
-	digit :
-
-assignment:
-	identifier = expression
-
-instruction:
-	iX86-instruction
-
-pseudo-instruction:
-	.extern identifier (, identifier)*
-	.define identifier (, identifier)*
-	.data1 expression (, expression)*
-	.data2 expression (, expression)*
-	.data4 expression (, expression)*
-	.ascii string
-	.asciz string
-	.align expression
-	.space expression
-	.comm identifier , expression
-	.sect identifier
-	.base expression
-	.assert expression
-	.symb XXX
-	.line XXX
-	.file XXX
-	.nolist
-	.list
-	iX86-pseudo
-
-expression:
-	C-like expression with [ and ] for grouping
-
-iX86-instruction:
-	prefix
-	prefix iX86-instruction
-	identifier
-	identifier iX86operand
-	identifier iX86operand , iX86operand
-	identifier iX86operand : iX86operand
-
-prefix:
-	o16
-	o32
-	a16
-	a32
-	rep
-	repz
-	repnz
-	repe
-	repne
-	cseg | dseg | eseg | fseg | gseg | sseg
-
-iX86operand:
-	register
-	( register )
-	expression
-	( expression )
-	expression ( register )
-	expression ( register * [1248] )
-	expression ? ( register ) ( register )
-	expression ? ( register ) ( register * [1248] )
-
-register:
-	al | bl | cl | dl | ah | bh | ch | dh
-	ax | bx | cx | dx | si | di | bp | sp
-	eax | ebx | ecx | edx | esi | edi | ebp | esp
-	cs | ds | es | fs | gs | ss
-	cr0 | cr1 | cr2 | cr3
-
-iX86-pseudo:
-	.use16
-	.use32
Index: trunk/minix/commands/i386/asmconv/token.h
===================================================================
--- trunk/minix/commands/i386/asmconv/token.h	(revision 9)
+++ 	(revision )
@@ -1,29 +1,0 @@
-/*	token.h - token definition			Author: Kees J. Bot
- *								13 Dec 1993
- */
-
-typedef enum toktype {
-	T_EOF,
-	T_CHAR,
-	T_WORD,
-	T_STRING
-} toktype_t;
-
-typedef struct token {
-	struct token	*next;
-	long		line;
-	toktype_t	type;
-	int		symbol;		/* Single character symbol. */
-	char		*name;		/* Word, number, etc. */
-	size_t		len;		/* Length of string. */
-} token_t;
-
-#define S_LEFTSHIFT	0x100		/* << */
-#define S_RIGHTSHIFT	0x101		/* >> */
-
-void set_file(char *file, long line);
-void get_file(char **file, long *line);
-void parse_err(int err, token_t *where, const char *fmt, ...);
-void tok_init(char *file, int comment);
-token_t *get_token(int n);
-void skip_token(int n);
Index: trunk/minix/commands/i386/asmconv/tokenize.c
===================================================================
--- trunk/minix/commands/i386/asmconv/tokenize.c	(revision 9)
+++ 	(revision )
@@ -1,306 +1,0 @@
-/*	tokenize.c - split input into tokens		Author: Kees J. Bot
- *								13 Dec 1993
- */
-#define nil 0
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include "asmconv.h"
-#include "token.h"
-
-static FILE *tf;
-static char *tfile;
-static char *orig_tfile;
-static int tcomment;
-static int tc;
-static long tline;
-static token_t *tq;
-
-static void readtc(void)
-/* Read one character from the input file and put it in the global 'tc'. */
-{
-	static int nl= 0;
-
-	if (nl) tline++;
-	if ((tc= getc(tf)) == EOF && ferror(tf)) fatal(orig_tfile);
-	nl= (tc == '\n');
-}
-
-void set_file(char *file, long line)
-/* Set file name and line number, changed by a preprocessor trick. */
-{
-	deallocate(tfile);
-	tfile= allocate(nil, (strlen(file) + 1) * sizeof(tfile[0]));
-	strcpy(tfile, file);
-	tline= line;
-}
-
-void get_file(char **file, long *line)
-/* Get file name and line number. */
-{
-	*file= tfile;
-	*line= tline;
-}
-
-void parse_err(int err, token_t *t, const char *fmt, ...)
-/* Report a parsing error. */
-{
-	va_list ap;
-
-	fprintf(stderr, "\"%s\", line %ld: ", tfile,
-						t == nil ? tline : t->line);
-	va_start(ap, fmt);
-	vfprintf(stderr, fmt, ap);
-	va_end(ap);
-	if (err) set_error();
-}
-
-void tok_init(char *file, int comment)
-/* Open the file to tokenize and initialize the tokenizer. */
-{
-	if (file == nil) {
-		file= "stdin";
-		tf= stdin;
-	} else {
-		if ((tf= fopen(file, "r")) == nil) fatal(file);
-	}
-	orig_tfile= file;
-	set_file(file, 1);
-	readtc();
-	tcomment= comment;
-}
-
-static int isspace(int c)
-{
-	return between('\0', c, ' ') && c != '\n';
-}
-
-#define iscomment(c)	((c) == tcomment)
-
-static int isidentchar(int c)
-{
-	return between('a', c, 'z')
-		|| between('A', c, 'Z')
-		|| between('0', c, '9')
-		|| c == '.'
-		|| c == '_'
-		;
-}
-
-static token_t *new_token(void)
-{
-	token_t *new;
-
-	new= allocate(nil, sizeof(*new));
-	new->next= nil;
-	new->line= tline;
-	new->name= nil;
-	new->symbol= -1;
-	return new;
-}
-
-static token_t *get_word(void)
-/* Read one word, an identifier, a number, a label, or a mnemonic. */
-{
-	token_t *w;
-	char *name;
-	size_t i, len;
-
-	i= 0;
-	len= 16;
-	name= allocate(nil, len * sizeof(name[0]));
-
-	while (isidentchar(tc)) {
-		name[i++]= tc;
-		readtc();
-		if (i == len) name= allocate(name, (len*= 2) * sizeof(name[0]));
-	}
-	name[i]= 0;
-	name= allocate(name, (i+1) * sizeof(name[0]));
-	w= new_token();
-	w->type= T_WORD;
-	w->name= name;
-	w->len= i;
-	return w;
-}
-
-static token_t *get_string(void)
-/* Read a single or double quotes delimited string. */
-{
-	token_t *s;
-	int quote;
-	char *str;
-	size_t i, len;
-	int n, j;
-	int seen;
-
-	quote= tc;
-	readtc();
-
-	i= 0;
-	len= 16;
-	str= allocate(nil, len * sizeof(str[0]));
-
-	while (tc != quote && tc != '\n' && tc != EOF) {
-		seen= -1;
-		if (tc == '\\') {
-			readtc();
-			if (tc == '\n' || tc == EOF) break;
-
-			switch (tc) {
-			case 'a':	tc= '\a'; break;
-			case 'b':	tc= '\b'; break;
-			case 'f':	tc= '\f'; break;
-			case 'n':	tc= '\n'; break;
-			case 'r':	tc= '\r'; break;
-			case 't':	tc= '\t'; break;
-			case 'v':	tc= '\v'; break;
-			case 'x':
-				n= 0;
-				for (j= 0; j < 3; j++) {
-					readtc();
-					if (between('0', tc, '9'))
-						tc-= '0' + 0x0;
-					else
-					if (between('A', tc, 'A'))
-						tc-= 'A' + 0xA;
-					else
-					if (between('a', tc, 'a'))
-						tc-= 'a' + 0xa;
-					else {
-						seen= tc;
-						break;
-					}
-					n= n*0x10 + tc;
-				}
-				tc= n;
-				break;
-			default:
-				if (!between('0', tc, '9')) break;
-				n= 0;
-				for (j= 0; j < 3; j++) {
-					if (between('0', tc, '9'))
-						tc-= '0';
-					else {
-						seen= tc;
-						break;
-					}
-					n= n*010 + tc;
-					readtc();
-				}
-				tc= n;
-			}
-		}
-		str[i++]= tc;
-		if (i == len) str= allocate(str, (len*= 2) * sizeof(str[0]));
-
-		if (seen < 0) readtc(); else tc= seen;
-	}
-
-	if (tc == quote) {
-		readtc();
-	} else {
-		parse_err(1, nil, "string contains newline\n");
-	}
-	str[i]= 0;
-	str= allocate(str, (i+1) * sizeof(str[0]));
-	s= new_token();
-	s->type= T_STRING;
-	s->name= str;
-	s->len= i;
-	return s;
-}
-
-static int old_n= 0;		/* To speed up n, n+1, n+2, ... accesses. */
-static token_t **old_ptq= &tq;
-
-token_t *get_token(int n)
-/* Return the n-th token on the input queue. */
-{
-	token_t *t, **ptq;
-
-	assert(n >= 0);
-
-	if (0 && n >= old_n) {
-		/* Go forward from the previous point. */
-		n-= old_n;
-		old_n+= n;
-		ptq= old_ptq;
-	} else {
-		/* Restart from the head of the queue. */
-		old_n= n;
-		ptq= &tq;
-	}
-
-	for (;;) {
-		if ((t= *ptq) == nil) {
-			/* Token queue doesn't have element <n>, read a
-			 * new token from the input stream.
-			 */
-			while (isspace(tc) || iscomment(tc)) {
-				if (iscomment(tc)) {
-					while (tc != '\n' && tc != EOF)
-						readtc();
-				} else {
-					readtc();
-				}
-			}
-
-			if (tc == EOF) {
-				t= new_token();
-				t->type= T_EOF;
-			} else
-			if (isidentchar(tc)) {
-				t= get_word();
-			} else
-			if (tc == '\'' || tc == '"') {
-				t= get_string();
-			} else {
-				if (tc == '\n') tc= ';';
-				t= new_token();
-				t->type= T_CHAR;
-				t->symbol= tc;
-				readtc();
-				if (t->symbol == '<' && tc == '<') {
-					t->symbol= S_LEFTSHIFT;
-					readtc();
-				} else
-				if (t->symbol == '>' && tc == '>') {
-					t->symbol= S_RIGHTSHIFT;
-					readtc();
-				}
-			}
-			*ptq= t;
-		}
-		if (n == 0) break;
-		n--;
-		ptq= &t->next;
-	}
-	old_ptq= ptq;
-	return t;
-}
-
-void skip_token(int n)
-/* Remove n tokens from the input queue.  One is not allowed to skip unread
- * tokens.
- */
-{
-	token_t *junk;
-
-	assert(n >= 0);
-
-	while (n > 0) {
-		assert(tq != nil);
-
-		junk= tq;
-		tq= tq->next;
-		deallocate(junk->name);
-		deallocate(junk);
-		n--;
-	}
-	/* Reset the old reference. */
-	old_n= 0;
-	old_ptq= &tq;
-}
Index: trunk/minix/commands/i386/build
===================================================================
--- trunk/minix/commands/i386/build	(revision 9)
+++ 	(revision )
@@ -1,3 +1,0 @@
-#!/bin/sh
-make clean
-make && make install
Index: trunk/minix/commands/i386/mtools-3.9.7/COPYING
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/COPYING	(revision 9)
+++ 	(revision )
@@ -1,351 +1,0 @@
-Copyright (C) 1995 Alain Knaff.
- You may use, distribute and copy this program according to the terms of the
-GNU General Public License version 2 or later.
-
- Alain Knaff
-----------------------------------------
-
-		    GNU GENERAL PUBLIC LICENSE
-		       Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
-                          675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-			    Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users.  This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it.  (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.)  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
-  To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have.  You must make sure that they, too, receive or can get the
-source code.  And you must show them these terms so they know their
-rights.
-
-  We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
-  Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software.  If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
-  Finally, any free program is threatened constantly by software
-patents.  We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary.  To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-
-
-		    GNU GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License.  The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language.  (Hereinafter, translation is included without limitation in
-the term "modification".)  Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
-  1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
-  2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) You must cause the modified files to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    b) You must cause any work that you distribute or publish, that in
-    whole or in part contains or is derived from the Program or any
-    part thereof, to be licensed as a whole at no charge to all third
-    parties under the terms of this License.
-
-    c) If the modified program normally reads commands interactively
-    when run, you must cause it, when started running for such
-    interactive use in the most ordinary way, to print or display an
-    announcement including an appropriate copyright notice and a
-    notice that there is no warranty (or else, saying that you provide
-    a warranty) and that users may redistribute the program under
-    these conditions, and telling the user how to view a copy of this
-    License.  (Exception: if the Program itself is interactive but
-    does not normally print such an announcement, your work based on
-    the Program is not required to print an announcement.)
-
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
-    a) Accompany it with the complete corresponding machine-readable
-    source code, which must be distributed under the terms of Sections
-    1 and 2 above on a medium customarily used for software interchange; or,
-
-    b) Accompany it with a written offer, valid for at least three
-    years, to give any third party, for a charge no more than your
-    cost of physically performing source distribution, a complete
-    machine-readable copy of the corresponding source code, to be
-    distributed under the terms of Sections 1 and 2 above on a medium
-    customarily used for software interchange; or,
-
-    c) Accompany it with the information you received as to the offer
-    to distribute corresponding source code.  (This alternative is
-    allowed only for noncommercial distribution and only if you
-    received the program in object code or executable form with such
-    an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it.  For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable.  However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-
-  4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License.  Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
-  5. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Program or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
-  6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
-  7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-
-  8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation.  If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
-  10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission.  For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this.  Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
-			    NO WARRANTY
-
-  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
-  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
-		     END OF TERMS AND CONDITIONS
-
-
-	Appendix: How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) 19yy  <name of author>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
-    Gnomovision version 69, Copyright (C) 19yy name of author
-    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
-  `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
-  <signature of Ty Coon>, 1 April 1989
-  Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs.  If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library.  If this is what you want to do, use the GNU Library General
-Public License instead of this License.
Index: trunk/minix/commands/i386/mtools-3.9.7/Makefile
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/Makefile	(revision 9)
+++ 	(revision )
@@ -1,399 +1,0 @@
-# Generated automatically from Makefile.in by configure.
-#
-#       Makefile for Mtools
-#
-# check the Configure file for some examples of device-specific setups
-# Berkeley flavors of Unix should include -DBSD in the CFLAGS.  Pick
-# a lock method... either -DLOCKF, -DFLOCK, or -DFCNTL and put that
-# string in the CFLAGS line below.
-
-# User specified flags
-USERCFLAGS = 
-USERLDFLAGS = -stack 11m
-USERLDLIBS =
-
-MAKEINFO = makeinfo
-TEXI2DVI = texi2dvi
-TEXI2HTML = texi2html
-
-
-# do not edit below this line
-# =============================================================================
-
-SHELL = /bin/sh
-
-top_srcdir=.
-srcdir=.
-
-prefix      = /usr
-exec_prefix = ${prefix}
-bindir      = ${exec_prefix}/bin
-infodir     = ${prefix}/info
-mandir      = ${prefix}/man
-infodir     = ${prefix}/info
-sysconfdir  = /etc
-
-CC         = exec cc -D_MINIX
-CXX        = @CXX@
-MYCFLAGS   = 
-MYCXXFLAGS = 
-CPPFLAGS   = 
-HOST_ID    = -DCPU_i386 -DVENDOR_pc -DOS_Minix 
-DEFS       = -DHAVE_CONFIG_H -DNO_CONFIG $(HOST_ID)
-
-LDFLAGS     = 
-LIBS        = 
-SHLIB       = 
-MACHDEPLIBS = 	
-LN_S        = ln -s
-
-INSTALL         = /usr/bin/install -cs
-INSTALL_PROGRAM = ${INSTALL}
-INSTALL_DATA    = ${INSTALL} -m 644
-INSTALL_INFO	= 
-
-.SUFFIXES:
-.SUFFIXES: .o .c
-.SUFFIXES: .o .c
-
-MAN1 = floppyd.1 mattrib.1 mbadblocks.1 mcat.1 mcd.1 mcopy.1 mdel.1 mdeltree.1 mdir.1 \
-mdu.1 mformat.1 mkmanifest.1 mlabel.1 mmd.1 mmount.1 mmove.1 mpartition.1 \
-mrd.1 mread.1 mren.1 mshowfat.1 mtoolstest.1 mtools.1 mtype.1 mzip.1
-MAN1EXT	= 1
-MAN1DIR	= $(mandir)/man${MAN1EXT}
-MAN5	= mtools.5
-MAN5EXT	= 5
-MAN5DIR	= $(mandir)/man${MAN5EXT}
-
-# all files in this directory included in the distribution 
-DIST = \
-COPYING Changelog INSTALL Makefile Makefile.in README Release.notes \
-buffer.c buffer.h codepage.c codepage.h codepages.c config.c \
-config.guess config.h.in config.log config.sub configure configure.in \
-copyfile.c devices.c devices.h dirCache.c dirCache.h directory.c direntry.c \
-expand.c fat.c \
-fat_free.c file.c file.h file_name.c file_read.c files filter.c floppyd.1 \
-floppyd.c floppyd_io.c floppyd_io.h force_io.c fs.h fsP.h \
-getopt.h hash.c htable.h init.c llong.c mainloop.c match.c mattrib.1 \
-mattrib.c mbadblocks.1 mbadblocks.c mcat.1 mcat.c mcd.1 mcd.c mcopy.1 \
-mcopy.c mdel.1 mdel.c mdeltree.1 mdir.1 mdir.c mdu.c mdu.1 mformat.1 \
-mformat.c minfo.c \
-misc.c tty.c scsi.c missFuncs.c mk_direntry.c mkmanifest.1 mkmanifest.c \
-mlabel.1 mlabel.c mmd.1 mmd.c mmount.1 mmount.c mmove.1 mmove.c \
-mpartition.1 mpartition.c mrd.1 \
-mread.1 mren.1 msdos.h mshowfat.1 mtoolstest.1 mtools.1 mtools.5 mtools.c \
-mtools.conf mtools.h mtype.1 nameclash.h patchlevel.c \
-plain_io.c plain_io.h precmd.c privileges.c scripts signal.c stream.c stream.h \
-streamcache.c streamcache.h subdir.c sysincludes.h unixdir.c todo toupper.c \
-vfat.c vfat.h xdf_io.c xdf_io.h
-
-#OBJS1 = buffer.o codepage.o codepages.o config.o copyfile.o devices.o \
-#dirCache.o directory.o direntry.o expand.o fat.o fat_free.o file.o file_name.o \
-#file_read.o filter.o floppyd_io.o force_io.o hash.o init.o llong.o match.o \
-#mainloop.o mattrib.o mbadblocks.o mcat.o mcd.o mcopy.o mdel.o mdir.o \
-#mdoctorfat.o mdu.o \
-#mformat.o minfo.o misc.o missFuncs.o mk_direntry.o mlabel.o mmd.o mmount.o \
-#mmove.o mpartition.o mshowfat.o mzip.o mtools.o patchlevel.o plain_io.o \
-#precmd.o privileges.o scsi.o signal.o stream.o streamcache.o subdir.o \
-#unixdir.o toupper.o tty.o vfat.o xdf_io.o
-
-OBJS1 = buffer.o config.o copyfile.o devices.o \
-dirCache.o directory.o direntry.o expand.o fat.o fat_free.o file.o file_name.o \
-file_read.o filter.o floppyd_io.o force_io.o hash.o init.o llong.o match.o \
-mainloop.o mattrib.o mbadblocks.o mcat.o mcd.o mcopy.o mdel.o mdir.o \
-mdoctorfat.o mdu.o \
-mformat.o minfo.o misc.o missFuncs.o mk_direntry.o mlabel.o mmd.o mmount.o \
-mmove.o mpartition.o mshowfat.o mtools.o patchlevel.o plain_io.o \
-precmd.o privileges.o scsi.o signal.o stream.o streamcache.o subdir.o \
-unixdir.o toupper.o tty.o vfat.o xdf_io.o
-
-OBJS2 = missFuncs.o mkmanifest.o misc.o patchlevel.o
-
-SRCS3 = floppyd.c
-
-OBJS4 = floppyd_installtest.o misc.o expand.o privileges.o
-
-SRCS = buffer.c codepage.c codepages.c config.c copyfile.c devices.c \
-dirCache.c directory.c direntry.c expand.c fat.c fat_free.c file.c file_name.c \
-file_read.c filter.c floppyd_io.c force_io.c hash.c init.c match.c mainloop.c \
-mattrib.c mbadblocks.c mcat.c mcd.c mcopy.c mdel.c mdir.c mdu.c mdoctorfat.c \
-mformat.c minfo.c misc.c \
-missFuncs.c mk_direntry.c mlabel.c mmd.c mmount.c mmove.c mpartition.c \
-mshowfat.c mzip.c mtools.c plain_io.c precmd.c privileges.c scsi.o \
-signal.c stream.c streamcache.c subdir.c unixdir.c toupper.c tty.o vfat.c \
-xdf_io.c mkmanifest.c
-
-
-SCRIPTS = mcheck mxtar uz tgz mcomp
-
-LINKS=mattrib mcat mcd mcopy mdel mdeltree mdir mdu mformat minfo mlabel \
-mmd mmount mmove mpartition mrd mread mren mtype mtoolstest mshowfat \
-mbadblocks mzip
-
-X_CFLAGS = 
-X_LIBS = 
-X_EXTRA_LIBS = 
-X_PRE_LIBS = 
-CFLAGS = $(CPPFLAGS) $(DEFS) $(MYCFLAGS) -I.  -I. $(USERCFLAGS) 
-CXXFLAGS  = $(CPPFLAGS) $(DEFS) $(MYCXXFLAGS) -I.  -I. $(USERCFLAGS) 
-LINK      = $(CC) $(LDFLAGS) $(USERLDFLAGS) 
-ALLLIBS   = $(USERLDLIBS) $(MACHDEPLIBS) $(SHLIB) $(LIBS)
-X_LDFLAGS = $(X_EXTRA_LIBS) $(X_LIBS) $(X_PRE_LIBS) -lXau -lX11 $(LIBS) 
-X_CCFLAGS = $(X_CFLAGS) $(CFLAGS)
-
-all:    mtools
-
-%.o: %.c
-	$(CC) $(CFLAGS) -c $<
-
-#%.o: %.cpp
-#	$(CXX) $(CXXFLAGS) -c $<
-
-mtools: $(OBJS1)
-	$(LINK) $(OBJS1) -o $@ $(ALLLIBS)
-
-mkmanifest: $(OBJS2)
-	$(LINK) $(OBJS2) -o $@ $(ALLLIBS)
-
-floppyd.o: floppyd.c
-	$(CC) $(X_CCFLAGS) -c $<
-
-floppyd: floppyd.o
-	$(LINK) $< -o $@ $(X_LDFLAGS)
-floppyd_installtest: $(OBJS4)
-	$(LINK) $(OBJS4) -o $@ $(ALLLIBS)
-
-
-$(LINKS): mtools
-	rm -f $@ && $(LN_S) mtools $@
-
-mostlyclean:
-	-rm -f *~ *.orig *.o a.out core 2>/dev/null
-
-clean:	mostlyclean
-	-rm -f mtools $(LINKS) floppyd floppyd_installtest mkmanifest *.info* *.dvi *.html 2>/dev/null
-
-
-texclean:
-	-rm mtools.aux mtools.toc mtools.log
-	-rm mtools.cps mtools.pgs mtools.vrs
-	-rm mtools.cp mtools.fn mtools.ky
-	-rm mtools.pg mtools.tp mtools.vr
-
-info: mtools.info
-%.info: %.texi
-	$(MAKEINFO) -I$(srcdir) $< --no-split --output=$@
-
-dvi: mtools.dvi
-%.dvi: %.texi
-	$(TEXI2DVI) $<
-
-ps: mtools.ps
-%.ps: %.dvi
-	dvips -f < $< > $@
-
-pdf: mtools.pdf
-%.pdf: %.ps
-	ps2pdf $< $@
-
-
-html: mtools.html mtools_toc.html
-%.html %_toc.html: %.texi
-	$(TEXI2HTML) $<
-
-# Don't cd, to avoid breaking install-sh references.
-install-info: info
-	$(top_srcdir)/mkinstalldirs $(infodir)
-	if test -f mtools.info; then \
-	  for i in mtools.info*; do \
-	    $(INSTALL_DATA) $$i $(infodir)/$$i; \
-	  done; \
-	else \
-	  for i in $(srcdir)/mtools.info*; do \
-	    $(INSTALL_DATA) $$i $(infodir)/`echo $$i | sed 's|^$(srcdir)/||'`; \
-	  done; \
-	fi; \
-	if [ -n "$(INSTALL_INFO)" ] ; then \
-		if [ -f $(infodir)/dir.info ] ; then \
-			$(INSTALL_INFO) $(infodir)/mtools.info $(infodir)/dir.info; \
-		fi; \
-		if [ -f $(infodir)/dir ] ; then \
-			$(INSTALL_INFO) $(infodir)/mtools.info $(infodir)/dir; \
-		fi; \
-	fi
-
-uninstall-info:
-	cd $(infodir) && rm -f mtools.info*
-
-install:	$(bindir)/mtools
-
-# The manual pages are of such horrible quality that one is better off without
-# them.  (Frankly this whole package is horrible.)  Using -? hopefully gives
-# enough clues for use.  -- kjb
-dontinstall:
-		$(MAN1DIR)/mattrib.1 $(MAN1DIR)/mbadblocks.1 \
-		$(MAN1DIR)/mcd.1 $(MAN1DIR)/mcopy.1 $(MAN1DIR)/mdel.1 \
-		$(MAN1DIR)/mdeltree.1 $(MAN1DIR)/mdir.1 $(MAN1DIR)/mdu.1 \
-		$(MAN1DIR)/mformat.1 $(MAN1DIR)/mlabel.1 \
-		$(MAN1DIR)/mmd.1 $(MAN1DIR)/mmove.1 $(MAN1DIR)/mrd.1 \
-		$(MAN1DIR)/mread.1 $(MAN1DIR)/mren.1 \
-		$(MAN1DIR)/mshowfat.1 $(MAN1DIR)/mtools.1 \
-		$(MAN1DIR)/mtype.1 $(MAN1DIR)/mzip.1
-
-$(bindir)/mtools:	mtools
-	install -c $? $@
-
-$(MAN1DIR)/mattrib.1:	mattrib.1
-	install -lc $? $@
-
-$(MAN1DIR)/mbadblocks.1:	mbadblocks.1
-	install -lc $? $@
-
-$(MAN1DIR)/mcd.1:	mcd.1
-	install -lc $? $@
-
-$(MAN1DIR)/mcopy.1:	mcopy.1
-	install -lc $? $@
-
-$(MAN1DIR)/mdel.1:	mdel.1
-	install -lc $? $@
-
-$(MAN1DIR)/mdeltree.1:	mdeltree.1
-	install -lc $? $@
-
-$(MAN1DIR)/mdir.1:	mdir.1
-	install -lc $? $@
-
-$(MAN1DIR)/mdu.1:	mdu.1
-	install -lc $? $@
-
-$(MAN1DIR)/mformat.1:	mformat.1
-	install -lc $? $@
-
-$(MAN1DIR)/mlabel.1:	mlabel.1
-	install -lc $? $@
-
-$(MAN1DIR)/mmd.1:	mmd.1
-	install -lc $? $@
-
-$(MAN1DIR)/mmove.1:	mmove.1
-	install -lc $? $@
-
-$(MAN1DIR)/mrd.1:	mrd.1
-	install -lc $? $@
-
-$(MAN1DIR)/mread.1:	mread.1
-	install -lc $? $@
-
-$(MAN1DIR)/mren.1:	mren.1
-	install -lc $? $@
-
-$(MAN1DIR)/mshowfat.1:	mshowfat.1
-	install -lc $? $@
-
-$(MAN1DIR)/mtools.1:	mtools.1
-	install -lc $? $@
-
-$(MAN1DIR)/mtype.1:	mtype.1
-	install -lc $? $@
-
-$(MAN1DIR)/mzip.1:	mzip.1
-	install -lc $? $@
-
-#install:	$(bindir)/mtools  install-man install-links \
-#		$(bindir)/mkmanifest install-scripts install-info
-#
-#uninstall:	uninstall-bin uninstall-man uninstall-links \
-#		uninstall-scripts
-
-distclean: clean texclean
-	rm -f config.cache config.h config.status config.log Makefile
-maintainer-clean: distclean
-
-
-#$(bindir)/floppyd: floppyd
-#	$(top_srcdir)/mkinstalldirs $(bindir)
-#	$(INSTALL_PROGRAM) floppyd $(bindir)/floppyd
-#
-#$(bindir)/floppyd_installtest: floppyd_installtest
-#	$(top_srcdir)/mkinstalldirs $(bindir)
-#	$(INSTALL_PROGRAM) floppyd_installtest $(bindir)/floppyd_installtest
-#
-#$(bindir)/mtools: mtools
-#	$(top_srcdir)/mkinstalldirs $(bindir)
-#	$(INSTALL_PROGRAM) mtools $(bindir)/mtools
-#
-#$(bindir)/mkmanifest: mkmanifest
-#	$(top_srcdir)/mkinstalldirs $(bindir)
-#	$(INSTALL_PROGRAM) mkmanifest $(bindir)/mkmanifest
-
-#$(ETCDIR)/mtools: mtools.etc
-#	cp mtools.etc $(ETCDIR)/mtools
-
-install-links: $(bindir)/mtools
-	@for j in $(LINKS); do \
-		rm -f $(bindir)/$$j ; \
-		$(LN_S) mtools $(bindir)/$$j ; \
-		echo $(bindir)/$$j ; \
-	done
-
-## "z" is the older version of "gz"; the name is just *too* short
-install-scripts: $(bindir)/mtools
-	@$(top_srcdir)/mkinstalldirs $(bindir)
-	@for j in $(SCRIPTS) ; do \
-		$(INSTALL_PROGRAM) $(srcdir)/scripts/$$j $(bindir)/$$j ; \
-		echo $(bindir)/$$j ; \
-	done
-	rm -f $(bindir)/lz
-	$(LN_S) uz $(bindir)/lz
-
-install-man:
-	@$(top_srcdir)/mkinstalldirs $(MAN1DIR)
-	@for j in $(MAN1); do \
-		$(INSTALL_DATA) $(srcdir)/$$j $(MAN1DIR)/$$j ; \
-		echo $(MAN1DIR)/$$j ; \
-	done
-	@$(top_srcdir)/mkinstalldirs $(MAN5DIR)
-	@for j in $(MAN5); do \
-		$(INSTALL_DATA) $(srcdir)/$$j $(MAN5DIR)/$$j ; \
-		echo $(MAN5DIR)/$$j ; \
-	done
-
-uninstall-bin:
-	@for j in mtools mkmanifest; do \
-		rm -f $(bindir)/$$j ; \
-		echo $(bindir)/$$j ; \
-	done
-
-uninstall-scripts:
-	@for j in $(SCRIPTS); do \
-		rm -f $(bindir)/$$j ; \
-		echo $(bindir)/$$j ; \
-	done
-
-uninstall-man:
-	@for j in $(MAN1); do \
-		rm -f $(MAN1DIR)/$$j ; \
-		echo $(MAN1DIR)/$$j ; \
-	done
-	@for j in $(MAN5); do \
-		rm -f $(MAN5DIR)/$$j ; \
-		echo $(MAN5DIR)/$$j ; \
-	done
-
-uninstall-links:
-	@for j in $(LINKS); \
-		do rm -f $(bindir)/$$j ; \
-		echo $(bindir)/$$j ; \
-	done
-
-depend: $(SRCS)
-	makedepend -- $(CFLAGS) -- $^
-
-check:
-	echo No self tests included
-# check target needed even if empty, in order to make life easyer for
-# automatic tools to install GNU soft
-
-
-# DO NOT DELETE THIS LINE -- make depend depends on it.
Index: trunk/minix/commands/i386/mtools-3.9.7/README
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/README	(revision 9)
+++ 	(revision )
@@ -1,53 +1,0 @@
-Compilation
------------
-
- Type 'make install'.
-
- This package has been heavily modified for Minix, and then minimized to
-only those files needed for Minix.  Don't use this as a basis for anything
-else, get the original package instead.  -- kjb
-
-Doc
----
-
- The most uptodate doc of this package is the texinfo doc. Type 'make
-info' to get online info doc, and 'make dvi ; dvips mtools.dvi' to get
-a printed copy.  The info doc has a concept index.  Make use of it.
- You may get an info copy using the following command 'make info'.
-This can then be viewed using emacs' info mode, or using a standalone
-info viewer.
- Man pages are still present, but contain less information, and are
-less uptodate than the texinfo documentation.
- If you do not have the necessary tools to view the texinfo doc, you
-may also find it on the Workd Wide Web at the following locations:
-  http://mtools.linux.lu/mtools_toc.html
-  http://www.tux.org/pub/knaff/mtools/mtools_toc.html
-
-Compiler
---------
-
- Mtools should be compiled with an Ansi compiler, preferably gcc
-
-Authors
--------
-
-Original code (versions through 2.0.7?) by Emmet P. Gray (Texas, USA), who
-no longer appears to be reachable by Internet e-mail.  Viktor Dukhovni (at
-Princeton, USA) had major input into v2.0.
-
-Since 2.0.7: maintained primarily and until now informally by Alain
-Knaff (Luxembourg) and David Niemi (Reston, Virginia, USA).
-
-Please report bugs to the mtools mailing list at mtools@www.tux.org.
-Before reporting any problems, check whether they have already been
-fixed in the Alpha patches at http://mtools.linux.lu and
-http://www.tux.org/pub/knaff
-
-You may subscribe to the mtools mailing list by sending a message
-containing 'subscribe mtools' in its body to majordomo@www.tux.org
-
-
-Current Status
---------------
-
-Stable release 3.3.
Index: trunk/minix/commands/i386/mtools-3.9.7/buffer.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/buffer.c	(revision 9)
+++ 	(revision )
@@ -1,365 +1,0 @@
-/*
- * Buffer read/write module
- */
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "buffer.h"
-
-typedef struct Buffer_t {
-	Class_t *Class;
-	int refs;
-	Stream_t *Next;
-	Stream_t *Buffer;
-	
-	size_t size;     	/* size of read/write buffer */
-	int dirty;	       	/* is the buffer dirty? */
-
-	int sectorSize;		/* sector size: all operations happen
-				 * in multiples of this */
-	int cylinderSize;	/* cylinder size: preferred alignemnt,
-				 * but for efficiency, less data may be read */
-	int ever_dirty;	       	/* was the buffer ever dirty? */
-	int dirty_pos;
-	int dirty_end;
-	mt_off_t current;		/* first sector in buffer */
-	size_t cur_size;		/* the current size */
-	char *buf;		/* disk read/write buffer */
-} Buffer_t;
-
-/*
- * Flush a dirty buffer to disk.  Resets Buffer->dirty to zero.
- * All errors are fatal.
- */
-
-static int _buf_flush(Buffer_t *Buffer)
-{
-	int ret;
-
-	if (!Buffer->Next || !Buffer->dirty)
-		return 0;
-	if(Buffer->current < 0L) {
-		fprintf(stderr,"Should not happen\n");
-		return -1;
-	}
-#ifdef DEBUG
-	fprintf(stderr, "write %08x -- %02x %08x %08x\n",
-		Buffer,
-		(unsigned char) Buffer->buf[0],
-		Buffer->current + Buffer->dirty_pos,
-		Buffer->dirty_end - Buffer->dirty_pos);
-#endif
-
-	ret = force_write(Buffer->Next, 
-			  Buffer->buf + Buffer->dirty_pos,
-			  Buffer->current + Buffer->dirty_pos,
-			  Buffer->dirty_end - Buffer->dirty_pos);
-	if(ret != Buffer->dirty_end - Buffer->dirty_pos) {
-		if(ret < 0)
-			perror("buffer_flush: write");
-		else
-			fprintf(stderr,"buffer_flush: short write\n");
-		return -1;
-	}
-	Buffer->dirty = 0;
-	Buffer->dirty_end = 0;
-	Buffer->dirty_pos = 0;
-	return 0;
-}
-
-static int invalidate_buffer(Buffer_t *Buffer, mt_off_t start)
-{
-	/*fprintf(stderr, "invalidate %x\n", Buffer);*/
-	if(Buffer->sectorSize == 32) {
-		fprintf(stderr, "refreshing directory\n");
-	}
-
-	if(_buf_flush(Buffer) < 0)
-		return -1;
-
-	/* start reading at the beginning of start's sector
-	 * don't start reading too early, or we might not even reach
-	 * start */
-	Buffer->current = ROUND_DOWN(start, Buffer->sectorSize);
-	Buffer->cur_size = 0;
-	return 0;
-}
-
-#undef OFFSET
-#define OFFSET (start - This->current)
-
-typedef enum position_t {
-	OUTSIDE,
-	APPEND,
-	INSIDE,
-	ERROR 
-} position_t;
-
-static position_t isInBuffer(Buffer_t *This, mt_off_t start, size_t *len)
-{
-	if(start >= This->current &&
-	   start < This->current + This->cur_size) {
-		maximize(*len, This->cur_size - OFFSET);
-		return INSIDE;
-	} else if(start == This->current + This->cur_size &&
-		  This->cur_size < This->size &&
-		  *len >= This->sectorSize) {
-		/* append to the buffer for this, three conditions have to
-		 * be met:
-		 *  1. The start falls exactly at the end of the currently
-		 *     loaded data
-		 *  2. There is still space
-		 *  3. We append at least one sector
-		 */
-		maximize(*len, This->size - This->cur_size);
-		*len = ROUND_DOWN(*len, This->sectorSize);
-		return APPEND;
-	} else {
-		if(invalidate_buffer(This, start) < 0)
-			return ERROR;
-		maximize(*len, This->cylinderSize - OFFSET);
-		maximize(*len, This->cylinderSize - This->current % This->cylinderSize);
-		return OUTSIDE;
-	}
-}
-
-static int buf_read(Stream_t *Stream, char *buf, mt_off_t start, size_t len)
-{
-	size_t length;
-	int offset;
-	char *disk_ptr;
-	int ret;
-	DeclareThis(Buffer_t);	
-
-	if(!len)
-		return 0;	
-
-	/*fprintf(stderr, "buf read %x   %x %x\n", Stream, start, len);*/
-	switch(isInBuffer(This, start, &len)) {
-		case OUTSIDE:
-		case APPEND:
-			/* always load until the end of the cylinder */
-			length = This->cylinderSize -
-				(This->current + This->cur_size) % This->cylinderSize;
-			maximize(length, This->size - This->cur_size);
-
-			/* read it! */
-			ret=READS(This->Next,
-				  This->buf + This->cur_size,
-				  This->current + This->cur_size,
-				  length);
-			if ( ret < 0 )
-				return ret;
-			This->cur_size += ret;
-			if (This->current+This->cur_size < start) {
-				fprintf(stderr, "Short buffer fill\n");
-				exit(1);
-			}														  
-			break;
-		case INSIDE:
-			/* nothing to do */
-			break;
-		case ERROR:
-			return -1;
-	}
-
-	offset = OFFSET;
-	disk_ptr = This->buf + offset;
-	maximize(len, This->cur_size - offset);
-	memcpy(buf, disk_ptr, len);
-	return len;
-}
-
-static int buf_write(Stream_t *Stream, char *buf, mt_off_t start, size_t len)
-{
-	char *disk_ptr;
-	DeclareThis(Buffer_t);	
-	int offset, ret;
-
-	if(!len)
-		return 0;
-
-	This->ever_dirty = 1;
-
-#ifdef DEBUG
-	fprintf(stderr, "buf write %x   %02x %08x %08x -- %08x %08x -- %08x\n", 
-		Stream, (unsigned char) This->buf[0],
-		start, len, This->current, This->cur_size, This->size);
-	fprintf(stderr, "%d %d %d %x %x\n", 
-		start == This->current + This->cur_size,
-		This->cur_size < This->size,
-		len >= This->sectorSize, len, This->sectorSize);
-#endif
-	switch(isInBuffer(This, start, &len)) {
-		case OUTSIDE:
-#ifdef DEBUG
-			fprintf(stderr, "outside\n");
-#endif
-			if(start % This->cylinderSize || 
-			   len < This->sectorSize) {
-				size_t readSize;
-
-				readSize = This->cylinderSize - 
-					This->current % This->cylinderSize;
-
-				ret=READS(This->Next, This->buf, This->current, readSize);
-				/* read it! */
-				if ( ret < 0 )
-					return ret;
-				This->cur_size = ret;
-				/* for dosemu. Autoextend size */
-				if(!This->cur_size) {
-					memset(This->buf,0,readSize);
-					This->cur_size = readSize;
-				}
-				offset = OFFSET;
-				break;
-			}
-			/* FALL THROUGH */
-		case APPEND:
-#ifdef DEBUG
-			fprintf(stderr, "append\n");
-#endif
-			len = ROUND_DOWN(len, This->sectorSize);
-			offset = OFFSET;
-			maximize(len, This->size - offset);
-			This->cur_size += len;
-			if(This->Next->Class->pre_allocate)
-				PRE_ALLOCATE(This->Next,
-							 This->current + This->cur_size);
-			break;
-		case INSIDE:
-			/* nothing to do */
-#ifdef DEBUG
-			fprintf(stderr, "inside\n");
-#endif
-			offset = OFFSET;
-			maximize(len, This->cur_size - offset);
-			break;
-		case ERROR:
-			return -1;
-		default:
-#ifdef DEBUG
-			fprintf(stderr, "Should not happen\n");
-#endif
-			exit(1);
-	}
-
-	disk_ptr = This->buf + offset;
-
-	/* extend if we write beyond end */
-	if(offset + len > This->cur_size) {
-		len -= (offset + len) % This->sectorSize;
-		This->cur_size = len + offset;
-	}
-
-	memcpy(disk_ptr, buf, len);
-	if(!This->dirty || offset < This->dirty_pos)
-		This->dirty_pos = ROUND_DOWN(offset, This->sectorSize);
-	if(!This->dirty || offset + len > This->dirty_end)
-		This->dirty_end = ROUND_UP(offset + len, This->sectorSize);
-	
-	if(This->dirty_end > This->cur_size) {
-		fprintf(stderr, 
-			"Internal error, dirty end too big %x %x %x %d %x\n",
-			This->dirty_end, (unsigned int) This->cur_size, (unsigned int) len, 
-				(int) offset, (int) This->sectorSize);
-		fprintf(stderr, "offset + len + grain - 1 = %x\n",
-				(int) (offset + len + This->sectorSize - 1));
-		fprintf(stderr, "ROUNDOWN(offset + len + grain - 1) = %x\n",
-				(int)ROUND_DOWN(offset + len + This->sectorSize - 1,
-								This->sectorSize));
-		fprintf(stderr, "This->dirty = %d\n", This->dirty);
-		exit(1);
-	}
-
-	This->dirty = 1;
-	return len;
-}
-
-static int buf_flush(Stream_t *Stream)
-{
-	int ret;
-	DeclareThis(Buffer_t);
-
-	if (!This->ever_dirty)
-		return 0;
-	ret = _buf_flush(This);
-	if(ret == 0)
-		This->ever_dirty = 0;
-	return ret;
-}
-
-
-static int buf_free(Stream_t *Stream)
-{
-	DeclareThis(Buffer_t);
-
-	if(This->buf)
-		free(This->buf);
-	This->buf = 0;
-	return 0;
-}
-
-static Class_t BufferClass = {
-	buf_read,
-	buf_write,
-	buf_flush,
-	buf_free,
-	0, /* set_geom */
-	get_data_pass_through, /* get_data */
-	0, /* pre-allocate */
-};
-
-Stream_t *buf_init(Stream_t *Next, int size, 
-		   int cylinderSize, 
-		   int sectorSize)
-{
-	Buffer_t *Buffer;
-	Stream_t *Stream;
-
-
-	if(size % cylinderSize != 0) {
-		fprintf(stderr, "size not multiple of cylinder size\n");
-		exit(1);
-	}
-	if(cylinderSize % sectorSize != 0) {
-		fprintf(stderr, "cylinder size not multiple of sector size\n");
-		exit(1);
-	}
-
-	if(Next->Buffer){
-		Next->refs--;
-		Next->Buffer->refs++;
-		return Next->Buffer;
-	}
-
-	Stream = (Stream_t *) malloc (sizeof(Buffer_t));
-	if(!Stream)
-		return 0;
-	Buffer = (Buffer_t *) Stream;
-	Buffer->buf = malloc(size);
-	if ( !Buffer->buf){
-		Free(Stream);
-		return 0;
-	}
-	Buffer->size = size;
-	Buffer->dirty = 0;
-	Buffer->cylinderSize = cylinderSize;
-	Buffer->sectorSize = sectorSize;
-
-	Buffer->ever_dirty = 0;
-	Buffer->dirty_pos = 0;
-	Buffer->dirty_end = 0;
-	Buffer->current = 0;
-	Buffer->cur_size = 0; /* buffer currently empty */
-
-	Buffer->Next = Next;
-	Buffer->Class = &BufferClass;
-	Buffer->refs = 1;
-	Buffer->Buffer = 0;
-	Buffer->Next->Buffer = (Stream_t *) Buffer;
-	return Stream;
-}
-
Index: trunk/minix/commands/i386/mtools-3.9.7/buffer.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/buffer.h	(revision 9)
+++ 	(revision )
@@ -1,11 +1,0 @@
-#ifndef MTOOLS_BUFFER_H
-#define MTOOLS_BUFFER_H
-
-#include "stream.h"
-
-Stream_t *buf_init(Stream_t *Next, 
-		   int size, 
-		   int cylinderSize,
-		   int sectorSize);
-
-#endif
Index: trunk/minix/commands/i386/mtools-3.9.7/build
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/build	(revision 9)
+++ 	(revision )
@@ -1,3 +1,0 @@
-#!/bin/sh
-
-make && make install
Index: trunk/minix/commands/i386/mtools-3.9.7/codepage.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/codepage.h	(revision 9)
+++ 	(revision )
@@ -1,35 +1,0 @@
-typedef struct Codepage_l {
-	int nr;   
-	unsigned char tounix[128];
-} Codepage_t;
-
-
-typedef struct country_l {
-	int country;
-	int codepage;
-	int default_codepage;
-	int to_upper;
-} country_t;
-
-
-#ifndef NO_CONFIG
-void init_codepage(void);
-unsigned char to_dos(unsigned char c);
-void to_unix(char *a, int n);
-#define mstoupper(c)	mstoupper[(c) & 0x7F]
-
-#else /* NO_CONFIG */
-
-/* Imagine a codepage with 128 uppercase letters for the top 128 characters. */
-#define mstoupper(c)	(c)
-#define to_dos(c)	(c)
-#define to_unix(a, n)	((void) 0)
-#define mstoupper(c)	(c)
-#endif
-
-extern Codepage_t *Codepage;
-extern char *mstoupper;
-extern country_t countries[];
-extern unsigned char toucase[][128];
-extern Codepage_t codepages[];
-extern char *country_string;
Index: trunk/minix/commands/i386/mtools-3.9.7/config.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/config.c	(revision 9)
+++ 	(revision )
@@ -1,808 +1,0 @@
-#include "sysincludes.h"
-#include "mtools.h"
-#include "codepage.h"
-#include "mtoolsPaths.h"
-
-/* global variables */
-/* they are not really harmful here, because there is only one configuration
- * file per invocations */
-
-#ifndef NO_CONFIG
-
-#define MAX_LINE_LEN 256
-
-/* scanner */
-static char buffer[MAX_LINE_LEN+1]; /* buffer for the whole line */
-static char *pos; /* position in line */
-static char *token; /* last scanned token */
-static int token_length; /* length of the token */
-static FILE *fp; /* file pointer for configuration file */
-static int linenumber; /* current line number. Only used for printing
-						* error messages */
-static int lastTokenLinenumber; /* line numnber for last token */
-static const char *filename; /* current file name. Only used for printing
-			      * error messages */
-static int file_nr=0;
-
-
-static int flag_mask; /* mask of currently set flags */
-
-/* devices */
-static int cur_devs; /* current number of defined devices */
-static int cur_dev; /* device being filled in. If negative, none */
-static int trusted=0; /* is the currently parsed device entry trusted? */
-static int nr_dev; /* number of devices that the current table can hold */
-static int token_nr; /* number of tokens in line */
-static char letters[][2] = { /* drive letter to letter-as-a-string */
-	"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
-	"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
-};
-
-#endif	/* !NO_CONFIG */
-
-struct device *devices; /* the device table */
-
-/* "environment" variables */
-unsigned int mtools_skip_check=0;
-unsigned int mtools_fat_compatibility=0;
-unsigned int mtools_ignore_short_case=0;
-unsigned int mtools_rate_0=0;
-unsigned int mtools_rate_any=0;
-unsigned int mtools_no_vfat=0;
-unsigned int mtools_numeric_tail=1;
-unsigned int mtools_dotted_dir=0;
-unsigned int mtools_twenty_four_hour_clock=1;
-char *mtools_date_string="mm-dd-yyyy";
-char *country_string=0;
-
-#ifndef NO_CONFIG
-
-typedef struct switches_l {
-    const char *name;
-    caddr_t address;
-    enum {
-	T_INT,
-	T_STRING,
-	T_UINT
-    } type;
-} switches_t;
-
-static switches_t switches[] = {
-    { "MTOOLS_LOWER_CASE", (caddr_t) & mtools_ignore_short_case, T_UINT },
-    { "MTOOLS_FAT_COMPATIBILITY", (caddr_t) & mtools_fat_compatibility, T_UINT },
-    { "MTOOLS_SKIP_CHECK", (caddr_t) & mtools_skip_check, T_UINT },
-    { "MTOOLS_NO_VFAT", (caddr_t) & mtools_no_vfat, T_UINT },
-    { "MTOOLS_RATE_0", (caddr_t) &mtools_rate_0, T_UINT },
-    { "MTOOLS_RATE_ANY", (caddr_t) &mtools_rate_any, T_UINT },
-    { "MTOOLS_NAME_NUMERIC_TAIL", (caddr_t) &mtools_numeric_tail, T_UINT },
-    { "MTOOLS_DOTTED_DIR", (caddr_t) &mtools_dotted_dir, T_UINT },
-    { "MTOOLS_TWENTY_FOUR_HOUR_CLOCK", 
-      (caddr_t) &mtools_twenty_four_hour_clock, T_UINT },
-    { "MTOOLS_DATE_STRING",
-      (caddr_t) &mtools_date_string, T_STRING },
-    { "COUNTRY", (caddr_t) &country_string, T_STRING }
-};
-
-typedef struct {
-    const char *name;
-    int flag;
-} flags_t;
-
-static flags_t openflags[] = {
-#ifdef O_SYNC
-    { "sync",		O_SYNC },
-#endif
-#ifdef O_NDELAY
-    { "nodelay",	O_NDELAY },
-#endif
-#ifdef O_EXCL
-    { "exclusive",	O_EXCL },
-#endif
-    { "none", 0 }  /* hack for those compilers that choke on commas
-		    * after the last element of an array */
-};
-
-static flags_t misc_flags[] = {
-#ifdef USE_XDF
-    { "use_xdf",		USE_XDF_FLAG },
-#endif
-    { "scsi",			SCSI_FLAG },
-    { "nolock",			NOLOCK_FLAG },
-    { "mformat_only",	MFORMAT_ONLY_FLAG },
-    { "filter",			FILTER_FLAG },
-    { "privileged",		PRIV_FLAG },
-    { "vold",			VOLD_FLAG },
-    { "remote",			FLOPPYD_FLAG }
-};
-
-static struct {
-    const char *name;
-    signed char fat_bits;
-    int tracks;
-    unsigned short heads;
-    unsigned short sectors;
-} default_formats[] = {
-    { "hd514",			12, 80, 2, 15 },
-    { "high-density-5-1/4",	12, 80, 2, 15 },
-    { "1.2m",			12, 80, 2, 15 },
-    
-    { "hd312",			12, 80, 2, 18 },
-    { "high-density-3-1/2",	12, 80, 2, 18 },
-    { "1.44m",	 		12, 80, 2, 18 },
-
-    { "dd312",			12, 80, 2, 9 },
-    { "double-density-3-1/2",	12, 80, 2, 9 },
-    { "720k",			12, 80, 2, 9 },
-
-    { "dd514",			12, 40, 2, 9 },
-    { "double-density-5-1/4",	12, 40, 2, 9 },
-    { "360k",			12, 40, 2, 9 },
-
-    { "320k",			12, 40, 2, 8 },
-    { "180k",			12, 40, 1, 9 },
-    { "160k",			12, 40, 1, 8 }
-};
-
-#define OFFS(x) ((caddr_t)&((struct device *)0)->x)
-
-static switches_t dswitches[]= {
-    { "FILE", OFFS(name), T_STRING },
-    { "OFFSET", OFFS(offset), T_UINT },
-    { "PARTITION", OFFS(partition), T_UINT },
-    { "FAT", OFFS(fat_bits), T_INT },
-    { "FAT_BITS", OFFS(fat_bits), T_UINT },
-    { "MODE", OFFS(mode), T_UINT },
-    { "TRACKS",  OFFS(tracks), T_UINT },
-    { "CYLINDERS",  OFFS(tracks), T_UINT },
-    { "HEADS", OFFS(heads), T_UINT },
-    { "SECTORS", OFFS(sectors), T_UINT },
-    { "HIDDEN", OFFS(hidden), T_UINT },
-    { "PRECMD", OFFS(precmd), T_STRING },
-    { "BLOCKSIZE", OFFS(blocksize), T_UINT }
-};
-
-static void syntax(const char *msg, int thisLine)
-{
-    char *drive=NULL;
-    if(thisLine)
-	lastTokenLinenumber = linenumber;
-    if(cur_dev >= 0)
-	drive = devices[cur_dev].drive;
-    fprintf(stderr,"Syntax error at line %d ", lastTokenLinenumber);
-    if(drive) fprintf(stderr, "for drive %s: ", drive);
-    if(token) fprintf(stderr, "column %ld ", (long)(token - buffer));
-    fprintf(stderr, "in file %s: %s\n", filename, msg);
-    exit(1);
-}
-
-static void get_env_conf(void)
-{
-    char *s;
-    int i;
-
-    for(i=0; i< sizeof(switches) / sizeof(*switches); i++) {
-	s = getenv(switches[i].name);
-	if(s) {
-	    if(switches[i].type == T_INT)
-		* ((int *)switches[i].address) = (int) strtol(s,0,0);
-	    if(switches[i].type == T_UINT)
-		* ((int *)switches[i].address) = (unsigned int) strtoul(s,0,0);
-	    else if (switches[i].type == T_STRING)
-		* ((char **)switches[i].address) = s;
-	}
-    }
-}
-
-static int mtools_getline(void)
-{
-    if(!fgets(buffer, MAX_LINE_LEN, fp))
-	return -1;
-    linenumber++;
-    pos = buffer;
-    token_nr = 0;
-    buffer[MAX_LINE_LEN] = '\0';
-    if(strlen(buffer) == MAX_LINE_LEN)
-	syntax("line too long", 1);
-    return 0;
-}
-		
-static void skip_junk(int expect)
-{
-    lastTokenLinenumber = linenumber;
-    while(!pos || !*pos || strchr(" #\n\t", *pos)) {
-	if(!pos || !*pos || *pos == '#') {
-	    if(mtools_getline()) {
-		pos = 0;
-		if(expect)
-		    syntax("end of file unexpected", 1);
-		return;
-	    }
-	} else
-	    pos++;
-    }
-    token_nr++;
-}
-
-/* get the next token */
-static char *get_next_token(void)
-{
-    skip_junk(0);
-    if(!pos) {
-	token_length = 0;
-	token = 0;
-	return 0;
-    }
-    token = pos;
-    token_length = strcspn(token, " \t\n#:=");
-    pos += token_length;
-    return token;
-}
-
-static int match_token(const char *template)
-{
-    return (strlen(template) == token_length &&
-	    !strncasecmp(template, token, token_length));
-}
-
-static void expect_char(char c)
-{
-    char buf[11];
-
-    skip_junk(1);
-    if(*pos != c) {
-	sprintf(buf, "expected %c", c);
-	syntax(buf, 1);
-    }
-    pos++;
-}
-
-static char *get_string(void)
-{
-    char *end, *str;
-
-    skip_junk(1);
-    if(*pos != '"')
-	syntax(" \" expected", 0);
-    str = pos+1;
-    end = strchr(str, '\"');
-    if(!end)
-	syntax("unterminated string constant", 1);
-    *end = '\0';
-    pos = end+1;
-    return str;
-}
-
-static unsigned int get_unumber(void)
-{
-    char *last;
-    unsigned int n;
-
-    skip_junk(1);
-    last = pos;
-    n=(unsigned int) strtoul(pos, &pos, 0);
-    if(last == pos)
-	syntax("numeral expected", 0);
-    pos++;
-    token_nr++;
-    return n;
-}
-
-static unsigned int get_number(void)
-{
-    char *last;
-    int n;
-
-    skip_junk(1);
-    last = pos;
-    n=(int) strtol(pos, &pos, 0);
-    if(last == pos)
-	syntax("numeral expected", 0);
-    pos++;
-    token_nr++;
-    return n;
-}
-
-/* purge all entries pertaining to a given drive from the table */
-static void purge(char drive, int fn)
-{
-    int i,j;
-
-    drive = toupper(drive);
-    for(j=0, i=0; i < cur_devs; i++) {
-	if(devices[i].drive[0] != drive ||
-	   devices[i].drive[1] != 0 ||
-	   devices[i].file_nr == fn)
-	    devices[j++] = devices[i];
-    }
-    cur_devs = j;
-}
-
-static void grow(void)
-{
-    if(cur_devs >= nr_dev - 2) {
-	nr_dev = (cur_devs + 2) << 1;
-	if(!(devices=Grow(devices, nr_dev, struct device))){
-	    printOom();
-	    exit(1);
-	}
-    }
-}
-	
-
-static void init_drive(void)
-{
-    memset((char *)&devices[cur_dev], 0, sizeof(struct device));
-    devices[cur_dev].ssize = 2;
-}
-
-/* prepends a device to the table */
-static void prepend(void)
-{
-    int i;
-
-    grow();
-    for(i=cur_devs; i>0; i--)
-	devices[i] = devices[i-1];
-    cur_dev = 0;
-    cur_devs++;
-    init_drive();
-}
-
-
-/* appends a device to the table */
-static void append(void)
-{
-    grow();
-    cur_dev = cur_devs;
-    cur_devs++;
-    init_drive();
-}
-
-
-static void finish_drive_clause(void)
-{
-    char *drive;
-    if(cur_dev == -1) {
-	trusted = 0;
-	return;
-    }
-    drive = devices[cur_dev].drive;
-    if(!devices[cur_dev].name)
-	syntax("missing filename", 0);
-    if(devices[cur_dev].tracks ||
-       devices[cur_dev].heads ||
-       devices[cur_dev].sectors) {
-	if(!devices[cur_dev].tracks ||
-	   !devices[cur_dev].heads ||
-	   !devices[cur_dev].sectors)
-	    syntax("incomplete geometry: either indicate all of track/heads/sectors or none of them", 0);
-	if(!(devices[cur_dev].misc_flags & 
-	     (MFORMAT_ONLY_FLAG | FILTER_FLAG)))
-	    syntax("if you supply a geometry, you also must supply one of the `mformat_only' or `filter' flags", 0);
-    }
-    devices[cur_dev].file_nr = file_nr;
-    devices[cur_dev].cfg_filename = filename;
-    if(! (flag_mask & PRIV_FLAG) && IS_SCSI(&devices[cur_dev]))
-	devices[cur_dev].misc_flags |= PRIV_FLAG;
-    if(!trusted && (devices[cur_dev].misc_flags & PRIV_FLAG)) {
-	fprintf(stderr,
-		"Warning: privileged flag ignored for drive %s: defined in file %s\n",
-		devices[cur_dev].drive, filename);
-	devices[cur_dev].misc_flags &= ~PRIV_FLAG;
-    }
-    trusted = 0;
-    cur_dev = -1;
-}
-
-static int set_var(struct switches_l *switches, int nr,
-		   caddr_t base_address)
-{
-    int i;
-    for(i=0; i < nr; i++) {
-	if(match_token(switches[i].name)) {
-	    expect_char('=');
-	    if(switches[i].type == T_UINT)
-		* ((int *)((long)switches[i].address+base_address)) = 
-		    get_unumber();
-	    if(switches[i].type == T_INT)
-		* ((int *)((long)switches[i].address+base_address)) = 
-		    get_number();
-	    else if (switches[i].type == T_STRING)
-		* ((char**)((long)switches[i].address+base_address))=
-		    strdup(get_string());
-	    return 0;
-	}
-    }
-    return 1;
-}
-
-static int set_openflags(struct device *dev)
-{
-    int i;
-
-    for(i=0; i < sizeof(openflags) / sizeof(*openflags); i++) {
-	if(match_token(openflags[i].name)) {
-	    dev->mode |= openflags[i].flag;
-	    return 0;
-	}
-    }
-    return 1;
-}
-
-static int set_misc_flags(struct device *dev)
-{
-    int i;
-
-    for(i=0; i < sizeof(misc_flags) / sizeof(*misc_flags); i++) {
-	if(match_token(misc_flags[i].name)) {
-	    flag_mask |= misc_flags[i].flag;
-	    skip_junk(0);
-	    if(pos && *pos == '=') {
-		pos++;
-		switch(get_number()) {
-		    case 0:
-			return 0;
-		    case 1:
-			break;
-		    default:
-			syntax("expected 0 or 1", 0);
-		}
-	    }
-	    dev->misc_flags |= misc_flags[i].flag;
-	    return 0;
-	}
-    }
-    return 1;
-}
-
-static int set_def_format(struct device *dev)
-{
-    int i;
-
-    for(i=0; i < sizeof(default_formats)/sizeof(*default_formats); i++) {
-	if(match_token(default_formats[i].name)) {
-	    if(!dev->ssize)
-		dev->ssize = 2;
-	    if(!dev->tracks)
-		dev->tracks = default_formats[i].tracks;
-	    if(!dev->heads)
-		dev->heads = default_formats[i].heads;
-	    if(!dev->sectors)
-		dev->sectors = default_formats[i].sectors;
-	    if(!dev->fat_bits)
-		dev->fat_bits = default_formats[i].fat_bits;
-	    return 0;
-	}
-    }
-    return 1;
-}    
-
-static void get_codepage(void)
-{
-    int i;
-    unsigned short n;
-
-    if(!Codepage)
-	Codepage = New(Codepage_t);
-    for(i=0; i<128; i++) {
-	n = get_number();
-	if(n > 0xff)
-	    n = 0x5f;
-	Codepage->tounix[i] = n;
-    }	
-}
-
-static void get_toupper(void)
-{
-    int i;
-
-    if(!mstoupper)
-	mstoupper = safe_malloc(128);
-    for(i=0; i<128; i++)
-	mstoupper[i] = get_number();
-}
-
-static void parse_old_device_line(char drive)
-{
-    char name[MAXPATHLEN];
-    int items;
-    long offset;
-    char newdrive;
-
-    /* finish any old drive */
-    finish_drive_clause();
-
-    /* purge out data of old configuration files */
-    purge(drive, file_nr);
-	
-    /* reserve slot */
-    append();
-    items = sscanf(token,"%c %s %i %i %i %i %li",
-		   &newdrive,name,&devices[cur_dev].fat_bits,
-		   &devices[cur_dev].tracks,&devices[cur_dev].heads,
-		   &devices[cur_dev].sectors, &offset);
-    devices[cur_dev].offset = (off_t) offset;
-    switch(items){
-	case 2:
-	    devices[cur_dev].fat_bits = 0;
-	    /* fall thru */
-	case 3:
-	    devices[cur_dev].sectors = 0;
-	    devices[cur_dev].heads = 0;
-	    devices[cur_dev].tracks = 0;
-	    /* fall thru */
-	case 6:
-	    devices[cur_dev].offset = 0;
-	    /* fall thru */
-	default:
-	    break;
-	case 0:
-	case 1:
-	case 4:
-	case 5:
-	    syntax("bad number of parameters", 1);
-	    exit(1);
-    }
-    if(!devices[cur_dev].tracks){
-	devices[cur_dev].sectors = 0;
-	devices[cur_dev].heads = 0;
-    }
-	
-    devices[cur_dev].drive = letters[toupper(newdrive) - 'A'];
-    if (!(devices[cur_dev].name = strdup(name))) {
-	printOom();
-	exit(1);
-    }
-    finish_drive_clause();
-    pos=0;
-}
-
-static int parse_one(int privilege)
-{
-    int action=0;
-
-    get_next_token();
-    if(!token)
-	return 0;
-
-    if((match_token("drive") && ((action = 1)))||
-       (match_token("drive+") && ((action = 2))) ||
-       (match_token("+drive") && ((action = 3))) ||
-       (match_token("clear_drive") && ((action = 4))) ) {
-	/* finish off the previous drive */
-	finish_drive_clause();
-
-	get_next_token();
-	if(token_length != 1)
-	    syntax("drive letter expected", 0);
-
-	if(action==1 || action==4)
-	    /* replace existing drive */			
-	    purge(token[0], file_nr);
-	if(action==4)
-	    return 1;
-	if(action==3)
-	    prepend();
-	else
-	    append();
-	memset((char*)(devices+cur_dev), 0, sizeof(*devices));
-	trusted = privilege;
-	flag_mask = 0;
-	devices[cur_dev].drive = letters[toupper(token[0]) - 'A'];
-	expect_char(':');
-	return 1;
-    }
-    if(token_nr == 1 && token_length == 1) {
-	parse_old_device_line(token[0]);
-	return 1;
-    }
-    if(match_token("default_fucase")) {
-	free(mstoupper);
-	mstoupper=0;
-    }
-    if(match_token("default_tounix")) {
-	Free(Codepage);
-	Codepage = 0;
-    }
-    if(match_token("fucase")) {
-	expect_char(':');
-	get_toupper();
-	return 1;
-    }
-    if(match_token("tounix")) {
-	expect_char(':');
-	get_codepage();
-	return 1;
-    }
-	
-    if((cur_dev < 0 || 
-	(set_var(dswitches,
-		 sizeof(dswitches)/sizeof(*dswitches),
-		 (caddr_t)&devices[cur_dev]) &&
-	 set_openflags(&devices[cur_dev]) &&
-	 set_misc_flags(&devices[cur_dev]) &&
-	 set_def_format(&devices[cur_dev]))) &&
-       set_var(switches,
-	       sizeof(switches)/sizeof(*switches), 0))
-	syntax("unrecognized keyword", 1);
-    return 1;
-}
-
-static int parse(const char *name, int privilege)
-{
-    fp = fopen(name, "r");
-    if(!fp)
-	return 0;
-    file_nr++;
-    filename = strdup(name);
-    linenumber = 0;
-    lastTokenLinenumber = 0;
-    pos = 0;
-    token = 0;
-    cur_dev = -1; /* no current device */
-
-    while(parse_one(privilege));
-    finish_drive_clause();
-    fclose(fp);
-    return 1;
-}
-
-void read_config(void)
-{
-    char *homedir;
-    char *envConfFile;
-    char conf_file[MAXPATHLEN+sizeof(CFG_FILE1)];
-
-	
-    /* copy compiled-in devices */
-    file_nr = 0;
-    cur_devs = nr_const_devices;
-    nr_dev = nr_const_devices + 2;
-    devices = NewArray(nr_dev, struct device);
-    if(!devices) {
-	printOom();
-	exit(1);
-    }
-    if(nr_const_devices)
-	memcpy(devices, const_devices,
-	       nr_const_devices*sizeof(struct device));
-
-    (void) ((parse(CONF_FILE,1) | 
-	     parse(LOCAL_CONF_FILE,1) |
-	     parse(SYS_CONF_FILE,1)) ||
-	    (parse(OLD_CONF_FILE,1) | 
-	     parse(OLD_LOCAL_CONF_FILE,1)));
-    /* the old-name configuration files only get executed if none of the
-     * new-name config files were used */
-
-    homedir = get_homedir();
-    if ( homedir ){
-	strncpy(conf_file, homedir, MAXPATHLEN );
-	conf_file[MAXPATHLEN]='\0';
-	strcat( conf_file, CFG_FILE1);
-	parse(conf_file,0);
-    }
-    memset((char *)&devices[cur_devs],0,sizeof(struct device));
-
-    envConfFile = getenv("MTOOLSRC");
-    if(envConfFile)
-	parse(envConfFile,0);
-
-    /* environmental variables */
-    get_env_conf();
-    if(mtools_skip_check)
-	mtools_fat_compatibility=1;
-    init_codepage();
-}
-
-void mtoolstest(int argc, char **argv, int type)
-{
-    /* testing purposes only */
-    struct device *dev;
-    int i,j;
-    char *drive=NULL;
-    char *path;
-
-    if (argc > 1 && (path = skip_drive(argv[1])) > argv[1]) {
-	drive = get_drive(argv[1], NULL);
-    }
-
-    for (dev=devices; dev->name; dev++) {
-	if(drive && strcmp(drive, dev->drive) != 0)
-	    continue;
-	printf("drive %s:\n", dev->drive);
-	printf("\t#fn=%d mode=%d ",
-	       dev->file_nr, dev->mode);
-	if(dev->cfg_filename)
-	    printf("defined in %s\n", dev->cfg_filename);
-	else
-	    printf("builtin\n");
-	printf("\tfile=\"%s\" fat_bits=%d \n",
-	       dev->name,dev->fat_bits);
-	printf("\ttracks=%d heads=%d sectors=%d hidden=%d\n",
-	       dev->tracks, dev->heads, dev->sectors, dev->hidden);
-	printf("\toffset=0x%lx\n", (long) dev->offset);
-	printf("\tpartition=%d\n", dev->partition);
-
-	if(dev->misc_flags)
-	    printf("\t");
-
-	if(IS_SCSI(dev))
-	    printf("scsi ");
-	if(IS_PRIVILEGED(dev))
-	    printf("privileged");
-	if(IS_MFORMAT_ONLY(dev))
-	    printf("mformat_only ");
-	if(SHOULD_USE_VOLD(dev))
-	    printf("vold ");
-#ifdef USE_XDF
-	if(SHOULD_USE_XDF(dev))
-	    printf("use_xdf ");
-#endif
-	if(dev->misc_flags)
-	    printf("\n");
-
-	if(dev->mode)
-	    printf("\t");
-#ifdef O_SYNC
-	if(dev->mode & O_SYNC)
-	    printf("sync ");
-#endif
-#ifdef O_NDELAY
-	if((dev->mode & O_NDELAY))
-	    printf("nodelay ");
-#endif
-#ifdef O_EXCL
-	if((dev->mode & O_EXCL))
-	    printf("exclusive ");
-#endif
-	if(dev->mode)
-	    printf("\n");
-
-	if(dev->precmd)
-	    printf("\tprecmd=%s\n", dev->precmd);
-
-	printf("\n");
-    }
-	
-    printf("tounix:\n");
-    for(i=0; i < 16; i++) {
-	putchar('\t');
-	for(j=0; j<8; j++)
-	    printf("0x%02x ",
-		   (unsigned char)Codepage->tounix[i*8+j]);
-	putchar('\n');
-    }
-    printf("\nfucase:\n");
-    for(i=0; i < 16; i++) {
-	putchar('\t');
-	for(j=0; j<8; j++)
-	    printf("0x%02x ",
-		   (unsigned char)mstoupper[i*8+j]);
-	putchar('\n');
-    }
-    if(country_string)
-	printf("COUNTRY=%s\n", country_string);
-    printf("mtools_fat_compatibility=%d\n",mtools_fat_compatibility);
-    printf("mtools_skip_check=%d\n",mtools_skip_check);
-    printf("mtools_lower_case=%d\n",mtools_ignore_short_case);
-
-    exit(0);
-}
-
-#else	/* NO_CONFIG */
-
-void read_config(void)
-{
-	/* only compiled-in devices */
-	devices = NewArray(nr_const_devices + 1, struct device);
-	if(!devices) {
-		fprintf(stderr,"Out of memory error\n");
-		exit(1);
-	}
-	if(nr_const_devices)
-	memcpy(devices, const_devices,
-		       nr_const_devices*sizeof(struct device));
-}
-
-#endif /* NO_CONFIG */
Index: trunk/minix/commands/i386/mtools-3.9.7/config.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/config.h	(revision 9)
+++ 	(revision )
@@ -1,301 +1,0 @@
-/* config.h.  Generated automatically by configure.  */
-/* config.h.in.  Generated automatically from configure.in by autoheader.  */
-
-/* Define if on AIX 3.
-   System headers sometimes define this.
-   We just want to avoid a redefinition error message.  */
-#ifndef _ALL_SOURCE
-/* #undef _ALL_SOURCE */
-#endif
-
-/* Define to empty if the keyword does not work.  */
-/* #undef const */
-
-/* Define if you have <sys/wait.h> that is POSIX.1 compatible.  */
-#define HAVE_SYS_WAIT_H 1
-
-/* Define as __inline if that's what the C compiler calls it.  */
-#define inline 
-
-/* Define if on MINIX.  */
-#define _MINIX 1
-
-/* Define if the system does not provide POSIX.1 features except
-   with this defined.  */
-#define _POSIX_1_SOURCE 2
-
-/* Define if you need to in order for stat and other things to work.  */
-#define _POSIX_SOURCE 1
-
-/* Define as the return type of signal handlers (int or void).  */
-#define RETSIGTYPE void
-
-/* Define if the `setpgrp' function takes no argument.  */
-#define SETPGRP_VOID 1
-
-/* Define to `unsigned' if <sys/types.h> doesn't define.  */
-/* #undef size_t */
-
-/* Define if you have the ANSI C header files.  */
-#define STDC_HEADERS 1
-
-/* Define if you can safely include both <sys/time.h> and <time.h>.  */
-/* #undef TIME_WITH_SYS_TIME */
-
-/* Define if your <sys/time.h> declares struct tm.  */
-/* #undef TM_IN_SYS_TIME */
-
-/* Define if the X Window System is missing or not being used.  */
-#define X_DISPLAY_MISSING 1
-
-/* Define this if you want to use Xdf */
-#define USE_XDF 1
-
-/* Define this if you use mtools together with Solaris' vold */
-/* #undef USING_VOLD */
-
-/* Define this if you use mtools together with the new Solaris' vold
- * support */
-/* #undef USING_NEW_VOLD */
-
-/* Define for debugging messages */
-/* #undef DEBUG */
-
-/* Define on non Unix OS'es which don't have the concept of tty's */
-/* #undef USE_RAWTERM */
-
-/* Define when sys_errlist is defined in the standard include files */
-/* #undef DECL_SYS_ERRLIST */
-
-/* Define when you want to include floppyd support */
-/* #undef USE_FLOPPYD */
-
-/* Define when the compiler supports LOFF_T type */
-/* #undef HAVE_LOFF_T */
-
-/* Define when the compiler supports OFFSET_T type */
-/* #undef HAVE_OFFSET_T */
-
-/* Define when the compiler supports LONG_LONG type */
-/* #undef HAVE_LONG_LONG */
-
-/* Define when the system has a 64 bit off_t type */
-/* #undef HAVE_OFF_T_64 */
-
-/* Define when you have an LLSEEK prototype */
-/* #undef HAVE_LLSEEK_PROTOTYPE */
-
-/* Define if you have the atexit function.  */
-#define HAVE_ATEXIT 1
-
-/* Define if you have the basename function.  */
-/* #undef HAVE_BASENAME */
-
-/* Define if you have the fchdir function.  */
-#ifdef __minix_vmd
-#define HAVE_FCHDIR 1
-#endif
-
-/* Define if you have the flock function.  */
-/* #undef HAVE_FLOCK */
-
-/* Define if you have the getpass function.  */
-#define HAVE_GETPASS 1
-
-/* Define if you have the gettimeofday function.  */
-#define HAVE_GETTIMEOFDAY 1
-
-/* Define if you have the htons function.  */
-/* #undef HAVE_HTONS */
-
-/* Define if you have the llseek function.  */
-/* #undef HAVE_LLSEEK */
-
-/* Define if you have the lockf function.  */
-#define HAVE_LOCKF 1
-
-/* Define if you have the lseek64 function.  */
-/* #undef HAVE_LSEEK64 */
-
-/* Define if you have the media_oldaliases function.  */
-/* #undef HAVE_MEDIA_OLDALIASES */
-
-/* Define if you have the memcpy function.  */
-#define HAVE_MEMCPY 1
-
-/* Define if you have the memmove function.  */
-#define HAVE_MEMMOVE 1
-
-/* Define if you have the memset function.  */
-#define HAVE_MEMSET 1
-
-/* Define if you have the on_exit function.  */
-/* #undef HAVE_ON_EXIT */
-
-/* Define if you have the random function.  */
-#define HAVE_RANDOM 1
-
-/* Define if you have the seteuid function.  */
-/* #undef HAVE_SETEUID */
-
-/* Define if you have the setresuid function.  */
-/* #undef HAVE_SETRESUID */
-
-/* Define if you have the snprintf function.  */
-#define HAVE_SNPRINTF 1
-
-/* Define if you have the srandom function.  */
-#define HAVE_SRANDOM 1
-
-/* Define if you have the strcasecmp function.  */
-#define HAVE_STRCASECMP 1
-
-/* Define if you have the strchr function.  */
-#define HAVE_STRCHR 1
-
-/* Define if you have the strcspn function.  */
-#define HAVE_STRCSPN 1
-
-/* Define if you have the strdup function.  */
-/* #undef HAVE_STRDUP */
-
-/* Define if you have the strerror function.  */
-#define HAVE_STRERROR 1
-
-/* Define if you have the strncasecmp function.  */
-#define HAVE_STRNCASECMP 1
-
-/* Define if you have the strpbrk function.  */
-#define HAVE_STRPBRK 1
-
-/* Define if you have the strrchr function.  */
-#define HAVE_STRRCHR 1
-
-/* Define if you have the strspn function.  */
-#define HAVE_STRSPN 1
-
-/* Define if you have the strtol function.  */
-#define HAVE_STRTOL 1
-
-/* Define if you have the strtoul function.  */
-#define HAVE_STRTOUL 1
-
-/* Define if you have the tcflush function.  */
-#define HAVE_TCFLUSH 1
-
-/* Define if you have the tcsetattr function.  */
-#define HAVE_TCSETATTR 1
-
-/* Define if you have the tzset function.  */
-#define HAVE_TZSET 1
-
-/* Define if you have the utime function.  */
-#define HAVE_UTIME 1
-
-/* Define if you have the utimes function.  */
-/* #undef HAVE_UTIMES */
-
-/* Define if you have the <arpa/inet.h> header file.  */
-/* #undef HAVE_ARPA_INET_H */
-
-/* Define if you have the <fcntl.h> header file.  */
-#define HAVE_FCNTL_H 1
-
-/* Define if you have the <getopt.h> header file.  */
-/* #undef HAVE_GETOPT_H */
-
-/* Define if you have the <libc.h> header file.  */
-/* #undef HAVE_LIBC_H */
-
-/* Define if you have the <limits.h> header file.  */
-#define HAVE_LIMITS_H 1
-
-/* Define if you have the <linux/unistd.h> header file.  */
-/* #undef HAVE_LINUX_UNISTD_H */
-
-/* Define if you have the <malloc.h> header file.  */
-/* #undef HAVE_MALLOC_H */
-
-/* Define if you have the <memory.h> header file.  */
-/* #undef HAVE_MEMORY_H */
-
-/* Define if you have the <mntent.h> header file.  */
-/* #undef HAVE_MNTENT_H */
-
-/* Define if you have the <netdb.h> header file.  */
-/* #undef HAVE_NETDB_H */
-
-/* Define if you have the <netinet/in.h> header file.  */
-/* #undef HAVE_NETINET_IN_H */
-
-/* Define if you have the <sgtty.h> header file.  */
-#define HAVE_SGTTY_H 1
-
-/* Define if you have the <signal.h> header file.  */
-#define HAVE_SIGNAL_H 1
-
-/* Define if you have the <stdlib.h> header file.  */
-#define HAVE_STDLIB_H 1
-
-/* Define if you have the <string.h> header file.  */
-#define HAVE_STRING_H 1
-
-/* Define if you have the <strings.h> header file.  */
-/* #undef HAVE_STRINGS_H */
-
-/* Define if you have the <sys/file.h> header file.  */
-/* #undef HAVE_SYS_FILE_H */
-
-/* Define if you have the <sys/floppy.h> header file.  */
-/* #undef HAVE_SYS_FLOPPY_H */
-
-/* Define if you have the <sys/ioctl.h> header file.  */
-#define HAVE_SYS_IOCTL_H 1
-
-/* Define if you have the <sys/param.h> header file.  */
-/* #undef HAVE_SYS_PARAM_H */
-
-/* Define if you have the <sys/signal.h> header file.  */
-/* #undef HAVE_SYS_SIGNAL_H */
-
-/* Define if you have the <sys/socket.h> header file.  */
-/* #undef HAVE_SYS_SOCKET_H */
-
-/* Define if you have the <sys/stat.h> header file.  */
-#define HAVE_SYS_STAT_H 1
-
-/* Define if you have the <sys/sysmacros.h> header file.  */
-/* #undef HAVE_SYS_SYSMACROS_H */
-
-/* Define if you have the <sys/termio.h> header file.  */
-/* #undef HAVE_SYS_TERMIO_H */
-
-/* Define if you have the <sys/termios.h> header file.  */
-/* #undef HAVE_SYS_TERMIOS_H */
-
-/* Define if you have the <sys/time.h> header file.  */
-/* #undef HAVE_SYS_TIME_H */
-
-/* Define if you have the <termio.h> header file.  */
-/* #undef HAVE_TERMIO_H */
-
-/* Define if you have the <termios.h> header file.  */
-#define HAVE_TERMIOS_H 1
-
-/* Define if you have the <unistd.h> header file.  */
-#define HAVE_UNISTD_H 1
-
-/* Define if you have the <utime.h> header file.  */
-#define HAVE_UTIME_H 1
-
-/* Define if you have the cam library (-lcam).  */
-/* #undef HAVE_LIBCAM */
-
-/* Define if you have the nsl library (-lnsl).  */
-/* #undef HAVE_LIBNSL */
-
-/* Define if you have the socket library (-lsocket).  */
-/* #undef HAVE_LIBSOCKET */
-
-/* Define if you have the sun library (-lsun).  */
-/* #undef HAVE_LIBSUN */
Index: trunk/minix/commands/i386/mtools-3.9.7/copyfile.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/copyfile.c	(revision 9)
+++ 	(revision )
@@ -1,62 +1,0 @@
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "file.h"
-#include "llong.h"
-
-/*
- * Copy the data from source to target
- */
-
-int copyfile(Stream_t *Source, Stream_t *Target)
-{
-	char buffer[8*16384];
-	int pos;
-	int ret, retw;
-	size_t len;
-	mt_size_t mt_len;
-
-	if (!Source){
-		fprintf(stderr,"Couldn't open source file\n");
-		return -1;
-	}
-
-	if (!Target){
-		fprintf(stderr,"Couldn't open target file\n");
-		return -1;
-	}
-
-	pos = 0;
-	GET_DATA(Source, 0, &mt_len, 0, 0);
-	if (mt_len & ~max_off_t_31) {
-		fprintf(stderr, "File too big\n");
-		return -1;
-	}
-	len = truncBytes32(mt_len);
-	while(1){
-		ret = READS(Source, buffer, (mt_off_t) pos, 8*16384);
-		if (ret < 0 ){
-			perror("file read");
-			return -1;
-		}
-		if(!ret)
-			break;
-		if(got_signal)
-			return -1;
-		if (ret == 0)
-			break;
-		if ((retw = force_write(Target, buffer, (mt_off_t) pos, ret)) != ret){
-			if(retw < 0 )
-				perror("write in copy");
-			else
-				fprintf(stderr,
-					"Short write %d instead of %d\n", retw,
-					ret);
-			if(errno == ENOSPC)
-				got_signal = 1;
-			return ret;
-		}
-		pos += ret;
-	}
-	return pos;
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/devices.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/devices.c	(revision 9)
+++ 	(revision )
@@ -1,1115 +1,0 @@
-/*
- * This file is modified to perform on the UXP/DS operating system 
- * by FUJITSU Limited on 1996.6.4
- */
-
-/*
- * Device tables.  See the Configure file for a complete description.
- */
-
-#define NO_TERMIO
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "devices.h"
-
-#define INIT_NOOP
-
-#define DEF_ARG1(x) (x), 0x2,0,(char *)0, 0, 0
-#define DEF_ARG0(x) 0,DEF_ARG1(x)
-
-#define MDEF_ARG 0L,DEF_ARG0(MFORMAT_ONLY_FLAG)
-#define FDEF_ARG 0L,DEF_ARG0(0)
-#define VOLD_DEF_ARG 0L,DEF_ARG0(VOLD_FLAG|MFORMAT_ONLY_FLAG)
-
-#define MED312	12,0,80,2,36,0,MDEF_ARG /* 3 1/2 extra density */
-#define MHD312	12,0,80,2,18,0,MDEF_ARG /* 3 1/2 high density */
-#define MDD312	12,0,80,2, 9,0,MDEF_ARG /* 3 1/2 double density */
-#define MHD514	12,0,80,2,15,0,MDEF_ARG /* 5 1/4 high density */
-#define MDD514	12,0,40,2, 9,0,MDEF_ARG /* 5 1/4 double density (360k) */
-#define MSS514	12,0,40,1, 9,0,MDEF_ARG /* 5 1/4 single sided DD, (180k) */
-#define MDDsmall	12,0,40,2, 8,0,MDEF_ARG /* 5 1/4 double density (320k) */
-#define MSSsmall	12,0,40,1, 8,0,MDEF_ARG /* 5 1/4 single sided DD, (160k) */
-
-#define FED312	12,0,80,2,36,0,FDEF_ARG /* 3 1/2 extra density */
-#define FHD312	12,0,80,2,18,0,FDEF_ARG /* 3 1/2 high density */
-#define FDD312	12,0,80,2, 9,0,FDEF_ARG /* 3 1/2 double density */
-#define FHD514	12,0,80,2,15,0,FDEF_ARG /* 5 1/4 high density */
-#define FDD514	12,0,40,2, 9,0,FDEF_ARG /* 5 1/4 double density (360k) */
-#define FSS514	12,0,40,1, 9,0,FDEF_ARG /* 5 1/4 single sided DD, (180k) */
-#define FDDsmall	12,0,40,2, 8,0,FDEF_ARG /* 5 1/4 double density (320k) */
-#define FSSsmall	12,0,40,1, 8,0,FDEF_ARG /* 5 1/4 single sided DD, (160k) */
-
-#define GENHD	16,0, 0,0, 0,0,MDEF_ARG /* Generic 16 bit FAT fs */
-#define GENFD	12,0,80,2,18,0,MDEF_ARG /* Generic 12 bit FAT fs */
-#define VOLDFD	12,0,80,2,18,0,VOLD_DEF_ARG /* Generic 12 bit FAT fs with vold */
-#define GEN    	 0,0, 0,0, 0,0,MDEF_ARG /* Generic fs of any FAT bits */
-
-#define ZIPJAZ(x,c,h,s,y) 16,(x),(c),(h),(s),(s),0L, 4, \
-		DEF_ARG1((y)|MFORMAT_ONLY_FLAG) /* Jaz disks */
-
-#define JAZ(x)	 ZIPJAZ(x,1021, 64, 32, 0)
-#define RJAZ(x)	 ZIPJAZ(x,1021, 64, 32, SCSI_FLAG|PRIV_FLAG)
-#define ZIP(x)	 ZIPJAZ(x,96, 64, 32, 0)
-#define RZIP(x)	 ZIPJAZ(x,96, 64, 32, SCSI_FLAG|PRIV_FLAG)
-
-#define REMOTE    {"$DISPLAY", 'X', 0,0, 0,0, 0,0,0L, DEF_ARG0(FLOPPYD_FLAG)}
-
-
-
-#if defined(INIT_GENERIC) || defined(INIT_NOOP)
-static int compare_geom(struct device *dev, struct device *orig_dev)
-{
-	if(IS_MFORMAT_ONLY(orig_dev))
-		return 0; /* geometry only for mformatting ==> ok */
-	if(!orig_dev || !orig_dev->tracks || !dev || !dev->tracks)
-		return 0; /* no original device. This is ok */
-	return(orig_dev->tracks != dev->tracks ||
-	       orig_dev->heads != dev->heads ||
-	       orig_dev->sectors  != dev->sectors);
-}
-#endif
-
-#define devices const_devices
-
-
-#ifdef OS_aux
-#define predefined_devices
-struct device devices[] = {
-   {"/dev/floppy0", "A", GENFD },
-   {"/dev/rdsk/c104d0s31", "J", JAZ(O_EXCL) },
-   {"/dev/rdsk/c105d0s31", "Z", ZIP(O_EXCL) },
-   REMOTE
-};
-#endif /* aux */
-
-
-#ifdef OS_lynxos
-#define predefined_devices
-struct device devices[] = {
-	{"/dev/fd1440.0", 	"A", MHD312 },
-	REMOTE
-};
-#endif
-
-
-#ifdef __BEOS__
-#define predefined_devices
-struct device devices[] = {
-	{"/dev/disk/floppy/raw", 	"A", MHD312 },
-	REMOTE
-};
-#endif /* BEBOX */
-
-
-#ifdef OS_hpux
-
-#define predefined_devices
-struct device devices[] = {
-#ifdef OS_hpux10
-/* hpux10 uses different device names according to Frank Maritato
- * <frank@math.hmc.edu> */
-	{"/dev/floppy/c0t0d0",		"A", MHD312 },
-	{"/dev/floppy/c0t0d1",		"B", MHD312 }, /* guessed by me */
- 	{"/dev/rscsi",			"C", GENHD }, /* guessed by me */
-#else
-/* Use rfloppy, according to Simao Campos <simao@iris.ctd.comsat.com> */
-	{"/dev/rfloppy/c201d0s0",	"A", FHD312 },
-	{"/dev/rfloppy/c20Ad0s0", 	"A", FHD312 },
- 	{"/dev/rfloppy/c201d1s0",	"B", FHD312 },
- 	{"/dev/rfloppy/c20Ad1s0",	"B", FHD312 },
- 	{"/dev/rscsi",			"C", GENHD },
-#endif
-	{"/dev/rdsk/c201d4",		"J", RJAZ(O_EXCL) },
-	{"/dev/rdsk/c201d4s0",		"J", RJAZ(O_EXCL) },
-	{"/dev/rdsk/c201d5",		"Z", RZIP(O_EXCL) },
-	{"/dev/rdsk/c201d5s0",		"Z", RZIP(O_EXCL) },
-	REMOTE
-};
-
-#ifdef HAVE_SYS_FLOPPY
-/* geometry setting ioctl's contributed by Paolo Zeppegno
- * <paolo@to.sem.it>, may cause "Not a typewriter" messages on other
- * versions according to support@vital.com */
-
-#include <sys/floppy.h>
-#undef SSIZE
-
-struct generic_floppy_struct
-{
-  struct floppy_geometry fg;
-};
-
-#define BLOCK_MAJOR 24
-#define CHAR_MAJOR 112
-
-static inline int get_parameters(int fd, struct generic_floppy_struct *floppy)
-{
-	if (ioctl(fd, FLOPPY_GET_GEOMETRY, &(floppy->fg)) != 0) {
-		perror("FLOPPY_GET_GEOMETRY");
-		return(1);
-	}
-	
-	return 0;
-}
-
-#define TRACKS(floppy) floppy.fg.tracks
-#define HEADS(floppy) floppy.fg.heads
-#define SECTORS(floppy) floppy.fg.sectors
-#define FD_SECTSIZE(floppy) floppy.fg.sector_size
-#define FD_SET_SECTSIZE(floppy,v) { floppy.fg.sector_size = v; }
-
-static inline int set_parameters(int fd, struct generic_floppy_struct *floppy, 
-				 struct stat *buf)
-{
-	if (ioctl(fd, FLOPPY_SET_GEOMETRY, &(floppy->fg)) != 0) {
-		perror("");
-		return(1);
-	}
-	
-	return 0;
-}
-#define INIT_GENERIC
-#endif
-
-#endif /* hpux */
- 
-
-#if (defined(OS_sinix) || defined(VENDOR_sni) || defined(SNI))
-#define predefined_devices
-struct device devices[] = {
-#ifdef CPU_mips     /* for Siemens Nixdorf's  SINIX-N/O (mips) 5.4x SVR4 */
-	{ "/dev/at/flp/f0t",    "A", FHD312},
-	{ "/dev/fd0",           "A", GENFD},
-#else
-#ifdef CPU_i386     /* for Siemens Nixdorf's  SINIX-D/L (intel) 5.4x SVR4 */
-	{ "/dev/fd0135ds18",	"A", FHD312},
-	{ "/dev/fd0135ds9",	"A", FDD312},
-	{ "/dev/fd0",		"A", GENFD},
-	{ "/dev/fd1135ds15",	"B", FHD514},
-	{ "/dev/fd1135ds9",	"B", FDD514},
-	{ "/dev/fd1",		"B", GENFD},
-#endif /* CPU_i386 */
-#endif /*mips*/
-	REMOTE
-};
-#endif
-
-#ifdef OS_ultrix
-#define predefined_devices
-struct device devices[] = {
-	{"/dev/rfd0a",		"A", GENFD}, /* guessed */
-	{"/dev/rfd0c",		"A", GENFD}, /* guessed */
-	REMOTE
-};
-
-#endif
-
-
-#ifdef OS_isc
-#define predefined_devices
-#if (defined(OS_isc2) && defined(OLDSTUFF))
-struct device devices[] = {
-	{"/dev/rdsk/f0d9dt",   	"A", FDD514},
-	{"/dev/rdsk/f0q15dt",	"A", FHD514},
-	{"/dev/rdsk/f0d8dt",	"A", FDDsmall},
-	{"/dev/rdsk/f13ht",	"B", FHD312},
-	{"/dev/rdsk/f13dt",	"B", FDD312},
-	{"/dev/rdsk/0p1",	"C", GENHD},
-	{"/usr/vpix/defaults/C:","D",12, 0, 0, 0, 0,8704L,DEF_ARG0},
-	{"$HOME/vpix/C:", 	"E", 12, 0, 0, 0, 0,8704L,MDEF_ARG},
-	REMOTE
-};
-#else
-/* contributed by larry.jones@sdrc.com (Larry Jones) */
-struct device devices[] = {
-	{"/dev/rfd0",		"A", GEN},
-	{"/dev/rfd1",		"B", GEN},
-	{"/dev/rdsk/0p1",	"C", GEN},
-	{"/usr/vpix/defaults/C:","D", GEN, 1},
-	{"$HOME/vpix/C:", 	"E", GEN, 1},
-	REMOTE
-};
-
-#include <sys/vtoc.h>
-#include <sys/sysmacros.h>
-#undef SSIZE
-#define BLOCK_MAJOR 1
-#define CHAR_MAJOR  1
-#define generic_floppy_struct disk_parms
-int ioctl(int, int, void *);
-
-static int get_parameters(int fd, struct generic_floppy_struct *floppy)
-{
-	mt_off_t off;
-	char buf[512];
-
-	off = lseek(fd, 0, SEEK_CUR);
-	if(off < 0) {
-		perror("device seek 1");
-		exit(1);
-	}
-	if (off == 0) {
-		/* need to read at least 1 sector to get correct info */
-		read(fd, buf, sizeof buf);
-		if(lseek(fd, 0, SEEK_SET) < 0) {
-			perror("device seek 2");
-			exit(1);
-		}
-	}
-	return ioctl(fd, V_GETPARMS, floppy);
-}
-
-#define TRACKS(floppy)  (floppy).dp_cyls
-#define HEADS(floppy)   (floppy).dp_heads
-#define SECTORS(floppy) (floppy).dp_sectors
-#define FD_SECTSIZE(floppy) (floppy).dp_secsiz
-#define FD_SET_SECTSIZE(floppy,v) { (floppy).dp_secsiz = (v); }
-
-static int set_parameters(int fd, struct generic_floppy_struct *floppy,
-	struct stat *buf)
-{
-	return 1;
-}
-
-#define INIT_GENERIC
-#endif
-#endif /* isc */
-
-#ifdef CPU_i370
-#define predefined_devices
-struct device devices[] = {
-	{"/dev/rfd0", "A", GENFD},
-	REMOTE
-};
-#endif /* CPU_i370 */
-
-#ifdef OS_aix
-/* modified by Federico Bianchi */
-#define predefined_devices
-struct device devices[] = {
-	{"/dev/fd0","A",GENFD},
-	REMOTE
-};
-#endif /* aix */
-
-  
-#ifdef OS_osf4
-/* modified by Chris Samuel <chris@rivers.dra.hmg.gb> */
-#define predefined_devices
-struct device devices[] = {
-	{"/dev/fd0c","A",GENFD},
-	REMOTE
-};
-#endif /* OS_osf4 */
-
-
-#ifdef OS_solaris
-
-#ifdef USING_NEW_VOLD
-
-char *alias_name = NULL;
-  
-extern char *media_oldaliases(char *);
-extern char *media_findname(char *);
-
-char *getVoldName(struct device *dev, char *name)
-{
-	char *rname;
-  
-	if(!SHOULD_USE_VOLD(dev))
-		return name;
-
-	/***
-	 * Solaris specific routines to use the volume management
-	 * daemon and libraries to get the correct device name...
-	 ***/
-	rname = media_findname(name);
-#ifdef HAVE_MEDIA_OLDALIASES
-	if (rname == NULL) {
-		if ((alias_name = media_oldaliases(name)) != NULL)
-			rname = media_findname(alias_name);
-	}
-#endif
-	if (rname == NULL) {
-		fprintf(stderr, 
-				"No such volume or no media in device: %s.\n", 
-				name);
-		exit(1);
-	}
-	return rname;
-}
-#endif /* USING_NEW_VOLD */
-
-#define predefined_devices
-struct device devices[] = {
-#ifdef  USING_NEW_VOLD
-	{"floppy", "A", VOLDFD },
-#elif	USING_VOLD
-	{"/vol/dev/aliases/floppy0", "A", GENFD},
-	{"/dev/rdiskette", "B", GENFD},
-#else	/* ! USING_VOLD */
-	{"/dev/rdiskette", "A", GENFD},
-	{"/vol/dev/aliases/floppy0", "B", GENFD},
-#endif	/* USING_VOLD */
-	{"/dev/rdsk/c0t4d0s2", "J", RJAZ(O_NDELAY)},
-	{"/dev/rdsk/c0t5d0s2", "Z", RZIP(O_NDELAY)},
-	REMOTE
-};
-
-
-
-/*
- * Ofer Licht <ofer@stat.Berkeley.EDU>, May 14, 1997.
- */
-
-#define INIT_GENERIC
-
-#include <sys/fdio.h>
-#include <sys/mkdev.h>	/* for major() */
-
-struct generic_floppy_struct
-{
-  struct fd_char fdchar;
-};
-
-#define BLOCK_MAJOR 36
-#define CHAR_MAJOR 36
-
-static inline int get_parameters(int fd, struct generic_floppy_struct *floppy)
-{
-	if (ioctl(fd, FDIOGCHAR, &(floppy->fdchar)) != 0) {
-		perror("");
-		ioctl(fd, FDEJECT, NULL);
-		return(1);
-	}
-	return 0;
-}
-
-#define TRACKS(floppy) floppy.fdchar.fdc_ncyl
-#define HEADS(floppy) floppy.fdchar.fdc_nhead
-#define SECTORS(floppy) floppy.fdchar.fdc_secptrack
-/* SECTORS_PER_DISK(floppy) not used */
-#define FD_SECTSIZE(floppy) floppy.fdchar.fdc_sec_size
-#define FD_SET_SECTSIZE(floppy,v) { floppy.fdchar.fdc_sec_size = v; }
-
-static inline int set_parameters(int fd, struct generic_floppy_struct *floppy, 
-				 struct stat *buf)
-{
-	if (ioctl(fd, FDIOSCHAR, &(floppy->fdchar)) != 0) {
-		ioctl(fd, FDEJECT, NULL);
-		perror("");
-		return(1);
-	}
-	return 0;
-}
-#define INIT_GENERIC
-#endif /* solaris */
-
-#ifdef OS_sunos3
-#define predefined_devices
-struct device devices[] = {
-	{"/dev/rfdl0c",	"A", FDD312},
-	{"/dev/rfd0c",	"A", FHD312},
-	REMOTE
-};
-#endif /* OS_sunos3 */
-
-#ifdef OS_xenix
-#define predefined_devices
-struct device devices[] = {
-	{"/dev/fd096ds15",	"A", FHD514},
-	{"/dev/fd048ds9",	"A", FDD514},
-	{"/dev/fd1135ds18",	"B", FHD312},
-	{"/dev/fd1135ds9",	"B", FDD312},
-	{"/dev/hd0d",		"C", GENHD},
-	REMOTE
-};
-#endif /* OS_xenix */
-
-#ifdef OS_sco
-#define predefined_devices
-struct device devices[] = {
-	{ "/dev/fd0135ds18",	"A", FHD312},
-	{ "/dev/fd0135ds9",	"A", FDD312},
-	{ "/dev/fd0",		"A", GENFD},
-	{ "/dev/fd1135ds15",	"B", FHD514},
-	{ "/dev/fd1135ds9",	"B", FDD514},
-	{ "/dev/fd1",		"B", GENFD},
-	{ "/dev/hd0d",		"C", GENHD},
-	REMOTE
-};
-#endif /* OS_sco */
-
-
-#ifdef OS_irix
-#define predefined_devices
-struct device devices[] = {
-  { "/dev/rdsk/fds0d2.3.5hi",	"A", FHD312},
-  { "/dev/rdsk/fds0d2.3.5",	"A", FDD312},
-  { "/dev/rdsk/fds0d2.96",	"A", FHD514},
-  {"/dev/rdsk/fds0d2.48",	"A", FDD514},
-  REMOTE
-};
-#endif /* OS_irix */
-
-
-#ifdef OS_sunos4
-#include <sys/ioctl.h>
-#include <sun/dkio.h>
-
-#define predefined_devices
-struct device devices[] = {
-	{"/dev/rfd0c",	"A", GENFD},
-	{"/dev/rsd4c",	"J", RJAZ(O_NDELAY)},
-	{"/dev/rsd5c",	"Z", RZIP(O_NDELAY)},
-	REMOTE
-};
-
-/*
- * Stuffing back the floppy parameters into the driver allows for gems
- * like 10 sector or single sided floppies from Atari ST systems.
- * 
- * Martin Schulz, Universite de Moncton, N.B., Canada, March 11, 1991.
- */
-
-#define INIT_GENERIC
-
-struct generic_floppy_struct
-{
-  struct fdk_char dkbuf;
-  struct dk_map dkmap;
-};
-
-#define BLOCK_MAJOR 16
-#define CHAR_MAJOR 54
-
-static inline int get_parameters(int fd, struct generic_floppy_struct *floppy)
-{
-	if (ioctl(fd, DKIOCGPART, &(floppy->dkmap)) != 0) {
-		perror("DKIOCGPART");
-		ioctl(fd, FDKEJECT, NULL);
-		return(1);
-	}
-	
-	if (ioctl(fd, FDKIOGCHAR, &( floppy->dkbuf)) != 0) {
-		perror("");
-		ioctl(fd, FDKEJECT, NULL);
-		return(1);
-	}
-	return 0;
-}
-
-#define TRACKS(floppy) floppy.dkbuf.ncyl
-#define HEADS(floppy) floppy.dkbuf.nhead
-#define SECTORS(floppy) floppy.dkbuf.secptrack
-#define SECTORS_PER_DISK(floppy) floppy.dkmap.dkl_nblk
-#define FD_SECTSIZE(floppy) floppy.dkbuf.sec_size
-#define FD_SET_SECTSIZE(floppy,v) { floppy.dkbuf.sec_size = v; }
-
-static inline int set_parameters(int fd, struct generic_floppy_struct *floppy, 
-				 struct stat *buf)
-{
-	if (ioctl(fd, FDKIOSCHAR, &(floppy->dkbuf)) != 0) {
-		ioctl(fd, FDKEJECT, NULL);
-		perror("");
-		return(1);
-	}
-	
-	if (ioctl(fd, ( unsigned int) DKIOCSPART, &(floppy->dkmap)) != 0) {
-		ioctl(fd, FDKEJECT, NULL);
-		perror("");
-		return(1);
-	}
-	return 0;
-}
-#define INIT_GENERIC
-#endif /* sparc && sunos */
-
-
-#ifdef DPX1000
-#define predefined_devices
-struct device devices[] = {
-	/* [block device]: DPX1000 has /dev/flbm60, DPX2 has /dev/easyfb */
-	{"/dev/flbm60", "A", MHD514};
-	{"/dev/flbm60", "B", MDD514},
-	{"/dev/flbm60", "C", MDDsmall},
-	{"/dev/flbm60", "D", MSS},
-	{"/dev/flbm60", "E", MSSsmall},
-	REMOTE
-};
-#endif /* DPX1000 */
-
-#ifdef OS_bosx
-#define predefined_devices
-struct device devices[] = {
-	/* [block device]: DPX1000 has /dev/flbm60, DPX2 has /dev/easyfb */
-	{"/dev/easyfb", "A", MHD514},
-	{"/dev/easyfb", "B", MDD514},
-	{"/dev/easyfb", "C", MDDsmall},
-	{"/dev/easyfb", "D", MSS},
-	{"/dev/easyfb", "E", MSSsmall},
-	REMOTE
-};
-#endif /* OS_bosx */
-
-#ifdef OS_linux
-
-const char *error_msg[22]={
-"Missing Data Address Mark",
-"Bad cylinder",
-"Scan not satisfied",
-"Scan equal hit",
-"Wrong cylinder",
-"CRC error in data field",
-"Control Mark = deleted",
-0,
-
-"Missing Address Mark",
-"Write Protect",
-"No Data - unreadable",
-0,
-"OverRun",
-"CRC error in data or address",
-0,
-"End Of Cylinder",
-
-0,
-0,
-0,
-"Not ready",
-"Equipment check error",
-"Seek end" };
-
-
-static inline void print_message(RawRequest_t *raw_cmd,const char *message)
-{
-	int i, code;
-	if(!message)
-		return;
-
-	fprintf(stderr,"   ");
-	for (i=0; i< raw_cmd->cmd_count; i++)
-		fprintf(stderr,"%2.2x ", 
-			(int)raw_cmd->cmd[i] );
-	fprintf(stderr,"\n");
-	for (i=0; i< raw_cmd->reply_count; i++)
-		fprintf(stderr,"%2.2x ",
-			(int)raw_cmd->reply[i] );
-	fprintf(stderr,"\n");
-	code = (raw_cmd->reply[0] <<16) + 
-		(raw_cmd->reply[1] << 8) + 
-		raw_cmd->reply[2];
-	for(i=0; i<22; i++){
-		if ((code & (1 << i)) && error_msg[i])
-			fprintf(stderr,"%s\n",
-				error_msg[i]);
-	}
-}
-
-
-/* return values:
- *  -1: Fatal error, don't bother retrying.
- *   0: OK
- *   1: minor error, retry
- */
-
-int send_one_cmd(int fd, RawRequest_t *raw_cmd, const char *message)
-{
-	if (ioctl( fd, FDRAWCMD, raw_cmd) >= 0) {
-		if (raw_cmd->reply_count < 7) {
-			fprintf(stderr,"Short reply from FDC\n");
-			return -1;
-		}		
-		return 0;
-	}
-
-	switch(errno) {
-		case EBUSY:
-			fprintf(stderr, "FDC busy, sleeping for a second\n");
-			sleep(1);
-			return 1;
-		case EIO:
-			fprintf(stderr,"resetting controller\n");
-			if(ioctl(fd, FDRESET, 2)  < 0){
-				perror("reset");
-				return -1;
-			}
-			return 1;
-		default:
-			perror(message);
-			return -1;
-	}
-}
-
-
-/*
- * return values
- *  -1: error
- *   0: OK, last sector
- *   1: more raw commands follow
- */
-
-int analyze_one_reply(RawRequest_t *raw_cmd, int *bytes, int do_print)
-{
-	
-	if(raw_cmd->reply_count == 7) {
-		int end;
-		
-		if (raw_cmd->reply[3] != raw_cmd->cmd[2]) {
-			/* end of cylinder */
-			end = raw_cmd->cmd[6] + 1;
-		} else {
-			end = raw_cmd->reply[5];
-		}
-
-		*bytes = end - raw_cmd->cmd[4];
-		/* FIXME: over/under run */
-		*bytes = *bytes << (7 + raw_cmd->cmd[5]);
-	} else
-		*bytes = 0;       
-
-	switch(raw_cmd->reply[0] & 0xc0){
-		case 0x40:
-			if ((raw_cmd->reply[0] & 0x38) == 0 &&
-			    (raw_cmd->reply[1]) == 0x80 &&
-			    (raw_cmd->reply[2]) == 0) {
-				*bytes += 1 << (7 + raw_cmd->cmd[5]);
-				break;
-			}
-
-			if ( raw_cmd->reply[1] & ST1_WP ){
-				*bytes = 0;
-				fprintf(stderr,
-					"This disk is write protected\n");
-				return -1;
-			}
-			if(!*bytes && do_print)
-				print_message(raw_cmd, "");
-			return -1;
-		case 0x80:
-			*bytes = 0;
-			fprintf(stderr,
-				"invalid command given\n");
-			return -1;
-		case 0xc0:
-			*bytes = 0;
-			fprintf(stderr,
-				"abnormal termination caused by polling\n");
-			return -1;
-		default:
-			break;
-	}	
-#ifdef FD_RAW_MORE
-	if(raw_cmd->flags & FD_RAW_MORE)
-		return 1;
-#endif
-	return 0;
-}
-
-#define predefined_devices
-struct device devices[] = {
-	{"/dev/fd0", "A", 0, O_EXCL, 80,2, 18,0, MDEF_ARG},
-	{"/dev/fd1", "B", 0, O_EXCL, 0,0, 0,0, FDEF_ARG},
-	/* we assume that the Zip or Jaz drive is the second on the SCSI bus */
-	{"/dev/sdb4","J", GENHD },
-	{"/dev/sdb4","Z", GENHD },
-	/*	{"/dev/sda4","D", GENHD },*/
-	REMOTE
-};
-
-/*
- * Stuffing back the floppy parameters into the driver allows for gems
- * like 21 sector or single sided floppies from Atari ST systems.
- * 
- * Alain Knaff, Université Joseph Fourier, France, November 12, 1993.
- */
-
-
-#define INIT_GENERIC
-#define generic_floppy_struct floppy_struct
-#define BLOCK_MAJOR 2
-#define SECTORS(floppy) floppy.sect
-#define TRACKS(floppy) floppy.track
-#define HEADS(floppy) floppy.head
-#define SECTORS_PER_DISK(floppy) floppy.size
-#define STRETCH(floppy) floppy.stretch
-#define USE_2M(floppy) ((floppy.rate & FD_2M) ? 0xff : 0x80 )
-#define SSIZE(floppy) ((((floppy.rate & 0x38) >> 3 ) + 2) % 8)
-
-static inline void set_2m(struct floppy_struct *floppy, int value)
-{
-	if (value & 0x7f)
-		value = FD_2M;
-	else
-		value = 0;
-	floppy->rate = (floppy->rate & ~FD_2M) | value;       
-}
-#define SET_2M set_2m
-
-static inline void set_ssize(struct floppy_struct *floppy, int value)
-{
-	value = (( (value & 7) + 6 ) % 8) << 3;
-
-	floppy->rate = (floppy->rate & ~0x38) | value;	
-}
-
-#define SET_SSIZE set_ssize
-
-static inline int set_parameters(int fd, struct floppy_struct *floppy, 
-				 struct stat *buf)
-{
-	if ( ( MINOR(buf->st_rdev ) & 0x7f ) > 3 )
-		return 1;
-	
-	return ioctl(fd, FDSETPRM, floppy);
-}
-
-static inline int get_parameters(int fd, struct floppy_struct *floppy)
-{
-	return ioctl(fd, FDGETPRM, floppy);
-}
-
-#endif /* linux */
-
-
-/* OS/2, gcc+emx */
-#ifdef __EMX__
-#define predefined_devices
-struct device devices[] = {
-  {"A:", "A", GENFD},
-  {"B:", "B", GENFD},
-};
-#define INIT_NOOP
-#endif
-
-
-
-/*** /jes -- for D.O.S. 486 BL DX2/80 ***/
-#ifdef OS_freebsd
-#define predefined_devices
-struct device devices[] = {
-	{"/dev/rfd0.1440", "A", FHD312},
-	{"/dev/rfd0.720",  "A", FDD312},
-	{"/dev/rfd1.1200", "B", MHD514},
-	{"/dev/sd0s1",     "C", GENHD},
-	REMOTE
-};
-#endif /* __FreeBSD__ */
- 
-/*** /jes -- for ALR 486 DX4/100 ***/
-#if defined(OS_netbsd)
-#define predefined_devices
-struct device devices[] = {
-	{"/dev/rfd0a", "A", FHD312},
-	{"/dev/rfd0f", "A", FDD312},
-	{"/dev/rfd0f", "S", MDD312},
-	{"/dev/rfd1a", "B", FHD514},
-	{"/dev/rfd1d", "B", FDD514},
-	{"/dev/rfd1d", "T", MDD514},
-	{"/dev/rwd0d", "C", 16, 0, 0, 0, 0, 0, 63L*512L, DEF_ARG0(0)},
-	REMOTE
-};
-#endif /* OS_NetBSD */
-
-/* fgsch@openbsd.org 2000/05/19 */
-#if defined(OS_openbsd)
-#define predefined_devices
-struct device devices[] = {
-	{"/dev/rfd0Bc", "A", FHD312},
-	{"/dev/rfd0Fc", "A", FDD312},
-	{"/dev/rfd1Cc", "B", FHD514},
-	{"/dev/rfd1Dc", "B", FDD514},
-	{"/dev/rwd0c", "C", 16, 0, 0, 0, 0, 0, 63L*512L, DEF_ARG0(0)},
-	REMOTE
-};
-#endif /* OS_openbsd */
-
-
-
-#if (!defined(predefined_devices) && defined (CPU_m68000) && defined (OS_sysv))
-#include <sys/gdioctl.h>
-
-#define predefined_devices
-struct device devices[] = {
-	{"/dev/rfp020",		"A", 12,O_NDELAY,40,2, 9, 0, MDEF_ARG},
-	{"/usr/bin/DOS/dvd000", "C", GENFD},
-	REMOTE
-};
-
-#undef INIT_NOOP
-int init_geom(int fd, struct device *dev, struct device *orig_dev,
-	      struct stat *stat)
-{
-	struct gdctl gdbuf;
-
-	if (ioctl(fd, GDGETA, &gdbuf) == -1) {
-		ioctl(fd, GDDISMNT, &gdbuf);
-		return 1;
-	}
-	if((dev->use_2m & 0x7f) || (dev->ssize & 0x7f))
-		return 1;
-	
-	SET_INT(gdbuf.params.cyls,dev->ntracks);
-	SET_INT(gdbuf.params.heads,dev->nheads);
-	SET_INT(gdbuf.params.psectrk,dev->nsect);
-	dev->ntracks = gdbuf.params.cyls;
-	dev->nheads = gdbuf.params.heads;
-	dev->nsect = gdbuf.params.psectrk;
-	dev->use_2m = 0x80;
-	dev->ssize = 0x82;
-
-	gdbuf.params.pseccyl = gdbuf.params.psectrk * gdbuf.params.heads;
-	gdbuf.params.flags = 1;		/* disk type flag */
-	gdbuf.params.step = 0;		/* step rate for controller */
-	gdbuf.params.sectorsz = 512;	/* sector size */
-
-	if (ioctl(fd, GDSETA, &gdbuf) < 0) {
-		ioctl(fd, GDDISMNT, &gdbuf);
-		return(1);
-	}
-	return(0);
-}
-#endif /* (defined (m68000) && defined (sysv))*/
-
-#ifdef CPU_alpha
-#ifndef OS_osf4
-#ifdef __osf__
-#include <sys/fcntl.h>
-#define predefined_devices
-struct device devices[] = {
-	{"/dev/rfd0c",		"A", GENFD},
-	REMOTE
-};
-#endif
-#endif
-#endif
-
-#ifdef OS_osf
-#ifndef predefined_devices
-#define predefined_devices
-struct device devices[] = {
-	{"/dev/fd0a", "A",  MHD312 } };
-	REMOTE
-#endif
-#endif
-
-
-#ifdef OS_nextstep
-#define predefined_devices
-struct device devices[] = {
-#ifdef CPU_m68k
-	{"/dev/rfd0b", "A", MED312 },
-	REMOTE
-#else
-	{"/dev/rfd0b", "A", MHD312 },
-	REMOTE
-#endif
-};
-#endif
-
-
-#if (!defined(predefined_devices) && defined(OS_sysv4))
-#ifdef __uxp__
-#define predefined_devices
-struct device devices[] = {
-      {"/dev/fpd0",   "A", FHD312},
-      {"/dev/fpd0",   "A", FDD312},
-	  REMOTE
-};
-#else
-#define predefined_devices
-struct device devices[] = {
-	{"/dev/rdsk/f1q15dt",	"B", FHD514},
-	{"/dev/rdsk/f1d9dt",	"B", FDD514},
-	{"/dev/rdsk/f1d8dt",	"B", FDDsmall},
-	{"/dev/rdsk/f03ht",	"A", FHD312},
-	{"/dev/rdsk/f03dt",	"A", FDD312},
-	{"/dev/rdsk/dos",	"C", GENHD},
-	REMOTE
-};
-#endif
-#endif /* sysv4 */
-
-#ifdef OS_Minix
-/* Minix and Minix-vmd device list.  Only present to attach the A: and B:
- * drive letters to the floppies by default.  Other devices can be given
- * a drive letter by linking the device file to /dev/dosX, where X is a
- * drive letter.  Or one can use something like 'fd0:' for a drive name.
- *						Kees J. Bot <kjb@cs.vu.nl>
- */
-#include <minix/partition.h>
-#include <minix/u64.h>
-
-#define predefined_devices
-struct device devices[] = {
-	{"/dev/fd0", "A", GEN},
-	{"/dev/fd1", "B", GEN},
-};
-
-#undef INIT_NOOP
-int init_geom(int fd, struct device *dev, struct device *orig_dev,
-	      struct stat *stat)
-{
-	/* Try to obtain the device parameters from the device driver.
-	 * Don't fret if you can't, mtools will use the DOS boot block.
-	 */
-	struct partition geom;
-	unsigned long tot_sectors;
-
-	if (ioctl(fd, DIOCGETP, &geom) == 0) {
-		dev->hidden = div64u(geom.base, 512);
-		tot_sectors = div64u(geom.size, 512);
-		dev->tracks = tot_sectors / (geom.heads * geom.sectors);
-		dev->heads = geom.heads;
-		dev->sectors = geom.sectors;
-	}
-	return(0);
-}
-#endif /* OS_Minix */
-
-#ifdef INIT_GENERIC
-
-#ifndef USE_2M
-#define USE_2M(x) 0x80
-#endif
-
-#ifndef SSIZE
-#define SSIZE(x) 0x82
-#endif
-
-#ifndef SET_2M
-#define SET_2M(x,y) return -1
-#endif
-
-#ifndef SET_SSIZE
-#define SET_SSIZE(x,y) return -1
-#endif
-
-#undef INIT_NOOP
-int init_geom(int fd, struct device *dev, struct device *orig_dev,
-	      struct stat *stat)
-{
-	struct generic_floppy_struct floppy;
-	int change;
-	
-	/* 
-	 * succeed if we don't have a floppy
-	 * this is the case for dosemu floppy image files for instance
-	 */
-	if (!((S_ISBLK(stat->st_mode) && major(stat->st_rdev) == BLOCK_MAJOR)
-#ifdef CHAR_MAJOR
-	      || (S_ISCHR(stat->st_mode) && major(stat->st_rdev) == CHAR_MAJOR) 
-#endif
-		))
-		return compare_geom(dev, orig_dev);
-	
-	/*
-	 * We first try to get the current floppy parameters from the kernel.
-	 * This allows us to
-	 * 1. get the rate
-	 * 2. skip the parameter setting if the parameters are already o.k.
-	 */
-	
-	if (get_parameters( fd, & floppy ) )
-		/* 
-		 * autodetection failure.
-		 * This mostly occurs because of an absent or unformatted disks.
-		 *
-		 * It might also occur because of bizarre formats (for example 
-		 * rate 1 on a 3 1/2 disk).
-
-		 * If this is the case, the user should do an explicit 
-		 * setfdprm before calling mtools
-		 *
-		 * Another cause might be pre-existing wrong parameters. The 
-		 * user should do an setfdprm -c to repair this situation.
-		 *
-		 * ...fail immediately... ( Theoretically, we could try to save
-		 * the situation by trying out all rates, but it would be slow 
-		 * and awkward)
-		 */
-		return 1;
-
-
-	/* 
-	 * if we have already have the correct parameters, keep them.
-	 * the number of tracks doesn't need to match exactly, it may be bigger.
-	 * the number of heads and sectors must match exactly, to avoid 
-	 * miscalculation of the location of a block on the disk
-	 */
-	change = 0;
-	if(compare(dev->sectors, SECTORS(floppy))){
-		SECTORS(floppy) = dev->sectors;
-		change = 1;
-	} else
-		dev->sectors = SECTORS(floppy);
-
-	if(compare(dev->heads, HEADS(floppy))){
-		HEADS(floppy) = dev->heads;
-		change = 1;
-	} else
-		dev->heads = HEADS(floppy);
-	 
-	if(compare(dev->tracks, TRACKS(floppy))){
-		TRACKS(floppy) = dev->tracks;
-		change = 1;
-	} else
-		dev->tracks = TRACKS(floppy);
-
-
-	if(compare(dev->use_2m, USE_2M(floppy))){
-		SET_2M(&floppy, dev->use_2m);
-		change = 1;
-	} else
-		dev->use_2m = USE_2M(floppy);
-	
-	if( ! (dev->ssize & 0x80) )
-		dev->ssize = 0;
-	if(compare(dev->ssize, SSIZE(floppy) + 128)){
-		SET_SSIZE(&floppy, dev->ssize);
-		change = 1;
-	} else
-		dev->ssize = SSIZE(floppy);
-
-	if(!change)
-		/* no change, succeed */
-		return 0;
-
-#ifdef SECTORS_PER_TRACK
-	SECTORS_PER_TRACK(floppy) = dev->sectors * dev->heads;
-#endif
-
-#ifdef SECTORS_PER_DISK
-	SECTORS_PER_DISK(floppy) = dev->sectors * dev->heads * dev->tracks;
-#endif
-	
-#ifdef STRETCH
-	/* ... and the stretch */
-	if ( dev->tracks > 41 ) 
-		STRETCH(floppy) = 0;
-	else
-		STRETCH(floppy) = 1;
-#endif
-	
-	return set_parameters( fd, &floppy, stat) ;
-}
-#endif /* INIT_GENERIC */  
-
-#ifdef INIT_NOOP
-int init_geom(int fd, struct device *dev, struct device *orig_dev,
-			  struct stat *stat)
-{
-	return compare_geom(dev, orig_dev);
-}
-#endif
-
-#ifdef predefined_devices
-const int nr_const_devices = sizeof(const_devices) / sizeof(*const_devices);
-#else
-struct device devices[]={
-	{"/dev/fd0", "A", 0, O_EXCL, 0,0, 0,0, MDEF_ARG},
-	/* to shut up Ultrix's native compiler, we can't make this empty :( */
-};
-const nr_const_devices = 0;
-#endif
Index: trunk/minix/commands/i386/mtools-3.9.7/devices.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/devices.h	(revision 9)
+++ 	(revision )
@@ -1,169 +1,0 @@
-#ifdef OS_linux
-
-#ifdef HAVE_SYS_SYSMACROS_H
-
-#include <sys/sysmacros.h>
-#ifndef MAJOR
-#define MAJOR(dev) major(dev)
-#endif  /* MAJOR not defined */
-#ifndef MINOR
-#define MINOR(dev) minor(dev)
-#endif  /* MINOR not defined */
-
-#else
- 
-#include <linux/fs.h>        /* get MAJOR/MINOR from Linux kernel */
-#ifndef major
-#define major(x) MAJOR(x)
-#endif
-
-#endif /* HAVE_SYS_SYSMACROS_H */
-
-#include <linux/fd.h>
-#include <linux/fdreg.h>
-#include <linux/major.h>
-
-
-typedef struct floppy_raw_cmd RawRequest_t;
-
-UNUSED(static inline void RR_INIT(struct floppy_raw_cmd *request))
-{
-	request->data = 0;
-	request->length = 0;
-	request->cmd_count = 9;
-	request->flags = FD_RAW_INTR | FD_RAW_NEED_SEEK | FD_RAW_NEED_DISK
-#ifdef FD_RAW_SOFTFAILUE
-		| FD_RAW_SOFTFAILURE | FD_RAW_STOP_IF_FAILURE
-#endif
-		;
-	request->cmd[1] = 0;
-	request->cmd[6] = 0;
-	request->cmd[7] = 0x1b;
-	request->cmd[8] = 0xff;
-	request->reply_count = 0;
-}
-
-UNUSED(static inline void RR_SETRATE(struct floppy_raw_cmd *request, int rate))
-{
-	request->rate = rate;
-}
-
-UNUSED(static inline void RR_SETDRIVE(struct floppy_raw_cmd *request,int drive))
-{
-	request->cmd[1] = (request->cmd[1] & ~3) | (drive & 3);
-}
-
-UNUSED(static inline void RR_SETTRACK(struct floppy_raw_cmd *request,int track))
-{
-	request->cmd[2] = track;
-}
-
-UNUSED(static inline void RR_SETPTRACK(struct floppy_raw_cmd *request,
-				       int track))
-{
-	request->track = track;
-}
-
-UNUSED(static inline void RR_SETHEAD(struct floppy_raw_cmd *request, int head))
-{
-	if(head)
-		request->cmd[1] |= 4;
-	else
-		request->cmd[1] &= ~4;
-	request->cmd[3] = head;
-}
-
-UNUSED(static inline void RR_SETSECTOR(struct floppy_raw_cmd *request, 
-				       int sector))
-{
-	request->cmd[4] = sector;
-	request->cmd[6] = sector-1;
-}
-
-UNUSED(static inline void RR_SETSIZECODE(struct floppy_raw_cmd *request, 
-					 int sizecode))
-{
-	request->cmd[5] = sizecode;
-	request->cmd[6]++;
-	request->length += 128 << sizecode;
-}
-
-#if 0
-static inline void RR_SETEND(struct floppy_raw_cmd *request, int end)
-{
-	request->cmd[6] = end;
-}
-#endif
-
-UNUSED(static inline void RR_SETDIRECTION(struct floppy_raw_cmd *request, 
-					  int direction))
-{
-	if(direction == MT_READ) {
-		request->flags |= FD_RAW_READ;
-		request->cmd[0] = FD_READ & ~0x80;
-	} else {
-		request->flags |= FD_RAW_WRITE;
-		request->cmd[0] = FD_WRITE & ~0x80;
-	}
-}
-
-
-UNUSED(static inline void RR_SETDATA(struct floppy_raw_cmd *request, 
-				     caddr_t data))
-{
-	request->data = data;
-}
-
-
-#if 0
-static inline void RR_SETLENGTH(struct floppy_raw_cmd *request, int length)
-{
-	request->length += length;
-}
-#endif
-
-UNUSED(static inline void RR_SETCONT(struct floppy_raw_cmd *request))
-{
-#ifdef FD_RAW_MORE
-	request->flags |= FD_RAW_MORE;
-#endif
-}
-
-
-UNUSED(static inline int RR_SIZECODE(struct floppy_raw_cmd *request))
-{
-	return request->cmd[5];
-}
-
-
-
-UNUSED(static inline int RR_TRACK(struct floppy_raw_cmd *request))
-{
-	return request->cmd[2];
-}
-
-
-UNUSED(static inline int GET_DRIVE(int fd))
-{
-	struct stat statbuf;
-
-	if (fstat(fd, &statbuf) < 0 ){
-		perror("stat");
-		return -1;
-	}
-	  
-	if (!S_ISBLK(statbuf.st_mode) ||
-	    MAJOR(statbuf.st_rdev) != FLOPPY_MAJOR)
-		return -1;
-	
-	return MINOR( statbuf.st_rdev );
-}
-
-
-
-/* void print_message(RawRequest_t *raw_cmd,char *message);*/
-int send_one_cmd(int fd, RawRequest_t *raw_cmd, const char *message);
-int analyze_one_reply(RawRequest_t *raw_cmd, int *bytes, int do_print);
-
-
-#endif
Index: trunk/minix/commands/i386/mtools-3.9.7/dirCache.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/dirCache.c	(revision 9)
+++ 	(revision )
@@ -1,329 +1,0 @@
-#include "sysincludes.h"
-#include "vfat.h"
-#include "dirCache.h"
-
-
-void myfree(void *a)
-{
-	free(a);
-}
-
-#define free myfree
-
-
-#define BITS_PER_INT (sizeof(unsigned int) * 8)
-
-
-static inline unsigned int rol(unsigned int arg, int shift)
-{
-	arg &= 0xffffffff; /* for 64 bit machines */
-	return (arg << shift) | (arg >> (32 - shift));
-}
-
-
-static int calcHash(char *name)
-{
-	unsigned long hash;
-	int i;
-	unsigned char c;
-
-	hash = 0;
-	i = 0;
-	while(*name) {
-		/* rotate it */
-		hash = rol(hash,5); /* a shift of 5 makes sure we spread quickly
-				     * over the whole width, moreover, 5 is
-				     * prime with 32, which makes sure that
-				     * successive letters cannot cover each 
-				     * other easily */
-		c = toupper(*name);
-		hash ^=  (c * (c+2)) ^ (i * (i+2));
-		hash &= 0xffffffff;
-		i++, name++;
-	}
-	hash = hash * (hash + 2);
-	/* the following two xors make sure all info is spread evenly over all
-	 * bytes. Important if we only keep the low order bits later on */
-	hash ^= (hash & 0xfff) << 12;
-	hash ^= (hash & 0xff000) << 24;
-	return hash;
-}
-
-static int addBit(unsigned int *bitmap, int hash, int checkOnly)
-{
-	int bit, entry;
-
-	bit = 1 << (hash % BITS_PER_INT);
-	entry = (hash / BITS_PER_INT) % DC_BITMAP_SIZE;
-	
-	if(checkOnly)
-		return bitmap[entry] & bit;
-	else {
-		bitmap[entry] |= bit;
-		return 1;
-	}
-}
-
-static int _addHash(dirCache_t *cache, unsigned int hash, int checkOnly)
-{
-	return
-		addBit(cache->bm0, hash, checkOnly) &&
-		addBit(cache->bm1, rol(hash,12), checkOnly) &&
-		addBit(cache->bm2, rol(hash,24), checkOnly);
-}
-
-
-static void addNameToHash(dirCache_t *cache, char *name)
-{	
-	_addHash(cache, calcHash(name), 0);
-}
-
-static void hashDce(dirCache_t *cache, dirCacheEntry_t *dce)
-{
-	if(dce->beginSlot != cache->nrHashed)
-		return;
-	cache->nrHashed = dce->endSlot;
-	if(dce->longName)
-		addNameToHash(cache, dce->longName);
-	addNameToHash(cache, dce->shortName);
-}
-
-int isHashed(dirCache_t *cache, char *name)
-{
-	int ret;
-
-	ret =  _addHash(cache, calcHash(name), 1);
-	return ret;
-}
-
-void checkXYZ(dirCache_t *cache)
-{
-	if(cache->entries[2])
-		printf(" at 2 = %d\n", cache->entries[2]->beginSlot);
-}
-
-
-int growDirCache(dirCache_t *cache, int slot)
-{
-	if(slot < 0) {
-		fprintf(stderr, "Bad slot %d\n", slot);
-		exit(1);
-	}
-
-	if( cache->nr_entries <= slot) {
-		int i;
-		
-		cache->entries = realloc(cache->entries,
-					 (slot+1) * 2 * 
-					 sizeof(dirCacheEntry_t *));
-		if(!cache->entries)
-			return -1;
-		for(i= cache->nr_entries; i < (slot+1) * 2; i++) {
-			cache->entries[i] = 0;
-		}
-		cache->nr_entries = (slot+1) * 2;
-	}
-	return 0;
-}
-
-dirCache_t *allocDirCache(Stream_t *Stream, int slot)
-{       
-	dirCache_t **dcp;
-
-	if(slot < 0) {
-		fprintf(stderr, "Bad slot %d\n", slot);
-		exit(1);
-	}
-
-	dcp = getDirCacheP(Stream);
-	if(!*dcp) {
-		*dcp = New(dirCache_t);
-		if(!*dcp)
-			return 0;
-		(*dcp)->entries = NewArray((slot+1)*2+5, dirCacheEntry_t *);
-		if(!(*dcp)->entries) {
-			free(*dcp);
-			return 0;
-		}
-		(*dcp)->nr_entries = (slot+1) * 2;
-		memset( (*dcp)->bm0, 0, DC_BITMAP_SIZE);
-		memset( (*dcp)->bm1, 0, DC_BITMAP_SIZE);
-		memset( (*dcp)->bm2, 0, DC_BITMAP_SIZE);
-		(*dcp)->nrHashed = 0;
-	} else
-		if(growDirCache(*dcp, slot) < 0)
-			return 0;
-	return *dcp;
-}
-
-static void freeDirCacheRange(dirCache_t *cache, int beginSlot, int endSlot)
-{
-	dirCacheEntry_t *entry;
-	int clearBegin;
-	int clearEnd;
-	int i;
-
-	if(endSlot < beginSlot) {
-		fprintf(stderr, "Bad slots %d %d in free range\n", 
-			beginSlot, endSlot);
-		exit(1);
-	}
-
-	while(beginSlot < endSlot) {
-		entry = cache->entries[beginSlot];
-		if(!entry) {
-			beginSlot++;
-			continue;
-		}
-		
-		clearEnd = entry->endSlot;
-		if(clearEnd > endSlot)
-			clearEnd = endSlot;
-		clearBegin = beginSlot;
-		
-		for(i = clearBegin; i <clearEnd; i++)
-			cache->entries[i] = 0;
-
-		if(entry->endSlot == endSlot)
-			entry->endSlot = beginSlot;
-		else if(entry->beginSlot == beginSlot)
-			entry->beginSlot = endSlot;
-		else {
-			fprintf(stderr, 
-				"Internal error, non contiguous de-allocation\n");
-			fprintf(stderr, "%d %d\n", beginSlot, endSlot);
-			fprintf(stderr, "%d %d\n", entry->beginSlot, 
-				entry->endSlot);
-			exit(1);			
-		}
-
-		if(entry->beginSlot == entry->endSlot) {
-			if(entry->longName)
-				free(entry->longName);
-			if(entry->shortName)
-				free(entry->shortName);
-			free(entry);
-		}
-
-		beginSlot = clearEnd;
-	}
-}
-
-static dirCacheEntry_t *allocDirCacheEntry(dirCache_t *cache, int beginSlot, 
-					   int endSlot,
-					   dirCacheEntryType_t type)
-{
-	dirCacheEntry_t *entry;
-	int i;
-
-	if(growDirCache(cache, endSlot) < 0)
-		return 0;
-
-	entry = New(dirCacheEntry_t);
-	if(!entry)
-		return 0;
-	entry->type = type;
-	entry->longName = 0;
-	entry->shortName = 0;
-	entry->beginSlot = beginSlot;
-	entry->endSlot = endSlot;
-
-	freeDirCacheRange(cache, beginSlot, endSlot);
-	for(i=beginSlot; i<endSlot; i++) {
-		cache->entries[i] = entry;
-	}
-	return entry;
-}
-
-dirCacheEntry_t *addUsedEntry(dirCache_t *cache, int beginSlot, int endSlot, 
-			      char *longName, char *shortName,
-			      struct directory *dir)
-{
-	dirCacheEntry_t *entry;
-
-	if(endSlot < beginSlot) {
-		fprintf(stderr, 
-			"Bad slots %d %d in add used entry\n", 
-			beginSlot, endSlot);
-		exit(1);
-	}
-
-
-	entry = allocDirCacheEntry(cache, beginSlot, endSlot, DCET_USED);
-	if(!entry)
-		return 0;
-	
-	entry->beginSlot = beginSlot;
-	entry->endSlot = endSlot;
-	if(longName)
-		entry->longName = strdup(longName);
-	entry->shortName = strdup(shortName);
-	entry->dir = *dir;
-	hashDce(cache, entry);
-	return entry;
-}
-
-static void mergeFreeSlots(dirCache_t *cache, int slot)
-{
-	dirCacheEntry_t *previous, *next;
-	int i;
-
-	if(slot == 0)
-		return;
-	previous = cache->entries[slot-1];
-	next = cache->entries[slot];
-	if(next && next->type == DCET_FREE &&
-	   previous && previous->type == DCET_FREE) {
-		for(i=next->beginSlot; i < next->endSlot; i++)
-			cache->entries[i] = previous;
-		previous->endSlot = next->endSlot;
-		free(next);		
-	}
-}
-
-dirCacheEntry_t *addFreeEntry(dirCache_t *cache, int beginSlot, int endSlot)
-{
-	dirCacheEntry_t *entry;
-
-	if(beginSlot < cache->nrHashed)
-		cache->nrHashed = beginSlot;
-
-	if(endSlot < beginSlot) {
-		fprintf(stderr, "Bad slots %d %d in add free entry\n", 
-			beginSlot, endSlot);
-		exit(1);
-	}
-
-	if(endSlot == beginSlot)
-		return 0;
-	entry = allocDirCacheEntry(cache, beginSlot, endSlot, DCET_FREE);
-	mergeFreeSlots(cache, beginSlot);
-	mergeFreeSlots(cache, endSlot);
-	return cache->entries[beginSlot];
-}
-
-
-dirCacheEntry_t *addEndEntry(dirCache_t *cache, int pos)
-{
-	return allocDirCacheEntry(cache, pos, pos+1, DCET_END);
-}
-
-dirCacheEntry_t *lookupInDircache(dirCache_t *cache, int pos)
-{
-	if(growDirCache(cache, pos+1) < 0)
-		return 0;
-	return cache->entries[pos];	
-}
-
-void freeDirCache(Stream_t *Stream)
-{
-	dirCache_t *cache, **dcp;
-
-	dcp = getDirCacheP(Stream);
-	cache = *dcp;
-	if(cache) {
-		freeDirCacheRange(cache, 0, cache->nr_entries);
-		free(cache);
-		*dcp = 0;
-	}
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/dirCache.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/dirCache.h	(revision 9)
+++ 	(revision )
@@ -1,40 +1,0 @@
-#ifndef MTOOLS_DIRCACHE_H
-#define MTOOLS_DIRCACHE_H
-
-typedef enum {
-	DCET_FREE,
-	DCET_USED,
-	DCET_END
-} dirCacheEntryType_t;
-
-#define DC_BITMAP_SIZE 128
-
-typedef struct dirCacheEntry_t {
-	dirCacheEntryType_t type;
-	int beginSlot;
-	int endSlot;
-	char *shortName;
-	char *longName;
-	struct directory dir;
-} dirCacheEntry_t;
-
-typedef struct dirCache_t {
-	struct dirCacheEntry_t **entries;
-	int nr_entries;
-	unsigned int nrHashed;
-	unsigned int bm0[DC_BITMAP_SIZE];
-	unsigned int bm1[DC_BITMAP_SIZE];
-	unsigned int bm2[DC_BITMAP_SIZE];
-} dirCache_t;
-
-int isHashed(dirCache_t *cache, char *name);
-int growDirCache(dirCache_t *cache, int slot);
-dirCache_t *allocDirCache(Stream_t *Stream, int slot);
-dirCacheEntry_t *addUsedEntry(dirCache_t *Stream, int begin, int end, 
-			      char *longName, char *shortName,
-			      struct directory *dir);
-void freeDirCache(Stream_t *Stream);
-dirCacheEntry_t *addFreeEntry(dirCache_t *Stream, int begin, int end);
-dirCacheEntry_t *addEndEntry(dirCache_t *Stream, int pos);
-dirCacheEntry_t *lookupInDircache(dirCache_t *Stream, int pos);
-#endif
Index: trunk/minix/commands/i386/mtools-3.9.7/directory.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/directory.c	(revision 9)
+++ 	(revision )
@@ -1,106 +1,0 @@
-#include "sysincludes.h"
-#include "msdos.h"
-#include "stream.h"
-#include "mtools.h"
-#include "file.h"
-#include "fs.h"
-
-/* #define DEBUG */
-
-/*
- * Read a directory entry into caller supplied buffer
- */
-struct directory *dir_read(direntry_t *entry, int *error)
-{
-	int n;
-	*error = 0;
-	if((n=force_read(entry->Dir, (char *) (&entry->dir), 
-			 (mt_off_t) entry->entry * MDIR_SIZE, 
-			 MDIR_SIZE)) != MDIR_SIZE) {
-		if (n < 0) {
-			*error = -1;
-		}
-		return NULL;
-	}
-	return &entry->dir;
-}
-
-/*
- * Make a subdirectory grow in length.  Only subdirectories (not root)
- * may grow.  Returns a 0 on success, 1 on failure (disk full), or -1
- * on error.
- */
-
-int dir_grow(Stream_t *Dir, int size)
-{
-	Stream_t *Stream = GetFs(Dir);
-	DeclareThis(FsPublic_t);
-	int ret;
-	int buflen;
-	char *buffer;
-	
-	if (!getfreeMinClusters(Dir, 1))
-		return -1;
-
-	buflen = This->cluster_size * This->sector_size;
-
-	if(! (buffer=malloc(buflen)) ){
-		perror("dir_grow: malloc");
-		return -1;
-	}
-		
-	memset((char *) buffer, '\0', buflen);
-	ret = force_write(Dir, buffer, (mt_off_t) size * MDIR_SIZE, buflen);
-	free(buffer);
-	if(ret < buflen)
-		return -1;
-	return 0;
-}
-
-
-void low_level_dir_write(direntry_t *entry)
-{
-	force_write(entry->Dir, 
-		    (char *) (&entry->dir), 
-		    (mt_off_t) entry->entry * MDIR_SIZE, MDIR_SIZE);
-}
-
-
-/*
- * Make a directory entry.  Builds a directory entry based on the
- * name, attribute, starting cluster number, and size.  Returns a pointer
- * to a static directory structure.
- */
-
-struct directory *mk_entry(const char *filename, char attr,
-			   unsigned int fat, size_t size, time_t date,
-			   struct directory *ndir)
-{
-	struct tm *now;
-	time_t date2 = date;
-	unsigned char hour, min_hi, min_low, sec;
-	unsigned char year, month_hi, month_low, day;
-
-	now = localtime(&date2);
-	strncpy(ndir->name, filename, 8);
-	strncpy(ndir->ext, filename + 8, 3);
-	ndir->attr = attr;
-	ndir->ctime_ms = 0;
-	hour = now->tm_hour << 3;
-	min_hi = now->tm_min >> 3;
-	min_low = now->tm_min << 5;
-	sec = now->tm_sec / 2;
-	ndir->ctime[1] = ndir->time[1] = hour + min_hi;
-	ndir->ctime[0] = ndir->time[0] = min_low + sec;
-	year = (now->tm_year - 80) << 1;
-	month_hi = (now->tm_mon + 1) >> 3;
-	month_low = (now->tm_mon + 1) << 5;
-	day = now->tm_mday;
-	ndir -> adate[1] = ndir->cdate[1] = ndir->date[1] = year + month_hi;
-	ndir -> adate[0] = ndir->cdate[0] = ndir->date[0] = month_low + day;
-
-	set_word(ndir->start, fat & 0xffff);
-	set_word(ndir->startHi, fat >> 16);
-	set_dword(ndir->size, size);
-	return ndir;
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/direntry.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/direntry.c	(revision 9)
+++ 	(revision )
@@ -1,119 +1,0 @@
-#include "sysincludes.h"
-#include "msdos.h"
-#include "stream.h"
-#include "file.h"
-#include "mtoolsDirent.h"
-
-void initializeDirentry(direntry_t *entry, Stream_t *Dir)
-{
-	entry->entry = -1;
-/*	entry->parent = getDirentry(Dir);*/
-	entry->Dir = Dir;
-	entry->beginSlot = 0;
-	entry->endSlot = 0;
-}
-
-int isNotFound(direntry_t *entry)
-{
-	return entry->entry == -2;
-}
-
-void rewindEntry(direntry_t *entry)
-{
-	entry->entry = -1;
-}
-
-
-direntry_t *getParent(direntry_t *entry)
-{
-	return getDirentry(entry->Dir);
-}
-
-
-static int getPathLen(direntry_t *entry)
-{
-	int length=0;
-
-	while(1) {
-		if(entry->entry == -3) /* rootDir */
-			return strlen(getDrive(entry->Dir)) + 1 + length + 1;
-		
-		length += 1 + strlen(entry->name);
-		entry = getDirentry(entry->Dir);
-	}
-}
-
-static char *sprintPwd(direntry_t *entry, char *ptr)
-{
-	if(entry->entry == -3) {
-		strcpy(ptr, getDrive(entry->Dir));
-		strcat(ptr, ":/");
-		ptr = strchr(ptr, 0);
-	} else {
-		ptr = sprintPwd(getDirentry(entry->Dir), ptr);
-		if(ptr[-1] != '/')
-			*ptr++ = '/';
-		strcpy(ptr, entry->name);
-		ptr += strlen(entry->name);
-	}
-	return ptr;		
-}
-
-
-#define NEED_ESCAPE "\"$\\"
-
-static void _fprintPwd(FILE *f, direntry_t *entry, int recurs, int escape)
-{
-	if(entry->entry == -3) {
-		fputs(getDrive(entry->Dir), f);
-		putc(':', f);
-		if(!recurs)
-			putc('/', f);
-	} else {
-		_fprintPwd(f, getDirentry(entry->Dir), 1, escape);
-		if (escape && strpbrk(entry->name, NEED_ESCAPE)) {
-			char *ptr;
-			for(ptr = entry->name; *ptr; ptr++) {
-				if (strchr(NEED_ESCAPE, *ptr))
-					putc('\\', f);
-				putc(*ptr, f);
-			}
-		} else {
-			fprintf(f, "/%s", entry->name);
-		}
-	}
-}
-
-void fprintPwd(FILE *f, direntry_t *entry, int escape)
-{
-	if (escape)
-		putc('"', f);
-	_fprintPwd(f, entry, 0, escape);
-	if(escape)
-		putc('"', f);
-}
-
-char *getPwd(direntry_t *entry)
-{
-	int size;
-	char *ret;
-
-	size = getPathLen(entry);
-	ret = malloc(size+1);
-	if(!ret)
-		return 0;
-	sprintPwd(entry, ret);
-	return ret;
-}
-
-int isSubdirOf(Stream_t *inside, Stream_t *outside)
-{
-	while(1) {
-		if(inside == outside) /* both are the same */
-			return 1;
-		if(getDirentry(inside)->entry == -3) /* root directory */
-			return 0;
-		/* look further up */
-		inside = getDirentry(inside)->Dir;
-	}			
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/expand.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/expand.c	(revision 9)
+++ 	(revision )
@@ -1,83 +1,0 @@
-/*
- * Do filename expansion with the shell.
- */
-
-#define EXPAND_BUF	2048
-
-#include "sysincludes.h"
-#include "mtools.h"
-
-
-int safePopenOut(char **command, char *output, int len)
-{
-	int pipefd[2];
-	pid_t pid;
-	int status;
-	int last;
-
-	if(pipe(pipefd)) {
-		return -2;
-	}
-	switch((pid=fork())){
-		case -1:
-			return -2;
-		case 0: /* the son */
-			close(pipefd[0]);
-			destroy_privs();
-			close(1);
-			close(2); /* avoid nasty error messages on stderr */
-			dup(pipefd[1]);
-			close(pipefd[1]);
-			execvp(command[0], command+1);
-			exit(1);
-		default:
-			close(pipefd[1]);
-			break;
-	}
-	last=read(pipefd[0], output, len);
-	kill(pid,9);
-	wait(&status);
-	if(last<0) {
-		return -1;
-	}
-	return last;
-}
-
-
-
-const char *expand(const char *input, char *ans)
-{
-	int last;
-	char buf[256];
-	char *command[] = { "/bin/sh", "sh", "-c", 0, 0 };
-
-	ans[EXPAND_BUF-1]='\0';
-
-	if (input == NULL)
-		return(NULL);
-	if (*input == '\0')
-		return("");
-					/* any thing to expand? */
-	if (!strpbrk(input, "$*(){}[]\\?`~")) {
-		strncpy(ans, input, EXPAND_BUF-1);
-		return(ans);
-	}
-					/* popen an echo */
-#ifdef HAVE_SNPRINTF
-	snprintf(buf, 255, "echo %s", input);
-#else
-	sprintf(buf, "echo %s", input);
-#endif
-
-	command[3]=buf;
-	last=safePopenOut(command, ans, EXPAND_BUF-1);
-	if(last<0) {
-		perror("Pipe read error");
-		exit(1);
-	}
-	if(last)
-		ans[last-1] = '\0';
-	else
-		strncpy(ans, input, EXPAND_BUF-1);
-	return ans;
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/fat.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/fat.c	(revision 9)
+++ 	(revision )
@@ -1,929 +1,0 @@
-#include "sysincludes.h"
-#include "msdos.h"
-#include "stream.h"
-#include "mtools.h"
-#include "fsP.h"
-
-extern Stream_t *default_drive;
-
-#ifdef HAVE_LONG_LONG
-typedef long long fatBitMask;
-#else
-typedef long fatBitMask;
-#endif
-
-typedef struct FatMap_t {
-	unsigned char *data;
-	fatBitMask dirty;
-	fatBitMask valid;
-} FatMap_t;
-
-#define SECT_PER_ENTRY (sizeof(fatBitMask)*8)
-#define ONE ((fatBitMask) 1)
-
-static inline int readSector(Fs_t *This, char *buf, unsigned int off,
-					  size_t size)
-{
-	return READS(This->Next, buf, sectorsToBytes((Stream_t *)This, off), 
-				 size << This->sectorShift);
-}
-
-
-static inline int forceReadSector(Fs_t *This, char *buf, unsigned int off,
-								  size_t size)
-{
-	return force_read(This->Next, buf, sectorsToBytes((Stream_t *)This, off), 
-					  size << This->sectorShift);
-}
-
-
-static inline int writeSector(Fs_t *This, char *buf, unsigned int off,
-							  size_t size)
-{
-	return WRITES(This->Next, buf, sectorsToBytes((Stream_t*)This, off), 
-				  size << This->sectorShift);
-}
-
-static inline int forceWriteSector(Fs_t *This, char *buf, unsigned int off,
-					  size_t size)
-{
-	return force_write(This->Next, buf, sectorsToBytes((Stream_t*)This, off), 
-					   size << This->sectorShift);
-}
-
-
-static FatMap_t *GetFatMap(Fs_t *Stream)
-{
-	int nr_entries,i;
-	FatMap_t *map;
-
-	Stream->fat_error = 0;
-	nr_entries = (Stream->fat_len + SECT_PER_ENTRY - 1) / SECT_PER_ENTRY;
-	map = NewArray(nr_entries, FatMap_t);
-	if(!map)
-		return 0;
-
-	for(i=0; i< nr_entries; i++) {
-		map[i].data = 0;
-		map[i].valid = 0;
-		map[i].dirty = 0;
-	}
-
-	return map;
-}
-
-static inline int locate(Fs_t *Stream, int offset, int *slot, int *bit)
-{
-	if(offset >= Stream->fat_len)
-		return -1;
-	*slot = offset / SECT_PER_ENTRY;
-	*bit = offset % SECT_PER_ENTRY;
-	return 0;
-}
-
-static inline int fatReadSector(Fs_t *This, int sector, int slot, 
-				int bit, int dupe)
-{
-	int fat_start, ret;
-
-	dupe = (dupe + This->primaryFat) % This->num_fat;
-	fat_start = This->fat_start + This->fat_len * dupe;
-	
-	/* first, read as much as the buffer can give us */
-	ret = readSector(This,
-					 (char *)(This->FatMap[slot].data+(bit<<This->sectorShift)),
-					 fat_start+sector,
-					 (SECT_PER_ENTRY - bit%SECT_PER_ENTRY));
-	if(ret < 0)
-		return 0;
-
-	if(ret < This->sector_size) {
-		/* if we got less than one sector's worth, insist to get at
-		 * least one sector */
-		ret = forceReadSector(This,
-							  (char *) (This->FatMap[slot].data + 
-										(bit << This->sectorShift)),
-							  fat_start+sector, 1);
-		if(ret < This->sector_size)
-			return 0;
-		return 1;
-	}
-
-	return ret >> This->sectorShift;
-}
-
-
-static int fatWriteSector(Fs_t *This, int sector, int slot, int bit, int dupe)
-{
-	int fat_start;
-
-	dupe = (dupe + This->primaryFat) % This->num_fat;
-	if(dupe && !This->writeAllFats)
-		return This->sector_size;
-
-	fat_start = This->fat_start + This->fat_len * dupe;
-
-	return forceWriteSector(This,
-							(char *) 
-							(This->FatMap[slot].data + bit * This->sector_size),
-							fat_start+sector, 1);
-}
-
-static unsigned char *loadSector(Fs_t *This,
-				 unsigned int sector, fatAccessMode_t mode,
-				 int recurs)
-{
-	int slot, bit, i, ret;
-
-	if(locate(This,sector, &slot, &bit) < 0)
-		return 0;
-#if 0
-        if (((This->fat_len + SECT_PER_ENTRY - 1) / SECT_PER_ENTRY) <= slot) {
-		fprintf(stderr,"This should not happen\n");
-		fprintf(stderr, "fat_len = %d\n", This->fat_len);
-		fprintf(stderr, "SECT_PER_ENTRY=%d\n", (int)SECT_PER_ENTRY);
-		fprintf(stderr, "sector = %d slot = %d bit=%d\n", 
-			sector, slot, bit);
-		fprintf(stderr, "left = %d",(int)
-			((This->fat_len+SECT_PER_ENTRY-1) / SECT_PER_ENTRY));
-                return 0;
-	}
-#endif
-	if(!This->FatMap[slot].data) {
-		/* allocate the storage space */
-		This->FatMap[slot].data = 
-			malloc(This->sector_size * SECT_PER_ENTRY);
-		if(!This->FatMap[slot].data)
-			return 0;
-		memset(This->FatMap[slot].data, 0xee,
-		       This->sector_size * SECT_PER_ENTRY);
-	}
-
-	if(! (This->FatMap[slot].valid & (ONE << bit))) {
-		ret = -1;
-		for(i=0; i< This->num_fat; i++) {
-			/* read the sector */
-			ret = fatReadSector(This, sector, slot, bit, i);
-
-			if(ret == 0) {
-				fprintf(stderr,
-					"Error reading fat number %d\n", i);
-				continue;
-			}
-			break;
-		}
-
-		/* all copies bad.  Return error */
-		if(ret == 0)
-			return 0;
-
-		for(i=0; i < ret; i++)
-			This->FatMap[slot].valid |= ONE << (bit + i);
-
-		if(!recurs && ret == 1)
-			/* do some prefetching, if we happened to only
-			 * get one sector */
-			loadSector(This, sector+1, mode, 1);
-		if(!recurs && batchmode)
-			for(i=0; i < 1024; i++)
-				loadSector(This, sector+i, mode, 1);
-	}
-
-	if(mode == FAT_ACCESS_WRITE) {
-		This->FatMap[slot].dirty |= ONE << bit;
-		This->fat_dirty = 1;
-	}
-	return This->FatMap[slot].data + (bit << This->sectorShift);
-}
-
-
-static unsigned char *getAddress(Fs_t *Stream,
-				 unsigned int num, fatAccessMode_t mode)
-{
-	unsigned char *ret;
-	int sector;
-	int offset;
-
-	sector = num >> Stream->sectorShift;
-	ret = 0;
-	if(sector == Stream->lastFatSectorNr &&
-	   Stream->lastFatAccessMode >= mode)
-		ret = Stream->lastFatSectorData;
-	if(!ret) {		
-		ret = loadSector(Stream, sector, mode, 0);
-		if(!ret)
-			return 0;
-		Stream->lastFatSectorNr = sector;
-		Stream->lastFatSectorData = ret;
-		Stream->lastFatAccessMode = mode;
-	}
-	offset = num & Stream->sectorMask;
-	return ret+offset;
-}
-
-
-static int readByte(Fs_t *Stream, int start)
-{
-	unsigned char *address;
-	
-	address = getAddress(Stream, start, FAT_ACCESS_READ);
-	if(!address)
-		return -1;
-	return *address;
-}
-
-
-/*
- * Fat 12 encoding:
- *	|    byte n     |   byte n+1    |   byte n+2    |
- *	|7|6|5|4|3|2|1|0|7|6|5|4|3|2|1|0|7|6|5|4|3|2|1|0|
- *	| | | | | | | | | | | | | | | | | | | | | | | | |
- *	| n+0.0 | n+0.5 | n+1.0 | n+1.5 | n+2.0 | n+2.5 |
- *	    \_____  \____   \______/________/_____   /
- *	      ____\______\________/   _____/  ____\_/
- *	     /     \      \          /       /     \
- *	| n+1.5 | n+0.0 | n+0.5 | n+2.0 | n+2.5 | n+1.0 |
- *	|      FAT entry k      |    FAT entry k+1      |
- */
- 
- /*
- * Get and decode a FAT (file allocation table) entry.  Returns the cluster
- * number on success or 1 on failure.
- */
-
-static unsigned int fat12_decode(Fs_t *Stream, unsigned int num)
-{
-	unsigned int start = num * 3 / 2;
-	int byte0 = readByte(Stream, start);
-	int byte1 = readByte(Stream, start+1);
-       
-	if (num < 2 || byte0 < 0 || byte1 < 0 || num > Stream->num_clus+1) {
-		fprintf(stderr,"[1] Bad address %d\n", num);
-		return 1;
-	}
-
-	if (num & 1)
-		return (byte1 << 4) | ((byte0 & 0xf0)>>4);
-	else
-		return ((byte1 & 0xf) << 8) | byte0;
-}
-
-
-/*
- * Puts a code into the FAT table.  Is the opposite of fat_decode().  No
- * sanity checking is done on the code.  Returns a 1 on error.
- */
-static void fat12_encode(Fs_t *Stream, unsigned int num, unsigned int code)
-{
-	int start = num * 3 / 2;
-	unsigned char *address0 = getAddress(Stream, start, FAT_ACCESS_WRITE);
-	unsigned char *address1 = getAddress(Stream, start+1, FAT_ACCESS_WRITE);
-
-	if (num & 1) {
-		/* (odd) not on byte boundary */
-		*address0 = (*address0 & 0x0f) | ((code << 4) & 0xf0);
-		*address1 = (code >> 4) & 0xff;
-	} else {
-		/* (even) on byte boundary */
-		*address0 = code & 0xff;
-		*address1 = (*address1 & 0xf0) | ((code >> 8) & 0x0f);
-	}
-}
-
-
-/*
- * Fat 16 encoding:
- *	|    byte n     |   byte n+1    |
- *	|7|6|5|4|3|2|1|0|7|6|5|4|3|2|1|0|
- *	| | | | | | | | | | | | | | | | |
- *	|         FAT entry k           |
- */
-
-static unsigned int fat16_decode(Fs_t *Stream, unsigned int num)
-{
-	unsigned char *address = getAddress(Stream, num << 1, FAT_ACCESS_READ);
-	return _WORD(address);
-}
-
-static void fat16_encode(Fs_t *Stream, unsigned int num, unsigned int code)
-{       
-	unsigned char *address = getAddress(Stream, num << 1, FAT_ACCESS_WRITE);
-	set_word(address, code);
-}
-
-
-static unsigned int fast_fat16_decode(Fs_t *Stream, unsigned int num)
-{
-	unsigned short *address = 
-		(unsigned short *) getAddress(Stream, num << 1, 
-					      FAT_ACCESS_READ);
-	return *address;
-}
-
-static void fast_fat16_encode(Fs_t *Stream, unsigned int num, unsigned int code)
-{       
-	unsigned short *address = 
-		(unsigned short *) getAddress(Stream, num << 1, 
-					      FAT_ACCESS_WRITE);
-	*address = code;
-}
-
-
-
-
-/*
- * Fat 32 encoding
- */
-static unsigned int fat32_decode(Fs_t *Stream, unsigned int num)
-{
-	unsigned char *address = getAddress(Stream, num << 2, FAT_ACCESS_READ);
-	return _DWORD(address);
-}
-
-static void fat32_encode(Fs_t *Stream, unsigned int num, unsigned int code)
-{       
-	unsigned char *address = getAddress(Stream, num << 2, FAT_ACCESS_WRITE);
-	set_dword(address, code);
-}
-
-
-static unsigned int fast_fat32_decode(Fs_t *Stream, unsigned int num)
-{
-	unsigned int *address = 
-		(unsigned int *) getAddress(Stream, num << 2, 
-					    FAT_ACCESS_READ);
-	return *address;
-}
-
-static void fast_fat32_encode(Fs_t *Stream, unsigned int num, unsigned int code)
-{       
-	unsigned int *address = 
-		(unsigned int *) getAddress(Stream, num << 2, 
-					    FAT_ACCESS_WRITE);
-	*address = code;
-}
-
-
-/*
- * Write the FAT table to the disk.  Up to now the FAT manipulation has
- * been done in memory.  All errors are fatal.  (Might not be too smart
- * to wait till the end of the program to write the table.  Oh well...)
- */
-
-void fat_write(Fs_t *This)
-{
-	int i, j, dups, ret, bit, slot;
-	int fat_start;
-
-	/*fprintf(stderr, "Fat write\n");*/
-
-	if (!This->fat_dirty)
-		return;
-
-	dups = This->num_fat;
-	if (This->fat_error)
-		dups = 1;
-
-
-	for(i=0; i<dups; i++){
-		j = 0;
-		fat_start = This->fat_start + i*This->fat_len;
-		for(slot=0;j<This->fat_len;slot++) {
-			if(!This->FatMap[slot].dirty) {
-				j += SECT_PER_ENTRY;
-				continue;
-			}
-			for(bit=0; 
-			    bit < SECT_PER_ENTRY && j<This->fat_len;
-			    bit++,j++) {
-				if(!(This->FatMap[slot].dirty & (ONE << bit)))
-					continue;
-				ret = fatWriteSector(This,j,slot, bit, i);
-				if (ret < This->sector_size){
-					if (ret < 0 ){
-						perror("error in fat_write");
-						exit(1);
-					} else {
-						fprintf(stderr,
-							"end of file in fat_write\n");
-						exit(1);
-					}
-				}
-				/* if last dupe, zero it out */
-				if(i==dups-1)
-					This->FatMap[slot].dirty &= ~(1<<bit);
-			}
-		}	 
-	}
-	/* write the info sector, if any */
-	if(This->infoSectorLoc && This->infoSectorLoc != MAX32) {
-		/* initialize info sector */
-		InfoSector_t *infoSector;
-		infoSector = (InfoSector_t *) safe_malloc(This->sector_size);
-		set_dword(infoSector->signature1, INFOSECT_SIGNATURE1);
-		memset(infoSector->filler1, sizeof(infoSector->filler1),0);
-		memset(infoSector->filler2, sizeof(infoSector->filler2),0);
-		set_dword(infoSector->signature2, INFOSECT_SIGNATURE2);
-		set_dword(infoSector->pos, This->last);
-		set_dword(infoSector->count, This->freeSpace);
-		set_dword(infoSector->signature3, 0xaa55);
-		if(forceWriteSector(This, (char *)infoSector, This->infoSectorLoc, 1) !=
-		   This->sector_size)
-			fprintf(stderr,"Trouble writing the info sector\n");
-		free(infoSector);
-	}
-	This->fat_dirty = 0;
-	This->lastFatAccessMode = FAT_ACCESS_READ;
-}
-
-
-
-/*
- * Zero-Fat
- * Used by mformat.
- */
-int zero_fat(Fs_t *Stream, int media_descriptor)
-{
-	int i, j;
-	int fat_start;
-	unsigned char *buf;
-
-	buf = malloc(Stream->sector_size);
-	if(!buf) {
-		perror("alloc fat sector buffer");
-		return -1;
-	}
-	for(i=0; i< Stream->num_fat; i++) {
-		fat_start = Stream->fat_start + i*Stream->fat_len;
-		for(j = 0; j < Stream->fat_len; j++) {
-			if(j <= 1)
-				memset(buf, 0, Stream->sector_size);
-			if(!j) {
-				buf[0] = media_descriptor;
-				buf[2] = buf[1] = 0xff;
-				if(Stream->fat_bits > 12)
-					buf[3] = 0xff;
-				if(Stream->fat_bits > 16) {
-					buf[4] = 0xff;
-					buf[5] = 0xff;
-					buf[6] = 0xff;
-					buf[7] = 0x0f;
-				}
-			}
-
-			if(forceWriteSector(Stream, (char *)buf,
-								fat_start + j, 1) !=
-			   Stream->sector_size) {
-				fprintf(stderr,
-						"Trouble initializing a FAT sector\n");
-				free(buf);
-				return -1;
-			}
-		}
-	}
-	
-	free(buf);
-	Stream->FatMap = GetFatMap(Stream);
-	if (Stream->FatMap == NULL) {
-		perror("alloc fat map");
-		return -1;
-	}
-	return 0;
-}
-
-
-void set_fat12(Fs_t *This)
-{
-	This->fat_bits = 12;
-	This->end_fat = 0xfff;
-	This->last_fat = 0xff6;
-	This->fat_decode = fat12_decode;
-	This->fat_encode = fat12_encode;
-}
-
-static char word_endian_test[] = { 0x34, 0x12 };
-
-void set_fat16(Fs_t *This)
-{
-	This->fat_bits = 16;
-	This->end_fat = 0xffff;
-	This->last_fat = 0xfff6;
-
-	if(sizeof(unsigned short) == 2 &&  
-	   * (unsigned short *) word_endian_test == 0x1234) {
-		This->fat_decode = fast_fat16_decode;
-		This->fat_encode = fast_fat16_encode;
-	} else {
-		This->fat_decode = fat16_decode;
-		This->fat_encode = fat16_encode;
-	}
-}
-
-static char dword_endian_test[] = { 0x78, 0x56, 0x34, 0x12 };
-
-void set_fat32(Fs_t *This)
-{
-	This->fat_bits = 32;
-	This->end_fat = 0xfffffff;
-	This->last_fat = 0xffffff6;
-	
-	if(sizeof(unsigned int) == 4 &&  
-	   * (unsigned int *) dword_endian_test == 0x12345678) {
-		This->fat_decode = fast_fat32_decode;
-		This->fat_encode = fast_fat32_encode;
-	} else {
-		This->fat_decode = fat32_decode;
-		This->fat_encode = fat32_encode;
-	}
-}
-
-
-static int check_fat(Fs_t *This)
-{
-	/* 
-	 * This is only a sanity check.  For disks with really big FATs,
-	 * there is no point in checking the whole FAT.
-	 */
-
-	int i, f, tocheck;
-	if(mtools_skip_check)
-		return 0;
-
-	/* too few sectors in the FAT */
-	if(This->fat_len < NEEDED_FAT_SIZE(This))
-		return -1;
-	/* we do not warn about too much sectors in FAT, which may
-	 * happen when a partition has been shrunk using FIPS, or on
-	 * other occurrences */
-	
-	tocheck = This->num_clus;
-	if (tocheck < 0 || tocheck + 1 >= This->last_fat) {
-		fprintf(stderr, "Too many clusters in FAT\n");
-		return -1;
-	}
-
-	if(tocheck > 4096)
-		tocheck = 4096;
-
-	for ( i= 3 ; i < tocheck; i++){
-		f = This->fat_decode(This,i);
-		if (f == 1 || (f < This->last_fat && f > This->num_clus)){
-			fprintf(stderr,
-				"Cluster # at %d too big(%#x)\n", i,f);
-			fprintf(stderr,"Probably non MS-DOS disk\n");
-			return -1;
-		}
-	}
-	return 0;
-}
-
-
-/*
- * Read the first sector of FAT table into memory.  Crude error detection on
- * wrong FAT encoding scheme.
- */
-static int check_media_type(Fs_t *This, struct bootsector *boot, 
-			    unsigned int tot_sectors)
-{
-	unsigned char *address;
-
-	This->num_clus = (tot_sectors - This->clus_start) / This->cluster_size;
-
-	This->FatMap = GetFatMap(This);
-	if (This->FatMap == NULL) {
-		perror("alloc fat map");
-		return -1;
-	}
-
-	address = getAddress(This, 0, FAT_ACCESS_READ);
-	if(!address) {
-		fprintf(stderr,
-			"Could not read first FAT sector\n");
-		return -1;
-	}
-
-	if(mtools_skip_check)
-		return 0;
-
-	if(!address[0] && !address[1] && !address[2])
-		/* Some Atari disks have zeroes where Dos has media descriptor
-		 * and 0xff.  Do not consider this as an error */
-		return 0;
-	
-	if((address[0] != boot->descr && boot->descr >= 0xf0 &&
-	    ((address[0] != 0xf9 && address[0] != 0xf7) 
-	     || boot->descr != 0xf0)) || address[0] < 0xf0) {
-		fprintf(stderr,
-			"Bad media types %02x/%02x, probably non-MSDOS disk\n", 
-				address[0],
-				boot->descr);
-		return -1;
-	}
-
-	if(address[1] != 0xff || address[2] != 0xff){
-		fprintf(stderr,"Initial byte of fat is not 0xff\n");
-		return -1;
-	}
-
-	return 0;
-}
-
-static int fat_32_read(Fs_t *This, struct bootsector *boot, 
-		       unsigned int tot_sectors)
-{
-	int size;
-
-	This->fat_len = DWORD(ext.fat32.bigFat);
-	This->writeAllFats = !(boot->ext.fat32.extFlags[0] & 0x80);
-	This->primaryFat = boot->ext.fat32.extFlags[0] & 0xf;
-	This->rootCluster = DWORD(ext.fat32.rootCluster);
-	This->clus_start = This->fat_start + This->num_fat * This->fat_len;
-
-	/* read the info sector */
-	size = This->sector_size;
-	This->infoSectorLoc = WORD(ext.fat32.infoSector);
-	if(This->sector_size >= 512 &&
-	   This->infoSectorLoc && This->infoSectorLoc != MAX32) {
-		InfoSector_t *infoSector;
-		infoSector = (InfoSector_t *) safe_malloc(size);
-		if(forceReadSector(This, (char *)infoSector,
-						   This->infoSectorLoc, 1) == This->sector_size &&
-		   _DWORD(infoSector->signature1) == INFOSECT_SIGNATURE1 &&
-		   _DWORD(infoSector->signature2) == INFOSECT_SIGNATURE2) {
-			This->freeSpace = _DWORD(infoSector->count);
-			This->last = _DWORD(infoSector->pos);
-		}
-		free(infoSector);
-	}
-	
-	set_fat32(This);
-	return(check_media_type(This,boot, tot_sectors) ||
-	       check_fat(This));
-}
-
-
-static int old_fat_read(Fs_t *This, struct bootsector *boot, 
-						int config_fat_bits,
-						size_t tot_sectors, int nodups)
-{
-	This->writeAllFats = 1;
-	This->primaryFat = 0;
-	This->dir_start = This->fat_start + This->num_fat * This->fat_len;
-	This->clus_start = This->dir_start + This->dir_len;
-	This->infoSectorLoc = MAX32;
-
-	if(nodups)
-		This->num_fat = 1;
-
-	if(check_media_type(This,boot, tot_sectors))
-		return -1;
-
-	if(This->num_clus > FAT12) {
-		set_fat16(This);
-		/* third FAT byte must be 0xff */
-		if(!mtools_skip_check && readByte(This, 3) != 0xff)
-			return -1;
-	} else
-		set_fat12(This);
-
-	return check_fat(This);
-}
-
-/*
- * Read the first sector of the  FAT table into memory and initialize 
- * structures.
- */
-int fat_read(Fs_t *This, struct bootsector *boot, int fat_bits,
-	   size_t tot_sectors, int nodups)
-{
-	This->fat_error = 0;
-	This->fat_dirty = 0;
-	This->last = MAX32;
-	This->freeSpace = MAX32;
-	This->lastFatSectorNr = 0;
-	This->lastFatSectorData = 0;
-
-	if(This->fat_len)
-		return old_fat_read(This, boot, fat_bits, tot_sectors, nodups);
-	else
-		return fat_32_read(This, boot, tot_sectors);
-}
-
-
-unsigned int fatDecode(Fs_t *This, unsigned int pos)
-{
-	int ret;
-
-	ret = This->fat_decode(This, pos);
-	if(ret && (ret < 2 || ret > This->num_clus+1) && ret < This->last_fat) {
-		fprintf(stderr, "Bad FAT entry %d at %d\n", ret, pos);
-		This->fat_error++;
-	}
-	return ret;
-}
-
-/* append a new cluster */
-void fatAppend(Fs_t *This, unsigned int pos, unsigned int newpos)
-{
-	This->fat_encode(This, pos, newpos);
-	This->fat_encode(This, newpos, This->end_fat);
-	if(This->freeSpace != MAX32)
-		This->freeSpace--;
-}
-
-/* de-allocates the given cluster */
-void fatDeallocate(Fs_t *This, unsigned int pos)
-{
-	This->fat_encode(This, pos, 0);
-	if(This->freeSpace != MAX32)
-		This->freeSpace++;
-}
-
-/* allocate a new cluster */
-void fatAllocate(Fs_t *This, unsigned int pos, unsigned int value)
-{
-	This->fat_encode(This, pos, value);
-	if(This->freeSpace != MAX32)
-		This->freeSpace--;
-}
-
-void fatEncode(Fs_t *This, unsigned int pos, unsigned int value)
-{
-	unsigned int oldvalue = This->fat_decode(This, pos);
-	This->fat_encode(This, pos, value);
-	if(This->freeSpace != MAX32) {
-		if(oldvalue)
-			This->freeSpace++;
-		if(value)
-			This->freeSpace--;
-	}
-}
-
-unsigned int get_next_free_cluster(Fs_t *This, unsigned int last)
-{
-	int i;
-
-	if(This->last != MAX32)
-		last = This->last;
-
-	if (last < 2 ||
-	    last >= This->num_clus+1)
-		last = 1;
-
-	for (i=last+1; i< This->num_clus+2; i++) {
-		if (!fatDecode(This, i)) {
-			This->last = i;
-			return i;
-		}
-	}
-
-	for(i=2; i < last+1; i++) {
-		if (!fatDecode(This, i)) {
-			This->last = i;
-			return i;
-		}
-	}
-
-
-	fprintf(stderr,"No free cluster %d %d\n", This->preallocatedClusters,
-		This->last);
-	return 1;
-}
-
-int fat_error(Stream_t *Dir)
-{
-	Stream_t *Stream = GetFs(Dir);
-	DeclareThis(Fs_t);
-
-	if(This->fat_error)
-		fprintf(stderr,"Fat error detected\n");
-
-	return This->fat_error;
-}
-
-int fat32RootCluster(Stream_t *Dir)
-{
-	Stream_t *Stream = GetFs(Dir);
-	DeclareThis(Fs_t);
-	
-	if(This->fat_bits == 32)
-		return This->rootCluster;
-	else
-		return 0;
-}
-
-
-/*
- * Get the amount of free space on the diskette
- */
-
-mt_size_t getfree(Stream_t *Dir)
-{
-	Stream_t *Stream = GetFs(Dir);
-	DeclareThis(Fs_t);
-
-	if(This->freeSpace == MAX32 || This->freeSpace == 0) {
-		register unsigned int i;
-		size_t total;
-
-		total = 0L;
-		for (i = 2; i < This->num_clus + 2; i++)
-			if (!fatDecode(This,i))
-				total++;
-		This->freeSpace = total;
-	}
-	return sectorsToBytes((Stream_t*)This, 
-						  This->freeSpace * This->cluster_size);
-}
-
-
-/*
- * Ensure that there is a minimum of total sectors free
- */
-int getfreeMinClusters(Stream_t *Dir, size_t size)
-{
-	Stream_t *Stream = GetFs(Dir);
-	DeclareThis(Fs_t);
-	register unsigned int i, last;
-	size_t total;
-
-	if(batchmode && This->freeSpace == MAX32)
-		getfree(Stream);
-
-	if(This->freeSpace != MAX32) {
-		if(This->freeSpace >= size)
-			return 1;
-		else {
-			fprintf(stderr, "Disk full\n");
-			got_signal = 1;
-			return 0;
-		}
-	}
-
-	total = 0L;
-
-	/* we start at the same place where we'll start later to actually
-	 * allocate the sectors.  That way, the same sectors of the FAT, which
-	 * are already loaded during getfreeMin will be able to be reused 
-	 * during get_next_free_cluster */
-	last = This->last;
-	
-	if ( last < 2 || last >= This->num_clus + 2)
-		last = 1;
-	for (i=last+1; i< This->num_clus+2; i++){
-		if (!fatDecode(This, i))
-			total++;
-		if(total >= size)
-			return 1;				
-	}
-	for(i=2; i < last+1; i++){
-		if (!fatDecode(This, i))
-			total++;
-		if(total >= size)
-			return 1;
-	}
-	fprintf(stderr, "Disk full\n");
-	got_signal = 1;
-	return 0;
-}
-
-
-int getfreeMinBytes(Stream_t *Dir, mt_size_t size)
-{
-	Stream_t *Stream = GetFs(Dir);
-	DeclareThis(Fs_t);
-	size_t size2;
-
-	size2 = size  / (This->sector_size * This->cluster_size);
-	if(size % (This->sector_size * This->cluster_size))
-		size2++;
-	return getfreeMinClusters(Dir, size2);
-}
-
-
-unsigned int getStart(Stream_t *Dir, struct directory *dir)
-{
-	Stream_t *Stream = GetFs(Dir);
-	unsigned int first;
-
-	first = START(dir);
-	if(fat32RootCluster(Stream))
-		first |= STARTHI(dir) << 16;
-	return first;
-}
-
-int fs_free(Stream_t *Stream)
-{
-	DeclareThis(Fs_t);
-
-	if(This->FatMap) {
-		int i, nr_entries;
-		nr_entries = (This->fat_len + SECT_PER_ENTRY - 1) / 
-			SECT_PER_ENTRY;
-		for(i=0; i< nr_entries; i++)
-			if(This->FatMap[i].data)
-				free(This->FatMap[i].data);		
-		free(This->FatMap);
-	}
-	return 0;
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/fat_free.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/fat_free.c	(revision 9)
+++ 	(revision )
@@ -1,55 +1,0 @@
-#include "sysincludes.h"
-#include "msdos.h"
-#include "fsP.h"
-#include "mtoolsDirent.h"
-
-/*
- * Remove a string of FAT entries (delete the file).  The argument is
- * the beginning of the string.  Does not consider the file length, so
- * if FAT is corrupted, watch out!
- */
-
-int fat_free(Stream_t *Dir, unsigned int fat)
-{
-	Stream_t *Stream = GetFs(Dir);
-	DeclareThis(Fs_t);
-	unsigned int next_no_step;
-					/* a zero length file? */
-	if (fat == 0)
-		return(0);
-
-	/* CONSTCOND */
-	while (!This->fat_error) {
-		/* get next cluster number */
-		next_no_step = fatDecode(This,fat);
-		/* mark current cluster as empty */
-		fatDeallocate(This,fat);
-		if (next_no_step >= This->last_fat)
-			break;
-		fat = next_no_step;
-	}
-	return(0);
-}
-
-int fatFreeWithDir(Stream_t *Dir, struct directory *dir)
-{
-	unsigned int first;
-
-	if((!strncmp(dir->name,".      ",8) ||
-	    !strncmp(dir->name,"..     ",8)) &&
-	   !strncmp(dir->ext,"   ",3)) {
-		fprintf(stderr,"Trying to remove . or .. entry\n");
-		return -1;
-	}
-
-	first = START(dir);
-  	if(fat32RootCluster(Dir))
-		first |= STARTHI(dir) << 16;
-	return fat_free(Dir, first);
-}
-
-int fatFreeWithDirentry(direntry_t *entry)
-{
-	return fatFreeWithDir(entry->Dir, &entry->dir);
-}
-    
Index: trunk/minix/commands/i386/mtools-3.9.7/file.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/file.c	(revision 9)
+++ 	(revision )
@@ -1,676 +1,0 @@
-#include "sysincludes.h"
-#include "msdos.h"
-#include "stream.h"
-#include "mtools.h"
-#include "fsP.h"
-#include "file.h"
-#include "htable.h"
-#include "dirCache.h"
-
-typedef struct File_t {
-	Class_t *Class;
-	int refs;
-	struct Fs_t *Fs;	/* Filesystem that this fat file belongs to */
-	Stream_t *Buffer;
-
-	int (*map)(struct File_t *this, off_t where, size_t *len, int mode,
-			   mt_off_t *res);
-	size_t FileSize;
-
-	size_t preallocatedSize;
-	int preallocatedClusters;
-
-	/* Absolute position of first cluster of file */
-	unsigned int FirstAbsCluNr;
-
-	/* Absolute position of previous cluster */
-	unsigned int PreviousAbsCluNr;
-
-	/* Relative position of previous cluster */
-	unsigned int PreviousRelCluNr;
-	direntry_t direntry;
-	int hint;
-	struct dirCache_t *dcp;
-
-	unsigned int loopDetectRel;
-	unsigned int loopDetectAbs;
-} File_t;
-
-static Class_t FileClass;
-T_HashTable *filehash;
-
-static File_t *getUnbufferedFile(Stream_t *Stream)
-{
-	while(Stream->Class != &FileClass)
-		Stream = Stream->Next;
-	return (File_t *) Stream;
-}
-
-Fs_t *getFs(Stream_t *Stream)
-{
-	return getUnbufferedFile(Stream)->Fs;
-}
-
-struct dirCache_t **getDirCacheP(Stream_t *Stream)
-{
-	return &getUnbufferedFile(Stream)->dcp;
-}
-
-direntry_t *getDirentry(Stream_t *Stream)
-{
-	return &getUnbufferedFile(Stream)->direntry;
-}
-
-
-static int recalcPreallocSize(File_t *This)
-{
-	size_t currentClusters, neededClusters;
-	int clus_size;
-	int neededPrealloc;
-	Fs_t *Fs = This->Fs;
-	int r;
-
-	if(This->FileSize & 0xc0000000) {
-		fprintf(stderr, "Bad filesize\n");
-	}
-	if(This->preallocatedSize & 0xc0000000) {
-		fprintf(stderr, "Bad preallocated size %x\n", 
-				(int) This->preallocatedSize);
-	}
-
-	clus_size = Fs->cluster_size * Fs->sector_size;
-
-	currentClusters = (This->FileSize + clus_size - 1) / clus_size;
-	neededClusters = (This->preallocatedSize + clus_size - 1) / clus_size;
-	neededPrealloc = neededClusters - currentClusters;
-	if(neededPrealloc < 0)
-		neededPrealloc = 0;
-	r = fsPreallocateClusters(Fs, neededPrealloc - This->preallocatedClusters);
-	if(r)
-		return r;
-	This->preallocatedClusters = neededPrealloc;
-	return 0;
-}
-
-static int _loopDetect(unsigned int *oldrel, unsigned int rel, 
-					   unsigned int *oldabs, unsigned int abs)
-{
-	if(*oldrel && rel > *oldrel && abs == *oldabs) {
-		fprintf(stderr, "loop detected! oldrel=%d newrel=%d abs=%d\n",
-				*oldrel, rel, abs);
-		return -1;
-	}
-
-	if(rel >= 2 * *oldrel + 1) {
-		*oldrel = rel;
-		*oldabs = abs;
-	}
-	return 0;
-}
-
-
-static int loopDetect(File_t *This, unsigned int rel, unsigned int abs)
-{
-	return _loopDetect(&This->loopDetectRel, rel, &This->loopDetectAbs, abs);
-}
-
-static unsigned int _countBlocks(Fs_t *This, unsigned int block)
-{
-	unsigned int blocks;
-	unsigned int rel, oldabs, oldrel;
-
-	blocks = 0;
-	
-	oldabs = oldrel = rel = 0;
-
-	while (block <= This->last_fat && block != 1 && block) {
-		blocks++;
-		block = fatDecode(This, block);
-		rel++;
-		if(_loopDetect(&oldrel, rel, &oldabs, block) < 0)
-			block = -1;
-	}
-	return blocks;
-}
-
-unsigned int countBlocks(Stream_t *Dir, unsigned int block)
-{
-	Stream_t *Stream = GetFs(Dir);
-	DeclareThis(Fs_t);
-
-	return _countBlocks(This, block);
-}
-
-/* returns number of bytes in a directory.  Represents a file size, and
- * can hence be not bigger than 2^32
- */
-static size_t countBytes(Stream_t *Dir, unsigned int block)
-{
-	Stream_t *Stream = GetFs(Dir);
-	DeclareThis(Fs_t);
-
-	return _countBlocks(This, block) * 
-		This->sector_size * This->cluster_size;
-}
-
-void printFat(Stream_t *Stream)
-{
-	File_t *This = getUnbufferedFile(Stream);
-	unsigned long n;
-	int rel;
-	unsigned long begin, end;
-	int first;
-
-	n = This->FirstAbsCluNr;
-	if(!n) {
-		printf("Root directory or empty file\n");
-		return;
-	}
-
-	rel = 0;
-	first = 1;
-	begin = end = 0;
-	do {
-		if (first || n != end+1) {
-			if (!first) {
-				if (begin != end)
-					printf("-%lu", end);
-				printf("> ");
-			}
-			begin = end = n;
-			printf("<%lu", begin);
-		} else {
-			end++;
-		}
-		first = 0;
-		n = fatDecode(This->Fs, n);
-		rel++;
-		if(loopDetect(This, rel, n) < 0)
-			n = 1;
-	} while (n <= This->Fs->last_fat && n != 1);
-	if(!first) {
-		if (begin != end)
-			printf("-%lu", end);
-		printf(">");
-	}
-}
-
-static int normal_map(File_t *This, off_t where, size_t *len, int mode,
-						   mt_off_t *res)
-{
-	int offset;
-	off_t end;
-	int NrClu; /* number of clusters to read */
-	unsigned int RelCluNr;
-	unsigned int CurCluNr;
-	unsigned int NewCluNr;
-	unsigned int AbsCluNr;
-	int clus_size;
-	Fs_t *Fs = This->Fs;
-
-	*res = 0;
-	clus_size = Fs->cluster_size * Fs->sector_size;
-	offset = where % clus_size;
-
-	if (mode == MT_READ)
-		maximize(*len, This->FileSize - where);
-	if (*len == 0 )
-		return 0;
-
-	if (This->FirstAbsCluNr < 2){
-		if( mode == MT_READ || *len == 0){
-			*len = 0;
-			return 0;
-		}
-		NewCluNr = get_next_free_cluster(This->Fs, 1);
-		if (NewCluNr == 1 ){
-			errno = ENOSPC;
-			return -2;
-		}
-		hash_remove(filehash, (void *) This, This->hint);
-		This->FirstAbsCluNr = NewCluNr;
-		hash_add(filehash, (void *) This, &This->hint);
-		fatAllocate(This->Fs, NewCluNr, Fs->end_fat);
-	}
-
-	RelCluNr = where / clus_size;
-	
-	if (RelCluNr >= This->PreviousRelCluNr){
-		CurCluNr = This->PreviousRelCluNr;
-		AbsCluNr = This->PreviousAbsCluNr;
-	} else {
-		CurCluNr = 0;
-		AbsCluNr = This->FirstAbsCluNr;
-	}
-
-
-	NrClu = (offset + *len - 1) / clus_size;
-	while (CurCluNr <= RelCluNr + NrClu){
-		if (CurCluNr == RelCluNr){
-			/* we have reached the beginning of our zone. Save
-			 * coordinates */
-			This->PreviousRelCluNr = RelCluNr;
-			This->PreviousAbsCluNr = AbsCluNr;
-		}
-		NewCluNr = fatDecode(This->Fs, AbsCluNr);
-		if (NewCluNr == 1 || NewCluNr == 0){
-			fprintf(stderr,"Fat problem while decoding %d %x\n", 
-				AbsCluNr, NewCluNr);
-			exit(1);
-		}
-		if(CurCluNr == RelCluNr + NrClu)			
-			break;
-		if (NewCluNr > Fs->last_fat && mode == MT_WRITE){
-			/* if at end, and writing, extend it */
-			NewCluNr = get_next_free_cluster(This->Fs, AbsCluNr);
-			if (NewCluNr == 1 ){ /* no more space */
-				errno = ENOSPC;
-				return -2;
-			}
-			fatAppend(This->Fs, AbsCluNr, NewCluNr);
-		}
-
-		if (CurCluNr < RelCluNr && NewCluNr > Fs->last_fat){
-			*len = 0;
-			return 0;
-		}
-
-		if (CurCluNr >= RelCluNr && NewCluNr != AbsCluNr + 1)
-			break;
-		CurCluNr++;
-		AbsCluNr = NewCluNr;
-		if(loopDetect(This, CurCluNr, AbsCluNr)) {
-			errno = EIO;
-			return -2;
-		}
-	}
-
-	maximize(*len, (1 + CurCluNr - RelCluNr) * clus_size - offset);
-	
-	end = where + *len;
-	if(batchmode && mode == MT_WRITE && end >= This->FileSize) {
-		*len += ROUND_UP(end, clus_size) - end;
-	}
-
-	if((*len + offset) / clus_size + This->PreviousAbsCluNr-2 >
-		Fs->num_clus) {
-		fprintf(stderr, "cluster too big\n");
-		exit(1);
-	}
-
-	*res = sectorsToBytes((Stream_t*)Fs, 
-						  (This->PreviousAbsCluNr-2) * Fs->cluster_size +
-						  Fs->clus_start) + offset;
-	return 1;
-}
-
-
-static int root_map(File_t *This, off_t where, size_t *len, int mode,
-					mt_off_t *res)
-{
-	Fs_t *Fs = This->Fs;
-
-	if(Fs->dir_len * Fs->sector_size < where) {
-		*len = 0;
-		errno = ENOSPC;
-		return -2;
-	}
-
-	maximize(*len, Fs->dir_len * Fs->sector_size - where);
-        if (*len == 0)
-            return 0;
-	
-	*res = sectorsToBytes((Stream_t*)Fs, Fs->dir_start) + where;
-	return 1;
-}
-	
-
-static int read_file(Stream_t *Stream, char *buf, mt_off_t iwhere, 
-					 size_t len)
-{
-	DeclareThis(File_t);
-	mt_off_t pos;
-	int err;
-	off_t where = truncBytes32(iwhere);
-
-	Stream_t *Disk = This->Fs->Next;
-	
-	err = This->map(This, where, &len, MT_READ, &pos);
-	if(err <= 0)
-		return err;
-	return READS(Disk, buf, pos, len);
-}
-
-static int write_file(Stream_t *Stream, char *buf, mt_off_t iwhere, size_t len)
-{
-	DeclareThis(File_t);
-	mt_off_t pos;
-	int ret;
-	size_t requestedLen;
-	Stream_t *Disk = This->Fs->Next;
-	off_t where = truncBytes32(iwhere);
-	int err;
-
-	requestedLen = len;
-	err = This->map(This, where, &len, MT_WRITE, &pos);
-	if( err <= 0)
-		return err;
-	if(batchmode)
-		ret = force_write(Disk, buf, pos, len);
-	else
-		ret = WRITES(Disk, buf, pos, len);
-	if(ret > requestedLen)
-		ret = requestedLen;
-	if (ret > 0 && where + ret > This->FileSize )
-		This->FileSize = where + ret;
-	recalcPreallocSize(This);
-	return ret;
-}
-
-
-/*
- * Convert an MSDOS time & date stamp to the Unix time() format
- */
-
-static int month[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334,
-					  0, 0, 0 };
-static inline time_t conv_stamp(struct directory *dir)
-{
-	struct tm *tmbuf;
-	long tzone, dst;
-	time_t accum, tmp;
-
-	accum = DOS_YEAR(dir) - 1970; /* years past */
-
-	/* days passed */
-	accum = accum * 365L + month[DOS_MONTH(dir)-1] + DOS_DAY(dir);
-
-	/* leap years */
-	accum += (DOS_YEAR(dir) - 1972) / 4L;
-
-	/* back off 1 day if before 29 Feb */
-	if (!(DOS_YEAR(dir) % 4) && DOS_MONTH(dir) < 3)
-	        accum--;
-	accum = accum * 24L + DOS_HOUR(dir); /* hours passed */
-	accum = accum * 60L + DOS_MINUTE(dir); /* minutes passed */
-	accum = accum * 60L + DOS_SEC(dir); /* seconds passed */
-
-#ifndef OS_Minix
-	/* correct for Time Zone */
-#ifdef HAVE_GETTIMEOFDAY
-	{
-		struct timeval tv;
-		struct timezone tz;
-		
-		gettimeofday(&tv, &tz);
-		tzone = tz.tz_minuteswest * 60L;
-	}
-#else
-#ifdef HAVE_TZSET
-	{
-#ifndef OS_ultrix
-		/* Ultrix defines this to be a different type */
-		extern long timezone;
-#endif
-		tzset();
-		tzone = (long) timezone;
-	}
-#else
-	tzone = 0;
-#endif /* HAVE_TZSET */
-#endif /* HAVE_GETTIMEOFDAY */
-
-	accum += tzone;
-#endif /* OS_Minix */
-
-	/* correct for Daylight Saving Time */
-	tmp = accum;
-	tmbuf = localtime(&tmp);
-#ifndef OS_Minix
-	dst = (tmbuf->tm_isdst) ? (-60L * 60L) : 0L;
-	accum += dst;
-#endif
-	
-	return accum;
-}
-
-
-static int get_file_data(Stream_t *Stream, time_t *date, mt_size_t *size,
-			 int *type, int *address)
-{
-	DeclareThis(File_t);
-
-	if(date)
-		*date = conv_stamp(& This->direntry.dir);
-	if(size)
-		*size = (mt_size_t) This->FileSize;
-	if(type)
-		*type = This->direntry.dir.attr & ATTR_DIR;
-	if(address)
-		*address = This->FirstAbsCluNr;
-	return 0;
-}
-
-
-static int free_file(Stream_t *Stream)
-{
-	DeclareThis(File_t);
-	Fs_t *Fs = This->Fs;
-	fsPreallocateClusters(Fs, -This->preallocatedClusters);       
-	FREE(&This->direntry.Dir);
-	freeDirCache(Stream);
-	return hash_remove(filehash, (void *) Stream, This->hint);
-}
-
-
-static int flush_file(Stream_t *Stream)
-{
-	DeclareThis(File_t);
-	direntry_t *entry = &This->direntry;
-
-	if(isRootDir(Stream)) {
-		return 0;
-	}
-
-	if(This->FirstAbsCluNr != getStart(entry->Dir, &entry->dir)) {
-		set_word(entry->dir.start, This->FirstAbsCluNr & 0xffff);
-		set_word(entry->dir.startHi, This->FirstAbsCluNr >> 16);
-		dir_write(entry);
-	}
-	return 0;
-}
-
-
-static int pre_allocate_file(Stream_t *Stream, mt_size_t isize)
-{
-	DeclareThis(File_t);
-
-	size_t size = truncBytes32(isize);
-
-	if(size > This->FileSize &&
-	   size > This->preallocatedSize) {
-		This->preallocatedSize = size;
-		return recalcPreallocSize(This);
-	} else
-		return 0;
-}
-
-static Class_t FileClass = {
-	read_file, 
-	write_file, 
-	flush_file, /* flush */
-	free_file, /* free */
-	0, /* get_geom */
-	get_file_data,
-	pre_allocate_file
-};
-
-static unsigned int getAbsCluNr(File_t *This)
-{
-	if(This->FirstAbsCluNr)
-		return This->FirstAbsCluNr;
-	if(isRootDir((Stream_t *) This))
-		return 0;
-	return 1;
-}
-
-static unsigned int func1(void *Stream)
-{
-	DeclareThis(File_t);
-
-	return getAbsCluNr(This) ^ (long) This->Fs;
-}
-
-static unsigned int func2(void *Stream)
-{
-	DeclareThis(File_t);
-
-	return getAbsCluNr(This);
-}
-
-static int comp(void *Stream, void *Stream2)
-{
-	DeclareThis(File_t);
-
-	File_t *This2 = (File_t *) Stream2;
-
-	return This->Fs != This2->Fs ||
-		getAbsCluNr(This) != getAbsCluNr(This2);
-}
-
-static void init_hash(void)
-{
-	static int is_initialised=0;
-	
-	if(!is_initialised){
-		make_ht(func1, func2, comp, 20, &filehash);
-		is_initialised = 1;
-	}
-}
-
-
-static Stream_t *_internalFileOpen(Stream_t *Dir, unsigned int first, 
-				   size_t size, direntry_t *entry)
-{
-	Stream_t *Stream = GetFs(Dir);
-	DeclareThis(Fs_t);
-	File_t Pattern;
-	File_t *File;
-
-	init_hash();
-	This->refs++;
-
-	if(first != 1){
-		/* we use the illegal cluster 1 to mark newly created files.
-		 * do not manage those by hashtable */
-		Pattern.Fs = This;
-		Pattern.Class = &FileClass;
-		if(first || (entry && !IS_DIR(entry)))
-			Pattern.map = normal_map;
-		else
-			Pattern.map = root_map;
-		Pattern.FirstAbsCluNr = first;
-		Pattern.loopDetectRel = 0;
-		Pattern.loopDetectAbs = first;
-		if(!hash_lookup(filehash, (T_HashTableEl) &Pattern, 
-				(T_HashTableEl **)&File, 0)){
-			File->refs++;
-			This->refs--;
-			return (Stream_t *) File;
-		}
-	}
-
-	File = New(File_t);
-	if (!File)
-		return NULL;
-	File->dcp = 0;
-	File->preallocatedClusters = 0;
-	File->preallocatedSize = 0;
-	/* memorize dir for date and attrib */
-	File->direntry = *entry;
-	if(entry->entry == -3)
-		File->direntry.Dir = (Stream_t *) File; /* root directory */
-	else
-		COPY(File->direntry.Dir);
-
-	File->Class = &FileClass;
-	File->Fs = This;
-	if(first || (entry && !IS_DIR(entry)))
-		File->map = normal_map;
-	else
-		File->map = root_map; /* FAT 12/16 root directory */
-	if(first == 1)
-		File->FirstAbsCluNr = 0;
-	else
-		File->FirstAbsCluNr = first;
-
-	File->loopDetectRel = 0;
-	File->loopDetectAbs = 0;
-
-	File->PreviousRelCluNr = 0xffff;
-	File->FileSize = size;
-	File->refs = 1;
-	File->Buffer = 0;
-	hash_add(filehash, (void *) File, &File->hint);
-	return (Stream_t *) File;
-}
-
-Stream_t *OpenRoot(Stream_t *Dir)
-{
-	unsigned int num;
-	direntry_t entry;
-	size_t size;
-	Stream_t *file;
-
-	memset(&entry, 0, sizeof(direntry_t));
-
-	num = fat32RootCluster(Dir);
-
-	/* make the directory entry */
-	entry.entry = -3;
-	entry.name[0] = '\0';
-	mk_entry("/", ATTR_DIR, num, 0, 0, &entry.dir);
-
-	if(num)
-		size = countBytes(Dir, num);
-	else {
-		Fs_t *Fs = (Fs_t *) GetFs(Dir);
-		size = Fs->dir_len * Fs->sector_size;
-	}
-	file = _internalFileOpen(Dir, num, size, &entry);
-	bufferize(&file);
-	return file;
-}
-
-
-Stream_t *OpenFileByDirentry(direntry_t *entry)
-{
-	Stream_t *file;
-	unsigned int first;
-	size_t size;
-
-	first = getStart(entry->Dir, &entry->dir);
-
-	if(!first && IS_DIR(entry))
-		return OpenRoot(entry->Dir);
-	if (IS_DIR(entry))
-		size = countBytes(entry->Dir, first);
-	else 
-		size = FILE_SIZE(&entry->dir);
-	file = _internalFileOpen(entry->Dir, first, size, entry);
-	if(IS_DIR(entry)) {
-		bufferize(&file);
-		if(first == 1)
-			dir_grow(file, 0);
-	}
-
-	return file;
-}
-
-
-int isRootDir(Stream_t *Stream)
-{
-	File_t *This = getUnbufferedFile(Stream);
-
-	return This->map == root_map;
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/file.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/file.h	(revision 9)
+++ 	(revision )
@@ -1,11 +1,0 @@
-#ifndef MTOOLS_FILE_H
-#define MTOOLS_FILE_H
-
-#include "stream.h"
-#include "mtoolsDirent.h"
-
-Stream_t *OpenFileByDirentry(direntry_t *entry);
-Stream_t *OpenRoot(Stream_t *Dir);
-void printFat(Stream_t *Stream);
-direntry_t *getDirentry(Stream_t *Stream);
-#endif
Index: trunk/minix/commands/i386/mtools-3.9.7/file_name.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/file_name.c	(revision 9)
+++ 	(revision )
@@ -1,203 +1,0 @@
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "vfat.h"
-#include "codepage.h"
-
-/* Write a DOS name + extension into a legal unix-style name.  */
-char *unix_normalize (char *ans, char *name, char *ext)
-{
-	char *a;
-	int j;
-	
-	for (a=ans,j=0; (j<8) && (name[j] > ' '); ++j,++a)
-		*a = name[j];
-	if(*ext > ' ') {
-		*a++ = '.';
-		for (j=0; j<3 && ext[j] > ' '; ++j,++a)
-			*a = ext[j];
-	}
-	*a++ = '\0';
-	return ans;
-}
-
-typedef enum Case_l {
-	NONE,
-	UPPER,
-	LOWER 
-} Case_t;
-
-static void TranslateToDos(const char *s, char *t, int count,
-			   char *end, Case_t *Case, int *mangled)
-{
-	*Case = NONE;
-	for( ;  *s && (s < end || !end); s++) {
-		if(!count) {
-			*mangled |= 3;
-			break;
-		}
-		/* skip spaces & dots */
-		if(*s == ' ' || *s == '.') {
-			*mangled |= 3;
-			continue;
-		}
-
-		/* convert to dos */
-		if((*s) & 0x80) {
-			*mangled |= 1;
-			*t = to_dos(*s);
-		}
-
-		if ((*s & 0x7f) < ' ' ) {
-			*mangled |= 3;
-			*t = '_';
-		} else if (islower((unsigned char)*s)) {
-			*t = toupper(*s);
-			if(*Case == UPPER && !mtools_no_vfat)
-				*mangled |= 1;
-			else
-				*Case = LOWER;
-		} else if (isupper((unsigned char)*s)) {
-			*t = *s;
-			if(*Case == LOWER && !mtools_no_vfat)
-				*mangled |= 1;
-			else
-				*Case = UPPER;
-		} else if((*s) & 0x80)
-			*t = mstoupper(*t);	/* upper case */
-		else
-			*t = *s;
-		count--;
-		t++;
-	}
-}
-
-/* dos_name
- *
- * Convert a Unix-style filename to a legal MSDOS name and extension.
- * Will truncate file and extension names, will substitute
- * the character '~' for any illegal character(s) in the name.
- */
-char *dos_name(char *name, int verbose, int *mangled, char *ans)
-{
-	char *s, *ext;
-	register int i;
-	Case_t BaseCase, ExtCase;
-
-	*mangled = 0;
-
-	/* skip drive letter */
-	name = skip_drive(name);
-
-	/* zap the leading path */
-	name = (char *) _basename(name);
-	if ((s = strrchr(name, '\\')))
-		name = s + 1;
-	
-	memset(ans, ' ', 11);
-	ans[11]='\0';
-
-	/* skip leading dots and spaces */
-	i = strspn(name, ". ");
-	if(i) {
-		name += i;
-		*mangled = 3;
-	}
-		
-	ext = strrchr(name, '.');
-
-	/* main name */
-	TranslateToDos(name, ans, 8, ext, &BaseCase, mangled);
-	if(ext)
-		TranslateToDos(ext+1, ans+8, 3, 0, &ExtCase,  mangled);
-
-	if(*mangled & 2)
-		autorename_short(ans, 0);
-
-	if(!*mangled) {
-		if(BaseCase == LOWER)
-			*mangled |= BASECASE;
-		if(ExtCase == LOWER)
-			*mangled |= EXTCASE;
-		if((BaseCase == LOWER || ExtCase == LOWER) &&
-		   !mtools_no_vfat) {
-		  *mangled |= 1;
-		}
-	}
-	return ans;
-}
-
-
-/*
- * Get rid of spaces in an MSDOS 'raw' name (one that has come from the
- * directory structure) so that it can be used for regular expression
- * matching with a Unix filename.  Also used to 'unfix' a name that has
- * been altered by dos_name().
- */
-
-char *unix_name(char *name, char *ext, char Case, char *ans)
-{
-	char *s, tname[9], text[4];
-	int i;
-
-	strncpy(tname, (char *) name, 8);
-	tname[8] = '\0';
-	if ((s = strchr(tname, ' ')))
-		*s = '\0';
-
-	if(!(Case & (BASECASE | EXTCASE)) && mtools_ignore_short_case)
-		Case |= BASECASE | EXTCASE;
-
-	if(Case & BASECASE)
-		for(i=0;i<8 && tname[i];i++)
-			tname[i] = tolower(tname[i]);
-
-	strncpy(text, (char *) ext, 3);
-	text[3] = '\0';
-	if ((s = strchr(text, ' ')))
-		*s = '\0';
-
-	if(Case & EXTCASE)
-		for(i=0;i<3 && text[i];i++)
-			text[i] = tolower(text[i]);
-
-	if (*text) {
-		strcpy(ans, tname);
-		strcat(ans, ".");
-		strcat(ans, text);
-	} else
-		strcpy(ans, tname);
-
-	/* fix special characters (above 0x80) */
-	to_unix(ans,11);
-	return(ans);
-}
-
-/* If null encountered, set *end to 0x40 and write nulls rest of way
- * 950820: Win95 does not like this!  It complains about bad characters.
- * So, instead: If null encountered, set *end to 0x40, write the null, and
- * write 0xff the rest of the way (that is what Win95 seems to do; hopefully
- * that will make it happy)
- */
-/* Always return num */
-int unicode_write(char *in, struct unicode_char *out, int num, int *end_p)
-{
-	int j;
-
-	for (j=0; j<num; ++j) {
-		out->uchar = '\0';	/* Hard coded to ASCII */
-		if (*end_p)
-			/* Fill with 0xff */
-			out->uchar = out->lchar = (char) 0xff;
-		else {
-			out->lchar = *in;
-			if (! *in) {
-				*end_p = VSE_LAST;
-			}
-		}
-
-		++out;
-		++in;
-	}
-	return num;
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/file_read.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/file_read.c	(revision 9)
+++ 	(revision )
@@ -1,37 +1,0 @@
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "file.h"
-
-/*
- * Read the clusters given the beginning FAT entry.  Returns 0 on success.
- */
-
-int file_read(FILE *fp, Stream_t *Source, int textmode, int stripmode)
-{
-	char buffer[16384];
-	int pos;
-	int ret;
-
-	if (!Source){
-		fprintf(stderr,"Couldn't open source file\n");
-		return -1;
-	}
-	
-	pos = 0;
-	while(1){
-		ret = Source->Class->read(Source, buffer, (mt_off_t) pos, 16384);
-		if (ret < 0 ){
-			perror("file read");
-			return -1;
-		}
-		if ( ret == 0)
-			break;
-		if(!fwrite(buffer, 1, ret, fp)){
-			perror("write");
-			return -1;
-		}
-		pos += ret;
-	}
-	return 0;
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/filter.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/filter.c	(revision 9)
+++ 	(revision )
@@ -1,140 +1,0 @@
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-
-typedef struct Filter_t {
-	Class_t *Class;
-	int refs;
-	Stream_t *Next;
-	Stream_t *Buffer;
-
-	int dospos;
-	int unixpos;
-	int mode;
-	int rw;
-	int lastchar;
-} Filter_t;
-
-#define F_READ 1
-#define F_WRITE 2
-
-/* read filter filters out messy dos' bizarre end of lines and final 0x1a's */
-
-static int read_filter(Stream_t *Stream, char *buf, mt_off_t iwhere, size_t len)
-{
-	DeclareThis(Filter_t);
-	int i,j,ret;
-
-	off_t where = truncBytes32(iwhere);
-
-	if ( where != This->unixpos ){
-		fprintf(stderr,"Bad offset\n");
-		exit(1);
-	}
-	if (This->rw == F_WRITE){
-		fprintf(stderr,"Change of transfer direction!\n");
-		exit(1);
-	}
-	This->rw = F_READ;
-	
-	ret = READS(This->Next, buf, (mt_off_t) This->dospos, len);
-	if ( ret < 0 )
-		return ret;
-
-	j = 0;
-	for (i=0; i< ret; i++){
-		if ( buf[i] == '\r' )
-			continue;
-		if (buf[i] == 0x1a)
-			break;
-		This->lastchar = buf[j++] = buf[i];	
-	}
-
-	This->dospos += i;
-	This->unixpos += j;
-	return j;
-}
-
-static int write_filter(Stream_t *Stream, char *buf, mt_off_t iwhere, 
-						size_t len)
-{
-	DeclareThis(Filter_t);
-	int i,j,ret;
-	char buffer[1025];
-
-	off_t where = truncBytes32(iwhere);
-
-	if(This->unixpos == -1)
-		return -1;
-
-	if (where != This->unixpos ){
-		fprintf(stderr,"Bad offset\n");
-		exit(1);
-	}
-	
-	if (This->rw == F_READ){
-		fprintf(stderr,"Change of transfer direction!\n");
-		exit(1);
-	}
-	This->rw = F_WRITE;
-
-	j=i=0;
-	while(i < 1024 && j < len){
-		if (buf[j] == '\n' ){
-			buffer[i++] = '\r';
-			buffer[i++] = '\n';
-			j++;
-			continue;
-		}
-		buffer[i++] = buf[j++];
-	}
-	This->unixpos += j;
-
-	ret = force_write(This->Next, buffer, (mt_off_t) This->dospos, i);
-	if(ret >0 )
-		This->dospos += ret;
-	if ( ret != i ){
-		/* no space on target file ? */
-		This->unixpos = -1;
-		return -1;
-	}
-	return j;
-}
-
-static int free_filter(Stream_t *Stream)
-{
-	DeclareThis(Filter_t);       
-	char buffer=0x1a;
-
-	/* write end of file */
-	if (This->rw == F_WRITE)
-		return force_write(This->Next, &buffer, (mt_off_t) This->dospos, 1);
-	else
-		return 0;
-}
-
-static Class_t FilterClass = { 
-	read_filter,
-	write_filter,
-	0, /* flush */
-	free_filter,
-	0, /* set geometry */
-	get_data_pass_through,
-	0
-};
-
-Stream_t *open_filter(Stream_t *Next)
-{
-	Filter_t *This;
-
-	This = New(Filter_t);
-	if (!This)
-		return NULL;
-	This->Class = &FilterClass;
-	This->dospos = This->unixpos = This->rw = 0;
-	This->Next = Next;
-	This->refs = 1;
-	This->Buffer = 0;
-
-	return (Stream_t *) This;
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/floppyd_io.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/floppyd_io.c	(revision 9)
+++ 	(revision )
@@ -1,559 +1,0 @@
-/*
- * IO to the floppyd daemon running on the local X-Server Host
- *
- * written by:
- *
- * Peter Schlaile
- *
- * udbz@rz.uni-karlsruhe.de
- *
- */
-
-#include "sysincludes.h"
-#include "stream.h"
-#include "mtools.h"
-#include "msdos.h"
-#include "scsi.h"
-#include "partition.h"
-#include "floppyd_io.h"
-
-#ifdef USE_FLOPPYD
-
-/* ######################################################################## */
-
-
-typedef unsigned char Byte;
-typedef unsigned long Dword;
-
-char* AuthErrors[] = {
-	"Auth success!",
-	"Auth failed: Packet oversized!",
-	"Auth failed: X-Cookie doesn't match!",
-	"Auth failed: Wrong transmission protocol version!",
-	"Auth failed: Device locked!"
-};
-
-
-typedef struct RemoteFile_t {
-	Class_t *Class;
-	int refs;
-	Stream_t *Next;
-	Stream_t *Buffer;
-	int fd;
-	mt_off_t offset;
-	mt_off_t lastwhere;
-	mt_off_t size;
-} RemoteFile_t;
-
-
-#ifndef HAVE_HTONS
-unsigned short myhtons(unsigned short parm) 
-{
-	Byte val[2];
-	
-	val[0] = (parm >> 8) & 0xff;
-	val[1] = parm        & 0xff;
-
-	return *((unsigned short*) (val));
-}
-#endif
-
-Dword byte2dword(Byte* val) 
-{
-	Dword l;
-	l = (val[0] << 24) + (val[1] << 16) + (val[2] << 8) + val[3];
-
-	return l;
-}	
-
-void dword2byte(Dword parm, Byte* rval) 
-{
-	rval[0] = (parm >> 24) & 0xff;
-	rval[1] = (parm >> 16) & 0xff;
-	rval[2] = (parm >> 8)  & 0xff;
-	rval[3] = parm         & 0xff;
-}
-
-Dword read_dword(int handle) 
-{
-	Byte val[4];
-	
-	read(handle, val, 4);
-
-	return byte2dword(val);
-}
-
-void write_dword(int handle, Dword parm) 
-{
-	Byte val[4];
-
-	dword2byte(parm, val);
-
-	write(handle, val, 4);
-}
-
-
-/* ######################################################################## */
-
-int authenticate_to_floppyd(int sock, char *display)
-{
-	off_t filelen;
-	Byte buf[16];
-	char *command[] = { "xauth", "xauth", "extract", "-", 0, 0 };
-	char *xcookie;
-	Dword errcode;
-
-	command[4] = display;
-
-	filelen=strlen(display);
-	filelen += 100;
-
-	xcookie = (char *) safe_malloc(filelen+4);
-	filelen = safePopenOut(command, xcookie+4, filelen);
-	if(filelen < 1)
-		return AUTH_AUTHFAILED;
-
-	dword2byte(4,buf);
-	dword2byte(FLOPPYD_PROTOCOL_VERSION,buf+4);
-	write(sock, buf, 8);
-
-	if (read_dword(sock) != 4) {
-		return AUTH_WRONGVERSION;
-	}
-
-	errcode = read_dword(sock);
-
-	if (errcode != AUTH_SUCCESS) {
-		return errcode;
-	}
-
-	dword2byte(filelen, xcookie);
-	write(sock, xcookie, filelen+4);
-
-	if (read_dword(sock) != 4) {
-		return AUTH_PACKETOVERSIZE;
-	}
-
-	errcode = read_dword(sock);
-	
-	return errcode;
-}
-
-
-static int floppyd_reader(int fd, char* buffer, int len) 
-{
-	Dword errcode;
-	Dword gotlen;
-	int l;
-	int start;
-	Byte buf[16];
-
-	dword2byte(1, buf);
-	buf[4] = OP_READ;
-	dword2byte(4, buf+5);
-	dword2byte(len, buf+9);
-	write(fd, buf, 13);
-
-	if (read_dword(fd) != 8) {
-		errno = EIO;
-		return -1;
-	}
-
-	gotlen = read_dword(fd);
-	errcode = read_dword(fd);
-
-	if (gotlen != -1) {
-		if (read_dword(fd) != gotlen) {
-			errno = EIO;
-			return -1;
-		}
-		for (start = 0, l = 0; start < gotlen; start += l) {
-			l = read(fd, buffer+start, gotlen-start);
-			if (l == 0) {
-				errno = EIO;
-				return -1;
-			}
-		}
-	} else {
-		errno = errcode;
-	}
-	return gotlen;
-}
-
-static int floppyd_writer(int fd, char* buffer, int len) 
-{
-	Dword errcode;
-	Dword gotlen;
-	Byte buf[16];
-
-	dword2byte(1, buf);
-	buf[4] = OP_WRITE;
-	dword2byte(len, buf+5);
-
-	write(fd, buf, 9);
-        write(fd, buffer, len);
-	
-	if (read_dword(fd) != 8) {
-		errno = EIO;
-		return -1;
-	}
-
-	gotlen = read_dword(fd);
-	errcode = read_dword(fd);
-
-	errno = errcode;
-	
-	return gotlen;
-}
-
-static int floppyd_lseek(int fd, mt_off_t offset, int whence) 
-{
-	Dword errcode;
-	Dword gotlen;
-	Byte buf[32];
-	
-	dword2byte(1, buf);
-	buf[4] = OP_SEEK;
-	
-	dword2byte(8, buf+5);
-	dword2byte(truncBytes32(offset), buf+9);
-	dword2byte(whence, buf+13);
-	
-	write(fd, buf, 17);
-       
-	if (read_dword(fd) != 8) {
-		errno = EIO;
-		return -1;
-	}
-
-	gotlen = read_dword(fd);
-	errcode = read_dword(fd);
-
-	errno = errcode;
-	
-	return gotlen;
-}
-
-/* ######################################################################## */
-
-typedef int (*iofn) (int, char *, int);
-
-static int floppyd_io(Stream_t *Stream, char *buf, mt_off_t where, int len,
-		   iofn io)
-{
-	DeclareThis(RemoteFile_t);
-	int ret;
-
-	where += This->offset;
-
-	if (where != This->lastwhere ){
-		if(floppyd_lseek( This->fd, where, SEEK_SET) < 0 ){
-			perror("floppyd_lseek");
-			This->lastwhere = (mt_off_t) -1;
-			return -1;
-		}
-	}
-	ret = io(This->fd, buf, len);
-	if ( ret == -1 ){
-		perror("floppyd_io");
-		This->lastwhere = (mt_off_t) -1;
-		return -1;
-	}
-	This->lastwhere = where + ret;
-	return ret;
-}
-
-static int floppyd_read(Stream_t *Stream, char *buf, mt_off_t where, size_t len)
-{	
-	return floppyd_io(Stream, buf, where, len, (iofn) floppyd_reader);
-}
-
-static int floppyd_write(Stream_t *Stream, char *buf, mt_off_t where, size_t len)
-{
-	return floppyd_io(Stream, buf, where, len, (iofn) floppyd_writer);
-}
-
-static int floppyd_flush(Stream_t *Stream)
-{
-#if 0
-	Byte buf[16];
-
-	DeclareThis(RemoteFile_t);
-
-	dword2byte(1, buf);
-	buf[4] = OP_FLUSH;
-
-	write(This->fd, buf, 5);
-
-	if (read_dword(This->fd) != 8) {
-		errno = EIO;
-		return -1;
-	}
-
-	read_dword(This->fd);
-	read_dword(This->fd);
-#endif
-	return 0;
-}
-
-static int floppyd_free(Stream_t *Stream)
-{
-	Byte buf[16];
-
-	DeclareThis(RemoteFile_t);
-
-	if (This->fd > 2) {
-		dword2byte(1, buf);
-		buf[4] = OP_CLOSE;
-		write(This->fd, buf, 5);
-		return close(This->fd);
-	} else {
-		return 0;
-	}
-}
-
-static int floppyd_geom(Stream_t *Stream, struct device *dev, 
-		     struct device *orig_dev,
-		     int media, struct bootsector *boot)
-{
-	size_t tot_sectors;
-	int sect_per_track;
-	DeclareThis(RemoteFile_t);
-
-	dev->ssize = 2; /* allow for init_geom to change it */
-	dev->use_2m = 0x80; /* disable 2m mode to begin */
-
-	if(media == 0xf0 || media >= 0x100){		
-		dev->heads = WORD(nheads);
-		dev->sectors = WORD(nsect);
-		tot_sectors = DWORD(bigsect);
-		SET_INT(tot_sectors, WORD(psect));
-		sect_per_track = dev->heads * dev->sectors;
-		tot_sectors += sect_per_track - 1; /* round size up */
-		dev->tracks = tot_sectors / sect_per_track;
-
-	} else if (media >= 0xf8){
-		media &= 3;
-		dev->heads = old_dos[media].heads;
-		dev->tracks = old_dos[media].tracks;
-		dev->sectors = old_dos[media].sectors;
-		dev->ssize = 0x80;
-		dev->use_2m = ~1;
-	} else {
-		fprintf(stderr,"Unknown media type\n");
-		exit(1);
-	}
-
-	This->size = (mt_off_t) 512 * dev->sectors * dev->tracks * dev->heads;
-
-	return 0;
-}
-
-
-static int floppyd_data(Stream_t *Stream, time_t *date, mt_size_t *size,
-		     int *type, int *address)
-{
-	DeclareThis(RemoteFile_t);
-
-	if(date)
-		/* unknown, and irrelevant anyways */
-		*date = 0;
-	if(size)
-		/* the size derived from the geometry */
-		*size = (mt_size_t) This->size;
-	if(type)
-		*type = 0; /* not a directory */
-	if(address)
-		*address = 0;
-	return 0;
-}
-
-/* ######################################################################## */
-
-static Class_t FloppydFileClass = {
-	floppyd_read, 
-	floppyd_write,
-	floppyd_flush,
-	floppyd_free,
-	floppyd_geom,
-	floppyd_data
-};
-
-/* ######################################################################## */
-
-int get_host_and_port(const char* name, char** hostname, char **display,
-					  short* port)
-{
-	char* newname = strdup(name);
-	char* p;
-	char* p2;
-
-	p = newname;
-	while (*p != '/' && *p) p++;
-	p2 = p;
-	if (*p) p++;
-	*p2 = 0;
-	
-	*port = atoi(p);
-	if (*port == 0) {
-		*port = FLOPPYD_DEFAULT_PORT;	
-	}
-
-	*display = strdup(newname);
-
-	p = newname;
-	while (*p != ':' && *p) p++;
-	p2 = p;
-	if (*p) p++;
-	*p2 = 0;
-
-	*port += atoi(p);  /* add display number to the port */
-
-	if (!*newname || strcmp(newname, "unix") == 0) {
-		free(newname);
-		newname = strdup("localhost");
-	}
-
-	*hostname = newname;
-	return 1;
-}
-
-/*
- *  * Return the IP address of the specified host.
- *  */
-static IPaddr_t getipaddress(char *ipaddr)
-{
-	
-	struct hostent  *host;
-	IPaddr_t        ip;
-
-	if (((ip = inet_addr(ipaddr)) == INADDR_NONE) &&
-	    (strcmp(ipaddr, "255.255.255.255") != 0)) {
-		
-		if ((host = gethostbyname(ipaddr)) != NULL) {
-			memcpy(&ip, host->h_addr, sizeof(ip));
-		}
-		
-		endhostent();
-	}
-	
-#ifdef DEBUG
-	fprintf(stderr, "IP lookup %s -> 0x%08lx\n", ipaddr, ip);
-#endif
-	  
-	return (ip);
-}
-
-/*
- *  * Connect to the floppyd server.
- *  */
-static int connect_to_server(IPaddr_t ip, short port)
-{
-	
-	struct sockaddr_in      addr;
-	int                     sock;
-	
-	/*
-	 * Allocate a socket.
-	 */
-	if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-		return (-1);
-	}
-	
-	/*
-	 * Set the address to connect to.
-	 */
-	
-	addr.sin_family = AF_INET;
-#ifndef HAVE_HTONS
-	addr.sin_port = myhtons(port);
-#else	
-	addr.sin_port = htons(port);
-#endif	
-	addr.sin_addr.s_addr = ip;
-	
-        /*
-	 * Connect our socket to the above address.
-	 */
-	if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-		return (-1);
-	}
-
-        /*
-	 * Set the keepalive socket option to on.
-	 */
-	{
-		int             on = 1;
-		setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, 
-			   (char *)&on, sizeof(on));
-	}
-	
-	return (sock);
-}
-
-static int ConnectToFloppyd(const char* name);
-
-Stream_t *FloppydOpen(struct device *dev, struct device *dev2,
-					  char *name, int mode, char *errmsg,
-					  int mode2, int locked)
-{
-	RemoteFile_t *This;
-
-	if (!dev ||  !(dev->misc_flags & FLOPPYD_FLAG))
-		return NULL;
-	
-	This = New(RemoteFile_t);
-	if (!This){
-		printOom();
-		return NULL;
-	}
-	This->Class = &FloppydFileClass;
-	This->Next = 0;
-	This->offset = 0;
-	This->lastwhere = 0;
-	This->refs = 1;
-	This->Buffer = 0;
-
-	This->fd = ConnectToFloppyd(name);
-	if (This->fd == -1) {
-		Free(This);
-		return NULL;
-	}
-	return (Stream_t *) This;
-}
-
-static int ConnectToFloppyd(const char* name) 
-{
-	char* hostname;
-	char* display;
-	short port;
-	int rval = get_host_and_port(name, &hostname, &display, &port);
-	int sock;
-	int reply;
-	
-	if (!rval) return -1;
-
-	sock = connect_to_server(getipaddress(hostname), port);
-
-	if (sock == -1) {
-		fprintf(stderr,
-			"Can't connect to floppyd server on %s, port %i!\n",
-			hostname, port);
-		return -1;
-	}
-	
-	reply = authenticate_to_floppyd(sock, display);
-
-	if (reply != 0) {
-		fprintf(stderr, 
-			"Permission denied, authentication failed!\n"
-			"%s\n", AuthErrors[reply]);
-		return -1;
-	}
-	
-	free(hostname);
-	free(display);
-
-	return sock;
-}
-#endif
Index: trunk/minix/commands/i386/mtools-3.9.7/floppyd_io.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/floppyd_io.h	(revision 9)
+++ 	(revision )
@@ -1,37 +1,0 @@
-#ifndef MTOOLS_FLOPPYDIO_H
-#define MTOOLS_FLOPPYDIO_H
-
-#ifdef USE_FLOPPYD
-
-#include "stream.h"
-
-/*extern int ConnectToFloppyd(const char* name, Class_t** ioclass);*/
-Stream_t *FloppydOpen(struct device *dev, struct device *dev2,
-					  char *name, int mode, char *errmsg,
-					  int mode2, int locked);
-
-#define FLOPPYD_DEFAULT_PORT 5703
-#define FLOPPYD_PROTOCOL_VERSION 10
-
-enum FloppydOpcodes {
-	OP_READ,
-	OP_WRITE,
-	OP_SEEK,
-	OP_FLUSH,
-	OP_CLOSE,
-	OP_IOCTL
-};
-
-enum AuthErrorsEnum {
-	AUTH_SUCCESS,
-	AUTH_PACKETOVERSIZE,
-	AUTH_AUTHFAILED,
-	AUTH_WRONGVERSION,
-	AUTH_DEVLOCKED,
-	AUTH_BADPACKET
-};
-
-typedef unsigned long IPaddr_t;
-
-#endif
-#endif
Index: trunk/minix/commands/i386/mtools-3.9.7/force_io.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/force_io.c	(revision 9)
+++ 	(revision )
@@ -1,48 +1,0 @@
-/*
- * Force I/O to be done to complete transfer length
- *
- * written by:
- *
- * Alain L. Knaff			
- * alain@linux.lu
- *
- */
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "stream.h"
-
-static int force_io(Stream_t *Stream,
-		    char *buf, mt_off_t start, size_t len,
-		    int (*io)(Stream_t *, char *, mt_off_t, size_t))
-{
-	int ret;
-	int done=0;
-	
-	while(len){
-		ret = io(Stream, buf, start, len);
-		if ( ret <= 0 ){
-			if (done)
-				return done;
-			else
-				return ret;
-		}
-		start += ret;
-		done += ret;
-		len -= ret;
-		buf += ret;
-	}
-	return done;
-}
-
-int force_write(Stream_t *Stream, char *buf, mt_off_t start, size_t len)
-{
-	return force_io(Stream, buf, start, len,
-					Stream->Class->write);
-}
-
-int force_read(Stream_t *Stream, char *buf, mt_off_t start, size_t len)
-{
-	return force_io(Stream, buf, start, len,
-					Stream->Class->read);
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/fs.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/fs.h	(revision 9)
+++ 	(revision )
@@ -1,26 +1,0 @@
-#ifndef MTOOLS_FS_H
-#define MTOOLS_FS_H
-
-#include "stream.h"
-
-
-typedef struct FsPublic_t {
-	Class_t *Class;
-	int refs;
-	Stream_t *Next;
-	Stream_t *Buffer;
-
-	int serialized;
-	unsigned long serial_number;
-	int cluster_size;
-	unsigned int sector_size;
-} FsPublic_t;
-
-Stream_t *fs_init(char *drive, int mode);
-int fat_free(Stream_t *Dir, unsigned int fat);
-int fatFreeWithDir(Stream_t *Dir, struct directory *dir);
-int fat_error(Stream_t *Dir);
-int fat32RootCluster(Stream_t *Dir);
-char *getDrive(Stream_t *Stream);
-
-#endif
Index: trunk/minix/commands/i386/mtools-3.9.7/fsP.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/fsP.h	(revision 9)
+++ 	(revision )
@@ -1,84 +1,0 @@
-#ifndef MTOOLS_FSP_H
-#define MTOOLS_FSP_H
-
-#include "stream.h"
-#include "msdos.h"
-#include "fs.h"
-
-typedef enum fatAccessMode_t { 
-	FAT_ACCESS_READ, 
-	FAT_ACCESS_WRITE
-} fatAccessMode_t;
-
-typedef struct Fs_t {
-	Class_t *Class;
-	int refs;
-	Stream_t *Next;
-	Stream_t *Buffer;
-	
-	int serialized;
-	unsigned long serial_number;
-	int cluster_size;
-	unsigned int sector_size;
-	int fat_error;
-
-	unsigned int (*fat_decode)(struct Fs_t *This, unsigned int num);
-	void (*fat_encode)(struct Fs_t *This, unsigned int num,
-			   unsigned int code);
-
-	Stream_t *Direct;
-	int fat_dirty;
-	unsigned int fat_start;
-	unsigned int fat_len;
-
-	int num_fat;
-	unsigned int end_fat;
-	unsigned int last_fat;
-	int fat_bits;
-	struct FatMap_t *FatMap;
-
-	int dir_start;
-	int dir_len;
-	int clus_start;
-
-	int num_clus;
-	char *drive; /* for error messages */
-
-	/* fat 32 */
-	unsigned int primaryFat;
-	unsigned int writeAllFats;
-	unsigned int rootCluster;
-	int infoSectorLoc;
-	unsigned int last; /* last sector allocated, or MAX32 if unknown */
-	unsigned int freeSpace; /* free space, or MAX32 if unknown */
-	int preallocatedClusters;
-
-	int lastFatSectorNr;
-	unsigned char *lastFatSectorData;
-	fatAccessMode_t lastFatAccessMode;
-	int sectorMask;
-	int sectorShift;
-} Fs_t;
-
-int fs_free(Stream_t *Stream);
-
-void set_fat12(Fs_t *Fs);
-void set_fat16(Fs_t *Fs);
-void set_fat32(Fs_t *Fs);
-unsigned int get_next_free_cluster(Fs_t *Fs, unsigned int last);
-unsigned int fatDecode(Fs_t *This, unsigned int pos);
-void fatAppend(Fs_t *This, unsigned int pos, unsigned int newpos);
-void fatDeallocate(Fs_t *This, unsigned int pos);
-void fatAllocate(Fs_t *This, unsigned int pos, unsigned int value);
-void fatEncode(Fs_t *This, unsigned int pos, unsigned int value);
-
-int fat_read(Fs_t *This, struct bootsector *boot, int fat_bits,
-			 size_t tot_sectors, int nodups);
-void fat_write(Fs_t *This);
-int zero_fat(Fs_t *Fs, int media_descriptor);
-extern Class_t FsClass;
-int fsPreallocateClusters(Fs_t *Fs, long);
-Fs_t *getFs(Stream_t *Stream);
-
-
-#endif
Index: trunk/minix/commands/i386/mtools-3.9.7/hash.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/hash.c	(revision 9)
+++ 	(revision )
@@ -1,205 +1,0 @@
-/*
- * hash.c - hash table.
- */
-
-#include "sysincludes.h"
-#include "htable.h"
-#include "mtools.h"
-
-struct hashtable {
-  T_HashFunc f1,f2;
-  T_ComparFunc compar;
-  int size;  /* actual size of the array */
-  int fill;  /* number of deleted or in use slots */
-  int inuse; /* number of slots in use */
-  int max;   /* maximal number of elements to keep efficient */
-  T_HashTableEl *entries;
-};
-
-static int sizes[]={5, 11, 23, 47, 97, 197, 397, 797, 1597, 3203, 6421, 12853,
-		    25717, 51437, 102877, 205759, 411527, 823117, 1646237,
-		    3292489, 6584983, 13169977, 26339969, 52679969, 105359939,
-		    210719881, 421439783, 842879579, 1685759167, 0 };
-static int deleted=0;
-static int unallocated=0;
-
-static int alloc_ht(T_HashTable *H, int size)
-{
-  int i;
-
-  for(i=0; sizes[i]; i++)
-    if (sizes[i] > size*4 )
-      break;
-  if (!sizes[i])
-    for(i=0; sizes[i]; i++)
-      if (sizes[i] > size*2 )
-	break;
-  if (!sizes[i])
-    for(i=0; sizes[i]; i++)
-      if (sizes[i] > size)
-	break;
-  if(!sizes[i])
-    return -1;
-  size = sizes[i];
-  if(size < H->size)
-	  size = H->size; /* never shrink the table */
-  H->max = size * 4 / 5 - 2;
-  H->size = size;
-  H->fill = 0;
-  H->inuse = 0;
-  H->entries = NewArray(size, T_HashTableEl);
-  if (H->entries == NULL)
-    return -1; /* out of memory error */
-  
-  for(i=0; i < size; i++)
-    H->entries[i] = &unallocated;
-  return 0;
-}
-
-int make_ht(T_HashFunc f1, T_HashFunc f2, T_ComparFunc c, int size,
-	    T_HashTable **H)
-{
-  *H = New(T_HashTable);
-  if (*H == NULL){
-    return -1; /* out of memory error */
-  }
-  
-  (*H)->f1 = f1;
-  (*H)->f2 = f2;
-  (*H)->compar = c;
-  (*H)->size = 0;
-  if(alloc_ht(*H,size))
-    return -1;
-  return 0;
-}
-
-int free_ht(T_HashTable *H, T_HashFunc entry_free)
-{
-  int i;
-  if(entry_free)
-    for(i=0; i< H->size; i++)
-      if (H->entries[i] != &unallocated &&
-	  H->entries[i] != &deleted)
-	entry_free(H->entries[i]);
-  Free(H->entries);
-  Free(H);
-  return 0;
-}
-
-/* add into hash table without checking for repeats */
-static int _hash_add(T_HashTable *H,T_HashTableEl *E, int *hint)
-{
-  int f2, pos, ctr;
-
-  pos = H->f1(E) % H->size;
-  f2 = -1;
-  ctr = 0;
-  while(H->entries[pos] != &unallocated &&
-	H->entries[pos] != &deleted){
-    if (f2 == -1)
-      f2 = H->f2(E) % (H->size - 1);
-    pos = (pos+f2+1) % H->size;
-    ctr++;
-  }
-  if(H->entries[pos] == &unallocated)
-     H->fill++; /* only increase fill if the previous element was not yet
-		 * counted, i.e. unallocated */
-  H->inuse++;
-  H->entries[pos] = E;
-  if(hint)
-	  *hint = pos;
-  return 0;
-}
-
-static int rehash(T_HashTable *H)
-{
-  int size,i;
-  T_HashTableEl *oldentries;
-  /* resize the table */
-  
-  size = H->size;
-  oldentries = H->entries;
-  if(alloc_ht(H,((H->inuse+1)*4+H->fill)/5))
-	  return -1;
-
-  for(i=0; i < size; i++){
-    if(oldentries[i] != &unallocated && oldentries[i] != &deleted)
-      _hash_add(H, oldentries[i], 0);
-  }
-  Free(oldentries);
-  return 0;
-}
-
-int hash_add(T_HashTable *H, T_HashTableEl *E, int *hint)
-{
-  if (H->fill >= H->max)
-    rehash(H);
-  if (H->fill == H->size)
-    return -1; /*out of memory error */
-  return _hash_add(H,E, hint);
-}
-
-
-/* add into hash table without checking for repeats */
-static int _hash_lookup(T_HashTable *H,T_HashTableEl *E, T_HashTableEl **E2,
-			int *hint, int isIdentity)
-{
-  int f2, pos, upos, ttl;
-
-  pos = H->f1(E) % H->size;
-  ttl = H->size;
-  f2 = -1;
-  upos = -1;
-  while(ttl &&
-	H->entries[pos] != &unallocated &&
-	(H->entries[pos] == &deleted ||
-	 ((isIdentity || H->compar(H->entries[pos], E) != 0) &&
-	  (!isIdentity || H->entries[pos] != E)))){
-    if (f2 == -1)
-      f2 = H->f2(E) % (H->size - 1);
-    if (upos == -1 && H->entries[pos] == &deleted)
-      upos = pos;
-    pos = (pos+f2+1) % H->size;
-    ttl--;
-  }
-  if(H->entries[pos] == &unallocated || !ttl)
-    return -1;
-  if (upos != -1){
-    H->entries[upos] = H->entries[pos];
-    H->entries[pos] = &deleted;
-    pos = upos;
-  }
-  if(hint)
-    *hint = pos;
-  *E2= H->entries[pos];
-  return 0;
-}
-
-
-int hash_lookup(T_HashTable *H,T_HashTableEl *E, T_HashTableEl **E2,
-		int *hint)
-{
-	return _hash_lookup(H, E, E2, hint, 0);
-}
-
-/* add into hash table without checking for repeats */
-int hash_remove(T_HashTable *H,T_HashTableEl *E, int hint)
-{
-  T_HashTableEl *E2;
-
-  if (hint >=0 && hint < H->size &&
-      H->entries[hint] == E){
-    H->inuse--;
-    H->entries[hint] = &deleted;
-    return 0;
-  }
-
-  if(_hash_lookup(H, E, &E2, &hint, 1)) {
-	  fprintf(stderr, "Removing non-existent entry\n");
-	  exit(1);
-	  return -1;
-  }
-  H->inuse--;
-  H->entries[hint] = &deleted;
-  return 0;
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/htable.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/htable.h	(revision 9)
+++ 	(revision )
@@ -1,17 +1,0 @@
-/*
- * hashtable
- */
-
-typedef struct hashtable T_HashTable;
-typedef void *T_HashTableEl;
-typedef unsigned int (*T_HashFunc)(void *);
-typedef int (*T_ComparFunc)(void *, void *);
-
-
-int make_ht(T_HashFunc f1, T_HashFunc f2, T_ComparFunc c, int size, T_HashTable **H);
-int hash_add(T_HashTable *H, T_HashTableEl *E, int *hint);
-int hash_remove(T_HashTable *H, T_HashTableEl *E, int hint);
-int hash_lookup(T_HashTable *H, T_HashTableEl *E, T_HashTableEl **E2,
-		int *hint);
-int free_ht(T_HashTable *H, T_HashFunc entry_free);
-
Index: trunk/minix/commands/i386/mtools-3.9.7/init.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/init.c	(revision 9)
+++ 	(revision )
@@ -1,414 +1,0 @@
-/*
- * Initialize an MSDOS diskette.  Read the boot sector, and switch to the
- * proper floppy disk device to match the format on the disk.  Sets a bunch
- * of global variables.  Returns 0 on success, or 1 on failure.
- */
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "stream.h"
-#include "mtools.h"
-#include "fsP.h"
-#include "plain_io.h"
-#include "floppyd_io.h"
-#include "xdf_io.h"
-#include "buffer.h"
-
-extern int errno;
-
-
-#ifndef OS_Minix		/* Minix is memory starved. */
-#define FULL_CYL
-#endif
-
-unsigned int num_clus;			/* total number of cluster */
-
-
-/*
- * Read the boot sector.  We glean the disk parameters from this sector.
- */
-static int read_boot(Stream_t *Stream, struct bootsector * boot, int size)
-{	
-	/* read the first sector, or part of it */
-	if(!size)
-		size = BOOTSIZE;
-	if(size > 1024)
-		size = 1024;
-
-	if (force_read(Stream, (char *) boot, 0, size) != size)
-		return -1;
-	return 0;
-}
-
-static int fs_flush(Stream_t *Stream)
-{
-	DeclareThis(Fs_t);
-
-	fat_write(This);
-	return 0;
-}
-
-Class_t FsClass = {
-	read_pass_through, /* read */
-	write_pass_through, /* write */
-	fs_flush, 
-	fs_free, /* free */
-	0, /* set geometry */
-	get_data_pass_through,
-	0 /* pre allocate */
-};
-
-static int get_media_type(Stream_t *St, struct bootsector *boot)
-{
-	int media;
-
-	media = boot->descr;
-	if(media < 0xf0){
-		char temp[512];
-		/* old DOS disk. Media descriptor in the first FAT byte */
-		/* old DOS disk always have 512-byte sectors */
-		if (force_read(St,temp,(mt_off_t) 512,512) == 512)
-			media = (unsigned char) temp[0];
-		else
-			media = 0;
-	} else
-		media += 0x100;
-	return media;
-}
-
-
-Stream_t *GetFs(Stream_t *Fs)
-{
-	while(Fs && Fs->Class != &FsClass)
-		Fs = Fs->Next;
-	return Fs;
-}
-
-Stream_t *find_device(char *drive, int mode, struct device *out_dev,
-		      struct bootsector *boot,
-		      char *name, int *media, mt_size_t *maxSize)
-{
-	char errmsg[200];
-	Stream_t *Stream;
-	struct device *dev;
-	int r;
-#ifdef OS_Minix
-	static char *devname;
-	struct device onedevice[2];
-	struct stat stbuf;
-
-	free(devname);
-	devname = safe_malloc((9 + strlen(drive)) * sizeof(devname[0]));
-	strcpy(devname, "/dev/dosX");
-	if (isupper(drive[0]) && drive[1] == 0) {
-		/* single letter device name, use /dev/dos$drive */
-		devname[8]= drive[0];
-	} else
-	if (strchr(drive, '/') == NULL) {
-		/* a simple name, use /dev/$drive */
-		strcpy(devname+5, drive);
-	} else {
-		/* a pathname, use as is. */
-		strcpy(devname, drive);
-	}
-	if (stat(devname, &stbuf) != -1) {
-		memset(onedevice, 0, sizeof(onedevice));
-		onedevice[0].name = devname;
-		onedevice[0].drive = drive;
-		onedevice[1].name = NULL;
-		onedevice[1].drive = NULL;
-		dev = onedevice;
-	} else {
-		dev = devices;
-	}
-#else
-	dev = devices;
-#endif
-
-	Stream = NULL;
-	sprintf(errmsg, "Drive '%s:' not supported", drive);	
-					/* open the device */
-	for (; dev->name; dev++) {
-		FREE(&Stream);
-		if (strcmp(dev->drive, drive) != 0)
-			continue;
-		*out_dev = *dev;
-		expand(dev->name,name);
-#ifdef USING_NEW_VOLD
-		strcpy(name, getVoldName(dev, name));
-#endif
-
-		Stream = 0;
-#ifdef USE_XDF
-		Stream = XdfOpen(out_dev, name, mode, errmsg, 0);
-		if(Stream) {
-			out_dev->use_2m = 0x7f;
-			if(maxSize)
-			    *maxSize = max_off_t_31;
-		}
-#endif
-
-#ifdef USE_FLOPPYD
-		if(!Stream) {
-			Stream = FloppydOpen(out_dev, dev, name, mode, errmsg, 0, 1);
-			if(Stream && maxSize)
-				*maxSize = max_off_t_31;
-		}
-#endif
-
-		if (!Stream)
-			Stream = SimpleFileOpen(out_dev, dev, name, mode,
-						errmsg, 0, 1, maxSize);
-
-		if( !Stream)
-			continue;
-
-		/* read the boot sector */
-		if ((r=read_boot(Stream, boot, out_dev->blocksize)) < 0){
-			sprintf(errmsg,
-				"init %s: could not read boot sector",
-				drive);
-			continue;
-		}
-
-		if((*media= get_media_type(Stream, boot)) <= 0xf0 ){
-			if (boot->jump[2]=='L') 
-				sprintf(errmsg,
-					"diskette %s: is Linux LILO, not DOS", 
-					drive);
-			else 
-				sprintf(errmsg,"init %s: non DOS media", drive);
-			continue;
-		}
-
-		/* set new parameters, if needed */
-		errno = 0;
-		if(SET_GEOM(Stream, out_dev, dev, *media, boot)){
-			if(errno)
-#ifdef HAVE_SNPRINTF
-				snprintf(errmsg, 199,
-					"Can't set disk parameters for %s: %s", 
-					drive, strerror(errno));
-#else
-				sprintf(errmsg,
-					"Can't set disk parameters for %s: %s", 
-					drive, strerror(errno));
-#endif
-			else
-				sprintf(errmsg, 
-					"Can't set disk parameters for %s", 
-					drive);
-			continue;
-		}
-		break;
-	}
-
-	/* print error msg if needed */	
-	if ( dev->drive == 0 ){
-		FREE(&Stream);
-		fprintf(stderr,"%s\n",errmsg);
-		return NULL;
-	}
-#ifdef OS_Minix
-	/* Minix can lseek up to 4G. */
-	if (maxSize) *maxSize = 0xFFFFFFFFUL;
-#endif
-	return Stream;
-}
-
-
-Stream_t *fs_init(char *drive, int mode)
-{
-	int blocksize;
-	int media,i;
-	int nhs;
-	int disk_size = 0;	/* In case we don't happen to set this below */
-	size_t tot_sectors;
-	char name[EXPAND_BUF];
-	int cylinder_size;
-	struct device dev;
-	mt_size_t maxSize;
-
-	struct bootsector boot0;
-#define boot (&boot0)
-	Fs_t *This;
-
-	This = New(Fs_t);
-	if (!This)
-		return NULL;
-
-	This->Direct = NULL;
-	This->Next = NULL;
-	This->refs = 1;
-	This->Buffer = 0;
-	This->Class = &FsClass;
-	This->preallocatedClusters = 0;
-	This->lastFatSectorNr = 0;
-	This->lastFatAccessMode = 0;
-	This->lastFatSectorData = 0;
-	This->drive = drive;
-	This->last = 0;
-
-	This->Direct = find_device(drive, mode, &dev, &boot0, name, &media, 
-							   &maxSize);
-	if(!This->Direct)
-		return NULL;
-	
-	This->sector_size = WORD(secsiz);
-	if(This->sector_size > MAX_SECTOR){
-		fprintf(stderr,"init %s: sector size too big\n", drive);
-		return NULL;
-	}
-
-	i = log_2(This->sector_size);
-
-	if(i == 24) {
-		fprintf(stderr, 
-			"init %c: sector size (%d) not a small power of two\n",
-			drive, This->sector_size);
-		return NULL;
-	}
-	This->sectorShift = i;
-	This->sectorMask = This->sector_size - 1;
-
-
-	cylinder_size = dev.heads * dev.sectors;
-	if (!tot_sectors) tot_sectors = dev.tracks * cylinder_size;
-
-	This->serialized = 0;
-	if ((media & ~7) == 0xf8){
-		i = media & 3;
-		This->cluster_size = old_dos[i].cluster_size;
-		tot_sectors = cylinder_size * old_dos[i].tracks;
-		This->fat_start = 1;
-		This->fat_len = old_dos[i].fat_len;
-		This->dir_len = old_dos[i].dir_len;
-		This->num_fat = 2;
-		This->sector_size = 512;
-		This->sectorShift = 9;
-		This->sectorMask = 511;
-		This->fat_bits = 12;
-		nhs = 0;
-	} else {
-		struct label_blk_t *labelBlock;
-		/*
-		 * all numbers are in sectors, except num_clus 
-		 * (which is in clusters)
-		 */
-		tot_sectors = WORD(psect);
-		if(!tot_sectors) {
-			tot_sectors = DWORD(bigsect);			
-			nhs = DWORD(nhs);
-		} else
-			nhs = WORD(nhs);
-
-
-		This->cluster_size = boot0.clsiz; 		
-		This->fat_start = WORD(nrsvsect);
-		This->fat_len = WORD(fatlen);
-		This->dir_len = WORD(dirents) * MDIR_SIZE / This->sector_size;
-		This->num_fat = boot0.nfat;
-
-		if (This->fat_len) {
-			labelBlock = &boot0.ext.old.labelBlock;
-		} else {
-			labelBlock = &boot0.ext.fat32.labelBlock;
-		}
-
-		if(labelBlock->dos4 == 0x29) {
-			This->serialized = 1;
-			This->serial_number = _DWORD(labelBlock->serial);
-		}
-	}
-
-	if (tot_sectors >= (maxSize >> This->sectorShift)) {
-		fprintf(stderr, "Big disks not supported on this architecture\n");
-		exit(1);
-	}
-
-#ifndef OS_Minix   /* Strange check, MS-DOS isn't that picky. */
-
-	if(!mtools_skip_check && (tot_sectors % dev.sectors)){
-		fprintf(stderr,
-			"Total number of sectors not a multiple of"
-			" sectors per track!\n");
-		fprintf(stderr,
-			"Add mtools_skip_check=1 to your .mtoolsrc file "
-			"to skip this test\n");
-		exit(1);
-	}
-#endif
-
-	/* full cylinder buffering */
-#ifdef FULL_CYL
-	disk_size = (dev.tracks) ? cylinder_size : 512;
-#else /* FULL_CYL */
-	disk_size = (dev.tracks) ? dev.sectors : 512;
-#endif /* FULL_CYL */
-
-#if (defined OS_sysv4 && !defined OS_solaris)
-	/*
-	 * The driver in Dell's SVR4 v2.01 is unreliable with large writes.
-	 */
-        disk_size = 0;
-#endif /* (defined sysv4 && !defined(solaris)) */
-
-#ifdef OS_linux
-	disk_size = cylinder_size;
-#endif
-
-#if 1
-	if(disk_size > 256) {
-		disk_size = dev.sectors;
-		if(dev.sectors % 2)
-			disk_size <<= 1;
-	}
-#endif
-	if (disk_size % 2)
-		disk_size *= 2;
-
-	if(!dev.blocksize || dev.blocksize < This->sector_size)
-		blocksize = This->sector_size;
-	else
-		blocksize = dev.blocksize;
-	if (disk_size)
-		This->Next = buf_init(This->Direct,
-				      8 * disk_size * blocksize,
-				      disk_size * blocksize,
-				      This->sector_size);
-	else
-		This->Next = This->Direct;
-
-	if (This->Next == NULL) {
-		perror("init: allocate buffer");
-		This->Next = This->Direct;
-	}
-
-	/* read the FAT sectors */
-	if(fat_read(This, &boot0, dev.fat_bits, tot_sectors, dev.use_2m&0x7f)){
-		This->num_fat = 1;
-		FREE(&This->Next);
-		Free(This->Next);
-		return NULL;
-	}
-	return (Stream_t *) This;
-}
-
-char *getDrive(Stream_t *Stream)
-{
-	DeclareThis(Fs_t);
-
-	if(This->Class != &FsClass)
-		return getDrive(GetFs(Stream));
-	else
-		return This->drive;
-}
-
-int fsPreallocateClusters(Fs_t *Fs, long size)
-{
-	if(size > 0 && getfreeMinClusters((Stream_t *)Fs, size) != 1)
-		return -1;
-
-	Fs->preallocatedClusters += size;
-	return 0;
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/llong.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/llong.c	(revision 9)
+++ 	(revision )
@@ -1,84 +1,0 @@
-#include "sysincludes.h"
-#include "stream.h"
-#include "fsP.h"
-#include "llong.h"
-#include "mtools.h"
-
-/* Warnings about integer overflow in expression can be ignored.  These are
- * due to the way that maximal values for those integers are computed: 
- * intentional overflow from smallest negative number (1000...) to highest 
- * positive number (0111...) by substraction of 1 */
-#ifdef __GNUC__
-/*
-#warning "The following warnings about integer overflow in expression can be safely ignored"
-*/
-#endif
-
-#if 1
-const mt_off_t max_off_t_31 = MAX_OFF_T_B(31); /* Floppyd */
-const mt_off_t max_off_t_41 = MAX_OFF_T_B(41); /* SCSI */
-const mt_off_t max_off_t_seek = MAX_OFF_T_B(SEEK_BITS); /* SCSI */
-#else
-const mt_off_t max_off_t_31 = MAX_OFF_T_B(10); /* Floppyd */
-const mt_off_t max_off_t_41 = MAX_OFF_T_B(10); /* SCSI */
-const mt_off_t max_off_t_seek = MAX_OFF_T_B(10); /* SCSI */
-#endif
-
-off_t truncBytes32(mt_off_t off)
-{
-	if (off & ~max_off_t_31) {
-		fprintf(stderr, "Internal error, offset too big\n");
-		exit(1);
-	}
-	return (off_t) off;
-}
-
-mt_off_t sectorsToBytes(Stream_t *Stream, off_t off)
-{
-	DeclareThis(Fs_t);
-	return (mt_off_t) off << This->sectorShift;
-}
-
-#if defined HAVE_LLSEEK
-# ifndef HAVE_LLSEEK_PROTOTYPE
-extern long long llseek (int fd, long long offset, int origin);
-# endif
-#endif
-
-#if defined HAVE_LSEEK64
-# ifndef HAVE_LSEEK64_PROTOTYPE
-extern long long lseek64 (int fd, long long offset, int origin);
-# endif
-#endif
-
-
-int mt_lseek(int fd, mt_off_t where, int whence)
-{
-#if defined HAVE_LSEEK64
-	if(lseek64(fd, where, whence) >= 0)
-		return 0;
-	else
-		return -1;
-#elif defined HAVE_LLSEEK
-	if(llseek(fd, where, whence) >= 0)
-		return 0;
-	else
-		return -1;		
-#else
-	if (lseek(fd, (off_t) where, whence) >= 0)
-		return 0;
-	else
-		return 1;
-#endif
-}
-
-int log_2(int size)
-{
-	int i;
-
-	for(i=0; i<24; i++) {
-		if(1 << i == size)
-			return i;
-	}
-	return 24;
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/llong.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/llong.h	(revision 9)
+++ 	(revision )
@@ -1,81 +1,0 @@
-#ifndef MTOOLS_LLONG_H
-#define MTOOLS_LLONG_H
-
-#if 1
-
-
-#ifdef HAVE_OFF_T_64
-/* if off_t is already 64 bits, be happy, and don't worry about the
- * loff_t and llseek stuff */
-#define MT_OFF_T off_t
-#endif
-
-#ifndef MT_OFF_T
-# ifdef HAVE_LLSEEK
-/* we have llseek. Now, what's its type called? loff_t or offset_t ? */
-#  ifdef HAVE_LOFF_T
-#   define MT_OFF_T loff_t
-#  else
-#   ifdef HAVE_OFFSET_T
-#    define MT_OFF_T offset_t
-#   endif
-#  endif
-# endif
-#endif
-
-#ifndef MT_OFF_T
-/* we still don't have a suitable mt_off_t type...*/
-# ifdef HAVE_LONG_LONG
-/* ... first try long long ... */
-#  define MT_OFF_T long long
-# else
-/* ... and if that fails, fall back on good ole' off_t */
-#  define MT_OFF_T off_t
-# endif
-#endif
-
-typedef MT_OFF_T mt_off_t;
-
-#else
-/* testing: meant to flag dubious assignments between 32 bit length types
- * and 64 bit ones */
-typedef struct {
-	int lo;
-	int high;
-} *mt_off_t;
-
-
-#endif
-
-typedef mt_off_t mt_size_t;
-
-#define min(a,b) ((a) < (b) ? (a) : (b))
-#define MAX_OFF_T_B(bits) \
-	(((mt_off_t) 1 << min(bits, sizeof(mt_off_t)*8 - 1)) - 1)
-
-#ifdef HAVE_LLSEEK
-# define SEEK_BITS 63
-#else
-# define SEEK_BITS (sizeof(off_t) * 8 - 1)
-#endif
-
-extern const mt_off_t max_off_t_31;
-extern const mt_off_t max_off_t_41;
-extern const mt_off_t max_off_t_seek;
-
-extern off_t truncBytes32(mt_off_t off);
-mt_off_t sectorsToBytes(Stream_t *This, off_t off);
-
-mt_size_t getfree(Stream_t *Stream);
-int getfreeMinBytes(Stream_t *Stream, mt_size_t ref);
-
-Stream_t *find_device(char *drive, int mode, struct device *out_dev,
-					  struct bootsector *boot,
-					  char *name, int *media, mt_size_t *maxSize);
-
-int mt_lseek(int fd, mt_off_t where, int whence);
-
-
-int log_2(int);
-
-#endif
Index: trunk/minix/commands/i386/mtools-3.9.7/mainloop.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mainloop.c	(revision 9)
+++ 	(revision )
@@ -1,557 +1,0 @@
-/*
- * mainloop.c
- * Iterating over all the command line parameters, and matching patterns
- * where needed
- */
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "vfat.h"
-#include "fs.h"
-#include "mainloop.h"
-#include "plain_io.h"
-#include "file.h"
-
-
-int unix_dir_loop(Stream_t *Stream, MainParam_t *mp); 
-int unix_loop(Stream_t *Stream, MainParam_t *mp, char *arg, 
-	      int follow_dir_link);
-
-static int _unix_loop(Stream_t *Dir, MainParam_t *mp, const char *filename)
-{
-	unix_dir_loop(Dir, mp);
-	return GOT_ONE;
-}
-
-int unix_loop(Stream_t *Stream, MainParam_t *mp, char *arg, int follow_dir_link)
-{
-	int ret;
-	int isdir;
-
-	mp->File = NULL;
-	mp->direntry = NULL;
-	mp->unixSourceName = arg;
-	/*	mp->dir.attr = ATTR_ARCHIVE;*/
-	mp->loop = _unix_loop;
-	if((mp->lookupflags & DO_OPEN)){
-		mp->File = SimpleFileOpen(0, 0, arg, O_RDONLY, 0, 0, 0, 0);
-		if(!mp->File){
-			perror(arg);
-#if 0
-			tmp = _basename(arg);
-			strncpy(mp->filename, tmp, VBUFSIZE);
-			mp->filename[VBUFSIZE-1] = '\0';
-#endif
-			return ERROR_ONE;
-		}
-		GET_DATA(mp->File, 0, 0, &isdir, 0);
-		if(isdir) {
-			struct stat buf;
-
-			FREE(&mp->File);
-#ifdef S_ISLNK
-			if(!follow_dir_link &&
-			   lstat(arg, &buf) == 0 &&
-			   S_ISLNK(buf.st_mode)) {
-				/* skip links to directories in order to avoid
-				 * infinite loops */
-				fprintf(stderr, 
-					"skipping directory symlink %s\n", 
-					arg);
-				return 0;				
-			}
-#endif
-			if(! (mp->lookupflags & ACCEPT_DIR))
-				return 0;
-			mp->File = OpenDir(Stream, arg);
-		}
-	}
-
-	if(isdir)
-		ret = mp->dirCallback(0, mp);
-	else
-		ret = mp->unixcallback(mp);
-	FREE(&mp->File);
-	return ret;
-}
-
-
-int isSpecial(const char *name)
-{
-	if(name[0] == '\0')
-		return 1;
-	if(!strcmp(name,"."))
-		return 1;
-	if(!strcmp(name,".."))
-		return 1;
-	return 0;			
-}
-
-
-static int checkForDot(int lookupflags, const char *name)
-{
-	return (lookupflags & NO_DOTS) && isSpecial(name);
-}
-
-
-typedef struct lookupState_t {
-	Stream_t *container;
-	int nbContainers;
-	Stream_t *Dir;
-	int nbDirs;
-	const char *filename;
-} lookupState_t;
-
-static int isUniqueTarget(const char *name)
-{
-	return name && strcmp(name, "-");
-}
-
-static int handle_leaf(direntry_t *direntry, MainParam_t *mp,
-		       lookupState_t *lookupState)
-{
-	Stream_t *MyFile=0;
-	int ret;
-
-	if(got_signal)
-		return ERROR_ONE;
-	if(lookupState) {
-		/* we are looking for a "target" file */
-		switch(lookupState->nbDirs) {
-			case 0: /* no directory yet, open it */
-				lookupState->Dir = OpenFileByDirentry(direntry);
-				lookupState->nbDirs++;
-				/* dump the container, we have
-				 * better now */
-				FREE(&lookupState->container);
-				return 0;
-			case 1: /* we have already a directory */
-				FREE(&lookupState->Dir);
-				fprintf(stderr,"Ambigous\n");
-				return STOP_NOW | ERROR_ONE;
-			default:
-				return STOP_NOW | ERROR_ONE;
-		}
-	}
-
-	mp->direntry = direntry;
-	if(IS_DIR(direntry)) {
-		if(mp->lookupflags & (DO_OPEN | DO_OPEN_DIRS))
-			MyFile = mp->File = OpenFileByDirentry(direntry);
-		ret = mp->dirCallback(direntry, mp);
-	} else {
-		if(mp->lookupflags & DO_OPEN)
-			MyFile = mp->File = OpenFileByDirentry(direntry);
-		ret = mp->callback(direntry, mp);
-	}
-	FREE(&MyFile);
-	if(isUniqueTarget(mp->targetName))
-		ret |= STOP_NOW;
-	return ret;
-}
-
-static int _dos_loop(Stream_t *Dir, MainParam_t *mp, const char *filename)
-{	
-	Stream_t *MyFile=0;
-	direntry_t entry;
-	int ret;
-	int r;
-	
-	ret = 0;
-	r=0;
-	initializeDirentry(&entry, Dir);
-	while(!got_signal &&
-	      (r=vfat_lookup(&entry, filename, -1,
-			     mp->lookupflags, mp->shortname, 
-			     mp->longname)) == 0 ){
-		mp->File = NULL;
-		if(!checkForDot(mp->lookupflags,entry.name)) {
-			MyFile = 0;
-			if((mp->lookupflags & DO_OPEN) ||
-			   (IS_DIR(&entry) && 
-			    (mp->lookupflags & DO_OPEN_DIRS))) {
-				MyFile = mp->File = OpenFileByDirentry(&entry);
-			}
-			if(got_signal)
-				break;
-			mp->direntry = &entry;
-			if(IS_DIR(&entry))
-				ret |= mp->dirCallback(&entry,mp);
-			else
-				ret |= mp->callback(&entry, mp);
-			FREE(&MyFile);
-		}
-		if (fat_error(Dir))
-			ret |= ERROR_ONE;
-		if(mp->fast_quit && (ret & ERROR_ONE))
-			break;
-	}
-	if (r == -2)
-	    return ERROR_ONE;
-	if(got_signal)
-		ret |= ERROR_ONE;
-	return ret;
-}
-
-static int recurs_dos_loop(MainParam_t *mp, const char *filename0, 
-			   const char *filename1,
-			   lookupState_t *lookupState)
-{
-	/* Dir is de-allocated by the same entity which allocated it */
-	const char *ptr;
-	direntry_t entry;
-	int length;
-	int lookupflags;
-	int ret;
-	int have_one;
-	int doing_mcwd;
-	int r;
-
-	while(1) {
-		/* strip dots and // */
-		if(!strncmp(filename0,"./", 2)) {
-			filename0 += 2;
-			continue;
-		}
-		if(!strcmp(filename0,".") && filename1) {
-			filename0 ++;
-			continue;
-		}
-		if(filename0[0] == '/') {
-			filename0++;
-			continue;
-		}
-		if(!filename0[0]) {
-			if(!filename1)
-				break;
-			filename0 = filename1;
-			filename1 = 0;
-			continue;
-		}
-		break;
-	}
-
-	if(!strncmp(filename0,"../", 3) || 
-	   (!strcmp(filename0, "..") && filename1)) {
-		/* up one level */
-		mp->File = getDirentry(mp->File)->Dir;
-		return recurs_dos_loop(mp, filename0+2, filename1, lookupState);
-	}
-
-	doing_mcwd = !!filename1;
-
-	ptr = strchr(filename0, '/');
-	if(!ptr) {			
-		length = strlen(filename0);		
-		ptr = filename1;
-		filename1 = 0;
-	} else {
-		length = ptr - filename0;
-		ptr++;
-	}
-	if(!ptr) {
-		if(mp->lookupflags & OPEN_PARENT) {
-			mp->targetName = filename0;
-			ret = handle_leaf(getDirentry(mp->File), mp, 
-					  lookupState);
-			mp->targetName = 0;
-			return ret;
-		}
-		
-		if(!strcmp(filename0, ".") || !filename0[0]) {
-			return handle_leaf(getDirentry(mp->File), 
-					   mp, lookupState);
-		}
-
-		if(!strcmp(filename0, "..")) {
-			return handle_leaf(getParent(getDirentry(mp->File)), mp,
-					   lookupState);
-		}
-
-		lookupflags = mp->lookupflags;
-		
-		if(lookupState) {
-			lookupState->filename = filename0;
-			if(lookupState->nbContainers + lookupState->nbDirs > 0){
-				/* we have already one target, don't bother 
-				 * with this one. */
-				FREE(&lookupState->container);
-			} else {
-				/* no match yet.  Remember this container for 
-				 * later use */
-				lookupState->container = COPY(mp->File);
-			}
-			lookupState->nbContainers++;
-		}
-	} else
-		lookupflags = ACCEPT_DIR | DO_OPEN | NO_DOTS;
-
-	ret = 0;
-	r = 0;
-	have_one = 0;
-	initializeDirentry(&entry, mp->File);
-	while(!(ret & STOP_NOW) &&
-	      !got_signal &&
-	      (r=vfat_lookup(&entry, filename0, length,
-			     lookupflags | NO_MSG, 
-			     mp->shortname, mp->longname)) == 0 ){
-		if(checkForDot(lookupflags, entry.name))
-			/* while following the path, ignore the
-			 * special entries if they were not
-			 * explicitly given */
-			continue;
-		have_one = 1;
-		if(ptr) {
-			Stream_t *SubDir;
-			SubDir = mp->File = OpenFileByDirentry(&entry);
-			ret |= recurs_dos_loop(mp, ptr, filename1, lookupState);
-			FREE(&SubDir);
-		} else {
-			ret |= handle_leaf(&entry, mp, lookupState);
-			if(isUniqueTarget(mp->targetName))
-				return ret | STOP_NOW;
-		}
-		if(doing_mcwd)
-			break;
-	}
-	if (r == -2)
-		return ERROR_ONE;
-	if(got_signal)
-		return ret | ERROR_ONE;
-	if(doing_mcwd & !have_one)
-		return NO_CWD;
-	return ret;
-}
-
-static int common_dos_loop(MainParam_t *mp, const char *pathname,
-			   lookupState_t *lookupState, int open_mode)
-
-{
-	Stream_t *RootDir;
-	char *cwd;
-	char *drive;
-	char *rest;
-
-	int ret;
-	mp->loop = _dos_loop;
-	
-	drive='\0';
-	cwd = "";
-	if((rest = skip_drive(pathname)) > pathname) {
-		drive = get_drive(pathname, NULL);
-		if (strncmp(pathname, mp->mcwd, rest - pathname) == 0)
-			cwd = skip_drive(mp->mcwd);
-		pathname = rest;
-	} else {
-		drive = get_drive(mp->mcwd, NULL);
-		cwd = skip_drive(mp->mcwd);
-	}
-
-	if(*pathname=='/') /* absolute path name */
-		cwd = "";
-
-	RootDir = mp->File = open_root_dir(drive, open_mode);
-	if(!mp->File)
-		return ERROR_ONE;
-
-	ret = recurs_dos_loop(mp, cwd, pathname, lookupState);
-	if(ret & NO_CWD) {
-		/* no CWD */
-		*mp->mcwd = '\0';
-		unlink_mcwd();
-		ret = recurs_dos_loop(mp, "", pathname, lookupState);
-	}
-	FREE(&RootDir);
-	return ret;
-}
-
-static int dos_loop(MainParam_t *mp, const char *arg)
-{
-	return common_dos_loop(mp, arg, 0, mp->openflags);
-}
-
-
-static int dos_target_lookup(MainParam_t *mp, const char *arg)
-{
-	lookupState_t lookupState;
-	int ret;
-	int lookupflags;
-
-	lookupState.nbDirs = 0;
-	lookupState.Dir = 0;
-	lookupState.nbContainers = 0;
-	lookupState.container = 0;
-
-	lookupflags = mp->lookupflags;
-	mp->lookupflags = DO_OPEN | ACCEPT_DIR;
-	ret = common_dos_loop(mp, arg, &lookupState, O_RDWR);
-	mp->lookupflags = lookupflags;
-	if(ret & ERROR_ONE)
-		return ret;
-
-	if(lookupState.nbDirs) {
-		mp->targetName = 0;
-		mp->targetDir = lookupState.Dir;
-		FREE(&lookupState.container); /* container no longer needed */
-		return ret;
-	}
-
-	switch(lookupState.nbContainers) {
-		case 0:
-			/* no match */
-			fprintf(stderr,"%s: no match for target\n", arg);
-			return MISSED_ONE;
-		case 1:
-			mp->targetName = strdup(lookupState.filename);
-			mp->targetDir = lookupState.container;
-			return ret;
-		default:
-			/* too much */
-			fprintf(stderr, "Ambigous %s\n", arg);
-			return ERROR_ONE;			
-	}
-}
-
-int unix_target_lookup(MainParam_t *mp, const char *arg)
-{
-	char *ptr;
-	mp->unixTarget = strdup(arg);
-	/* try complete filename */
-	if(access(mp->unixTarget, F_OK) == 0)
-		return GOT_ONE;
-	ptr = strrchr(mp->unixTarget, '/');
-	if(!ptr) {
-		mp->targetName = mp->unixTarget;
-		mp->unixTarget = strdup(".");
-		return GOT_ONE;
-	} else {
-		*ptr = '\0';
-		mp->targetName = ptr+1;
-		return GOT_ONE;
-	}
-}
-
-int target_lookup(MainParam_t *mp, const char *arg)
-{
-	if((mp->lookupflags & NO_UNIX) || skip_drive(arg) > arg)
-		return dos_target_lookup(mp, arg);
-	else
-		return unix_target_lookup(mp, arg);
-}
-
-int main_loop(MainParam_t *mp, char **argv, int argc)
-{
-	int i;
-	int ret, Bret;
-	
-	Bret = 0;
-
-	if(argc != 1 && mp->targetName) {
-		fprintf(stderr,
-			"Several file names given, but last argument (%s) not a directory\n", mp->targetName);
-	}
-
-	for (i = 0; i < argc; i++) {
-		if ( got_signal )
-			break;
-		mp->originalArg = argv[i];
-		mp->basenameHasWildcard = strpbrk(_basename(mp->originalArg), 
-						  "*[?") != 0;
-		if (mp->unixcallback && skip_drive(argv[i]) == argv[i])
-			ret = unix_loop(0, mp, argv[i], 1);
-		else
-			ret = dos_loop(mp, argv[i]);
-		
-		if (! (ret & (GOT_ONE | ERROR_ONE)) ) {
-			/* one argument was unmatched */
-			fprintf(stderr, "%s: File \"%s\" not found\n",
-				progname, argv[i]);
-			ret |= ERROR_ONE;
-		}
-		Bret |= ret;
-		if(mp->fast_quit && (Bret & (MISSED_ONE | ERROR_ONE)))
-			break;
-	}
-	FREE(&mp->targetDir);
-	if(Bret & ERROR_ONE)
-		return 1;
-	if ((Bret & GOT_ONE) && ( Bret & MISSED_ONE))
-		return 2;
-	if (Bret & MISSED_ONE)
-		return 1;
-	return 0;
-}
-
-static int dispatchToFile(direntry_t *entry, MainParam_t *mp)
-{
-	if(entry)
-		return mp->callback(entry, mp);
-	else
-		return mp->unixcallback(mp);
-}
-
-
-void init_mp(MainParam_t *mp)
-{
-	fix_mcwd(mp->mcwd);
-	mp->openflags = 0;
-	mp->targetName = 0;
-	mp->targetDir = 0;
-	mp->unixTarget = 0;
-	mp->dirCallback = dispatchToFile;
-	mp->unixcallback = NULL;
-	mp->shortname = mp->longname = 0;
-	mp->File = 0;
-	mp->fast_quit = 0;
-}
-
-const char *mpGetBasename(MainParam_t *mp)
-{
-	if(mp->direntry)
-		return mp->direntry->name;
-	else
-		return _basename(mp->unixSourceName);
-}
-
-void mpPrintFilename(FILE *fp, MainParam_t *mp)
-{
-	if(mp->direntry)
-		fprintPwd(fp, mp->direntry, 0);
-	else
-		fprintf(fp,"%s",mp->originalArg);
-}
-
-const char *mpPickTargetName(MainParam_t *mp)
-{
-	/* picks the target name: either the one explicitly given by the
-	 * user, or the same as the source */
-	if(mp->targetName)
-		return mp->targetName;
-	else
-		return mpGetBasename(mp);
-}
-
-char *mpBuildUnixFilename(MainParam_t *mp)
-{
-	const char *target;
-	char *ret;
-
-	target = mpPickTargetName(mp);
-	ret = malloc(strlen(mp->unixTarget) + 2 + strlen(target));
-	if(!ret)
-		return 0;
-	strcpy(ret, mp->unixTarget);
-	if(*target) {
-#if 1 /* fix for 'mcopy -n x:file existingfile' -- H. Lermen 980816 */
-		if(!mp->targetName && !mp->targetDir) {
-			struct stat buf;
-			if (!stat(ret, &buf) && !S_ISDIR(buf.st_mode))
-				return ret;
-		}
-#endif
-		strcat(ret, "/");
-		strcat(ret, target);
-	}
-	return ret;
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/mainloop.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mainloop.h	(revision 9)
+++ 	(revision )
@@ -1,79 +1,0 @@
-#ifndef MTOOLS_MAINLOOP_H
-#define MTOOLS_MAINLOOP_H
-
-#ifndef OS_Minix
-#include <sys/param.h>
-#endif
-#include "vfat.h"
-#include "mtoolsDirent.h"
-
-typedef struct MainParam_t {
-	/* stuff needing to be initialised by the caller */
-	int (*loop)(Stream_t *Dir, struct MainParam_t *mp, 
-		    const char *filename);
-	int (*dirCallback)(direntry_t *, struct MainParam_t *);
-	int (*callback)(direntry_t *, struct MainParam_t *);
-	int (*unixcallback)(struct MainParam_t *mp);
-
-	void *arg; /* command-specific parameters 
-		    * to be passed to callback */
-
-       	int openflags; /* flags used to open disk */
-	int lookupflags; /* flags used to lookup up using vfat_lookup */
-	int fast_quit; /* for commands manipulating multiple files, quit
-			* as soon as even _one_ file has a problem */
-
-	char *shortname; /* where to put the short name of the matched file */
-	char *longname; /* where to put the long name of the matched file */
-
-	/* out parameters */
-	Stream_t *File;
-
-	direntry_t *direntry;  /* dir of this entry */
-	char *unixSourceName;  /* filename of the last opened Unix source 
-				* file (Unix equiv of Dos direntry) */
-
-	Stream_t *targetDir; /* directory where to place files */
-	char *unixTarget; /* directory on Unix where to put files */
-
-	const char *targetName; /* basename of target file, or NULL if same
-				 * basename as source should be conserved */
-
-	char *originalArg; /* original argument, complete with wildcards */
-	int basenameHasWildcard; /* true if there are wildcards in the
-				  * basename */
-
-
-	/* internal data */
-	char mcwd[MAX_PATH+4];
-
-	char *fileName; /* resolved Unix filename */
-} MainParam_t;
-
-void init_mp(MainParam_t *MainParam);
-int main_loop(MainParam_t *MainParam, char **argv, int argc);
-
-int target_lookup(MainParam_t *mp, const char *arg);
-
-Stream_t *open_root_dir(char *drivename, int flags);
-
-const char *mpGetBasename(MainParam_t *mp); /* statically allocated 
-					     * string */
-
-void mpPrintFilename(FILE *file, MainParam_t *mp);
-const char *mpPickTargetName(MainParam_t *mp); /* statically allocated string */
-
-char *mpBuildUnixFilename(MainParam_t *mp); /* dynamically allocated, must
-					     * be freed */
-
-int isSpecial(const char *name);
-
-#define MISSED_ONE 2  /* set if one cmd line argument didn't match any files */
-#define GOT_ONE 4     /* set if a match was found, used for exit status */
-#define NO_CWD 8     /* file not found while looking for current working 
-		      * directory */
-#define ERROR_ONE 16 /* flat out error, such as problems with target file, 
-			interrupt by user, etc. */
-#define STOP_NOW 32 /* stop as soon as possible, not necessarily an error */
-
-#endif
Index: trunk/minix/commands/i386/mtools-3.9.7/match.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/match.c	(revision 9)
+++ 	(revision )
@@ -1,142 +1,0 @@
-/*
- * Do shell-style pattern matching for '?', '\', '[..]', and '*' wildcards.
- * Returns 1 if match, 0 if not.
- */
-
-#include "sysincludes.h"
-#include "mtools.h"
-
-
-static int casecmp(char a,char b)
-{
-	return toupper(a) == toupper(b);
-}
-
-static int exactcmp(char a,char b)
-{
-	return a == b;
-}
-
-
-static int parse_range(const char **p, const char *s, char *out, 
-		       int (*compfn)(char a, char b))
-{
-	char table[256];
-	int reverse;
-	int i;
-	short first, last;
-
-	if (**p == '^') {
-		reverse = 1;
-		(*p)++;
-	} else
-		reverse=0;	
-	for(i=0; i<256; i++)
-		table[i]=0;
-	while(**p != ']') {
-		if(!**p)
-			return 0;
-		if((*p)[1] == '-') {
-			first = **p;
-			(*p)+=2;
-			if(**p == ']')
-				last = 256;
-			else
-				last = *((*p)++);				
-			for(i=first; i<last; i++)
-				table[i] = 1;
-		} else
-			table[(int) *((*p)++)] = 1;
-	}
-	if(out)
-		*out = *s;
-	if(table[(int) *s])
-		return 1 ^ reverse;
-	if(compfn == exactcmp)
-		return reverse;
-	if(table[tolower(*s)]) {
-		if(out)
-			*out = tolower(*s);
-		return 1 ^ reverse;
-	}
-	if(table[toupper(*s)]) {
-		if(out)
-			*out = toupper(*s);
-		return 1 ^ reverse;
-	}
-	return reverse;
-}
-
-
-static int _match(const char *s, const char *p, char *out, int Case,
-		  int length,
-		  int (*compfn) (char a, char b))
-{
-	for (; *p != '\0' && length; ) {
-		switch (*p) {
-			case '?':	/* match any one character */
-				if (*s == '\0')
-					return(0);
-				if(out)
-					*(out++) = *s;
-				break;
-			case '*':	/* match everything */
-				while (*p == '*' && length) {
-					p++;
-					length--;
-				}
-
-					/* search for next char in pattern */
-				while(*s) {
-					if(_match(s, p, out, Case, length, 
-						  compfn))
-						return 1;
-					if(out)
-						*out++ = *s;
-					s++;
-				}
-				continue;
-			case '[':	 /* match range of characters */
-				p++;
-				length--;
-				if(!parse_range(&p, s, out++, compfn))
-					return 0;
-				break;
-			case '\\':	/* Literal match with next character */
-				p++;
-				length--;
-				/* fall thru */
-			default:
-				if (!compfn(*s,*p))
-					return(0);
-				if(out)
-					*(out++) = *p;
-				break;
-		}
-		p++;
-		length--;
-		s++;
-	}
-	if(out)
-		*out = '\0';
-
-					/* string ended prematurely ? */
-	if (*s != '\0')
-		return(0);
-	else
-		return(1);
-}
-
-
-int match(const char *s, const char *p, char *out, int Case, int length)
-{
-	int (*compfn)(char a, char b);
-
-	if(Case)
-		compfn = casecmp;
-	else
-		/*compfn = exactcmp;*/
-		compfn = casecmp;
-	return _match(s, p, out, Case, length, compfn);
-}
-
Index: trunk/minix/commands/i386/mtools-3.9.7/mattrib.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mattrib.c	(revision 9)
+++ 	(revision )
@@ -1,233 +1,0 @@
-/*
- * mattrib.c
- * Change MSDOS file attribute flags
- */
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "mainloop.h"
-
-typedef struct Arg_t {
-	char add;
-	unsigned char remove;
-	struct MainParam_t mp;
-	int recursive;
-	int doPrintName;
-} Arg_t;
-
-int concise;
-
-static int attrib_file(direntry_t *entry, MainParam_t *mp)
-{
-	Arg_t *arg=(Arg_t *) mp->arg;
-
-	if(entry->entry != -3) {
-		/* if not root directory, change it */
-		entry->dir.attr = (entry->dir.attr & arg->remove) | arg->add;
-		dir_write(entry);
-	}
-	return GOT_ONE;
-}
-
-static int replay_attrib(direntry_t *entry, MainParam_t *mp)
-{
-	if ( (IS_ARCHIVE(entry) && IS_DIR(entry)) ||
-		 (!IS_ARCHIVE(entry) && !IS_DIR(entry)) ||
-		 IS_SYSTEM(entry) || IS_HIDDEN(entry)) {
-
-		printf("mattrib ");
-
-		if (IS_ARCHIVE(entry) && IS_DIR(entry)) {
-			printf("+a ");
-		}
-
-		if (!IS_ARCHIVE(entry) && !IS_DIR(entry)) {
-			printf("-a ");
-		}
-
-		if (IS_SYSTEM(entry)) {
-			printf("+s ");
-		}
-
-		if (IS_HIDDEN(entry)) {
-			printf("+h ");
-		}
-
-		fprintPwd(stdout, entry, 1);
-		printf("\n");
-	}
-	return GOT_ONE;
-}
-
-
-
-static int view_attrib(direntry_t *entry, MainParam_t *mp)
-{
-	printf("  ");
-	if(IS_ARCHIVE(entry))
-		putchar('A');
-	else
-		putchar(' ');
-	fputs("  ",stdout);
-	if(IS_SYSTEM(entry))
-		putchar('S');
-	else
-		putchar(' ');
-	if(IS_HIDDEN(entry))
-		putchar('H');
-	else
-		putchar(' ');
-	if(IS_READONLY(entry))
-		putchar('R');
-	else
-		putchar(' ');
-	printf("     ");
-	fprintPwd(stdout, entry, 0);
-	printf("\n");
-	return GOT_ONE;
-}
-
-
-static int concise_view_attrib(direntry_t *entry, MainParam_t *mp)
-{
-	Arg_t *arg=(Arg_t *) mp->arg;
-
-	if(IS_ARCHIVE(entry))
-		putchar('A');
-	if(IS_DIR(entry))
-		putchar('D');	
-	if(IS_SYSTEM(entry))
-		putchar('S');
-	if(IS_HIDDEN(entry))
-		putchar('H');
-	if(IS_READONLY(entry))
-		putchar('R');
-	if(arg->doPrintName) {
-		putchar(' ');
-		fprintPwd(stdout, entry, 0);
-	}
-	putchar('\n');
-	return GOT_ONE;
-}
-
-static int recursive_attrib(direntry_t *entry, MainParam_t *mp)
-{
-	mp->callback(entry, mp);
-	return mp->loop(mp->File, mp, "*");
-}
-
-
-static void usage(void) NORETURN;
-static void usage(void)
-{
-	fprintf(stderr, "Mtools version %s, dated %s\n", 
-		mversion, mdate);
-	fprintf(stderr, 
-		"Usage: %s [-p/X] [-a|+a] [-h|+h] [-r|+r] [-s|+s] msdosfile [msdosfiles...]\n"
-		"\t-p Replay how mattrib would set up attributes\n"
-		"\t-/ Recursive\n"
-		"\t-X Concise\n",
-		progname);
-	exit(1);
-}
-
-static int letterToCode(int letter)
-{
-	switch (toupper(letter)) {
-		case 'A':
-			return ATTR_ARCHIVE;
-		case 'H':
-			return ATTR_HIDDEN;
-		case 'R':
-			return ATTR_READONLY;
-		case 'S':
-			return ATTR_SYSTEM;
-		default:
-			usage();
-	}
-}
-
-
-void mattrib(int argc, char **argv, int type)
-{
-	Arg_t arg;
-	int view;
-	int c;
-	int concise;
-	int replay;
-	char *ptr;
-
-	arg.add = 0;
-	arg.remove = 0xff;
-	arg.recursive = 0;
-	arg.doPrintName = 1;
-	view = 0;
-	concise = 0;
-	replay = 0;
-	
-	while ((c = getopt(argc, argv, "/ahrsAHRSXp")) != EOF) {
-		switch (c) {
-			default:
-				arg.remove &= ~letterToCode(c);
-				break;
-			case 'p':
-				replay = 1;
-				break;
-			case '/':
-				arg.recursive = 1;
-				break;
-			case 'X':
-				concise = 1;
-				break;
-			case '?':
-				usage();
-		}
-	}
-
-	for(;optind < argc;optind++) {
-		switch(argv[optind][0]) {
-			case '+':
-				for(ptr = argv[optind] + 1; *ptr; ptr++)
-					arg.add |= letterToCode(*ptr);
-				continue;
-			case '-':
-				for(ptr = argv[optind] + 1; *ptr; ptr++)
-					arg.remove &= ~letterToCode(*ptr);
-				continue;
-		}
-		break;
-	}
-
-	if(arg.remove == 0xff && !arg.add)
-		view = 1;
-
-	if (optind >= argc)
-		usage();
-
-	init_mp(&arg.mp);
-	if(view){
-		if(concise) {
-			arg.mp.callback = concise_view_attrib;
-			arg.doPrintName = (argc - optind > 1 ||
-					   arg.recursive ||
-					   strpbrk(argv[optind], "*[?") != 0);
-		} else if (replay) {
-			arg.mp.callback = replay_attrib;
-		} else
-			arg.mp.callback = view_attrib;
-		arg.mp.openflags = O_RDONLY;
-	} else {
-		arg.mp.callback = attrib_file;
-		arg.mp.openflags = O_RDWR;
-	}
-
-	if(arg.recursive)
-		arg.mp.dirCallback = recursive_attrib;
-
-	arg.mp.arg = (void *) &arg;
-	arg.mp.lookupflags = ACCEPT_PLAIN | ACCEPT_DIR;
-	if(arg.recursive)
-		arg.mp.lookupflags |= DO_OPEN_DIRS | NO_DOTS;
-	exit(main_loop(&arg.mp, argv + optind, argc - optind));
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/mbadblocks.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mbadblocks.c	(revision 9)
+++ 	(revision )
@@ -1,77 +1,0 @@
-/*
- * mbadblocks.c
- * Mark bad blocks on disk
- *
- */
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "mainloop.h"
-#include "fsP.h"
-
-void mbadblocks(int argc, char **argv, int type)
-{
-	int i;
-	char *in_buf;
-	int in_len;
-	off_t start;
-	struct MainParam_t mp;
-	Fs_t *Fs;
-	Stream_t *Dir;
-	int ret;
-
-	if (argc != 2 || skip_drive(argv[1]) == argv[1]) {
-		fprintf(stderr, "Mtools version %s, dated %s\n", 
-			mversion, mdate);
-		fprintf(stderr, "Usage: %s drive:\n", argv[0]);
-		exit(1);
-	}
-
-	init_mp(&mp);
-
-	Dir = open_root_dir(get_drive(argv[1], NULL), O_RDWR);
-	if (!Dir) {
-		fprintf(stderr,"%s: Cannot initialize drive\n", argv[0]);
-		exit(1);
-	}
-
-	Fs = (Fs_t *)GetFs(Dir);
-	in_len = Fs->cluster_size * Fs->sector_size;
-	in_buf = malloc(in_len);
-	if(!in_buf) {
-		FREE(&Dir);
-		printOom();
-		exit(1);
-	}
-	for(i=0; i < Fs->clus_start; i++ ){
-		ret = READS(Fs->Next, 
-					in_buf, sectorsToBytes((Stream_t*)Fs, i), Fs->sector_size);
-		if( ret < 0 ){
-			perror("early error");
-			exit(1);
-		}
-		if(ret < Fs->sector_size){
-			fprintf(stderr,"end of file in file_read\n");
-			exit(1);
-		}
-	}
-		
-	in_len = Fs->cluster_size * Fs->sector_size;
-	for(i=2; i< Fs->num_clus + 2; i++){
-		if(got_signal)
-			break;
-		if(Fs->fat_decode((Fs_t*)Fs,i))
-			continue;
-		start = (i - 2) * Fs->cluster_size + Fs->clus_start;
-		ret = force_read(Fs->Next, in_buf, 
-						 sectorsToBytes((Stream_t*)Fs, start), in_len);
-		if(ret < in_len ){
-			printf("Bad cluster %d found\n", i);
-			fatEncode((Fs_t*)Fs, i, 0xfff7);
-			continue;
-		}
-	}
-	FREE(&Dir);
-	exit(0);
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/mcat.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mcat.c	(revision 9)
+++ 	(revision )
@@ -1,129 +1,0 @@
-/*
- * mcat.c
- * Same thing as cat /dev/fd0 or cat file >/dev/fd0
- * Something, that isn't possible with floppyd anymore.
- */
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "mainloop.h"
-#include "fsP.h"
-#include "xdf_io.h"
-#include "floppyd_io.h"
-#include "plain_io.h"
-
-void usage(void) 
-{
-	fprintf(stderr, "Mtools version %s, dated %s\n", 
-		mversion, mdate);
-	fprintf(stderr, "Usage: mcat [-w] device\n");
-	fprintf(stderr, "       -w write on device else read\n");
-	exit(1);
-}
-
-#define BUF_SIZE 16000
-
-void mcat(int argc, char **argv, int type)
-{
-	struct device *dev;
-	struct device out_dev;
-	char *drive, name[EXPAND_BUF];
-        char errmsg[200];
-        Stream_t *Stream;
-	char buf[BUF_SIZE];
-
-	mt_off_t address = 0;
-
-	char mode = O_RDONLY;
-	int optindex = 1;
-	size_t len;
-
-	noPrivileges = 1;
-
-	if (argc < 2) {
-		usage();
-	}
-
-	if (argv[1][0] == '-') {
-		if (argv[1][1] != 'w') {
-			usage();
-		}
-		mode = O_WRONLY;
-		optindex++;
-	}
-
-	if (argc - optindex < 1)
-		usage();
-
-
-	if (skip_drive(argv[optindex]) == argv[optindex])
-		usage();
-
-        drive = get_drive(argv[optindex], NULL);
-
-        /* check out a drive whose letter and parameters match */       
-        sprintf(errmsg, "Drive '%s:' not supported", drive);    
-        Stream = NULL;
-        for (dev=devices; dev->name; dev++) {
-                FREE(&Stream);
-                if (strcmp(dev->drive, drive) != 0)
-                        continue;
-                out_dev = *dev;
-                expand(dev->name,name);
-#ifdef USING_NEW_VOLD
-                strcpy(name, getVoldName(dev, name));
-#endif
-
-                Stream = 0;
-#ifdef USE_XDF
-                Stream = XdfOpen(&out_dev, name, mode, errmsg, 0);
-				if(Stream)
-                        out_dev.use_2m = 0x7f;
-
-#endif
-
-#ifdef USE_FLOPPYD
-                if(!Stream)
-                        Stream = FloppydOpen(&out_dev, dev, name, 
-					     mode, errmsg, 0, 1);
-#endif
-
-
-                if (!Stream)
-                        Stream = SimpleFileOpen(&out_dev, dev, name, mode,
-						errmsg, 0, 1, 0);
-
-                if( !Stream)
-                        continue;
-                break;
-        }
-
-        /* print error msg if needed */ 
-        if ( dev->drive == 0 ){
-                FREE(&Stream);
-                fprintf(stderr,"%s\n",errmsg);
-                exit(1);
-        }
-
-	if (mode == O_WRONLY) {
-		while ((len = fread(buf, 1, BUF_SIZE, stdin)) 
-		       == BUF_SIZE) {
-			WRITES(Stream, buf, address, BUF_SIZE);
-			address += BUF_SIZE;
-		}
-		if (len)
-			WRITES(Stream, buf, address, len);
-	} else {
-		while ((len = READS(Stream, buf, address, BUF_SIZE)) 
-		       == BUF_SIZE) {
-			fwrite(buf, 1, BUF_SIZE, stdout);
-			address += BUF_SIZE;
-		}
-		if (len)
-			fwrite(buf, 1, len, stdout);
-	}
-
-	FREE(&Stream);
-	exit(0);
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/mcd.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mcd.c	(revision 9)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- * mcd.c: Change MSDOS directories
- */
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mainloop.h"
-#include "mtools.h"
-
-
-static int mcd_callback(direntry_t *entry, MainParam_t *mp)
-{
-	FILE *fp;
-
-	if (!(fp = open_mcwd("w"))){
-		fprintf(stderr,"mcd: Can't open mcwd .file for writing\n");
-		return ERROR_ONE;
-	}
-	
-	fprintPwd(fp, entry,0);
-	fprintf(fp, "\n");
-	fclose(fp);
-	return GOT_ONE | STOP_NOW;
-}
-
-
-void mcd(int argc, char **argv, int type)
-{
-	struct MainParam_t mp;
-
-	if (argc > 2) {
-		fprintf(stderr, "Mtools version %s, dated %s\n", 
-			mversion, mdate);
-		fprintf(stderr, "Usage: %s: msdosdirectory\n", argv[0]);
-		exit(1);
-	}
-
-	init_mp(&mp);
-	mp.lookupflags = ACCEPT_DIR | NO_DOTS;
-	mp.dirCallback = mcd_callback;
-	if (argc == 1) {
-		printf("%s\n", mp.mcwd);
-		exit(0);
-	} else 
-		exit(main_loop(&mp, argv + 1, 1));
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/mcopy.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mcopy.c	(revision 9)
+++ 	(revision )
@@ -1,584 +1,0 @@
-/*
- * mcopy.c
- * Copy an MSDOS files to and from Unix
- *
- */
-
-
-#define LOWERCASE
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "vfat.h"
-#include "mainloop.h"
-#include "plain_io.h"
-#include "nameclash.h"
-#include "file.h"
-#include "fs.h"
-
-
-/*
- * Preserve the file modification times after the fclose()
- */
-
-static void set_mtime(const char *target, time_t mtime)
-{
-	if (target && strcmp(target, "-") && mtime != 0L) {
-#ifdef HAVE_UTIMES
-		struct timeval tv[2];	
-		tv[0].tv_sec = mtime;
-		tv[0].tv_usec = 0;
-		tv[1].tv_sec = mtime;
-		tv[1].tv_usec = 0;
-		utimes((char *)target, tv);
-#else
-#ifdef HAVE_UTIME
-		struct utimbuf utbuf;
-
-		utbuf.actime = mtime;
-		utbuf.modtime = mtime;
-		utime(target, &utbuf);
-#endif
-#endif
-	}
-	return;
-}
-
-typedef struct Arg_t {
-	int recursive;
-	int preserveAttributes;
-	int preserveTime;
-	unsigned char attr;
-	char *path;
-	int textmode;
-	int needfilter;
-	int nowarn;
-	int verbose;
-	int type;
-	MainParam_t mp;
-	ClashHandling_t ch;
-} Arg_t;
-
-/* Write the Unix file */
-static int unix_write(direntry_t *entry, MainParam_t *mp, int needfilter)
-{
-	Arg_t *arg=(Arg_t *) mp->arg;
-	time_t mtime;
-	Stream_t *File=mp->File;
-	Stream_t *Target, *Source;
-	struct stat stbuf;
-	int ret;
-	char errmsg[80];
-	char *unixFile;
-
-	File->Class->get_data(File, &mtime, 0, 0, 0);
-
-	if (!arg->preserveTime)
-		mtime = 0L;
-
-	if(arg->type)
-		unixFile = "-";
-	else
-		unixFile = mpBuildUnixFilename(mp);
-	if(!unixFile) {
-		printOom();
-		return ERROR_ONE;
-	}
-
-	/* if we are creating a file, check whether it already exists */
-	if(!arg->type) {
-		if (!arg->nowarn && &arg->type && !access(unixFile, 0)){
-			if( ask_confirmation("File \"%s\" exists, overwrite (y/n) ? ",
-					     unixFile,0)) {
-				free(unixFile);
-				return ERROR_ONE;
-			}
-			
-			/* sanity checking */
-			if (!stat(unixFile, &stbuf) && !S_ISREG(stbuf.st_mode)) {
-				fprintf(stderr,"\"%s\" is not a regular file\n",
-					unixFile);
-				
-				free(unixFile);
-				return ERROR_ONE;
-			}
-		}
-	}
-
-	if(!arg->type && arg->verbose) {
-		fprintf(stderr,"Copying ");
-		mpPrintFilename(stderr,mp);
-		fprintf(stderr,"\n");
-	}
-	
-	if(got_signal) {
-		free(unixFile);
-		return ERROR_ONE;
-	}
-
-	if ((Target = SimpleFileOpen(0, 0, unixFile,
-				     O_WRONLY | O_CREAT | O_TRUNC,
-				     errmsg, 0, 0, 0))) {
-		ret = 0;
-		if(needfilter && arg->textmode){
-			Source = open_filter(COPY(File));
-			if (!Source)
-				ret = -1;
-		} else
-			Source = COPY(File);
-
-		if (ret == 0 )
-			ret = copyfile(Source, Target);
-		FREE(&Source);
-		FREE(&Target);
-		if(ret <= -1){
-			if(!arg->type) {
-				unlink(unixFile);
-				free(unixFile);
-			}
-			return ERROR_ONE;
-		}
-		if(!arg->type) {
-			set_mtime(unixFile, mtime);
-			free(unixFile);
-		}
-		return GOT_ONE;
-	} else {
-		fprintf(stderr,"%s\n", errmsg);
-		if(!arg->type)
-			free(unixFile);
-		return ERROR_ONE;
-	}
-}
-
-static int makeUnixDir(char *filename)
-{
-	if(!mkdir(filename, 0777))
-		return 0;
-	if(errno == EEXIST) {
-		struct stat buf;
-		if(stat(filename, &buf) < 0)
-			return -1;
-		if(S_ISDIR(buf.st_mode))
-			return 0;
-		errno = ENOTDIR;
-	}
-	return -1;
-}
-
-/* Copy a directory to Unix */
-static int unix_copydir(direntry_t *entry, MainParam_t *mp)
-{
-	Arg_t *arg=(Arg_t *) mp->arg;
-	time_t mtime;
-	Stream_t *File=mp->File;
-	int ret;
-	char *unixFile;
-
-	if (!arg->recursive && mp->basenameHasWildcard)
-		return 0;
-
-	File->Class->get_data(File, &mtime, 0, 0, 0);	
-	if (!arg->preserveTime)
-		mtime = 0L;
-	if(!arg->type && arg->verbose) {
-		fprintf(stderr,"Copying ");
-		fprintPwd(stderr, entry,0);
-		fprintf(stderr, "\n");
-	}
-	if(got_signal)
-		return ERROR_ONE;
-	unixFile = mpBuildUnixFilename(mp);
-	if(!unixFile) {
-		printOom();
-		return ERROR_ONE;
-	}
-	if(arg->type || !*mpPickTargetName(mp) || !makeUnixDir(unixFile)) {
-		Arg_t newArg;
-
-		newArg = *arg;
-		newArg.mp.arg = (void *) &newArg;
-		newArg.mp.unixTarget = unixFile;
-		newArg.mp.targetName = 0;
-		newArg.mp.basenameHasWildcard = 1;
-
-		ret = mp->loop(File, &newArg.mp, "*");
-		set_mtime(unixFile, mtime);
-		free(unixFile);
-		return ret | GOT_ONE;		
-	} else {
-		perror("mkdir");
-		fprintf(stderr, 
-			"Failure to make directory %s\n", 
-			unixFile);
-		free(unixFile);
-		return ERROR_ONE;
-	}
-}
-
-static  int dos_to_unix(direntry_t *entry, MainParam_t *mp)
-{
-	return unix_write(entry, mp, 1);
-}
-
-
-static  int unix_to_unix(MainParam_t *mp)
-{
-	return unix_write(0, mp, 0);
-}
-
-
-static int directory_dos_to_unix(direntry_t *entry, MainParam_t *mp)
-{
-	return unix_copydir(entry, mp);
-}
-
-/*
- * Open the named file for read, create the cluster chain, return the
- * directory structure or NULL on error.
- */
-static int writeit(char *dosname,
-		   char *longname,
-		   void *arg0,
-		   direntry_t *entry)
-{
-	Stream_t *Target;
-	time_t now;
-	int type, fat, ret;
-	time_t date;
-	mt_size_t filesize, newsize;
-	Arg_t *arg = (Arg_t *) arg0;
-
-
-
-	if (arg->mp.File->Class->get_data(arg->mp.File,
-									  & date, &filesize, &type, 0) < 0 ){
-		fprintf(stderr, "Can't stat source file\n");
-		return -1;
-	}
-
-	if (type){
-		if (arg->verbose)
-			fprintf(stderr, "\"%s\" is a directory\n", longname);
-		return -1;
-	}
-
-	/*if (!arg->single || arg->recursive)*/
-	if(arg->verbose)
-		fprintf(stderr,"Copying %s\n", longname);
-	if(got_signal)
-		return -1;
-
-	/* will it fit? */
-	if (!getfreeMinBytes(arg->mp.targetDir, filesize))
-		return -1;
-	
-	/* preserve mod time? */
-	if (arg->preserveTime)
-		now = date;
-	else
-		getTimeNow(&now);
-
-	mk_entry(dosname, arg->attr, 1, 0, now, &entry->dir);
-
-	Target = OpenFileByDirentry(entry);
-	if(!Target){
-		fprintf(stderr,"Could not open Target\n");
-		exit(1);
-	}
-	if (arg->needfilter & arg->textmode)
-		Target = open_filter(Target);
-
-
-
-	ret = copyfile(arg->mp.File, Target);
-	GET_DATA(Target, 0, &newsize, 0, &fat);
-	FREE(&Target);
-	if (arg->needfilter & arg->textmode)
-	    newsize++; /* ugly hack: we gathered the size before the Ctrl-Z
-			* was written.  Increment it manually */
-	if(ret < 0 ){
-		fat_free(arg->mp.targetDir, fat);
-		return -1;
-	} else {
-		mk_entry(dosname, arg->attr, fat, truncBytes32(newsize),
-				 now, &entry->dir);
-		return 0;
-	}
-}
-
-
-
-static int dos_write(direntry_t *entry, MainParam_t *mp, int needfilter)
-/* write a messy dos file to another messy dos file */
-{
-	int result;
-	Arg_t * arg = (Arg_t *) (mp->arg);
-	const char *targetName = mpPickTargetName(mp);
-
-	if(entry && arg->preserveAttributes)
-		arg->attr = entry->dir.attr;
-	else
-		arg->attr = ATTR_ARCHIVE;
-
-	arg->needfilter = needfilter;
-	if (entry && mp->targetDir == entry->Dir){
-		arg->ch.ignore_entry = -1;
-		arg->ch.source = entry->entry;
-	} else {
-		arg->ch.ignore_entry = -1;
-		arg->ch.source = -2;
-	}
-	result = mwrite_one(mp->targetDir, targetName, 0,
-			    writeit, (void *)arg, &arg->ch);
-	if(result == 1)
-		return GOT_ONE;
-	else
-		return ERROR_ONE;
-}
-
-static Stream_t *subDir(Stream_t *parent, const char *filename)
-{
-	direntry_t entry;		
-	initializeDirentry(&entry, parent);
-
-	switch(vfat_lookup(&entry, filename, -1, ACCEPT_DIR, 0, 0)) {
-	    case 0:
-		return OpenFileByDirentry(&entry);
-	    case -1:
-		return NULL;
-	    default: /* IO Error */
-		return NULL;
-	}
-}
-
-static int dos_copydir(direntry_t *entry, MainParam_t *mp)
-/* copyes a directory to Dos */
-{
-	Arg_t * arg = (Arg_t *) (mp->arg);
-	Arg_t newArg;
-	time_t now;
-	time_t date;
-	int ret;
-	const char *targetName = mpPickTargetName(mp);
-
-	if (!arg->recursive && mp->basenameHasWildcard)
-		return 0;
-
-	if(entry && isSubdirOf(mp->targetDir, mp->File)) {
-		fprintf(stderr, "Cannot recursively copy directory ");
-		fprintPwd(stderr, entry,0);
-		fprintf(stderr, " into one of its own subdirectories ");
-		fprintPwd(stderr, getDirentry(mp->targetDir),0);
-		fprintf(stderr, "\n");
-		return ERROR_ONE;
-	}
-
-	if (arg->mp.File->Class->get_data(arg->mp.File,
-					  & date, 0, 0, 0) < 0 ){
-		fprintf(stderr, "Can't stat source file\n");
-		return ERROR_ONE;
-	}
-
-	if(!arg->type && arg->verbose)
-		fprintf(stderr,"Copying %s\n", mpGetBasename(mp));
-
-	if(entry && arg->preserveAttributes)
-		arg->attr = entry->dir.attr;
-	else
-		arg->attr = 0;
-
-	if (entry && (mp->targetDir == entry->Dir)){
-		arg->ch.ignore_entry = -1;
-		arg->ch.source = entry->entry;
-	} else {
-		arg->ch.ignore_entry = -1;
-		arg->ch.source = -2;
-	}
-
-	/* preserve mod time? */
-	if (arg->preserveTime)
-		now = date;
-	else
-		getTimeNow(&now);
-
-	newArg = *arg;
-	newArg.mp.arg = &newArg;
-	newArg.mp.targetName = 0;
-	newArg.mp.basenameHasWildcard = 1;
-	if(*targetName) {
-		/* maybe the directory already exist. Use it */
-		newArg.mp.targetDir = subDir(mp->targetDir, targetName);
-		if(!newArg.mp.targetDir)
-			newArg.mp.targetDir = createDir(mp->targetDir, 
-							targetName,
-							&arg->ch, arg->attr, 
-							now);
-	} else
-		newArg.mp.targetDir = mp->targetDir;
-
-	if(!newArg.mp.targetDir)
-		return ERROR_ONE;
-
-	ret = mp->loop(mp->File, &newArg.mp, "*");
-	if(*targetName)
-		FREE(&newArg.mp.targetDir);
-	return ret | GOT_ONE;
-}
-
-
-static int dos_to_dos(direntry_t *entry, MainParam_t *mp)
-{
-	return dos_write(entry, mp, 0);
-}
-
-static int unix_to_dos(MainParam_t *mp)
-{
-	return dos_write(0, mp, 1);
-}
-
-
-static void usage(void)
-{
-	fprintf(stderr,
-		"Mtools version %s, dated %s\n", mversion, mdate);
-	fprintf(stderr,
-		"Usage: %s [-/spabtnmvQB] [-D clash_option] sourcefile targetfile\n", progname);
-	fprintf(stderr,
-		"       %s [-/spabtnmvQB] [-D clash_option] sourcefile [sourcefiles...] targetdirectory\n", 
-		progname);
-	fprintf(stderr,
-		"\t-/ -s Recursive\n"
-		"\t-p Preserve attributes\n"
-		"\t-a -t Textmode\n"
-		"\t-n Overwrite UNIX files without confirmation\n"
-		"\t-m Preserve file time (default under Minix)\n"
-		"\t-v Verbose\n"
-		"\t-Q Quit on the first error\n"
-		"\t-b -B Batch mode (faster, but less crash resistent)\n"
-		"\t-o Overwrite DOS files without confirmation\n");
-	exit(1);
-}
-
-void mcopy(int argc, char **argv, int mtype)
-{
-	Arg_t arg;
-	int c, ret, fastquit;
-	int todir;
-	
-
-	/* get command line options */
-
-	init_clash_handling(& arg.ch);
-
-	/* get command line options */
-	todir = 0;
-	arg.recursive = 0;
-#ifdef OS_Minix
-	arg.preserveTime = 1;	/* Copy file time as DOS does. */
-#else
-	arg.preserveTime = 0;
-#endif
-	arg.preserveAttributes = 0;
-	arg.nowarn = 0;
-	arg.textmode = 0;
-	arg.verbose = 0;
-	arg.type = mtype;
-	fastquit = 0;
-	while ((c = getopt(argc, argv, "abB/sptnmvQD:o")) != EOF) {
-		switch (c) {
-			case 's':
-			case '/':
-				arg.recursive = 1;
-				break;
-			case 'p':
-				arg.preserveAttributes = 1;
-				break;
-			case 'a':
-			case 't':
-				arg.textmode = 1;
-				break;
-			case 'n':
-				arg.nowarn = 1;
-				break;
-			case 'm':
-				arg.preserveTime = 1;
-				break;
-			case 'v':
-				arg.verbose = 1;
-				break;
-			case 'Q':
-				fastquit = 1;
-				break;
-			case 'B':
-			case 'b':
-				batchmode = 1;
-				break;
-			case 'o':
-				handle_clash_options(&arg.ch, c);
-				break;
-			case 'D':
-				if(handle_clash_options(&arg.ch, *optarg))
-					usage();
-				break;
-			case '?':
-				usage();
-			default:
-				break;
-		}
-	}
-
-	if (argc - optind < 1)
-		usage();
-
-	init_mp(&arg.mp);
-	arg.mp.lookupflags = ACCEPT_PLAIN | ACCEPT_DIR | DO_OPEN | NO_DOTS;
-	arg.mp.fast_quit = fastquit;
-	arg.mp.arg = (void *) &arg;
-	arg.mp.openflags = O_RDONLY;
-
-	/* last parameter is "-", use mtype mode */
-	if(!mtype && !strcmp(argv[argc-1], "-")) {
-		arg.type = mtype = 1;
-		argc--;
-	}
-
-	if(mtype){
-		/* Mtype = copying to stdout */
-		arg.mp.targetName = strdup("-");
-		arg.mp.unixTarget = strdup("");
-		arg.mp.callback = dos_to_unix;
-		arg.mp.dirCallback = unix_copydir;
-		arg.mp.unixcallback = unix_to_unix;		
-	} else {
-		char *target;
-		if (argc - optind == 1) {
-			/* copying to the current directory */
-			target = ".";
-		} else {
-			/* target is the last item mentioned */
-			argc--;
-			target = argv[argc];
-		}
-
-		ret = target_lookup(&arg.mp, target);
-		if(!arg.mp.targetDir && !arg.mp.unixTarget) {
-			fprintf(stderr,"Bad target %s\n", target);
-			exit(1);
-		}
-
-		/* callback functions */
-		if(arg.mp.unixTarget) {
-			arg.mp.callback = dos_to_unix;
-			arg.mp.dirCallback = directory_dos_to_unix;
-			arg.mp.unixcallback = unix_to_unix;
-		} else {
-			arg.mp.dirCallback = dos_copydir;
-			arg.mp.callback = dos_to_dos;
-			arg.mp.unixcallback = unix_to_dos;
-		}
-	}
-
-	exit(main_loop(&arg.mp, argv + optind, argc - optind));
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/mdel.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mdel.c	(revision 9)
+++ 	(revision )
@@ -1,173 +1,0 @@
-/*
- * mdel.c
- * Delete an MSDOS file
- *
- */
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "stream.h"
-#include "mainloop.h"
-#include "fs.h"
-#include "file.h"
-
-typedef struct Arg_t {
-	int deltype;
-	int verbose;
-} Arg_t;
-
-static int del_entry(direntry_t *entry, MainParam_t *mp)
-{
-	Arg_t *arg=(Arg_t *) mp->arg;
-	direntry_t longNameEntry;
-	int i;
-
-	if(got_signal)
-		return ERROR_ONE;
-
-	if(entry->entry == -3) {
-		fprintf(stderr, "Cannot remove root directory\n");
-		return ERROR_ONE;
-	}
-
-	if (arg->verbose) {
-		fprintf(stderr,"Removing ");
-		fprintPwd(stdout, entry,0);
-		putchar('\n');
-	}
-
-	if ((entry->dir.attr & (ATTR_READONLY | ATTR_SYSTEM)) &&
-	    (ask_confirmation("%s: \"%s\" is read only, erase anyway (y/n) ? ",
-			      progname, entry->name)))
-		return ERROR_ONE;
-	if (fatFreeWithDirentry(entry)) 
-		return ERROR_ONE;
-
-	initializeDirentry(&longNameEntry, entry->Dir);
-	for(i=entry->beginSlot; i< entry->endSlot; i++) {
-	    int error;
-	    longNameEntry.entry=i;
-	    dir_read(&longNameEntry, &error);
-	    if(error)
-		break;
-	    longNameEntry.dir.name[0] = (char) DELMARK;
-	    dir_write(&longNameEntry);
-	}
-
-	entry->dir.name[0] = (char) DELMARK;
-	dir_write(entry);
-	return GOT_ONE;
-}
-
-static int del_file(direntry_t *entry, MainParam_t *mp)
-{
-	char shortname[13];
-	direntry_t subEntry;
-	Stream_t *SubDir;
-	Arg_t *arg = (Arg_t *) mp->arg;
-	MainParam_t sonmp;
-	int ret;
-	int r;
-
-	sonmp = *mp;
-	sonmp.arg = mp->arg;
-
-	r = 0;
-	if (IS_DIR(entry)){
-		/* a directory */
-		SubDir = OpenFileByDirentry(entry);
-		initializeDirentry(&subEntry, SubDir);
-		ret = 0;
-		while((r=vfat_lookup(&subEntry, "*", 1,
-				     ACCEPT_DIR | ACCEPT_PLAIN,
-				     shortname, NULL)) == 0 ){
-			if(shortname[0] != DELMARK &&
-			   shortname[0] &&
-			   shortname[0] != '.' ){
-				if(arg->deltype != 2){
-					fprintf(stderr,
-						"Directory ");
-					fprintPwd(stderr, entry,0);
-					fprintf(stderr," non empty\n");
-					ret = ERROR_ONE;
-					break;
-				}
-				if(got_signal) {
-					ret = ERROR_ONE;
-					break;
-				}
-				ret = del_file(&subEntry, &sonmp);
-				if( ret & ERROR_ONE)
-					break;
-				ret = 0;
-			}
-		}
-		FREE(&SubDir);
-		if (r == -2)
-			return ERROR_ONE;
-		if(ret)
-			return ret;
-	}
-	return del_entry(entry, mp);
-}
-
-
-static void usage(void)
-{
-	fprintf(stderr, 
-		"Mtools version %s, dated %s\n", mversion, mdate);
-	fprintf(stderr, 
-		"Usage: %s [-v] msdosfile [msdosfiles...]\n"
-		"\t-v Verbose\n",
-		progname);
-	exit(1);
-}
-
-void mdel(int argc, char **argv, int deltype)
-{
-	Arg_t arg;
-	MainParam_t mp;
-	int c,i;
-
-	arg.verbose = 0;
-	while ((c = getopt(argc, argv, "v")) != EOF) {
-		switch (c) {
-			case 'v':
-				arg.verbose = 1;
-				break;
-			default:
-				usage();
-		}
-	}
-
-	if(argc == optind)
-		usage();
-
-	init_mp(&mp);
-	mp.callback = del_file;
-	mp.arg = (void *) &arg;
-	mp.openflags = O_RDWR;
-	arg.deltype = deltype;
-	switch(deltype){
-	case 0:
-		mp.lookupflags = ACCEPT_PLAIN; /* mdel */
-		break;
-	case 1:
-		mp.lookupflags = ACCEPT_DIR; /* mrd */
-		break;
-	case 2:
-		mp.lookupflags = ACCEPT_DIR | ACCEPT_PLAIN; /* mdeltree */
-		break;
-	}
-	mp.lookupflags |= NO_DOTS;
-	for(i=optind;i<argc;i++) {
-		int b,l;
-		b = skip_drive(argv[i]) - argv[i];
-		l = strlen(argv[i]+b);
-		if(l > 1 && argv[i][b+l-1] == '/')
-			argv[i][b+l-1] = '\0';
-	}
-		
-	exit(main_loop(&mp, argv + optind, argc - optind));
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/mdir.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mdir.c	(revision 9)
+++ 	(revision )
@@ -1,579 +1,0 @@
-/*
- * mdir.c:
- * Display an MSDOS directory
- */
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "vfat.h"
-#include "mtools.h"
-#include "file.h"
-#include "mainloop.h"
-#include "fs.h"
-#include "codepage.h"
-
-#ifdef TEST_SIZE
-#include "fsP.h"
-#endif
-
-static int recursive;
-static int wide;
-static int all;
-static int concise;
-static int fast=0;
-#if 0
-static int testmode = 0;
-#endif
-static char *dirPath;
-static char *currentDrive;
-static Stream_t *currentDir;
-
-static int filesInDir; /* files in current dir */
-static int filesOnDrive; /* files on drive */
-	
-static int dirsOnDrive; /* number of listed directories on this drive */
-
-static int debug = 0; /* debug mode */
-
-static mt_size_t bytesInDir;
-static mt_size_t bytesOnDrive;
-static Stream_t *RootDir;	
-
-
-static char shortname[13];
-static char longname[VBUFSIZE];
-
-
-/*
- * Print an MSDOS directory date stamp.
- */
-static inline void print_date(struct directory *dir)
-{
-	char year[5];
-	char day[3];
-	char month[3];
-	char *p;
-
-	sprintf(year, "%04d", DOS_YEAR(dir));
-	sprintf(day, "%02d", DOS_DAY(dir));
-	sprintf(month, "%02d", DOS_MONTH(dir));
-
-	for(p=mtools_date_string; *p; p++) {
-		if(!strncasecmp(p, "yyyy", 4)) {
-			printf("%04d", DOS_YEAR(dir));
-			p+= 3;
-			continue;
-		} else if(!strncasecmp(p, "yy", 2)) {
-			printf("%02d", DOS_YEAR(dir) % 100);
-			p++;
-			continue;
-		} else if(!strncasecmp(p, "dd", 2)) {
-			printf("%02d", DOS_DAY(dir));
-			p++;
-			continue;
-		} else if(!strncasecmp(p, "mm", 2)) {
-			printf("%02d", DOS_MONTH(dir));
-			p++;
-			continue;
-		}
-		putchar(*p);
-	}
-}
-
-/*
- * Print an MSDOS directory time stamp.
- */
-static inline void print_time(struct directory *dir)
-{
-	char am_pm;
-	int hour = DOS_HOUR(dir);
-       
-	if(!mtools_twenty_four_hour_clock) {
-		am_pm = (hour >= 12) ? 'p' : 'a';
-		if (hour > 12)
-			hour = hour - 12;
-		if (hour == 0)
-			hour = 12;
-	} else
-		am_pm = ' ';
-
-	printf("%2d:%02d%c", hour, DOS_MINUTE(dir), am_pm);
-}
-
-/*
- * Return a number in dotted notation
- */
-static const char *dotted_num(mt_size_t num, int width, char **buf)
-{
-	int      len;
-	register char *srcp, *dstp;
-	int size;
-
-	unsigned long numlo;
-	unsigned long numhi;
-
-	if (num < 0) {
-	    /* warn about negative numbers here.  They should not occur */
-	    fprintf(stderr, "Invalid negative number\n");
-	}
-
-	size = width + width;
-	*buf = malloc(size+1);
-
-	if (*buf == NULL)
-		return "";
-	
-	/* Create the number in maximum width; make sure that the string
-	 * length is not exceeded (in %6ld, the result can be longer than 6!)
-	 */
-
-	numlo = num % 1000000000;
-	numhi = num / 1000000000;
-
-	if(numhi && size > 9) {
-		sprintf(*buf, "%.*lu%09lu", size-9, numhi, numlo);
-	} else {
-		sprintf(*buf, "%.*lu", size, numlo);
-	}
-
-	for (srcp=*buf; srcp[1] != '\0'; ++srcp)
-		if (srcp[0] == '0')
-			srcp[0] = ' ';
-		else
-			break;
-	
-	len = strlen(*buf);
-	srcp = (*buf)+len;
-	dstp = (*buf)+len+1;
-
-	for ( ; dstp >= (*buf)+4 && isdigit (srcp[-1]); ) {
-		srcp -= 3;  /* from here we copy three digits */
-		dstp -= 4;  /* that's where we put these 3 digits */
-	}
-
-	/* now finally copy the 3-byte blocks to their new place */
-	while (dstp < (*buf) + len) {
-		dstp[0] = srcp[0];
-		dstp[1] = srcp[1];
-		dstp[2] = srcp[2];
-		if (dstp + 3 < (*buf) + len)
-			/* use spaces instead of dots: they please both
-			 * Americans and Europeans */
-			dstp[3] = ' ';		
-		srcp += 3;
-		dstp += 4;
-	}
-
-	return (*buf) + len-width;
-}
-
-static inline int print_volume_label(Stream_t *Dir, char *drive)
-{
-	Stream_t *Stream = GetFs(Dir);
-	direntry_t entry;
-	DeclareThis(FsPublic_t);
-	char shortname[13];
-	char longname[VBUFSIZE];
-	int r;
-
-	RootDir = OpenRoot(Stream);
-	if(concise)
-		return 0;
-	
-	/* find the volume label */
-
-	initializeDirentry(&entry, RootDir);
-	if((r=vfat_lookup(&entry, 0, 0, ACCEPT_LABEL | MATCH_ANY,
-			  shortname, longname)) ) {
-		if (r == -2) {
-			/* I/O Error */
-			return -1;
-		}
-		printf(" Volume in drive %s has no label", drive);
-	} else if (*longname)
-		printf(" Volume in drive %s is %s (abbr=%s)",
-		       drive, longname, shortname);
-	else
-		printf(" Volume in drive %s is %s",
-		       drive, shortname);
-	if(This->serialized)
-		printf("\n Volume Serial Number is %04lX-%04lX",
-		       (This->serial_number >> 16) & 0xffff, 
-		       This->serial_number & 0xffff);
-	return 0;
-}
-
-
-static void printSummary(int files, mt_size_t bytes)
-{
-	if(!filesInDir)
-		printf("No files\n");
-	else {		
-		char *s1;
-		printf("      %3d file", files);
-		if(files == 1)
-			putchar(' ');
-		else
-			putchar('s');
-		printf("       %s bytes\n",
-		       dotted_num(bytes, 13, &s1));
-		if(s1)
-			free(s1);
-	}
-}
-
-static void leaveDirectory(int haveError);
-
-static void leaveDrive(int haveError)
-{
-	if(!currentDrive)
-		return;
-	leaveDirectory(haveError);
-	if(!concise && !haveError) {
-		char *s1;
-
-		if(dirsOnDrive > 1) {
-			printf("\nTotal files listed:\n");
-			printSummary(filesOnDrive, bytesOnDrive);
-		}
-		if(RootDir && !fast) {
-			mt_off_t bytes = getfree(RootDir);
-			printf("                  %s bytes free\n\n",
-			       dotted_num(bytes,17, &s1));
-#ifdef TEST_SIZE
-			((Fs_t*)GetFs(RootDir))->freeSpace = 0;
-			bytes = getfree(RootDir);
-			printf("                  %s bytes free\n\n",
-			       dotted_num(bytes,17, &s1));
-#endif
-		}
-		if(s1)
-			free(s1);
-	}
-	FREE(&RootDir);
-	currentDrive = NULL;
-}
-
-
-static int enterDrive(Stream_t *Dir, char *drive)
-{
-	int r;
-	if(currentDrive != NULL && strcmp(currentDrive, drive) == 0)
-		return 0; /* still the same */
-	
-	leaveDrive(0);
-	currentDrive = drive;
-	
-	r = print_volume_label(Dir, drive);
-	if (r)
-		return r;
-
-
-	bytesOnDrive = 0;
-	filesOnDrive = 0;
-	dirsOnDrive = 0;
-	return 0;
-}
-
-static char *emptyString="<out-of-memory>";
-
-static void leaveDirectory(int haveError)
-{
-	if(!currentDir)
-		return;
-
-	if (!haveError) {
-		if(dirPath && dirPath != emptyString)
-			free(dirPath);
-		if(wide)
-			putchar('\n');
-		
-		if(!concise)
-			printSummary(filesInDir, bytesInDir);
-	}
-	FREE(&currentDir);
-}
-
-static int enterDirectory(Stream_t *Dir)
-{
-	int r;
-	char *drive;
-	char *slash;
-
-	if(currentDir == Dir)
-		return 0; /* still the same directory */
-
-	leaveDirectory(0);
-
-	drive = getDrive(Dir);
-	r=enterDrive(Dir, drive);
-	if(r)
-		return r;
-	currentDir = COPY(Dir);
-
-	dirPath = getPwd(getDirentry(Dir));
-	if(!dirPath)
-		dirPath=emptyString;
-	if(concise &&
-	    (slash = strrchr(dirPath, '/')) != NULL && slash[1] == '\0')
-		*slash = '\0';
-
-	/* print directory title */
-	if(!concise)
-		printf("\nDirectory for %s\n", dirPath);
-
-	if(!wide && !concise)
-		printf("\n");
-
-	dirsOnDrive++;
-	bytesInDir = 0;
-	filesInDir = 0;
-	return 0;
-}
-
-static int list_file(direntry_t *entry, MainParam_t *mp)
-{
-	unsigned long size;
-	int i;
-	int Case;
-	int r;
-
-	if(!all && (entry->dir.attr & 0x6))
-		return 0;
-
-	if(concise && isSpecial(entry->name))
-		return 0;
-
-	r=enterDirectory(entry->Dir);
-	if (r)
-		return ERROR_ONE;
-	if (wide) {
-		if(filesInDir % 5)
-			putchar(' ');				
-		else
-			putchar('\n');
-	}
-	
-	if(IS_DIR(entry)){
-		size = 0;
-	} else
-		size = FILE_SIZE(&entry->dir);
-	
-	Case = entry->dir.Case;
-	if(!(Case & (BASECASE | EXTCASE)) && 
-	   mtools_ignore_short_case)
-		Case |= BASECASE | EXTCASE;
-	
-	if(Case & EXTCASE){
-		for(i=0; i<3;i++)
-			entry->dir.ext[i] = tolower(entry->dir.ext[i]);
-	}
-	to_unix(entry->dir.ext,3);
-	if(Case & BASECASE){
-		for(i=0; i<8;i++)
-			entry->dir.name[i] = tolower(entry->dir.name[i]);
-	}
-	to_unix(entry->dir.name,8);
-	if(wide){
-		if(IS_DIR(entry))
-			printf("[%s]%*s", shortname,
-			       (int) (15 - 2 - strlen(shortname)), "");
-		else
-			printf("%-15s", shortname);
-	} else if(!concise) {				
-		/* is a subdirectory */
-		if(mtools_dotted_dir)
-			printf("%-13s", shortname);
-		else
-			printf("%-8.8s %-3.3s ",
-			       entry->dir.name, 
-			       entry->dir.ext);
-		if(IS_DIR(entry))
-			printf("<DIR>    ");
-		else
-			printf(" %8ld", (long) size);
-		printf(" ");
-		print_date(&entry->dir);
-		printf("  ");
-		print_time(&entry->dir);
-
-		if(debug)
-			printf(" %s %d ", entry->dir.name, START(&entry->dir));
-		
-		if(*longname)
-			printf(" %s", longname);
-		printf("\n");
-	} else {
-		printf("%s/%s", dirPath, entry->name);
-		if(IS_DIR(entry))
-			putchar('/');
-		putchar('\n');
-	}
-
-	filesOnDrive++;
-	filesInDir++;
-
-	bytesOnDrive += (mt_size_t) size;
-	bytesInDir += (mt_size_t) size;
-	return GOT_ONE;
-}
-
-static int list_non_recurs_directory(direntry_t *entry, MainParam_t *mp)
-{
-	int r;
-	/* list top-level directory
-	 *   If this was matched by wildcard in the basename, list it as
-	 *   file, otherwise, list it as directory */
-	if (mp->basenameHasWildcard) {
-		/* wildcard, list it as file */
-		return list_file(entry, mp);
-	} else {
-		/* no wildcard, list it as directory */
-		MainParam_t subMp;
-
-		r=enterDirectory(mp->File);
-		if(r)
-			return ERROR_ONE;
-
-		subMp = *mp;
-		subMp.dirCallback = subMp.callback;
-		return mp->loop(mp->File, &subMp, "*") | GOT_ONE;
-	}
-}
-
-
-static int list_recurs_directory(direntry_t *entry, MainParam_t *mp)
-{
-	MainParam_t subMp;
-	int ret;
-
-	/* first list the files */
-	subMp = *mp;
-	subMp.lookupflags = ACCEPT_DIR | ACCEPT_PLAIN;
-	subMp.dirCallback = list_file;
-	subMp.callback = list_file;
-
-	ret = mp->loop(mp->File, &subMp, "*");
-
-	/* then list subdirectories */
-	subMp = *mp;
-	subMp.lookupflags = ACCEPT_DIR | NO_DOTS | NO_MSG | DO_OPEN;
-	return ret | mp->loop(mp->File, &subMp, "*");
-}
-
-#if 0
-static int test_directory(direntry_t *entry, MainParam_t *mp)
-{
-	Stream_t *File=mp->File;
-	Stream_t *Target;
-	char errmsg[80];
-
-	if ((Target = SimpleFileOpen(0, 0, "-",
-				     O_WRONLY,
-				     errmsg, 0, 0, 0))) {
-		copyfile(File, Target);
-		FREE(&Target);
-	}
-	return GOT_ONE;
-}
-#endif
-
-static void usage(void)
-{
-		fprintf(stderr, "Mtools version %s, dated %s\n",
-			mversion, mdate);
-		fprintf(stderr, "Usage: %s: [-waXbfds/] msdosdirectory\n",
-			progname);
-		fprintf(stderr,
-			"       %s: [-waXbfds/] msdosfile [msdosfiles...]\n",
-			progname);
-		fprintf(stderr,
-			"\t-w Wide listing\n"
-			"\t-a All, including hidden files\n"
-			"\t-b -X Concise listing\n"
-			"\t-f Fast, no free space summary\n"
-			"\t-d Debug mode\n"
-			"\t-s -/ Recursive\n");
-		exit(1);
-}
-
-
-void mdir(int argc, char **argv, int type)
-{
-	int ret;
-	MainParam_t mp;
-	int faked;
-	int c;
-	char *fakedArgv[] = { "." };
-	
-	concise = 0;
-	recursive = 0;
-	wide = all = 0;
-					/* first argument */
-	while ((c = getopt(argc, argv, "waXbfds/")) != EOF) {
-		switch(c) {
-			case 'w':
-				wide = 1;
-				break;
-			case 'a':
-				all = 1;
-				break;
-			case 'b':
-			case 'X':
-				concise = 1;
-				/*recursive = 1;*/
-				break;
-			case 's':
-			case '/':
-				recursive = 1;
-				break;
-			case 'f':
-				fast = 1;
-				break;
-			case 'd':
-				debug = 1;
-				break;
-#if 0
-			case 't': /* test mode */
-				testmode = 1;
-				break;
-#endif
-			default:
-				usage();
-		}
-	}
-
-	/* fake an argument */
-	faked = 0;
-	if (optind == argc) {
-		argv = fakedArgv;
-		argc = 1;
-		optind = 0;
-	}
-
-	init_mp(&mp);
-	currentDrive = '\0';
-	currentDir = 0;
-	RootDir = 0;
-	dirPath = 0;
-#if 0
-	if (testmode) {
-		mp.lookupflags = ACCEPT_DIR | NO_DOTS;
-		mp.dirCallback = test_directory;
-	} else 
-#endif
-		if(recursive) {
-		mp.lookupflags = ACCEPT_DIR | DO_OPEN_DIRS | NO_DOTS;
-		mp.dirCallback = list_recurs_directory;
-	} else {
-		mp.lookupflags = ACCEPT_DIR | ACCEPT_PLAIN | DO_OPEN_DIRS;
-		mp.dirCallback = list_non_recurs_directory;
-		mp.callback = list_file;
-	}
-	mp.longname = longname;
-	mp.shortname = shortname;
-	ret=main_loop(&mp, argv + optind, argc - optind);
-	leaveDirectory(ret);
-	leaveDrive(ret);
-	exit(ret);
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/mdoctorfat.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mdoctorfat.c	(revision 9)
+++ 	(revision )
@@ -1,166 +1,0 @@
-/* Test program for doctoring the fat */
-
-
-/*
- * mcopy.c
- * Copy an MSDOS files to and from Unix
- *
- */
-
-
-#define LOWERCASE
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "vfat.h"
-#include "mainloop.h"
-#include "plain_io.h"
-#include "nameclash.h"
-#include "file.h"
-#include "fs.h"
-#include "fsP.h"
-
-typedef struct Arg_t {
-	char *target;
-	MainParam_t mp;
-	ClashHandling_t ch;
-	Stream_t *sourcefile;
-	unsigned long fat;
-	int markbad;
-	int setsize;
-	unsigned long size;
-	Fs_t *Fs;
-} Arg_t;
-
-static int dos_doctorfat(direntry_t *entry, MainParam_t *mp)
-{
-	Fs_t *Fs = getFs(mp->File);
-	Arg_t *arg=(Arg_t *) mp->arg;
-	
-	if(!arg->markbad && entry->entry != -3) {
-		/* if not root directory, change it */
-		set_word(entry->dir.start, arg->fat & 0xffff);
-		set_word(entry->dir.startHi, arg->fat >> 16);
-		if(arg->setsize)
-			set_dword(entry->dir.size, arg->size);
-		dir_write(entry);		
-	}
-	arg->Fs = Fs; 
-	return GOT_ONE;
-}
-
-static int unix_doctorfat(MainParam_t *mp)
-{
-	fprintf(stderr,"File does not reside on a Dos fs\n");
-	return ERROR_ONE;
-}
-
-
-static void usage(void)
-{
-	fprintf(stderr,
-		"Mtools version %s, dated %s\n", mversion, mdate);
-	fprintf(stderr,
-		"Usage: %s [-b] [-o offset] [-s size] file fat\n", progname);
-	exit(1);
-}
-
-void mdoctorfat(int argc, char **argv, int mtype)
-{
-	Arg_t arg;
-	int c, ret;
-	long address, begin, end;
-	char *number, *eptr;
-	int i, j;
-	long offset;
-	
-	/* get command line options */
-
-	init_clash_handling(& arg.ch);
-
-	offset = 0;
-
-	arg.markbad = 0;
-	arg.setsize = 0;
-
-	/* get command line options */
-	while ((c = getopt(argc, argv, "bo:s:")) != EOF) {
-		switch (c) {
-			case 'b':
-				arg.markbad = 1;
-				break;
-			case 'o':
-				offset = strtoul(optarg,0,0);
-				break;
-			case 's':
-				arg.setsize=1;
-				arg.size = strtoul(optarg,0,0);
-				break;
-			case '?':
-				usage();
-				break;
-		}
-	}
-
-	if (argc - optind < 2)
-		usage();
-
-
-	/* only 1 file to copy... */
-	init_mp(&arg.mp);
-	arg.mp.arg = (void *) &arg;
-		
-	arg.mp.callback = dos_doctorfat;
-	arg.mp.unixcallback = unix_doctorfat;
-	
-	arg.mp.lookupflags = ACCEPT_PLAIN | ACCEPT_DIR | DO_OPEN;
-	arg.mp.openflags = O_RDWR;
-	arg.fat = strtoul(argv[optind+1], 0, 0) + offset;
-	ret=main_loop(&arg.mp, argv + optind, 1);
-	if(ret)
-		exit(ret);
-	address = 0;
-	for(i=optind+1; i < argc; i++) {
-		number = argv[i];
-		if (*number == '<') {
-			number++;
-		}
-		begin = strtoul(number, &eptr, 0);
-		if (eptr && *eptr == '-') {
-			number = eptr+1;
-			end = strtoul(number, &eptr, 0);
-		} else {
-			end = begin;
-		}
-		if (eptr == number) {
-			fprintf(stderr, "Not a number: %s\n", number);
-			exit(-1);
-		}
-
-		if (eptr && *eptr == '>') {
-			eptr++;
-		}
-		if (eptr && *eptr) {
-			fprintf(stderr, "Not a number: %s\n", eptr);
-			exit(-1);
-		}
-
-		for (j=begin; j <= end; j++) {
-			if(arg.markbad) {
-				arg.Fs->fat_encode(arg.Fs, j+offset, arg.Fs->last_fat ^ 6 ^ 8);
-			} else {
-				if(address) {
-					arg.Fs->fat_encode(arg.Fs, address, j+offset);
-				}
-				address = j+offset;
-			}
-		}
-	}
-
-	if (address && !arg.markbad) {
-		arg.Fs->fat_encode(arg.Fs, address, arg.Fs->end_fat);
-	}
-
-	exit(ret);
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/mdu.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mdu.c	(revision 9)
+++ 	(revision )
@@ -1,121 +1,0 @@
-/*
- * mdu.c:
- * Display the space occupied by an MSDOS directory
- */
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "vfat.h"
-#include "mtools.h"
-#include "file.h"
-#include "mainloop.h"
-#include "fs.h"
-#include "codepage.h"
-
-
-typedef struct Arg_t {
-	int all;
-	int inDir;
-	int summary;
-	struct Arg_t *parent;
-	char *target;
-	char *path;
-	unsigned int blocks;
-	MainParam_t mp;
-} Arg_t;
-
-static void usage(void)
-{
-		fprintf(stderr, "Mtools version %s, dated %s\n",
-			mversion, mdate);
-		fprintf(stderr, "Usage: %s [-as] msdosdirectory\n"
-			"\t-a All (also show individual files)\n"
-			"\t-s Summary for directory only\n",
-			progname);
-		exit(1);
-}
-
-static int file_mdu(direntry_t *entry, MainParam_t *mp)
-{
-	unsigned int blocks;
-	Arg_t * arg = (Arg_t *) (mp->arg);
-
-	blocks = countBlocks(entry->Dir,getStart(entry->Dir, &entry->dir));
-	if(arg->all || !arg->inDir) {
-		printf("%-7d ", blocks);
-		fprintPwd(stdout, entry,0);
-		fputc('\n', stdout);
-	}
-	arg->blocks += blocks;
-	return GOT_ONE;
-}
-
-
-static int dir_mdu(direntry_t *entry, MainParam_t *mp)
-{
-	Arg_t *parentArg = (Arg_t *) (mp->arg);
-	Arg_t arg;
-	int ret;
-	
-	arg = *parentArg;
-	arg.mp.arg = (void *) &arg;
-	arg.parent = parentArg;
-	arg.inDir = 1;
-
-	/* account for the space occupied by the directory itself */
-	if(!isRootDir(entry->Dir)) {
-		arg.blocks = countBlocks(entry->Dir,
-					 getStart(entry->Dir, &entry->dir));
-	} else {
-		arg.blocks = 0;
-	}
-
-	/* recursion */
-	ret = mp->loop(mp->File, &arg.mp, "*");
-	if(!arg.summary || !parentArg->inDir) {
-		printf("%-7d ", arg.blocks);
-		fprintPwd(stdout, entry,0);
-		fputc('\n', stdout);
-	}
-	arg.parent->blocks += arg.blocks;
-	return ret;
-}
-
-void mdu(int argc, char **argv, int type)
-{
-	Arg_t arg;
-	int c;
-
-	arg.all = 0;
-	arg.inDir = 0;
-	arg.summary = 0;
-	while ((c = getopt(argc, argv, "as")) != EOF) {
-		switch (c) {
-			case 'a':
-				arg.all = 1;
-				break;
-			case 's':
-				arg.summary = 1;
-				break;
-			case '?':
-				usage();
-		}
-	}
-
-	if (optind >= argc)
-		usage();
-
-	if(arg.summary && arg.all) {
-		fprintf(stderr,"-a and -s options are mutually exclusive\n");
-		usage();
-	}
-
-	init_mp(&arg.mp);
-	arg.mp.callback = file_mdu;
-	arg.mp.openflags = O_RDONLY;
-	arg.mp.dirCallback = dir_mdu;
-
-	arg.mp.arg = (void *) &arg;
-	arg.mp.lookupflags = ACCEPT_PLAIN | ACCEPT_DIR | DO_OPEN_DIRS | NO_DOTS;
-	exit(main_loop(&arg.mp, argv + optind, argc - optind));
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/mformat.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mformat.c	(revision 9)
+++ 	(revision )
@@ -1,1140 +1,0 @@
-/*
- * mformat.c
- */
-
-#define DONT_NEED_WAIT
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "mainloop.h"
-#include "fsP.h"
-#include "file.h"
-#include "plain_io.h"
-#include "floppyd_io.h"
-#include "nameclash.h"
-#include "buffer.h"
-#ifdef USE_XDF
-#include "xdf_io.h"
-#endif
-#include "partition.h"
-
-#ifndef abs
-#define abs(x) ((x)>0?(x):-(x))
-#endif
-
-#ifdef OS_linux
-#include "linux/hdreg.h"
-
-#define _LINUX_STRING_H_
-#define kdev_t int
-#include "linux/fs.h"
-#undef _LINUX_STRING_H_
-
-#endif
-
-
-extern int errno;
-
-static int init_geometry_boot(struct bootsector *boot, struct device *dev,
-			       int sectors0, int rate_0, int rate_any,
-			       int *tot_sectors, int keepBoot)
-{
-	int i;
-	int nb_renum;
-	int sector2;
-	int size2;
-	int j;
-	int sum;
-
-	set_word(boot->nsect, dev->sectors);
-	set_word(boot->nheads, dev->heads);
-
-	*tot_sectors = dev->heads * dev->sectors * dev->tracks - DWORD(nhs);
-
-	if (*tot_sectors < 0x10000){
-		set_word(boot->psect, *tot_sectors);
-		set_dword(boot->bigsect, 0);
-	} else {
-		set_word(boot->psect, 0);
-		set_dword(boot->bigsect, *tot_sectors);
-	}
-
-	if (dev->use_2m & 0x7f){
-		int bootOffset;
-		strncpy(boot->banner, "2M-STV04", 8);
-		boot->ext.old.res_2m = 0;
-		boot->ext.old.fmt_2mf = 6;
-		if ( dev->sectors % ( ((1 << dev->ssize) + 3) >> 2 ))
-			boot->ext.old.wt = 1;
-		else
-			boot->ext.old.wt = 0;
-		boot->ext.old.rate_0= rate_0;
-		boot->ext.old.rate_any= rate_any;
-		if (boot->ext.old.rate_any== 2 )
-			boot->ext.old.rate_any= 1;
-		i=76;
-
-		/* Infp0 */
-		set_word(boot->ext.old.Infp0, i);
-		boot->jump[i++] = sectors0;
-		boot->jump[i++] = 108;
-		for(j=1; j<= sectors0; j++)
-			boot->jump[i++] = j;
-
-		set_word(boot->ext.old.InfpX, i);
-		
-		boot->jump[i++] = 64;
-		boot->jump[i++] = 3;
-		nb_renum = i++;
-		sector2 = dev->sectors;
-		size2 = dev->ssize;
-		j=1;
-		while( sector2 ){
-			while ( sector2 < (1 << size2) >> 2 )
-				size2--;
-			boot->jump[i++] = 128 + j;
-			boot->jump[i++] = j++;
-			boot->jump[i++] = size2;
-			sector2 -= (1 << size2) >> 2;
-		}
-		boot->jump[nb_renum] = ( i - nb_renum - 1 ) / 3;
-
-		set_word(boot->ext.old.InfTm, i);
-
-		sector2 = dev->sectors;
-		size2= dev->ssize;
-		while(sector2){
-			while ( sector2 < 1 << ( size2 - 2) )
-				size2--;
-			boot->jump[i++] = size2;
-			sector2 -= 1 << (size2 - 2 );
-		}
-		
-		set_word(boot->ext.old.BootP,i);
-		bootOffset = i;
-
-		/* checksum */		
-		for (sum=0, j=64; j<i; j++) 
-			sum += boot->jump[j];/* checksum */
-		boot->ext.old.CheckSum=-sum;
-		return bootOffset;
-	} else {
-		if(!keepBoot) {
-			boot->jump[0] = 0xeb;
-			boot->jump[1] = 0;
-			boot->jump[2] = 0x90;
-			strncpy(boot->banner, "MTOOL397", 8);
-			/* It looks like some versions of DOS are
-			 * rather picky about this, and assume default
-			 * parameters without this, ignoring any
-			 * indication about cluster size et al. */
-		}
-		return 0;
-	}
-}
-
-
-static int comp_fat_bits(Fs_t *Fs, int estimate, 
-			 unsigned int tot_sectors, int fat32)
-{
-	int needed_fat_bits;
-
-	needed_fat_bits = 12;
-
-#define MAX_DISK_SIZE(bits,clusters) \
-	TOTAL_DISK_SIZE((bits), Fs->sector_size, (clusters), \
-			Fs->num_fat, MAX_SECT_PER_CLUSTER)
-
-	if(tot_sectors > MAX_DISK_SIZE(12, FAT12))
-		needed_fat_bits = 16;
-	if(fat32 || tot_sectors > MAX_DISK_SIZE(16, FAT16))
-		needed_fat_bits = 32;
-
-#undef MAX_DISK_SIZE
-
-	if(abs(estimate) && abs(estimate) < needed_fat_bits) {
-		if(fat32) {
-			fprintf(stderr,
-				"Contradiction between FAT size on command line and FAT size in conf file\n");
-			exit(1);
-		}
-		fprintf(stderr,
-			"Device too big for a %d bit FAT\n",
-			estimate);
-		exit(1);
-	}
-
-	if(needed_fat_bits == 32 && !fat32 && abs(estimate) !=32){
-		fprintf(stderr,"Warning: Using 32 bit FAT.  Drive will only be accessibly by Win95 OEM / Win98\n");
-	}
-
-	if(!estimate) {
-		int min_fat16_size;
-
-		if(needed_fat_bits > 12)
-			return needed_fat_bits;
-		min_fat16_size = DISK_SIZE(16, Fs->sector_size, FAT12+1,
-					   Fs->num_fat, 1);
-		if(tot_sectors < min_fat16_size)
-			return 12;
-		else if(tot_sectors >= 2* min_fat16_size)
-			return 16; /* heuristics */
-	}
-
-	return estimate;
-}
-
-static void calc_fat_bits2(Fs_t *Fs, unsigned int tot_sectors, int fat_bits)
-{
-	unsigned int rem_sect;
-
-	/*
-	 * the "remaining sectors" after directory and boot
-	 * hasve been accounted for.
-	 */
-	rem_sect = tot_sectors - Fs->dir_len - Fs->fat_start;
-	switch(abs(fat_bits)) {
-		case 0:
-
-#define MY_DISK_SIZE(bits,clusters) \
-			DISK_SIZE( (bits), Fs->sector_size, (clusters), \
-				   Fs->num_fat, Fs->cluster_size)
-
-			if(rem_sect >= MY_DISK_SIZE(16, FAT12 + 1))
-				/* big enough for FAT16 */
-				set_fat16(Fs);
-			else if(rem_sect <= MY_DISK_SIZE(12, FAT12))
-				 /* small enough for FAT12 */
-				 set_fat12(Fs);
-			else {
-				/* "between two chairs",
-				 * augment cluster size, and
-				 * settle it */
-				if(Fs->cluster_size < MAX_SECT_PER_CLUSTER)
-					Fs->cluster_size <<= 1;
-				set_fat12(Fs);
-			}
-			break;
-#undef MY_DISK_SIZE
-
-		case 12:
-			set_fat12(Fs);
-			break;
-		case 16:
-			set_fat16(Fs);
-			break;
-		case 32:
-			set_fat32(Fs);
-			break;
-	}
-}
-
-static inline void format_root(Fs_t *Fs, char *label, struct bootsector *boot)
-{
-	Stream_t *RootDir;
-	char *buf;
-	int i;
-	struct ClashHandling_t ch;
-	int dirlen;
-
-	init_clash_handling(&ch);
-	ch.name_converter = label_name;
-	ch.ignore_entry = -2;
-
-	buf = safe_malloc(Fs->sector_size);
-	RootDir = OpenRoot((Stream_t *)Fs);
-	if(!RootDir){
-		fprintf(stderr,"Could not open root directory\n");
-		exit(1);
-	}
-
-	memset(buf, '\0', Fs->sector_size);
-
-	if(Fs->fat_bits == 32) {
-		/* on a FAT32 system, we only write one sector,
-		 * as the directory can be extended at will...*/
-		dirlen = 1;
-		fatAllocate(Fs, Fs->rootCluster, Fs->end_fat);
-	} else
-		dirlen = Fs->dir_len; 
-	for (i = 0; i < dirlen; i++)
-		WRITES(RootDir, buf, sectorsToBytes((Stream_t*)Fs, i),  
-			   Fs->sector_size);
-
-	ch.ignore_entry = 1;
-	if(label[0])
-		mwrite_one(RootDir,label, 0, labelit, NULL,&ch);
-
-	FREE(&RootDir);
-	if(Fs->fat_bits == 32)
-		set_word(boot->dirents, 0);
-	else
-		set_word(boot->dirents, Fs->dir_len * (Fs->sector_size / 32));
-	free(buf);
-}
-
-
-static void xdf_calc_fat_size(Fs_t *Fs, unsigned int tot_sectors, int fat_bits)
-{
-	unsigned int rem_sect;
-
-	rem_sect = tot_sectors - Fs->dir_len - Fs->fat_start - 2 * Fs->fat_len;
-
-	if(Fs->fat_len) {
-		/* an XDF disk, we know the fat_size and have to find
-		 * out the rest. We start with a cluster size of 1 and
-		 * keep doubling until everything fits into the
-		 * FAT. This will occur eventually, as our FAT has a
-		 * minimal size of 1 */
-		for(Fs->cluster_size = 1; 1 ; Fs->cluster_size <<= 1) {
-			Fs->num_clus = rem_sect / Fs->cluster_size;
-			if(abs(fat_bits) == 16 || Fs->num_clus > FAT12)
-				set_fat16(Fs);
-			else
-				set_fat12(Fs);
-			if (Fs->fat_len >= NEEDED_FAT_SIZE(Fs))
-				return;
-		}
-	}
-	fprintf(stderr,"Internal error while calculating Xdf fat size\n");
-	exit(1);
-}
-
-
-static void calc_fat_size(Fs_t *Fs, unsigned int tot_sectors)
-{
-	unsigned int rem_sect;
-	int tries;
-	int occupied;
-	
-	tries=0;
-	/* rough estimate of fat size */
-	Fs->fat_len = 1;
-	rem_sect = tot_sectors - Fs->dir_len - Fs->fat_start;
-	while(1){
-		Fs->num_clus = (rem_sect - 2 * Fs->fat_len ) /Fs->cluster_size;
-		Fs->fat_len = NEEDED_FAT_SIZE(Fs);
-		occupied = 2 * Fs->fat_len + Fs->cluster_size * Fs->num_clus;
-		
-		/* if we have used up more than we have,
-		 * we'll have to reloop */
-		
-		if ( occupied > rem_sect )
-			continue;
-
-
-		/* if we have exactly used up all
-		 * sectors, fine */
-		if ( rem_sect - occupied < Fs->cluster_size )
-			break;
-
-		/* if we have not used up all our
-		 * sectors, try again.  After the second
-		 * try, decrease the amount of available
-		 * space. This is to deal with the case of
-		 * 344 or 345, ..., 1705, ... available
-		 * sectors.  */
-		
-		switch(tries++){
-			default:
-				/* this should never happen */
-				fprintf(stderr,
-					"Internal error in cluster/fat repartition"
-					" calculation.\n");
-				exit(1);
-			case 2:
-				/* FALLTHROUGH */
-			case 1:
-				rem_sect-= Fs->cluster_size;
-				Fs->dir_len += Fs->cluster_size;
-			case 0:
-				continue;
-		}
-	}
-
-	if ( Fs->num_clus > FAT12 && Fs->fat_bits == 12 ){
-		fprintf(stderr,"Too many clusters for this fat size."
-			" Please choose a 16-bit fat in your /etc/mtools"
-			" or .mtoolsrc file\n");
-		exit(1);
-	}
-	if ( Fs->num_clus <= FAT12 && Fs->fat_bits > 12 ){
-		fprintf(stderr,"Too few clusters for this fat size."
-			" Please choose a 12-bit fat in your /etc/mtools"
-			" or .mtoolsrc file\n");
-		exit(1);
-	}
-}
-
-
-static unsigned char bootprog[]=
-{0xfa, 0x31, 0xc0, 0x8e, 0xd8, 0x8e, 0xc0, 0xfc, 0xb9, 0x00, 0x01,
- 0xbe, 0x00, 0x7c, 0xbf, 0x00, 0x80, 0xf3, 0xa5, 0xea, 0x00, 0x00,
- 0x00, 0x08, 0xb8, 0x01, 0x02, 0xbb, 0x00, 0x7c, 0xba, 0x80, 0x00,
- 0xb9, 0x01, 0x00, 0xcd, 0x13, 0x72, 0x05, 0xea, 0x00, 0x7c, 0x00,
- 0x00, 0xcd, 0x19};
-
-static inline void inst_boot_prg(struct bootsector *boot, int offset)
-{
-	memcpy((char *) boot->jump + offset, 
-	       (char *) bootprog, sizeof(bootprog) /sizeof(bootprog[0]));
-	boot->jump[0] = 0xeb;
-	boot->jump[1] = offset - 1;
-	boot->jump[2] = 0x90;
-	set_word(boot->jump + offset + 20, offset + 24);
-}
-
-static void calc_cluster_size(struct Fs_t *Fs, unsigned int tot_sectors,
-			      int fat_bits)
-			      
-{
-	unsigned int max_clusters; /* maximal possible number of sectors for
-				   * this FAT entry length (12/16/32) */
-	unsigned int max_fat_size; /* maximal size of the FAT for this FAT
-				    * entry length (12/16/32) */
-	unsigned int rem_sect; /* remaining sectors after we accounted for
-				* the root directory and boot sector(s) */
-
-	switch(abs(fat_bits)) {
-		case 12:			
-			max_clusters = FAT12;
-			max_fat_size = Fs->num_fat * 
-				FAT_SIZE(12, Fs->sector_size, max_clusters);
-			break;
-		case 16:
-		case 0: /* still hesititating between 12 and 16 */
-			max_clusters = FAT16;
-			max_fat_size = Fs->num_fat * 
-				FAT_SIZE(16, Fs->sector_size, max_clusters);
-			break;
-		case 32:		  
-			Fs->cluster_size = 8;
-			/* According to
-			 * http://www.microsoft.com/kb/articles/q154/9/97.htm,
-			 * Micro$oft does not support FAT32 with less than 4K
-			 */
-			return;
-		default:
-			fprintf(stderr,"Bad fat size\n");
-			exit(1);
-	}
-
-	rem_sect = tot_sectors - Fs->dir_len - Fs->fat_start;
-
-	/* double the cluster size until we can fill up the disk with
-	 * the maximal number of sectors of this size */
-	while(Fs->cluster_size * max_clusters  + max_fat_size < rem_sect) {
-		if(Fs->cluster_size > 64) {
-			/* bigger than 64. Should fit */
-			fprintf(stderr,
-				"Internal error while calculating cluster size\n");
-			exit(1);
-		}
-		Fs->cluster_size <<= 1;
-	}
-}
-
-
-struct OldDos_t old_dos[]={
-{   40,  9,  1, 4, 1, 2, 0xfc },
-{   40,  9,  2, 7, 2, 2, 0xfd },
-{   40,  8,  1, 4, 1, 1, 0xfe },
-{   40,  8,  2, 7, 2, 1, 0xff },
-{   80,  9,  2, 7, 2, 3, 0xf9 },
-{   80, 15,  2,14, 1, 7, 0xf9 },
-{   80, 18,  2,14, 1, 9, 0xf0 },
-{   80, 36,  2,15, 2, 9, 0xf0 },
-{    1,  8,  1, 1, 1, 1, 0xf0 },
-};
-
-static int old_dos_size_to_geom(int size, int *cyls, int *heads, int *sects)
-{
-	int i;
-	size = size * 2;
-	for(i=0; i < sizeof(old_dos) / sizeof(old_dos[0]); i++){
-		if (old_dos[i].sectors * 
-		    old_dos[i].tracks * 
-		    old_dos[i].heads == size) {
-			*cyls = old_dos[i].tracks;
-			*heads = old_dos[i].heads;
-			*sects = old_dos[i].sectors;
-			return 0;
-		}
-	}
-	return 1;
-}
-
-
-static void calc_fs_parameters(struct device *dev, unsigned int tot_sectors,
-			       struct Fs_t *Fs, struct bootsector *boot)
-{
-	int i;
-
-	for(i=0; i < sizeof(old_dos) / sizeof(old_dos[0]); i++){
-		if (dev->sectors == old_dos[i].sectors &&
-		    dev->tracks == old_dos[i].tracks &&
-		    dev->heads == old_dos[i].heads &&
-		    (dev->fat_bits == 0 || abs(dev->fat_bits) == 12)){
-			boot->descr = old_dos[i].media;
-			Fs->cluster_size = old_dos[i].cluster_size;
-			Fs->dir_len = old_dos[i].dir_len;
-			Fs->fat_len = old_dos[i].fat_len;
-			Fs->fat_bits = 12;
-			break;
-		}
-	}
-	if (i == sizeof(old_dos) / sizeof(old_dos[0]) ){
-		/* a non-standard format */
-		if(DWORD(nhs))
-			boot->descr = 0xf8;
-		  else
-			boot->descr = 0xf0;
-
-
-		if(!Fs->cluster_size) {
-			if (dev->heads == 1)
-				Fs->cluster_size = 1;
-			else {
-				Fs->cluster_size = (tot_sectors > 2000 ) ? 1:2;
-				if (dev->use_2m & 0x7f)
-					Fs->cluster_size = 1;
-			}
-		}
-		
-		if(!Fs->dir_len) {
-			if (dev->heads == 1)
-				Fs->dir_len = 4;
-			else
-				Fs->dir_len = (tot_sectors > 2000) ? 11 : 7;
-		}			
-
-		calc_cluster_size(Fs, tot_sectors, dev->fat_bits);
-		if(Fs->fat_len)
-			xdf_calc_fat_size(Fs, tot_sectors, dev->fat_bits);
-		else {
-			calc_fat_bits2(Fs, tot_sectors, dev->fat_bits);
-			calc_fat_size(Fs, tot_sectors);
-		}
-	}
-
-	set_word(boot->fatlen, Fs->fat_len);
-}
-
-
-
-static void calc_fs_parameters_32(unsigned int tot_sectors,
-				  struct Fs_t *Fs, struct bootsector *boot)
-{
-	if(DWORD(nhs))
-		boot->descr = 0xf8;
-	else
-		boot->descr = 0xf0;
-	if(!Fs->cluster_size)
-		/* According to
-		 * http://www.microsoft.com/kb/articles/q154/9/97.htm,
-		 * Micro$oft does not support FAT32 with less than 4K
-		 */
-		Fs->cluster_size = 8;
-	
-	Fs->dir_len = 0;
-	Fs->num_clus = tot_sectors / Fs->cluster_size;
-	set_fat32(Fs);
-	calc_fat_size(Fs, tot_sectors);
-	set_word(boot->fatlen, 0);
-	set_dword(boot->ext.fat32.bigFat, Fs->fat_len);
-}
-
-
-
-
-static void usage(void)
-{
-	fprintf(stderr, 
-		"Mtools version %s, dated %s\n", mversion, mdate);
-	fprintf(stderr, 
-		"Usage: %s [-t tracks] [-h heads] [-n sectors] "
-		"[-v label] [-1] [-4] [-8] [-f size] "
-		"[-N serialnumber] "
-		"[-k] [-B bootsector] [-r root_dir_len] [-L fat_len] "
-		"[-F] [-I fsVersion] [-C] [-c cluster_size] "
-		"[-H hidden_sectors] "
-#ifdef USE_XDF
-		"[-X] "
-#endif
-		"[-S hardsectorsize] [-M softsectorsize] [-3] "
-		"[-2 track0sectors] [-0 rate0] [-A rateany] [-a]"
-		"device\n", progname);
-	exit(1);
-}
-
-void mformat(int argc, char **argv, int dummy)
-{
-	int r; /* generic return value */
-	Fs_t Fs;
-	int hs, hs_set;
-	int arguse_2m = 0;
-	int sectors0=18; /* number of sectors on track 0 */
-	int create = 0;
-	int rate_0, rate_any;
-	int mangled;
-	int argssize=0; /* sector size */
-	int msize=0;
-	int fat32 = 0;
-	struct label_blk_t *labelBlock;
-	int bootOffset;
-
-#ifdef USE_XDF
-	int i;
-	int format_xdf = 0;
-	struct xdf_info info;
-#endif
-	struct bootsector *boot;
-	char *bootSector=0;
-	int c;
-	int keepBoot = 0;
-	struct device used_dev;
-	int argtracks, argheads, argsectors;
-	int tot_sectors;
-	int blocksize;
-
-	char *drive, name[EXPAND_BUF];
-
-	char label[VBUFSIZE], buf[MAX_SECTOR], shortlabel[13];
-	struct device *dev;
-	char errmsg[200];
-
-	unsigned long serial;
- 	int serial_set;
-	int fsVersion;
-
-	mt_off_t maxSize;
-
-	int Atari = 0; /* should we add an Atari-style serial number ? */
-#ifdef OS_Minix
-	char *devname;
-	struct device onedevice[2];
-	struct stat stbuf;
-#endif
- 
-	hs = hs_set = 0;
-	argtracks = 0;
-	argheads = 0;
-	argsectors = 0;
-	arguse_2m = 0;
-	argssize = 0x2;
-	label[0] = '\0';
-	serial_set = 0;
-	serial = 0;
-	fsVersion = 0;
-	
-	Fs.cluster_size = 0;
-	Fs.refs = 1;
-	Fs.dir_len = 0;
-	Fs.fat_len = 0;
-	Fs.Class = &FsClass;	
-	rate_0 = mtools_rate_0;
-	rate_any = mtools_rate_any;
-
-	/* get command line options */
-	while ((c = getopt(argc,argv,
-			   "148f:t:n:v:qub"
-			   "kB:r:L:IFCc:Xh:s:l:N:H:M:S:230:Aa"))!= EOF) {
-		switch (c) {
-			/* standard DOS flags */
-			case '1':
-				argheads = 1;
-				break;
-			case '4':
-				argsectors = 9;
-				argtracks = 40;
-				break;
-			case '8':
-				argsectors = 8;
-				argtracks = 40;
-				break;
-			case 'f':
-				r=old_dos_size_to_geom(atoi(optarg),
-						       &argtracks, &argheads,
-						       &argsectors);
-				if(r) {
-					fprintf(stderr, 
-						"Bad size %s\n", optarg);
-					exit(1);
-				}
-				break;
-			case 't':
-				argtracks = atoi(optarg);
-				break;
-
-			case 'n': /*non-standard*/
-			case 's':
-				argsectors = atoi(optarg);
-				break;
-
-			case 'l': /* non-standard */
-			case 'v':
-				strncpy(label, optarg, VBUFSIZE-1);
-				label[VBUFSIZE-1] = '\0';
-				break;
-
-			/* flags supported by Dos but not mtools */
-			case 'q':
-			case 'u':
-			case 'b':
-			/*case 's': leave this for compatibility */
-				fprintf(stderr, 
-					"Flag %c not supported by mtools\n",c);
-				exit(1);
-				
-
-
-			/* flags added by mtools */
-			case 'F':
-				fat32 = 1;
-				break;
-
-
-			case 'S':
-				argssize = atoi(optarg) | 0x80;
-				if(argssize < 0x81)
-					usage();
-				break;
-
-#ifdef USE_XDF
-			case 'X':
-				format_xdf = 1;
-				break;
-#endif
-
-			case '2':
-				arguse_2m = 0xff;
-				sectors0 = atoi(optarg);
-				break;
-			case '3':
-				arguse_2m = 0x80;
-				break;
-
-			case '0': /* rate on track 0 */
-				rate_0 = atoi(optarg);
-				break;
-			case 'A': /* rate on other tracks */
-				rate_any = atoi(optarg);
-				break;
-
-			case 'M':
-				msize = atoi(optarg);
-				if (msize % 256 || msize > 8192 )
-					usage();
-				break;
-
-			case 'N':
- 				serial = strtoul(optarg,0,16);
- 				serial_set = 1;
- 				break;
-			case 'a': /* Atari style serial number */
-				Atari = 1;
-				break;
-
-			case 'C':
-				create = O_CREAT;
-				break;
-
-			case 'H':
-				hs = atoi(optarg);
-				hs_set = 1;
-				break;
-
-			case 'I':
-				fsVersion = strtoul(optarg,0,0);
-				break;
-
-			case 'c':
-				Fs.cluster_size = atoi(optarg);
-				break;
-
-			case 'r': 
-				Fs.dir_len = strtoul(optarg,0,0);
-				break;
-			case 'L':
-				Fs.fat_len = strtoul(optarg,0,0);
-				break;
-
-
-			case 'B':
-				bootSector = optarg;
-				break;
-			case 'k':
-				keepBoot = 1;
-				break;
-			case 'h':
-				argheads = atoi(optarg);
-				break;
-
-			default:
-				usage();
-		}
-	}
-
-	if (argc - optind != 1 ||
-	    skip_drive(argv[optind]) == argv[optind])
-		usage();
-
-#ifdef USE_XDF
-	if(create && format_xdf) {
-		fprintf(stderr,"Create and XDF can't be used together\n");
-		exit(1);
-	}
-#endif
-	
-	drive = get_drive(argv[argc -1], NULL);
-
-#ifdef OS_Minix
-	devname = safe_malloc((9 + strlen(drive)) * sizeof(devname[0]));
-	strcpy(devname, "/dev/dosX");
-	if (isupper(drive[0]) && drive[1] == 0) {
-		/* single letter device name, use /dev/dos$drive */
-		devname[8]= drive[0];
-	} else
-	if (strchr(drive, '/') == NULL) {
-		/* a simple name, use /dev/$drive */
-		strcpy(devname+5, drive);
-	} else {
-		/* a pathname, use as is. */
-		strcpy(devname, drive);
-	}
-	if (stat(devname, &stbuf) != -1) {
-		memset(onedevice, 0, sizeof(onedevice));
-		onedevice[0].name = devname;
-		onedevice[0].drive = drive;
-		onedevice[1].name = NULL;
-		onedevice[1].drive = NULL;
-		dev = onedevice;
-	} else {
-		dev = devices;
-	}
-#else
-	dev = devices;
-#endif
-
-	/* check out a drive whose letter and parameters match */	
-	sprintf(errmsg, "Drive '%s:' not supported", drive);	
-	Fs.Direct = NULL;
-	blocksize = 0;
-	for(;dev->drive;dev++) {
-		FREE(&(Fs.Direct));
-		/* drive name */
-		if (strcmp(dev->drive, drive) != 0)
-			continue;
-		used_dev = *dev;
-
-		SET_INT(used_dev.tracks, argtracks);
-		SET_INT(used_dev.heads, argheads);
-		SET_INT(used_dev.sectors, argsectors);
-		SET_INT(used_dev.use_2m, arguse_2m);
-		SET_INT(used_dev.ssize, argssize);
-		if(hs_set)
-			used_dev.hidden = hs;
-		
-		expand(dev->name, name);
-#ifdef USING_NEW_VOLD
-		strcpy(name, getVoldName(dev, name));
-#endif
-
-#ifdef USE_XDF
-		if(!format_xdf) {
-#endif
-			Fs.Direct = 0;
-#ifdef USE_FLOPPYD
-			Fs.Direct = FloppydOpen(&used_dev, dev, name, O_RDWR | create,
-									errmsg, 0, 1);
-			if(Fs.Direct) {
-				maxSize = max_off_t_31;
-			}
-#endif
-			if(!Fs.Direct) {			
-				Fs.Direct = SimpleFileOpen(&used_dev, dev, name,
-										   O_RDWR | create,
-										   errmsg, 0, 1, &maxSize);
-			}
-#ifdef USE_XDF
-		} else {
-			used_dev.misc_flags |= USE_XDF_FLAG;
-			Fs.Direct = XdfOpen(&used_dev, name, O_RDWR,
-					    errmsg, &info);
-			if(Fs.Direct && !Fs.fat_len)
-				Fs.fat_len = info.FatSize;
-			if(Fs.Direct && !Fs.dir_len)
-				Fs.dir_len = info.RootDirSize;
-		}
-#endif
-
-		if (!Fs.Direct)
-			continue;
-
-#ifdef OS_linux
-		if ((!used_dev.tracks || !used_dev.heads || !used_dev.sectors) &&
-			(!IS_SCSI(dev))) {
-			int fd= get_fd(Fs.Direct);
-			struct stat buf;
-
-			if (fstat(fd, &buf) < 0) {
-				sprintf(errmsg, "Could not stat file (%s)", strerror(errno));
-				continue;						
-			}
-
-			if (S_ISBLK(buf.st_mode)) {
-				struct hd_geometry geom;
-				long size;
-				int sect_per_track;
-
-				if (ioctl(fd, HDIO_GETGEO, &geom) < 0) {
-					sprintf(errmsg, "Could not get geometry of device (%s)",
-							strerror(errno));
-					continue;
-				}
-
-				if (ioctl(fd, BLKGETSIZE, &size) < 0) {
-					sprintf(errmsg, "Could not get size of device (%s)",
-							strerror(errno));
-					continue;
-				}
-
-				sect_per_track = geom.heads * geom.sectors;
-				used_dev.heads = geom.heads;
-				used_dev.sectors = geom.sectors;
-				used_dev.hidden = geom.start % sect_per_track;
-				used_dev.tracks = (size + used_dev.hidden) / sect_per_track;
-			}
-		}
-#endif
-
-		/* no way to find out geometry */
-		if (!used_dev.tracks || !used_dev.heads || !used_dev.sectors){
-			sprintf(errmsg, 
-				"Unknown geometry "
-				"(You must tell the complete geometry "
-				"of the disk, \neither in /etc/mtools.conf or "
-				"on the command line) ");
-			continue;
-		}
-
-#if 0
-		/* set parameters, if needed */
-		if(SET_GEOM(Fs.Direct, &used_dev, 0xf0, boot)){
-			sprintf(errmsg,"Can't set disk parameters: %s", 
-				strerror(errno));
-			continue;
-		}
-#endif
-		Fs.sector_size = 512;
-		if( !(used_dev.use_2m & 0x7f)) {
-			Fs.sector_size = 128 << (used_dev.ssize & 0x7f);
-		}
-
-		SET_INT(Fs.sector_size, msize);
-		{
-		    int i;
-		    for(i = 0; i < 31; i++) {
-			if (Fs.sector_size == 1 << i) {
-			    Fs.sectorShift = i;
-			    break;
-			}
-		    }
-		    Fs.sectorMask = Fs.sector_size - 1;
-		}
-
-		if(!used_dev.blocksize || used_dev.blocksize < Fs.sector_size)
-			blocksize = Fs.sector_size;
-		else
-			blocksize = used_dev.blocksize;
-		
-		if(blocksize > MAX_SECTOR)
-			blocksize = MAX_SECTOR;
-
-		/* do a "test" read */
-		if (!create &&
-		    READS(Fs.Direct, (char *) buf, 0, Fs.sector_size) != 
-		    Fs.sector_size) {
-			sprintf(errmsg, 
-				"Error reading from '%s', wrong parameters?",
-				name);
-			continue;
-		}
-		break;
-	}
-
-
-	/* print error msg if needed */	
-	if ( dev->drive == 0 ){
-		FREE(&Fs.Direct);
-		fprintf(stderr,"%s: %s\n", argv[0],errmsg);
-		exit(1);
-	}
-
-	/* the boot sector */
-	boot = (struct bootsector *) buf;
-	if(bootSector) {
-		int fd;
-
-		fd = open(bootSector, O_RDONLY);
-		if(fd < 0) {
-			perror("open boot sector");
-			exit(1);
-		}
-		read(fd, buf, blocksize);
-		keepBoot = 1;
-	}
-	if(!keepBoot) {
-		memset((char *)boot, '\0', Fs.sector_size);
-		if(Fs.sector_size == 512 && !used_dev.partition) {
-			/* install fake partition table pointing to itself */
-			struct partition *partTable=(struct partition *)
-				(((char*) boot) + 0x1ae);
-			setBeginEnd(&partTable[1], 0,
-						used_dev.heads * used_dev.sectors * used_dev.tracks,
-						used_dev.heads, used_dev.sectors, 1, 0);
-		}
-	}
-	set_dword(boot->nhs, used_dev.hidden);
-
-	Fs.Next = buf_init(Fs.Direct,
-			   blocksize * used_dev.heads * used_dev.sectors,
-			   blocksize * used_dev.heads * used_dev.sectors,
-			   blocksize);
-	Fs.Buffer = 0;
-
-	boot->nfat = Fs.num_fat = 2;
-	if(!keepBoot)
-		set_word(boot->jump + 510, 0xaa55);
-	
-	/* get the parameters */
-	tot_sectors = used_dev.tracks * used_dev.heads * used_dev.sectors - 
-		DWORD(nhs);
-
-	set_word(boot->nsect, dev->sectors);
-	set_word(boot->nheads, dev->heads);
-
-	dev->fat_bits = comp_fat_bits(&Fs,dev->fat_bits, tot_sectors, fat32);
-
-	if(dev->fat_bits == 32) {
-		Fs.primaryFat = 0;
-		Fs.writeAllFats = 1;
-		Fs.fat_start = 32;
-		calc_fs_parameters_32(tot_sectors, &Fs, boot);
-
-		Fs.clus_start = Fs.num_fat * Fs.fat_len + Fs.fat_start;
-
-		/* extension flags: mirror fats, and use #0 as primary */
-		set_word(boot->ext.fat32.extFlags,0);
-
-		/* fs version.  What should go here? */
-		set_word(boot->ext.fat32.fsVersion,fsVersion);
-
-		/* root directory */
-		set_dword(boot->ext.fat32.rootCluster, Fs.rootCluster = 2);
-
-		/* info sector */
-		set_word(boot->ext.fat32.infoSector, Fs.infoSectorLoc = 1);
-		Fs.infoSectorLoc = 1;
-
-		/* no backup boot sector */
-		set_word(boot->ext.fat32.backupBoot, 6);
-		
-		labelBlock = & boot->ext.fat32.labelBlock;
-	} else {
-		Fs.infoSectorLoc = 0;
-		Fs.fat_start = 1;
-		calc_fs_parameters(&used_dev, tot_sectors, &Fs, boot);
-		Fs.dir_start = Fs.num_fat * Fs.fat_len + Fs.fat_start;
-		Fs.clus_start = Fs.dir_start + Fs.dir_len;
-		labelBlock = & boot->ext.old.labelBlock;
-
-	}
-	
-	if (!keepBoot)
-		/* only zero out physdrive if we don't have a template
-		 * bootsector */
-		labelBlock->physdrive = 0x00;
-	labelBlock->reserved = 0;
-	labelBlock->dos4 = 0x29;
-
-	if (!serial_set || Atari)
-		srandom((long)time (0));
-	if (!serial_set)
-		serial=random();
-	set_dword(labelBlock->serial, serial);	
-	if(!label[0])
-		strncpy(shortlabel, "NO NAME    ",11);
-	else
-		label_name(label, 0, &mangled, shortlabel);
-	strncpy(labelBlock->label, shortlabel, 11);
-	sprintf(labelBlock->fat_type, "FAT%2.2d  ", Fs.fat_bits);
-	labelBlock->fat_type[7] = ' ';
-
-	set_word(boot->secsiz, Fs.sector_size);
-	boot->clsiz = (unsigned char) Fs.cluster_size;
-	set_word(boot->nrsvsect, Fs.fat_start);
-
-	bootOffset = init_geometry_boot(boot, &used_dev, sectors0, 
-					rate_0, rate_any,
-					&tot_sectors, keepBoot);
-	if(!bootOffset) {
-		bootOffset = ((char *) labelBlock) - ((char *) boot) +
-			sizeof(struct label_blk_t);
-	}
-	if(Atari) {
-		boot->banner[4] = 0;
-		boot->banner[5] = random();
-		boot->banner[6] = random();
-		boot->banner[7] = random();
-	}		
-
-	if (create) {
-		WRITES(Fs.Direct, (char *) buf,
-		       sectorsToBytes((Stream_t*)&Fs, tot_sectors-1),
-		       Fs.sector_size);
-	}
-
-	if(!keepBoot)
-		inst_boot_prg(boot, bootOffset);
-	if(dev->use_2m & 0x7f)
-		Fs.num_fat = 1;
-	Fs.lastFatSectorNr = 0;
-	Fs.lastFatSectorData = 0;
-	zero_fat(&Fs, boot->descr);
-	Fs.freeSpace = Fs.num_clus;
-	Fs.last = 2;
-
-#ifdef USE_XDF
-	if(format_xdf)
-		for(i=0; 
-		    i < (info.BadSectors+Fs.cluster_size-1)/Fs.cluster_size; 
-		    i++)
-			fatEncode(&Fs, i+2, 0xfff7);
-#endif
-
-	format_root(&Fs, label, boot);
-	WRITES((Stream_t *)&Fs, (char *) boot, (mt_off_t) 0, Fs.sector_size);
-	if(Fs.fat_bits == 32 && WORD(ext.fat32.backupBoot) != MAX32) {
-		WRITES((Stream_t *)&Fs, (char *) boot, 
-		       sectorsToBytes((Stream_t*)&Fs, WORD(ext.fat32.backupBoot)),
-		       Fs.sector_size);
-	}
-	FLUSH((Stream_t *)&Fs); /* flushes Fs. 
-				 * This triggers the writing of the FAT */
-	FREE(&Fs.Next);
-	Fs.Class->freeFunc((Stream_t *)&Fs);
-#ifdef USE_XDF
-	if(format_xdf && isatty(0) && !getenv("MTOOLS_USE_XDF"))
-		fprintf(stderr,
-			"Note:\n"
-			"Remember to set the \"MTOOLS_USE_XDF\" environmental\n"
-			"variable before accessing this disk\n\n"
-			"Bourne shell syntax (sh, ash, bash, ksh, zsh etc):\n"
-			" export MTOOLS_USE_XDF=1\n\n"
-			"C shell syntax (csh and tcsh):\n"
-			" setenv MTOOLS_USE_XDF 1\n" );	
-#endif
-	exit(0);
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/minfo.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/minfo.c	(revision 9)
+++ 	(revision )
@@ -1,172 +1,0 @@
-/*
- * mlabel.c
- * Make an MSDOS volume label
- */
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mainloop.h"
-#include "vfat.h"
-#include "mtools.h"
-#include "nameclash.h"
-
-static void usage(void)
-{
-	fprintf(stderr, 
-		"Mtools version %s, dated %s\n", mversion, mdate);
-	fprintf(stderr, 
-		"Usage: %s [-v] drive\n\t-v Verbose\n", progname);
-	exit(1);
-}
-
-
-static void displayInfosector(Stream_t *Stream, struct bootsector *boot)
-{
-	InfoSector_t *infosec;
-
-	if(WORD(ext.fat32.infoSector) == MAX32)
-		return;
-
-	infosec = (InfoSector_t *) safe_malloc(WORD(secsiz));
-	force_read(Stream, (char *) infosec, 
-			   (mt_off_t) WORD(secsiz) * WORD(ext.fat32.infoSector),
-			   WORD(secsiz));
-	printf("\nInfosector:\n");
-	printf("signature=0x%08x\n", _DWORD(infosec->signature1));
-	if(_DWORD(infosec->count) != MAX32)
-		printf("free clusters=%u\n", _DWORD(infosec->count));
-	if(_DWORD(infosec->pos) != MAX32)
-		printf("last allocated cluster=%u\n", _DWORD(infosec->pos));
-}
-
-
-void minfo(int argc, char **argv, int type)
-{
-	struct bootsector boot0;
-#define boot (&boot0)
-	char name[EXPAND_BUF];
-	int media;
-	int tot_sectors;
-	struct device dev;
-	char *drive;
-	int verbose=0;
-	int c;
-	Stream_t *Stream;
-	struct label_blk_t *labelBlock;
-	
-	while ((c = getopt(argc, argv, "v")) != EOF) {
-		switch (c) {
-			case 'v':
-				verbose = 1;
-				break;
-			default:
-				usage();
-		}
-	}
-
-	if(argc == optind)
-		usage();
-
-	for(;optind < argc; optind++) {
-		if(skip_drive(argv[optind]) == argv[optind])
-			usage();
-		drive = get_drive(argv[optind], NULL);
-
-		if(! (Stream = find_device(drive, O_RDONLY, &dev, boot, 
-					   name, &media, 0)))
-			exit(1);
-
-		tot_sectors = DWORD(bigsect);
-		SET_INT(tot_sectors, WORD(psect));
-		printf("device information:\n");
-		printf("===================\n");
-		printf("filename=\"%s\"\n", name);
-		printf("sectors per track: %d\n", dev.sectors);
-		printf("heads: %d\n", dev.heads);
-		printf("cylinders: %d\n\n", dev.tracks);
-		printf("mformat command line: mformat -t %d -h %d -s %d ",
-		       dev.tracks, dev.heads, dev.sectors);
-		if(DWORD(nhs))
-			printf("-H %d ", DWORD(nhs));
-		printf("%s:\n", drive);
-		printf("\n");
-		
-		printf("bootsector information\n");
-		printf("======================\n");
-		printf("banner:\"%8s\"\n", boot->banner);
-		printf("sector size: %d bytes\n", WORD(secsiz));
-		printf("cluster size: %d sectors\n", boot->clsiz);
-		printf("reserved (boot) sectors: %d\n", WORD(nrsvsect));
-		printf("fats: %d\n", boot->nfat);
-		printf("max available root directory slots: %d\n", 
-		       WORD(dirents));
-		printf("small size: %d sectors\n", WORD(psect));
-		printf("media descriptor byte: 0x%x\n", boot->descr);
-		printf("sectors per fat: %d\n", WORD(fatlen));
-		printf("sectors per track: %d\n", WORD(nsect));
-		printf("heads: %d\n", WORD(nheads));
-		printf("hidden sectors: %d\n", DWORD(nhs));
-		printf("big size: %d sectors\n", DWORD(bigsect));
-
-		if(WORD(fatlen)) {
-		    labelBlock = &boot->ext.old.labelBlock;
-		} else {
-		    labelBlock = &boot->ext.fat32.labelBlock;
-		}
-
-		printf("physical drive id: 0x%x\n", 
-		       labelBlock->physdrive);
-		printf("reserved=0x%x\n", 
-		       labelBlock->reserved);
-		printf("dos4=0x%x\n", 
-		       labelBlock->dos4);
-		printf("serial number: %08X\n", 
-		       _DWORD(labelBlock->serial));
-		printf("disk label=\"%11.11s\"\n", 
-		       labelBlock->label);
-		printf("disk type=\"%8.8s\"\n", 
-		       labelBlock->fat_type);
-
-		if(!WORD(fatlen)){
-			printf("Big fatlen=%u\n",
-			       DWORD(ext.fat32.bigFat));
-			printf("Extended flags=0x%04x\n",
-			       WORD(ext.fat32.extFlags));
-			printf("FS version=0x%04x\n",
-			       WORD(ext.fat32.fsVersion));
-			printf("rootCluster=%u\n",
-			       DWORD(ext.fat32.rootCluster));
-			if(WORD(ext.fat32.infoSector) != MAX32)
-				printf("infoSector location=%d\n",
-				       WORD(ext.fat32.infoSector));
-			if(WORD(ext.fat32.backupBoot) != MAX32)
-				printf("backup boot sector=%d\n",
-				       WORD(ext.fat32.backupBoot));
-			displayInfosector(Stream,boot);
-		}
-
-		if(verbose) {
-			int size;
-			unsigned char *buf;
-
-			printf("\n");
-			size = WORD(secsiz);
-			
-			buf = (unsigned char *) malloc(size);
-			if(!buf) {
-				fprintf(stderr, "Out of memory error\n");
-				exit(1);
-			}
-
-			size = READS(Stream, buf, (mt_off_t) 0, size);
-			if(size < 0) {
-				perror("read boot sector");
-				exit(1);
-			}
-
-			print_sector("Boot sector hexdump", buf, size);
-		}
-	}
-
-	exit(0);
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/misc.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/misc.c	(revision 9)
+++ 	(revision )
@@ -1,307 +1,0 @@
-/*
- * Miscellaneous routines.
- */
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "stream.h"
-#include "vfat.h"
-#include "mtools.h"
-
-
-void printOom(void)
-{
-	fprintf(stderr, "Out of memory error");
-}
-
-char *get_homedir(void)
-{
-	struct passwd *pw;
-	uid_t uid;
-	char *homedir;
-	char *username;
-	
-	homedir = getenv ("HOME");    
-	/* 
-	 * first we call getlogin. 
-	 * There might be several accounts sharing one uid 
-	 */
-	if ( homedir )
-		return homedir;
-	
-	pw = 0;
-	
-	username = getenv("LOGNAME");
-	if ( !username )
-		username = getlogin();
-	if ( username )
-		pw = getpwnam( username);
-  
-	if ( pw == 0 ){
-		/* if we can't getlogin, look up the pwent by uid */
-		uid = geteuid();
-		pw = getpwuid(uid);
-	}
-	
-	/* we might still get no entry */
-	if ( pw )
-		return pw->pw_dir;
-	return 0;
-}
-
-
-static void get_mcwd_file_name(char *file)
-{
-	char *mcwd_path;
-	char *homedir;
-
-	mcwd_path = getenv("MCWD");
-	if (mcwd_path == NULL || *mcwd_path == '\0'){
-		homedir= get_homedir();
-		if(!homedir)
-			homedir="/tmp";
-		strncpy(file, homedir, MAXPATHLEN-6);
-		file[MAXPATHLEN-6]='\0';
-		strcat( file, "/.mcwd");
-	} else {
-		strncpy(file, mcwd_path, MAXPATHLEN);
-		file[MAXPATHLEN]='\0';
-	}
-}
-
-void unlink_mcwd()
-{
-	char file[MAXPATHLEN+1];
-	get_mcwd_file_name(file);
-	unlink(file);
-}
-
-FILE *open_mcwd(const char *mode)
-{
-	struct stat sbuf;
-	char file[MAXPATHLEN+1];
-	time_t now;
-	
-	get_mcwd_file_name(file);
-	if (*mode == 'r'){
-		if (stat(file, &sbuf) < 0)
-			return NULL;
-		/*
-		 * Ignore the info, if the file is more than 6 hours old
-		 */
-		getTimeNow(&now);
-		if (now - sbuf.st_mtime > 6 * 60 * 60) {
-			fprintf(stderr,
-				"Warning: \"%s\" is out of date, removing it\n",
-				file);
-			unlink(file);
-			return NULL;
-		}
-	}
-	
-	return  fopen(file, mode);
-}
-	
-
-/* Fix the info in the MCWD file to be a proper directory name.
- * Always has a leading separator.  Never has a trailing separator
- * (unless it is the path itself).  */
-
-const char *fix_mcwd(char *ans)
-{
-	FILE *fp;
-	char *s;
-	char buf[MAX_PATH];
-
-	fp = open_mcwd("r");
-	if(!fp){
-		strcpy(ans, "A:/");
-		return ans;
-	}
-
-	if (!fgets(buf, MAX_PATH, fp))
-		return("A:/");
-
-	buf[strlen(buf) -1] = '\0';
-	fclose(fp);
-					/* drive letter present? */
-	s = skip_drive(buf);
-	if (s > buf) {
-		strncpy(ans, buf, s - buf);
-		ans[s - buf] = '\0';
-	} else 
-		strcpy(ans, "A:");
-					/* add a leading separator */
-	if (*s != '/' && *s != '\\') {
-		strcat(ans, "/");
-		strcat(ans, s);
-	} else
-		strcat(ans, s);
-
-#if 0
-					/* translate to upper case */
-	for (s = ans; *s; ++s) {
-		*s = toupper(*s);
-		if (*s == '\\')
-			*s = '/';
-	}
-#endif
-					/* if only drive, colon, & separator */
-	if (strlen(ans) == 3)
-		return(ans);
-					/* zap the trailing separator */
-	if (*--s == '/')
-		*s = '\0';
-	return ans;
-}
-
-void *safe_malloc(size_t size)
-{
-	void *p;
-
-	p = malloc(size);
-	if(!p){
-		printOom();
-		exit(1);
-	}
-	return p;
-}
-
-void print_sector(char *message, unsigned char *data, int size)
-{
-	int col;
-	int row;
-
-	printf("%s:\n", message);
-	
-	for(row = 0; row * 16 < size; row++){
-		printf("%03x  ", row * 16);
-		for(col = 0; col < 16; col++)			
-			printf("%02x ", data [row*16+col]);
-		for(col = 0; col < 16; col++) {
-			if(isprint(data [row*16+col]))
-				printf("%c", data [row*16+col]);
-			else
-				printf(".");
-		}
-		printf("\n");
-	}
-}
-
-
-time_t getTimeNow(time_t *now)
-{
-	static int haveTime = 0;
-	static time_t sharedNow;
-
-	if(!haveTime) {
-		time(&sharedNow);
-		haveTime = 1;
-	}
-	if(now)
-		*now = sharedNow;
-	return sharedNow;
-}
-
-char *skip_drive(const char *filename)
-{
-	char *p;
-
-	/* Skip drive name.  Return pointer just after the `:', or a pointer
-	 * to the start of the file name if there is is no drive name.
-	 */
-	p = strchr(filename, ':');
-	return (p == NULL || p == filename) ? (char *) filename : p + 1;
-}
-
-char *get_drive(const char *filename, const char *def)
-{
-	const char *path;
-	char *drive;
-	const char *rest;
-	size_t len;
-
-	/* Return the drive name part of a full filename. */
-
-	path = filename;
-	rest = skip_drive(path);
-	if (rest == path) {
-		if (def == NULL) def = "A:";
-		path = def;
-		rest = skip_drive(path);
-		if (rest == path) {
-			path = "A:";
-			rest = path+2;
-		}
-	}
-	len = rest - path;
-	drive = safe_malloc(len * sizeof(drive[0]));
-	len--;
-	memcpy(drive, path, len);
-	drive[len] = 0;
-	if (len == 1) drive[0] = toupper(drive[0]);
-	return drive;
-}
-
-#if 0
-
-#undef free
-#undef malloc
-
-static int total=0;
-
-void myfree(void *ptr)
-{
-	int *size = ((int *) ptr)-1;
-	total -= *size;
-	fprintf(stderr, "freeing %d bytes at %p total alloced=%d\n",
-		*size, ptr, total);
-	free(size);
-}
-
-void *mymalloc(size_t size)
-{
-	int *ptr;
-	ptr = (int *)malloc(size+sizeof(int));
-	if(!ptr)
-		return 0;
-	*ptr = size;
-	ptr++;
-	total += size;
-	fprintf(stderr, "allocating %d bytes at %p total allocated=%d\n",
-		size, ptr, total);
-	return (void *) ptr;
-}
-
-void *mycalloc(size_t nmemb, size_t size)
-{
-	void *ptr = mymalloc(nmemb * size);
-	if(!ptr)
-		return 0;
-	memset(ptr, 0, size);
-	return ptr;
-}
-
-void *myrealloc(void *ptr, size_t size)
-{
-	int oldsize = ((int *)ptr) [-1];
-	void *new = mymalloc(size);
-	if(!new)
-		return 0;
-	memcpy(new, ptr, oldsize);
-	myfree(ptr);
-	return new;
-}
-
-char *mystrdup(char *src)
-{
-	char *dest;
-	dest = mymalloc(strlen(src)+1);
-	if(!dest)
-		return 0;
-	strcpy(dest, src);
-	return dest;
-}
-
-
-#endif
Index: trunk/minix/commands/i386/mtools-3.9.7/missFuncs.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/missFuncs.c	(revision 9)
+++ 	(revision )
@@ -1,386 +1,0 @@
-/* Copyright (C) 1991 Free Software Foundation, Inc.
-This file contains excerpts of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB.  If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.  */
-
-#include "sysincludes.h"
-#include "mtools.h"
-
-#ifndef HAVE_STRDUP
-
-
-char *strdup(const char *str)
-{
-    char *nstr;
-
-    if (str == (char*)0)
-        return 0;
-
-    nstr = (char*)malloc((strlen(str) + 1));
-
-    if (nstr == (char*)0)
-    {
-        (void)fprintf(stderr, "strdup(): not enough memory to duplicate `%s'\n",
-		      str);
-	exit(1);
-    }
-
-    (void)strcpy(nstr, str);
-
-    return nstr;
-}
-#endif /* HAVE_STRDUP */
-
-
-#ifndef HAVE_MEMCPY
-/*
- * Copy contents of memory (with possible overlapping).
- */
-char *memcpy(char *s1, const char *s2, size_t n)
-{
-	bcopy(s2, s1, n);
-	return(s1);
-}
-#endif
-
-#ifndef HAVE_MEMSET
-/*
- * Copies the character c, n times to string s
- */
-char *memset(char *s, char c, size_t n)
-{
-	char *s1 = s;
-
-	while (n > 0) {
-		--n;
-		*s++ = c;
-	}
-	return(s1);
-}
-#endif /* HAVE_MEMSET */
-
-
-#ifndef HAVE_STRCHR
-
-char * strchr (const char* s, int c)
-{
-	if (!s) return NULL;
-	while (*s && *s != c) s++;
-	if (*s) 
-		return (char*) s;
-	else
-		return NULL;
-}
-
-#endif
-
-#ifndef HAVE_STRRCHR
-
-char * strrchr (const char* s1, int c) 
-{
-	char* s = (char*) s1;
-	char* start = (char*) s;
-	if (!s) return NULL;
-	s += strlen(s)-1;
-	while (*s != c && (unsigned long) s != (unsigned long) start) s--;
-	if ((unsigned long) s == (unsigned long) start && *s != c)
-		return NULL;
-	else
-		return s;
-}
-
-#endif
-
-#ifndef HAVE_STRPBRK
-/*
- * Return ptr to first occurrence of any character from `brkset'
- * in the character string `string'; NULL if none exists.
- */
-char *strpbrk(const char *string, const char *brkset)
-{
-	register char *p;
-
-	if (!string || !brkset)
-		return(0);
-	do {
-		for (p = brkset; *p != '\0' && *p != *string; ++p)
-			;
-		if (*p != '\0')
-			return(string);
-	}
-	while (*string++);
-	return(0);
-}
-#endif /* HAVE_STRPBRK */
-
-
-#ifndef HAVE_STRTOUL
-static int getdigit(char a, int max)
-{
-	int dig;
-	
-	if(a < '0')
-		return -1;
-	if(a <= '9') {
-		dig = a - '0';
-	} else if(a >= 'a')
-		dig = a - 'a' + 10;
-	else if(a >= 'A')
-		dig = a - 'A' + 10;
-	if(dig >= max)
-		return -1;
-	else
-		return dig;
-}
-
-unsigned long strtoul(const char *string, char **eptr, int base)
-{
-	int accu, dig;
-
-	if(base < 1 || base > 36) {
-		if(string[0] == '0') {
-			switch(string[1]) {
-			       	case 'x':
-				case 'X':
-					return strtoul(string+2, eptr, 16);
-				case 'b':
-			       	case 'B':
-					return strtoul(string+2, eptr, 2);
-				default:
-					return strtoul(string, eptr, 8);
-			}
-		}
-	       	return strtoul(string, eptr, 10);
-	}
-	if(base == 16 && string[0] == '0' &&
-	   (string[1] == 'x' || string[1] == 'X'))
-		string += 2;
-
-	if(base == 2 && string[0] == '0' &&
-	   (string[1] == 'b' || string[1] == 'B'))
-		string += 2;
-	accu = 0;
-	while( (dig = getdigit(*string, base)) != -1 ) {
-		accu = accu * base + dig;
-		string++;
-	}
-	if(eptr)
-		*eptr = (char *) string;
-	return accu;
-}
-#endif /* HAVE_STRTOUL */
-
-#ifndef HAVE_STRTOL
-long strtol(const char *string, char **eptr, int base)
-{
-	long l;
-
-	if(*string == '-') {
-		return -(long) strtoul(string+1, eptr, base);
-	} else {
-		if (*string == '+')
-			string ++;
-		return (long) strtoul(string, eptr, base);
-	}
-}
-#endif
-
-
-
-#ifndef HAVE_STRSPN
-/* Return the length of the maximum initial segment
-   of S which contains only characters in ACCEPT.  */
-size_t strspn(const char *s, const char *accept)
-{
-  register char *p;
-  register char *a;
-  register size_t count = 0;
-
-  for (p = s; *p != '\0'; ++p)
-    {
-      for (a = accept; *a != '\0'; ++a)
-	if (*p == *a)
-	  break;
-      if (*a == '\0')
-	return count;
-      else
-	++count;
-    }
-
-  return count;
-}
-#endif /* HAVE_STRSPN */
-
-#ifndef HAVE_STRCSPN
-/* Return the length of the maximum inital segment of S
-   which contains no characters from REJECT.  */
-size_t strcspn (const char *s, const char *reject)
-{
-  register size_t count = 0;
-
-  while (*s != '\0')
-    if (strchr (reject, *s++) == NULL)
-      ++count;
-    else
-      return count;
-
-  return count;
-}
-
-#endif /* HAVE_STRCSPN */
-
-#ifndef HAVE_STRERROR
-
-#ifndef DECL_SYS_ERRLIST
-extern char *sys_errlist[];
-#endif
-
-char *strerror(int errno)
-{
-  return sys_errlist[errno];
-}
-#endif
-
-#ifndef HAVE_STRCASECMP
-/* Compare S1 and S2, ignoring case, returning less than, equal to or
-   greater than zero if S1 is lexiographically less than,
-   equal to or greater than S2.  */
-int strcasecmp(const char *s1, const char *s2)
-{
-  register const unsigned char *p1 = (const unsigned char *) s1;
-  register const unsigned char *p2 = (const unsigned char *) s2;
-  unsigned char c1, c2;
-
-  if (p1 == p2)
-    return 0;
-
-  do
-    {
-      c1 = tolower (*p1++);
-      c2 = tolower (*p2++);
-      if (c1 == '\0')
-	break;
-    }
-  while (c1 == c2);
-
-  return c1 - c2;
-}
-#endif
-
-
-
-#ifndef HAVE_STRCASECMP
-/* Compare S1 and S2, ignoring case, returning less than, equal to or
-   greater than zero if S1 is lexiographically less than,
-   equal to or greater than S2.  */
-int strncasecmp(const char *s1, const char *s2, size_t n)
-{
-  register const unsigned char *p1 = (const unsigned char *) s1;
-  register const unsigned char *p2 = (const unsigned char *) s2;
-  unsigned char c1, c2;
-
-  if (p1 == p2)
-    return 0;
-
-  c1 = c2 = 1;
-  while (c1 && c1 == c2 && n-- > 0)
-    {
-      c1 = tolower (*p1++);
-      c2 = tolower (*p2++);
-    }
-
-  return c1 - c2;
-}
-#endif
-
-#ifndef HAVE_GETPASS
-char *getpass(const char *prompt)
-{
-	static char password[129];
-	int l;
-
-	fprintf(stderr,"%s",prompt);
-	fgets(password, 128, stdin);
-	l = strlen(password);
-	if(l && password[l-1] == '\n')
-		password[l-1] = '\0';
-	return password;
-
-}
-#endif
-
-#ifndef HAVE_ATEXIT
-
-#ifdef HAVE_ON_EXIT
-int atexit(void (*function)(void))
-{
-	return on_exit( (void(*)(int,void*)) function, 0);
-}
-#else
-
-typedef struct exitCallback {
-	void (*function) (void);
-	struct exitCallback *next;
-} exitCallback_t;
-
-static exitCallback_t *callback = 0;
-
-int atexit(void (*function) (void))
-{
-	exitCallback_t *newCallback;
-		
-	newCallback = New(exitCallback_t);
-	if(!newCallback) {
-		printOom();
-		exit(1);
-	}
-	newCallback->function = function;
-	newCallback->next = callback;
-	callback = newCallback;
-	return 0;
-}
-#undef exit
-
-void myexit(int code)
-{
-  void (*function)(void);
-
-  while(callback) {
-    function = callback->function;
-    callback = callback->next;
-    function();
-  }
-  exit(code);
-}
-
-#endif
-
-#endif
-
-/*#ifndef HAVE_BASENAME*/
-const char *_basename(const char *filename)
-{
-	char *ptr;
-
-	ptr = strrchr(filename, '/');
-	if(ptr)
-		return ptr+1;
-	else
-		return filename;
-}
-/*#endif*/
-
-
Index: trunk/minix/commands/i386/mtools-3.9.7/mk_direntry.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mk_direntry.c	(revision 9)
+++ 	(revision )
@@ -1,618 +1,0 @@
-/*
- * mk_direntry.c
- * Make new directory entries, and handles name clashes
- *
- */
-
-/*
- * This file is used by those commands that need to create new directory entries
- */
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "vfat.h"
-#include "nameclash.h"
-#include "fs.h"
-#include "stream.h"
-#include "mainloop.h"
-
-static inline int ask_rename(ClashHandling_t *ch,
-			     char *longname, int isprimary, char *argname)
-{
-	char shortname[13];
-	int mangled;
-
-	/* TODO: Would be nice to suggest "autorenamed" version of name, press 
-	 * <Return> to get it.
-	 */
-#if 0
-	fprintf(stderr,"Entering ask_rename, isprimary=%d.\n", isprimary);
-#endif
-
-	if(!opentty(0))
-		return 0;
-
-#define maxsize (isprimary ?  MAX_VNAMELEN+1 : 11+1)
-#define name (isprimary ? argname : shortname)
-
-	mangled = 0;
-	do {
-		fprintf(stderr, "New %s name for \"%s\": ",
-			isprimary ? "primary" : "secondary", longname);
-		fflush(stderr);
-		if (! fgets(name, maxsize, opentty(0)))
-			return 0;
-
-		/* Eliminate newline(s) in the file name */
-		name[strlen(name)-1]='\0';
-		if (!isprimary)
-			ch->name_converter(shortname,0, &mangled, argname);
-	} while (mangled & 1);
-	return 1;
-#undef maxsize
-#undef name
-}
-
-static inline clash_action ask_namematch(char *name, int isprimary, 
-					 ClashHandling_t *ch, int no_overwrite,
-					 int reason)
-{
-	char ans[10];
-	clash_action a;
-	int perm;
-	char unix_shortname[13];
-
-
-#define EXISTS 0
-#define RESERVED 1
-#define ILLEGALS 2
-
-	static const char *reasons[]= {
-		"already exists",
-		"is reserved",
-		"contains illegal character(s)"};
-
-
-	if (!isprimary)
-		name = unix_normalize(unix_shortname, name, name+8);
-
-	a = ch->action[isprimary];
-
-	if(a == NAMEMATCH_NONE && !opentty(1)) {
-		/* no default, and no tty either . Skip the troublesome file */
-		return NAMEMATCH_SKIP;
-	}
-
-	perm = 0;
-	while (a == NAMEMATCH_NONE) {
-		fprintf(stderr, "%s file name \"%s\" %s.\n",
-			isprimary ? "Long" : "Short", name, reasons[reason]);
-		fprintf(stderr,
-			"a)utorename A)utorename-all r)ename R)ename-all ");
-		if(!no_overwrite)
-			fprintf(stderr,"o)verwrite O)verwrite-all");
-		fprintf(stderr,
-			"\ns)kip S)kip-all q)uit (aArR");
-		if(!no_overwrite)
-			fprintf(stderr,"oO");
-		fprintf(stderr,"sSq): ");
-		fflush(stderr);
-		fflush(opentty(1));
-		if (mtools_raw_tty) {
-			int rep;
-			rep = fgetc(opentty(1));			
-			fputs("\n", stderr);
-			if(rep == EOF)
-				ans[0] = 'q';
-			else
-				ans[0] = rep;
-		} else {
-			fgets(ans, 9, opentty(0));
-		}
-		perm = isupper((unsigned char)ans[0]);
-		switch(tolower((unsigned char)ans[0])) {
-			case 'a':
-				a = NAMEMATCH_AUTORENAME;
-				break;
-			case 'r':
-				if(isprimary)
-					a = NAMEMATCH_PRENAME;
-				else
-					a = NAMEMATCH_RENAME;
-				break;
-			case 'o':
-				if(no_overwrite)
-					continue;
-				a = NAMEMATCH_OVERWRITE;
-				break;
-			case 's':
-				a = NAMEMATCH_SKIP;
-				break;
-			case 'q':
-				perm = 0;
-				a = NAMEMATCH_QUIT;
-				break;
-			default:
-				perm = 0;
-		}
-	}
-
-	/* Keep track of this action in case this file collides again */
-	ch->action[isprimary]  = a;
-	if (perm)
-		ch->namematch_default[isprimary] = a;
-
-	/* if we were asked to overwrite be careful. We can't set the action
-	 * to overwrite, else we get won't get a chance to specify another
-	 * action, should overwrite fail. Indeed, we'll be caught in an
-	 * infinite loop because overwrite will fail the same way for the
-	 * second time */
-	if(a == NAMEMATCH_OVERWRITE)
-		ch->action[isprimary] = NAMEMATCH_NONE;
-	return a;
-}
-
-/* Returns:
- * 2 if file is to be overwritten
- * 1 if file was renamed
- * 0 if it was skipped
- *
- * If a short name is involved, handle conversion between the 11-character
- * fixed-length record DOS name and a literal null-terminated name (e.g.
- * "COMMAND  COM" (no null) <-> "COMMAND.COM" (null terminated)).
- *
- * Also, immediately copy the original name so that messages can use it.
- */
-static inline clash_action process_namematch(char *name,
-					     char *longname,
-					     int isprimary,
-					     ClashHandling_t *ch,
-					     int no_overwrite,
-					     int reason)
-{
-	clash_action action;
-
-#if 0
-	fprintf(stderr,
-		"process_namematch: name=%s, default_action=%d, ask=%d.\n",
-		name, default_action, ch->ask);
-#endif
-
-	action = ask_namematch(name, isprimary, ch, no_overwrite, reason);
-
-	switch(action){
-	case NAMEMATCH_QUIT:
-		got_signal = 1;
-		return NAMEMATCH_SKIP;
-	case NAMEMATCH_SKIP:
-		return NAMEMATCH_SKIP;
-	case NAMEMATCH_RENAME:
-	case NAMEMATCH_PRENAME:
-		/* We need to rename the file now.  This means we must pass
-		 * back through the loop, a) ensuring there isn't a potential
-		 * new name collision, and b) finding a big enough VSE.
-		 * Change the name, so that it won't collide again.
-		 */
-		ask_rename(ch, longname, isprimary, name);
-		return action;
-	case NAMEMATCH_AUTORENAME:
-		/* Very similar to NAMEMATCH_RENAME, except that we need to
-		 * first generate the name.
-		 * TODO: Remember previous name so we don't
-		 * keep trying the same one.
-		 */
-		if (isprimary) {
-			autorename_long(name, 1);
-			return NAMEMATCH_PRENAME;
-		} else {
-			autorename_short(name, 1);
-			return NAMEMATCH_RENAME;
-		}
-	case NAMEMATCH_OVERWRITE:
-		if(no_overwrite)
-			return NAMEMATCH_SKIP;
-		else
-			return NAMEMATCH_OVERWRITE;
-	default:
-		return NAMEMATCH_NONE;
-	}
-}
-
-
-static void clear_scan(char *longname, int use_longname, struct scan_state *s)
-{
-	s->shortmatch = s->longmatch = s->slot = -1;
-	s->free_end = s->got_slots = s->free_start = 0;
-
-	if (use_longname & 1)
-                s->size_needed = 2 + (strlen(longname)/VSE_NAMELEN);
-	else
-                s->size_needed = 1;
-}
-
-
-static int contains_illegals(const char *string, const char *illegals)
-{
-	for(; *string ; string++)
-		if((*string < ' ' && *string != '\005' && !(*string & 0x80)) ||
-		   strchr(illegals, *string))
-			return 1;
-	return 0;
-}
-
-static int is_reserved(char *ans, int islong)
-{
-	int i;
-	static const char *dev3[] = {"CON", "AUX", "PRN", "NUL", "   "};
-	static const char *dev4[] = {"COM", "LPT" };
-
-	for (i = 0; i < sizeof(dev3)/sizeof(*dev3); i++)
-		if (!strncasecmp(ans, dev3[i], 3) &&
-		    ((islong && !ans[3]) ||
-		     (!islong && !strncmp(ans+3,"     ",5))))
-			return 1;
-
-	for (i = 0; i < sizeof(dev4)/sizeof(*dev4); i++)
-		if (!strncasecmp(ans, dev4[i], 3) &&
-		    (ans[3] >= '1' && ans[3] <= '4') &&
-		    ((islong && !ans[4]) ||
-		     (!islong && !strncmp(ans+4,"    ",4))))
-			return 1;
-	
-	return 0;
-}
-
-static inline clash_action get_slots(Stream_t *Dir,
-				     char *dosname, char *longname,
-				     struct scan_state *ssp,
-				     ClashHandling_t *ch)
-{
-	int error;
-	clash_action ret;
-	int match=0;
-	direntry_t entry;
-	int isprimary;
-	int no_overwrite;
-	int reason;
-	int pessimisticShortRename;
-
-	pessimisticShortRename = (ch->action[0] == NAMEMATCH_AUTORENAME);
-
-	entry.Dir = Dir;
-	no_overwrite = 1;
-	if((is_reserved(longname,1)) ||
-	   longname[strspn(longname,". ")] == '\0'){
-		reason = RESERVED;
-		isprimary = 1;
-	} else if(contains_illegals(longname,long_illegals)) {
-		reason = ILLEGALS;
-		isprimary = 1;
-	} else if(is_reserved(dosname,0)) {
-		reason = RESERVED;
-		ch->use_longname = 1;
-		isprimary = 0;
-	} else if(contains_illegals(dosname,short_illegals)) {
-		reason = ILLEGALS;
-		ch->use_longname = 1;
-		isprimary = 0;
-	} else {
-		reason = EXISTS;
-		clear_scan(longname, ch->use_longname, ssp);
-		switch (lookupForInsert(Dir, dosname, longname, ssp,
-								ch->ignore_entry, 
-								ch->source_entry,
-								pessimisticShortRename && 
-								ch->use_longname)) {
-			case -1:
-				return NAMEMATCH_ERROR;
-				
-			case 0:
-				return NAMEMATCH_SKIP; 
-				/* Single-file error error or skip request */
-				
-			case 5:
-				return NAMEMATCH_GREW;
-				/* Grew directory, try again */
-				
-			case 6:
-				return NAMEMATCH_SUCCESS; /* Success */
-		}	    
-		match = -2;
-		if (ssp->longmatch > -1) {
-			/* Primary Long Name Match */
-#ifdef debug
-			fprintf(stderr,
-				"Got longmatch=%d for name %s.\n", 
-				longmatch, longname);
-#endif			
-			match = ssp->longmatch;
-			isprimary = 1;
-		} else if ((ch->use_longname & 1) && (ssp->shortmatch != -1)) {
-			/* Secondary Short Name Match */
-#ifdef debug
-			fprintf(stderr,
-				"Got secondary short name match for name %s.\n", 
-				longname);
-#endif
-
-			match = ssp->shortmatch;
-			isprimary = 0;
-		} else if (ssp->shortmatch >= 0) {
-			/* Primary Short Name Match */
-#ifdef debug
-			fprintf(stderr,
-				"Got primary short name match for name %s.\n", 
-				longname);
-#endif
-			match = ssp->shortmatch;
-			isprimary = 1;
-		} else 
-			return NAMEMATCH_RENAME;
-
-		if(match > -1) {
-			entry.entry = match;
-			dir_read(&entry, &error);
-			if (error)
-			    return NAMEMATCH_ERROR;
-			/* if we can't overwrite, don't propose it */
-			no_overwrite = (match == ch->source || IS_DIR(&entry));
-		}
-	}
-	ret = process_namematch(isprimary ? longname : dosname, longname,
-				isprimary, ch, no_overwrite, reason);
-	
-	if (ret == NAMEMATCH_OVERWRITE && match > -1){
-		if((entry.dir.attr & 0x5) &&
-		   (ask_confirmation("file is read only, overwrite anyway (y/n) ? ",0,0)))
-			return NAMEMATCH_RENAME;
-		
-		/* Free up the file to be overwritten */
-		if(fatFreeWithDirentry(&entry))
-			return NAMEMATCH_ERROR;
-		
-#if 0
-		if(isprimary &&
-		   match - ssp->match_free + 1 >= ssp->size_needed){
-			/* reuse old entry and old short name for overwrite */
-			ssp->free_start = match - ssp->size_needed + 1;
-			ssp->free_size = ssp->size_needed;
-			ssp->slot = match;
-			ssp->got_slots = 1;
-			strncpy(dosname, dir.name, 3);
-			strncpy(dosname + 8, dir.ext, 3);
-			return ret;
-		} else
-#endif
-			{
-			entry.dir.name[0] = DELMARK;
-			dir_write(&entry);
-			return NAMEMATCH_RENAME;
-		}
-	}
-
-	return ret;
-}
-
-
-static inline int write_slots(Stream_t *Dir,
-			      char *dosname, 
-			      char *longname,
-			      struct scan_state *ssp,
-			      write_data_callback *cb,
-			      void *arg,
-			      int Case)
-{
-	direntry_t entry;
-
-	/* write the file */
-	if (fat_error(Dir))
-		return 0;
-
-	entry.Dir = Dir;
-	entry.entry = ssp->slot;
-	strncpy(entry.name, longname, sizeof(entry.name)-1);
-	entry.name[sizeof(entry.name)-1]='\0';
-	entry.dir.Case = Case & (EXTCASE | BASECASE);
-	if (cb(dosname, longname, arg, &entry) >= 0) {
-		if ((ssp->size_needed > 1) &&
-		    (ssp->free_end - ssp->free_start >= ssp->size_needed)) {
-			ssp->slot = write_vfat(Dir, dosname, longname,
-					       ssp->free_start, &entry);
-		} else {
-			ssp->size_needed = 1;
-			write_vfat(Dir, dosname, 0,
-				   ssp->free_start, &entry);
-		}
-		/* clear_vses(Dir, ssp->free_start + ssp->size_needed, 
-		   ssp->free_end); */
-	} else
-		return 0;
-
-	return 1;	/* Successfully wrote the file */
-}
-
-static void stripspaces(char *name)
-{
-	char *p,*non_space;
-
-	non_space = name;
-	for(p=name; *p; p++)
-		if (*p != ' ')
-			non_space = p;
-	if(name[0])
-		non_space[1] = '\0';
-}
-
-
-int _mwrite_one(Stream_t *Dir,
-		char *argname,
-		char *shortname,
-		write_data_callback *cb,
-		void *arg,
-		ClashHandling_t *ch)
-{
-	char longname[VBUFSIZE];
-	const char *dstname;
-	char dosname[13];
-	int expanded;
-	struct scan_state scan;
-	clash_action ret;
-
-	expanded = 0;
-
-	if(isSpecial(argname)) {
-		fprintf(stderr, "Cannot create entry named . or ..\n");
-		return -1;
-	}
-
-	if(ch->name_converter == dos_name) {
-		if(shortname)
-			stripspaces(shortname);
-		if(argname)
-			stripspaces(argname);
-	}
-
-	if(shortname){
-		ch->name_converter(shortname,0, &ch->use_longname, dosname);
-		if(ch->use_longname & 1){
-			/* short name mangled, treat it as a long name */
-			argname = shortname;
-			shortname = 0;
-		}
-	}
-						
-	/* Skip drive letter */
-	dstname = skip_drive(argname);
-
-	/* Copy original argument dstname to working value longname */
-	strncpy(longname, dstname, VBUFSIZE-1);
-
-	if(shortname) {
-		ch->name_converter(shortname,0, &ch->use_longname, dosname);
-		if(strcmp(shortname, longname))
-			ch->use_longname |= 1;
-	} else
-		ch->name_converter(longname,0, &ch->use_longname, dosname);
-
-	ch->action[0] = ch->namematch_default[0];
-	ch->action[1] = ch->namematch_default[1];
-
-	while (1) {
-		switch((ret=get_slots(Dir, dosname, longname,
-				      &scan, ch))){
-			case NAMEMATCH_ERROR:
-				return -1;	/* Non-file-specific error, 
-						 * quit */
-				
-			case NAMEMATCH_SKIP:
-				return -1;	/* Skip file (user request or 
-						 * error) */
-
-			case NAMEMATCH_PRENAME:
-				ch->name_converter(longname,0,
-						   &ch->use_longname, dosname);
-				continue;
-			case NAMEMATCH_RENAME:
-				continue;	/* Renamed file, loop again */
-
-			case NAMEMATCH_GREW:
-				/* No collision, and not enough slots.
-				 * Try to grow the directory
-				 */
-				if (expanded) {	/* Already tried this 
-						 * once, no good */
-					fprintf(stderr, 
-						"%s: No directory slots\n",
-						progname);
-					return -1;
-				}
-				expanded = 1;
-				
-				if (dir_grow(Dir, scan.max_entry))
-					return -1;
-				continue;
-			case NAMEMATCH_OVERWRITE:
-			case NAMEMATCH_SUCCESS:
-				return write_slots(Dir, dosname, longname,
-						   &scan, cb, arg,
-						   ch->use_longname);
-			default:
-				fprintf(stderr,
-					"Internal error: clash_action=%d\n",
-					ret);
-				return -1;
-		}
-
-	}
-}
-
-int mwrite_one(Stream_t *Dir,
-	       const char *_argname,
-	       const char *_shortname,
-	       write_data_callback *cb,
-	       void *arg,
-	       ClashHandling_t *ch)
-{
-	char *argname;
-	char *shortname;
-	int ret;
-
-	if(_argname)
-		argname = strdup(_argname);
-	else
-		argname = 0;
-	if(_shortname)
-		shortname = strdup(_shortname);
-	else
-		shortname = 0;
-	ret = _mwrite_one(Dir, argname, shortname, cb, arg, ch);
-	if(argname)
-		free(argname);
-	if(shortname)
-		free(shortname);
-	return ret;
-}
-
-void init_clash_handling(ClashHandling_t *ch)
-{
-	ch->ignore_entry = -1;
-	ch->source_entry = -2;
-	ch->nowarn = 0;	/*Don't ask, just do default action if name collision */
-	ch->namematch_default[0] = NAMEMATCH_AUTORENAME;
-	ch->namematch_default[1] = NAMEMATCH_NONE;
-	ch->name_converter = dos_name; /* changed by mlabel */
-	ch->source = -2;
-}
-
-int handle_clash_options(ClashHandling_t *ch, char c)
-{
-	int isprimary;
-	if(isupper(c))
-		isprimary = 0;
-	else
-		isprimary = 1;
-	c = tolower(c);
-	switch(c) {
-		case 'o':
-			/* Overwrite if primary name matches */
-			ch->namematch_default[isprimary] = NAMEMATCH_OVERWRITE;
-			return 0;
-		case 'r':
-				/* Rename primary name interactively */
-			ch->namematch_default[isprimary] = NAMEMATCH_RENAME;
-			return 0;
-		case 's':
-			/* Skip file if primary name collides */
-			ch->namematch_default[isprimary] = NAMEMATCH_SKIP;
-			return 0;
-		case 'm':
-			ch->namematch_default[isprimary] = NAMEMATCH_NONE;
-			return 0;
-		case 'a':
-			ch->namematch_default[isprimary] = NAMEMATCH_AUTORENAME;
-			return 0;
-		default:
-			return -1;
-	}
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/mlabel.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mlabel.c	(revision 9)
+++ 	(revision )
@@ -1,251 +1,0 @@
-/*
- * mlabel.c
- * Make an MSDOS volume label
- */
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mainloop.h"
-#include "vfat.h"
-#include "mtools.h"
-#include "nameclash.h"
-
-char *label_name(char *filename, int verbose, 
-		 int *mangled, char *ans)
-{
-	int len;
-	int i;
-	int have_lower, have_upper;
-
-	strcpy(ans,"           ");
-	len = strlen(filename);
-	if(len > 11){
-		*mangled = 1;
-		len = 11;
-	} else
-		*mangled = 0;
-	strncpy(ans, filename, len);
-	have_lower = have_upper = 0;
-	for(i=0; i<11; i++){
-		if(islower((unsigned char)ans[i]))
-			have_lower = 1;
-		if(isupper(ans[i]))
-			have_upper = 1;
-		ans[i] = toupper((unsigned char)ans[i]);
-
-		if(strchr("^+=/[]:,?*\\<>|\".", ans[i])){
-			*mangled = 1;
-			ans[i] = '~';
-		}
-	}
-	if (have_lower && have_upper)
-		*mangled = 1;
-	return ans;
-}
-
-int labelit(char *dosname,
-	    char *longname,
-	    void *arg0,
-	    direntry_t *entry)
-{
-	time_t now;
-
-	/* find out current time */
-	getTimeNow(&now);
-	mk_entry(dosname, 0x8, 0, 0, now, &entry->dir);
-	return 0;
-}
-
-static void usage(void)
-{
-	fprintf(stderr, "Mtools version %s, dated %s\n",
-		mversion, mdate);
-	fprintf(stderr, "Usage: %s [-vscn] [-N serial] drive:[label]\n"
-		"\t-v Verbose\n"
-		"\t-s Show label\n"
-		"\t-c Clear label\n"
-		"\t-n New random serial number\n"
-		"\t-N New given serial number\n", progname);
-	exit(1);
-}
-
-
-void mlabel(int argc, char **argv, int type)
-{
-    
-	char *drive, *newLabel;
-	int verbose, clear, interactive, show, open_mode;
-	direntry_t entry;
-	int result=0;
-	char longname[VBUFSIZE];
-	char shortname[13];
-	ClashHandling_t ch;
-	struct MainParam_t mp;
-	Stream_t *RootDir;
-	int c;
-	int mangled;
-	enum { SER_NONE, SER_RANDOM, SER_SET }  set_serial = SER_NONE;
-	long serial = 0;
-	int need_write_boot = 0;
-	int have_boot = 0;
-	char *eptr = "";
-	struct bootsector boot;
-	Stream_t *Fs=0;
-	int r;
-	struct label_blk_t *labelBlock;
-
-	init_clash_handling(&ch);
-	ch.name_converter = label_name;
-	ch.ignore_entry = -2;
-
-	verbose = 0;
-	clear = 0;
-	show = 0;
-
-	while ((c = getopt(argc, argv, "vcsnN:")) != EOF) {
-		switch (c) {
-			case 'v':
-				verbose = 1;
-				break;
-			case 'c':
-				clear = 1;
-				break;
-			case 's':
-				show = 1;
-				break;
-			case 'n':
-				set_serial = SER_RANDOM;
-				srandom((long)time (0));
-				serial=random();
-				break;
-			case 'N':
-				set_serial = SER_SET;
-				serial = strtol(optarg, &eptr, 16);
-				if(*eptr) {
-					fprintf(stderr,
-						"%s not a valid serial number\n",
-						optarg);
-					exit(1);
-				}
-				break;
-			default:
-				usage();
-			}
-	}
-
-	if (argc - optind != 1 || skip_drive(argv[optind]) == argv[optind]) 
-		usage();
-
-	init_mp(&mp);
-	newLabel = skip_drive(argv[optind]);
-	interactive = !show && !clear &&!newLabel[0] && 
-		(set_serial == SER_NONE);
-	open_mode = O_RDWR;
-	drive = get_drive(argv[optind], NULL);
-	RootDir = open_root_dir(drive, open_mode);
-	if(strlen(newLabel) > VBUFSIZE) {
-		fprintf(stderr, "Label too long\n");
-		FREE(&RootDir);
-		exit(1);
-	}
-
-	if(!RootDir && open_mode == O_RDWR && !clear && !newLabel[0] &&
-	   ( errno == EACCES || errno == EPERM) ) {
-		show = 1;
-		interactive = 0;
-		RootDir = open_root_dir(drive, O_RDONLY);
-	}	    
-	if(!RootDir) {
-		fprintf(stderr, "%s: Cannot initialize drive\n", argv[0]);
-		exit(1);
-	}
-
-	initializeDirentry(&entry, RootDir);
-	r=vfat_lookup(&entry, 0, 0, ACCEPT_LABEL | MATCH_ANY,
-		      shortname, longname);
-	if (r == -2) {
-		FREE(&RootDir);
-		exit(1);
-	}
-
-	if(show || interactive){
-		if(isNotFound(&entry))
-			printf(" Volume has no label\n");
-		else if (*longname)
-			printf(" Volume label is %s (abbr=%s)\n",
-			       longname, shortname);
-		else
-			printf(" Volume label is %s\n", shortname);
-
-	}
-
-	/* ask for new label */
-	if(interactive){
-		newLabel = longname;
-		fprintf(stderr,"Enter the new volume label : ");
-		fgets(newLabel, VBUFSIZE, stdin);
-		if(newLabel[0])
-			newLabel[strlen(newLabel)-1] = '\0';
-	}
-
-	if((!show || newLabel[0]) && !isNotFound(&entry)){
-		/* if we have a label, wipe it out before putting new one */
-		if(interactive && newLabel[0] == '\0')
-			if(ask_confirmation("Delete volume label (y/n): ",0,0)){
-				FREE(&RootDir);
-				exit(0);
-			}		
-		entry.dir.name[0] = DELMARK;
-		entry.dir.attr = 0; /* for old mlabel */
-		dir_write(&entry);
-	}
-
-	if (newLabel[0] != '\0') {
-		ch.ignore_entry = 1;
-		result = mwrite_one(RootDir,newLabel,0,labelit,NULL,&ch) ? 
-		  0 : 1;
-	}
-
-	have_boot = 0;
-	if( (!show || newLabel[0]) || set_serial != SER_NONE) {
-		Fs = GetFs(RootDir);
-		have_boot = (force_read(Fs,(char *)&boot,0,sizeof(boot)) == 
-			     sizeof(boot));
-	}
-
-	if(_WORD(boot.fatlen)) {
-	    labelBlock = &boot.ext.old.labelBlock;
-	} else {
-	    labelBlock = &boot.ext.fat32.labelBlock;
-	}
-
-	if(!show || newLabel[0]){
-
-		if(!newLabel[0])
-			strncpy(shortname, "NO NAME    ",11);
-		else
-			label_name(newLabel, verbose, &mangled, shortname);
-
-		if(have_boot && boot.descr >= 0xf0 &&
-		   labelBlock->dos4 == 0x29) {
-			strncpy(labelBlock->label, shortname, 11);
-			need_write_boot = 1;
-
-		}
-	}
-
-	if((set_serial != SER_NONE) & have_boot) {
-		if(have_boot && boot.descr >= 0xf0 &&
-		   labelBlock->dos4 == 0x29) {
-			set_dword(labelBlock->serial, serial);	
-			need_write_boot = 1;
-		}
-	}
-
-	if(need_write_boot) {
-		force_write(Fs, (char *)&boot, 0, sizeof(boot));
-	}
-
-	FREE(&RootDir);
-	exit(result);
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/mmd.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mmd.c	(revision 9)
+++ 	(revision )
@@ -1,174 +1,0 @@
-/*
- * mmd.c
- * Makes an MSDOS directory
- */
-
-
-#define LOWERCASE
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "vfat.h"
-#include "mainloop.h"
-#include "plain_io.h"
-#include "nameclash.h"
-#include "file.h"
-#include "fs.h"
-
-/*
- * Preserve the file modification times after the fclose()
- */
-
-typedef struct Arg_t {
-	char *target;
-	MainParam_t mp;
-
-	Stream_t *SrcDir;
-	int entry;
-	ClashHandling_t ch;
-	Stream_t *targetDir;
-} Arg_t;
-
-
-typedef struct CreateArg_t {
-	Stream_t *Dir;
-	Stream_t *NewDir;
-	unsigned char attr;
-	time_t mtime;
-} CreateArg_t;
-
-/*
- * Open the named file for read, create the cluster chain, return the
- * directory structure or NULL on error.
- */
-int makeit(char *dosname,
-	    char *longname,
-	    void *arg0,
-	    direntry_t *targetEntry)
-{
-	Stream_t *Target;
-	CreateArg_t *arg = (CreateArg_t *) arg0;
-	int fat;
-	direntry_t subEntry;	
-
-	/* will it fit? At least one cluster must be free */
-	if (!getfreeMinClusters(targetEntry->Dir, 1))
-		return -1;
-	
-	mk_entry(dosname, ATTR_DIR, 1, 0, arg->mtime, &targetEntry->dir);
-	Target = OpenFileByDirentry(targetEntry);
-	if(!Target){
-		fprintf(stderr,"Could not open Target\n");
-		return -1;
-	}
-
-	/* this allocates the first cluster for our directory */
-
-	initializeDirentry(&subEntry, Target);
-
-	subEntry.entry = 1;
-	GET_DATA(targetEntry->Dir, 0, 0, 0, &fat);
-	if (fat == fat32RootCluster(targetEntry->Dir)) {
-	    fat = 0;
-	}
-	mk_entry("..         ", ATTR_DIR, fat, 0, arg->mtime, &subEntry.dir);
-	dir_write(&subEntry);
-
-	FLUSH((Stream_t *) Target);
-	subEntry.entry = 0;
-	GET_DATA(Target, 0, 0, 0, &fat);
-	mk_entry(".          ", ATTR_DIR, fat, 0, arg->mtime, &subEntry.dir);
-	dir_write(&subEntry);
-
-	mk_entry(dosname, ATTR_DIR | arg->attr, fat, 0, arg->mtime, 
-		 &targetEntry->dir);
-	arg->NewDir = Target;
-	return 0;
-}
-
-
-static void usage(void)
-{
-	fprintf(stderr,
-		"Mtools version %s, dated %s\n", mversion, mdate);
-	fprintf(stderr,
-		"Usage: %s [-D clash_option] file targetfile\n", progname);
-	fprintf(stderr,
-		"       %s [-D clash_option] file [files...] target_directory\n", 
-		progname);
-	exit(1);
-}
-
-Stream_t *createDir(Stream_t *Dir, const char *filename, ClashHandling_t *ch, 
-					unsigned char attr, time_t mtime)
-{
-	CreateArg_t arg;
-	int ret;
-
-	arg.Dir = Dir;
-	arg.attr = attr;
-	arg.mtime = mtime;
-
-	if (!getfreeMinClusters(Dir, 1))
-		return NULL;
-
-	ret = mwrite_one(Dir, filename,0, makeit, &arg, ch);
-	if(ret < 1)
-		return NULL;
-	else
-		return arg.NewDir;
-}
-
-static int createDirCallback(direntry_t *entry, MainParam_t *mp)
-{
-	Stream_t *ret;
-	time_t now;
-
-	ret = createDir(mp->File, mp->targetName, &((Arg_t *)(mp->arg))->ch, 
-					ATTR_DIR, getTimeNow(&now));
-	if(ret == NULL)
-		return ERROR_ONE;
-	else {
-		FREE(&ret);
-		return GOT_ONE;
-	}
-	
-}
-
-void mmd(int argc, char **argv, int type)
-{
-	Arg_t arg;
-	int c;
-
-	/* get command line options */
-
-	init_clash_handling(& arg.ch);
-
-	/* get command line options */
-	while ((c = getopt(argc, argv, "D:o")) != EOF) {
-		switch (c) {
-			case '?':
-				usage();
-			case 'o':
-				handle_clash_options(&arg.ch, c);
-				break;
-			case 'D':
-				if(handle_clash_options(&arg.ch, *optarg))
-					usage();
-				break;
-			default:
-				break;
-		}
-	}
-
-	if (argc - optind < 1)
-		usage();
-
-	init_mp(&arg.mp);
-	arg.mp.arg = (void *) &arg;
-	arg.mp.openflags = O_RDWR;
-	arg.mp.callback = createDirCallback;
-	arg.mp.lookupflags = OPEN_PARENT | DO_OPEN_DIRS;
-	exit(main_loop(&arg.mp, argv + optind, argc - optind));
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/mmount.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mmount.c	(revision 9)
+++ 	(revision )
@@ -1,85 +1,0 @@
-/*
- * Mount an MSDOS disk
- *
- * written by:
- *
- * Alain L. Knaff			
- * alain@linux.lu
- *
- */
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-
-#ifdef OS_linux
-#include <sys/wait.h>
-#include "mainloop.h"
-#include "fs.h"
-
-extern int errno;
-
-void mmount(int argc, char **argv, int type)
-{
-	char drive;
-	int pid;
-	int status;
-	struct device dev;
-	char name[EXPAND_BUF];
-	int media;
-	struct bootsector boot;
-	Stream_t *Stream;
-	
-	if (argc<2 || !argv[1][0]  || argv[1][1] != ':' || argv[1][2]){
-		fprintf(stderr,"Usage: %s -V drive:\n", argv[0]);
-		exit(1);
-	}
-	drive = toupper(argv[1][0]);
-	Stream = find_device(drive, O_RDONLY, &dev, &boot, name, &media, 0);
-	if(!Stream)
-		exit(1);
-	FREE(&Stream);
-
-	destroy_privs();
-
-	if ( dev.partition ) {
-		char part_name[4];
-		sprintf(part_name, "%d", dev.partition %1000);
-		strcat(name, part_name); 
-	}
-
-	/* and finally mount it */
-	switch((pid=fork())){
-	case -1:
-		fprintf(stderr,"fork failed\n");
-		exit(1);
-	case 0:
-		close(2);
-		open("/dev/null", O_RDWR);
-		argv[1] = strdup("mount");
-		if ( argc > 2 )
-			execvp("mount", argv + 1 );
-		else
-			execlp("mount", "mount", name, 0);
-		perror("exec mount");
-		exit(1);
-	default:
-		while ( wait(&status) != pid );
-	}	
-	if ( WEXITSTATUS(status) == 0 )
-		exit(0);
-	argv[0] = strdup("mount");
-	argv[1] = strdup("-r");
-	if(!argv[0] || !argv[1]){
-		printOom();
-		exit(1);
-	}
-	if ( argc > 2 )
-		execvp("mount", argv);
-	else
-		execlp("mount", "mount","-r", name, 0);
-	exit(1);
-}
-
-#endif /* linux */
-
Index: trunk/minix/commands/i386/mtools-3.9.7/mmove.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mmove.c	(revision 9)
+++ 	(revision )
@@ -1,314 +1,0 @@
-/*
- * mmove.c
- * Renames/moves an MSDOS file
- *
- */
-
-
-#define LOWERCASE
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "vfat.h"
-#include "mainloop.h"
-#include "plain_io.h"
-#include "nameclash.h"
-#include "file.h"
-#include "fs.h"
-
-/*
- * Preserve the file modification times after the fclose()
- */
-
-typedef struct Arg_t {
-	const char *fromname;
-	int verbose;
-	MainParam_t mp;
-
-	direntry_t *entry;
-	ClashHandling_t ch;
-} Arg_t;
-
-
-/*
- * Open the named file for read, create the cluster chain, return the
- * directory structure or NULL on error.
- */
-int renameit(char *dosname,
-	     char *longname,
-	     void *arg0,
-	     direntry_t *targetEntry)
-{
-	Arg_t *arg = (Arg_t *) arg0;
-	int fat;
-
-	targetEntry->dir = arg->entry->dir;
-	strncpy(targetEntry->dir.name, dosname, 8);
-	strncpy(targetEntry->dir.ext, dosname + 8, 3);
-
-	if(IS_DIR(targetEntry)) {
-		direntry_t *movedEntry;
-
-		/* get old direntry. It is important that we do this
-		 * on the actual direntry which is stored in the file,
-		 * and not on a copy, because we will modify it, and the
-		 * modification should be visible at file 
-		 * de-allocation time */
-		movedEntry = getDirentry(arg->mp.File);
-		if(movedEntry->Dir != targetEntry->Dir) {
-			/* we are indeed moving it to a new directory */
-			direntry_t subEntry;
-			Stream_t *oldDir;
-			/* we have a directory here. Change its parent link */
-			
-			initializeDirentry(&subEntry, arg->mp.File);
-
-			switch(vfat_lookup(&subEntry, "..", 2, ACCEPT_DIR,
-					   NULL, NULL)) {
-			    case -1:
-				fprintf(stderr,
-					" Directory has no parent entry\n");
-				break;
-			    case -2:
-				return ERROR_ONE;
-			    case 0:
-				GET_DATA(targetEntry->Dir, 0, 0, 0, &fat);
-				if (fat == fat32RootCluster(targetEntry->Dir)) {
-				    fat = 0;
-				}
-
-				subEntry.dir.start[1] = (fat >> 8) & 0xff;
-				subEntry.dir.start[0] = fat & 0xff;
-				dir_write(&subEntry);
-				if(arg->verbose){
-					fprintf(stderr,
-						"Easy, isn't it? I wonder why DOS can't do this.\n");
-				}
-				break;
-			}
-			
-			/* wipe out original entry */			
-			movedEntry->dir.name[0] = DELMARK;
-			dir_write(movedEntry);
-			
-			/* free the old parent, allocate the new one. */
-			oldDir = movedEntry->Dir;
-			*movedEntry = *targetEntry;
-			COPY(targetEntry->Dir);
-			FREE(&oldDir);
-			return 0;
-		}
-	}
-
-	/* wipe out original entry */
-	arg->mp.direntry->dir.name[0] = DELMARK;
-	dir_write(arg->mp.direntry);
-	return 0;
-}
-
-
-
-static int rename_file(direntry_t *entry, MainParam_t *mp)
-/* rename a messy DOS file to another messy DOS file */
-{
-	int result;
-	Stream_t *targetDir;
-	char *shortname;
-	const char *longname;
-
-	Arg_t * arg = (Arg_t *) (mp->arg);
-
-	arg->entry = entry;
-	targetDir = mp->targetDir;
-
-	if (targetDir == entry->Dir){
-		arg->ch.ignore_entry = -1;
-		arg->ch.source = entry->entry;
-		arg->ch.source_entry = entry->entry;
-	} else {
-		arg->ch.ignore_entry = -1;
-		arg->ch.source = -2;
-	}
-
-	longname = mpPickTargetName(mp);
-	shortname = 0;
-	result = mwrite_one(targetDir, longname, shortname,
-			    renameit, (void *)arg, &arg->ch);
-	if(result == 1)
-		return GOT_ONE;
-	else
-		return ERROR_ONE;
-}
-
-
-static int rename_directory(direntry_t *entry, MainParam_t *mp)
-{
-	int ret;
-
-	/* moves a DOS dir */
-	if(isSubdirOf(mp->targetDir, mp->File)) {
-		fprintf(stderr, "Cannot move directory ");
-		fprintPwd(stderr, entry,0);
-		fprintf(stderr, " into one of its own subdirectories (");
-		fprintPwd(stderr, getDirentry(mp->targetDir),0);
-		fprintf(stderr, ")\n");
-		return ERROR_ONE;
-	}
-
-	if(entry->entry == -3) {
-		fprintf(stderr, "Cannot move a root directory: ");
-		fprintPwd(stderr, entry,0);
-		return ERROR_ONE;
-	}
-
-	ret = rename_file(entry, mp);
-	if(ret & ERROR_ONE)
-		return ret;
-	
-	return ret;
-}
-
-static int rename_oldsyntax(direntry_t *entry, MainParam_t *mp)
-{
-	int result;
-	Stream_t *targetDir;
-	const char *shortname, *longname;
-
-	Arg_t * arg = (Arg_t *) (mp->arg);
-	arg->entry = entry;
-	targetDir = entry->Dir;
-
-	arg->ch.ignore_entry = -1;
-	arg->ch.source = entry->entry;
-	arg->ch.source_entry = entry->entry;
-
-#if 0
-	if(!strcasecmp(mp->shortname, arg->fromname)){
-		longname = mp->longname;
-		shortname = mp->targetName;
-	} else {
-#endif
-		longname = mp->targetName;
-		shortname = 0;
-#if 0
-	}
-#endif
-	result = mwrite_one(targetDir, longname, shortname,
-			    renameit, (void *)arg, &arg->ch);
-	if(result == 1)
-		return GOT_ONE;
-	else
-		return ERROR_ONE;
-}
-
-
-static void usage(void)
-{
-	fprintf(stderr,
-		"Mtools version %s, dated %s\n", mversion, mdate);
-	fprintf(stderr,
-		"Usage: %s [-vo] [-D clash_option] file targetfile\n", progname);
-	fprintf(stderr,
-		"       %s [-vo] [-D clash_option] file [files...] target_directory\n", 
-		progname);
-	fprintf(stderr, "\t-v Verbose\n");
-	exit(1);
-}
-
-void mmove(int argc, char **argv, int oldsyntax)
-{
-	Arg_t arg;
-	int c;
-	char shortname[13];
-	char longname[VBUFSIZE];
-	char *def_drive;
-	int i;
-
-	/* get command line options */
-
-	init_clash_handling(& arg.ch);
-
-	/* get command line options */
-	arg.verbose = 0;
-	while ((c = getopt(argc, argv, "vD:o")) != EOF) {
-		switch (c) {
-			case 'v':	/* dummy option for mcopy */
-				arg.verbose = 1;
-				break;
-			case '?':
-				usage();
-			case 'o':
-				handle_clash_options(&arg.ch, c);
-				break;
-			case 'D':
-				if(handle_clash_options(&arg.ch, *optarg))
-					usage();
-				break;
-			default:
-				break;
-		}
-	}
-
-	if (argc - optind < 2)
-		usage();
-
-	init_mp(&arg.mp);		
-	arg.mp.arg = (void *) &arg;
-	arg.mp.openflags = O_RDWR;
-
-	/* look for a default drive */
-	def_drive = NULL;
-	for(i=optind; i<argc; i++)
-		if(skip_drive(argv[i]) > argv[i]){
-			char *drive = get_drive(argv[i], NULL);
-			if(!def_drive)
-				def_drive = drive;
-			else if(strcmp(def_drive, drive) != 0){
-				fprintf(stderr,
-					"Cannot move files across different drives\n");
-				exit(1);
-			}
-		}
-
-	if(def_drive) {
-		char mcwd[MAXPATHLEN];
-
-		strcpy(mcwd, skip_drive(arg.mp.mcwd));
-		if(strlen(def_drive) + 1 + strlen(mcwd) + 1 > MAXPATHLEN){
-			fprintf(stderr,
-				"Path name to current directory too long\n");
-			exit(1);
-		}
-		strcpy(arg.mp.mcwd, def_drive);
-		strcat(arg.mp.mcwd, ":");
-		strcat(arg.mp.mcwd, mcwd);
-	}
-
-	if (oldsyntax && (argc - optind != 2 || strpbrk(":/", argv[argc-1])))
-		oldsyntax = 0;
-
-	arg.mp.lookupflags = 
-	  ACCEPT_PLAIN | ACCEPT_DIR | DO_OPEN_DIRS | NO_DOTS | NO_UNIX;
-
-	if (!oldsyntax){
-		target_lookup(&arg.mp, argv[argc-1]);
-		arg.mp.callback = rename_file;
-		arg.mp.dirCallback = rename_directory;
-	} else {
-		/* do not look up the target; it will be the same dir as the
-		 * source */
-		arg.fromname = _basename(skip_drive(argv[optind]));
-		arg.mp.targetName = strdup(argv[argc-1]);
-		arg.mp.callback = rename_oldsyntax;
-	}
-
-
-	arg.mp.longname = longname;
-	longname[0]='\0';
-
-	arg.mp.shortname = shortname;
-	shortname[0]='\0';
-
-	exit(main_loop(&arg.mp, argv + optind, argc - optind - 1));
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/mpartition.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mpartition.c	(revision 9)
+++ 	(revision )
@@ -1,706 +1,0 @@
-/*
- * mformat.c
- */
-#define DONT_NEED_WAIT
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "mainloop.h"
-#include "fsP.h"
-#include "file.h"
-#include "plain_io.h"
-#include "nameclash.h"
-#include "buffer.h"
-#include "scsi.h"
-#include "partition.h"
-
-#ifdef OS_linux
-#include "linux/hdreg.h"
-
-#define _LINUX_STRING_H_
-#define kdev_t int
-#include "linux/fs.h"
-#undef _LINUX_STRING_H_
-
-#endif
-
-#define tolinear(x) \
-(sector(x)-1+(head(x)+cyl(x)*used_dev->heads)*used_dev->sectors)
-
-
-static inline void print_hsc(hsc *h)
-{
-	printf(" h=%d s=%d c=%d\n", 
-	       head(*h), sector(*h), cyl(*h));
-}
-
-static void set_offset(hsc *h, int offset, int heads, int sectors)
-{
-	int head, sector, cyl;
-
-	if(! heads || !sectors)
-		head = sector = cyl = 0; /* linear mode */
-	else {
-		sector = offset % sectors;
-		offset = offset / sectors;
-
-		head = offset % heads;
-		cyl = offset / heads;
-		if(cyl > 1023) cyl = 1023;
-	}
-
-	h->head = head;
-	h->sector = ((sector+1) & 0x3f) | ((cyl & 0x300)>>2);
-	h->cyl = cyl & 0xff;
-}
-
-void setBeginEnd(struct partition *partTable, int begin, int end,
-				 int heads, int sectors, int activate, int type)
-{
-	set_offset(&partTable->start, begin, heads, sectors);
-	set_offset(&partTable->end, end-1, heads, sectors);
-	set_dword(partTable->start_sect, begin);
-	set_dword(partTable->nr_sects, end-begin);
-	if(activate)
-		partTable->boot_ind = 0x80;
-	else
-		partTable->boot_ind = 0;
-	if(!type) {
-		if(end-begin < 4096)
-			type = 1; /* DOS 12-bit FAT */
-		else if(end-begin<32*2048)
-			type = 4; /* DOS 16-bit FAT, <32M */
-		else
-			type = 6; /* DOS 16-bit FAT >= 32M */
-	}
-	partTable->sys_ind = type;
-}
-
-int consistencyCheck(struct partition *partTable, int doprint, int verbose,
-		     int *has_activated, int *last_end, int *j, 
-		     struct device *used_dev, int target_partition)
-{
-	int i;
-	int inconsistency;
-	
-	*j = 0;
-	*last_end = 1;
-
-	/* quick consistency check */
-	inconsistency = 0;
-	*has_activated = 0;
-	for(i=1; i<5; i++){
-		if(!partTable[i].sys_ind)
-			continue;
-		if(partTable[i].boot_ind)
-			(*has_activated)++;
-		if((used_dev && 
-		    (used_dev->heads != head(partTable[i].end)+1 ||
-		     used_dev->sectors != sector(partTable[i].end))) ||
-		   sector(partTable[i].start) != 1){
-			fprintf(stderr,
-				"Partition %d is not aligned\n",
-				i);
-			inconsistency=1;
-		}
-		
-		if(*j && *last_end > BEGIN(partTable[i])) {
-			fprintf(stderr,
-				"Partitions %d and %d badly ordered or overlapping\n",
-				*j,i);
-			inconsistency=1;
-		}
-			
-		*last_end = END(partTable[i]);
-		*j = i;
-
-		if(used_dev &&
-		   cyl(partTable[i].start) != 1023 &&
-		   tolinear(partTable[i].start) != BEGIN(partTable[i])) {
-			fprintf(stderr,
-				"Start position mismatch for partition %d\n",
-				i);
-			inconsistency=1;
-		}
-		if(used_dev &&
-		   cyl(partTable[i].end) != 1023 &&
-		   tolinear(partTable[i].end)+1 != END(partTable[i])) {
-			fprintf(stderr,
-				"End position mismatch for partition %d\n",
-				i);
-			inconsistency=1;
-		}
-
-		if(doprint && verbose) {
-			if(i==target_partition)
-				putchar('*');
-			else
-				putchar(' ');
-			printf("Partition %d\n",i);
-
-			printf("  active=%x\n", partTable[i].boot_ind);
-			printf("  start:");
-			print_hsc(&partTable[i].start);
-			printf("  type=0x%x\n", partTable[i].sys_ind);
-			printf("  end:");
-			print_hsc(&partTable[i].end);
-			printf("  start=%d\n", BEGIN(partTable[i]));
-			printf("  nr=%d\n", _DWORD(partTable[i].nr_sects));
-			printf("\n");
-		}
-	}
-	return inconsistency;
-}
-
-/* setsize function.  Determines scsicam mapping if this cannot be inferred from
- * any existing partitions. Shamelessly snarfed from the Linux kernel ;-) */
-
-/*
- * Function : static int setsize(unsigned long capacity,unsigned int *cyls,
- *	unsigned int *hds, unsigned int *secs);
- *
- * Purpose : to determine a near-optimal int 0x13 mapping for a
- *	SCSI disk in terms of lost space of size capacity, storing
- *	the results in *cyls, *hds, and *secs.
- *
- * Returns : -1 on failure, 0 on success.
- *
- * Extracted from
- *
- * WORKING                                                    X3T9.2
- * DRAFT                                                        792D
- *
- *
- *                                                        Revision 6
- *                                                         10-MAR-94
- * Information technology -
- * SCSI-2 Common access method
- * transport and SCSI interface module
- * 
- * ANNEX A :
- *
- * setsize() converts a read capacity value to int 13h
- * head-cylinder-sector requirements. It minimizes the value for
- * number of heads and maximizes the number of cylinders. This
- * will support rather large disks before the number of heads
- * will not fit in 4 bits (or 6 bits). This algorithm also
- * minimizes the number of sectors that will be unused at the end
- * of the disk while allowing for very large disks to be
- * accommodated. This algorithm does not use physical geometry. 
- */
-
-static int setsize(unsigned long capacity,unsigned int *cyls,unsigned int *hds,
-    unsigned int *secs) { 
-    unsigned int rv = 0; 
-    unsigned long heads, sectors, cylinders, temp; 
-
-    cylinders = 1024L;			/* Set number of cylinders to max */ 
-    sectors = 62L;      		/* Maximize sectors per track */ 
-
-    temp = cylinders * sectors;		/* Compute divisor for heads */ 
-    heads = capacity / temp;		/* Compute value for number of heads */
-    if (capacity % temp) {		/* If no remainder, done! */ 
-    	heads++;                	/* Else, increment number of heads */ 
-    	temp = cylinders * heads;	/* Compute divisor for sectors */ 
-    	sectors = capacity / temp;	/* Compute value for sectors per
-					       track */ 
-    	if (capacity % temp) {		/* If no remainder, done! */ 
-      	    sectors++;                  /* Else, increment number of sectors */ 
-      	    temp = heads * sectors;	/* Compute divisor for cylinders */
-      	    cylinders = capacity / temp;/* Compute number of cylinders */ 
-      	} 
-    } 
-    if (cylinders == 0) rv=(unsigned)-1;/* Give error if 0 cylinders */ 
-
-    *cyls = (unsigned int) cylinders;	/* Stuff return values */ 
-    *secs = (unsigned int) sectors; 
-    *hds  = (unsigned int) heads; 
-    return(rv); 
-} 
-
-static void setsize0(unsigned long capacity,unsigned int *cyls,
-		     unsigned int *hds, unsigned int *secs)
-{
-	int r;
-
-	/* 1. First try "Megabyte" sizes */
-	if(capacity < 1024 * 2048 && !(capacity % 1024)) {
-		*cyls = capacity >> 11;
-		*hds  = 64;
-		*secs = 32;
-		return;
-	}
-
-	/* then try scsicam's size */
-	r = setsize(capacity,cyls,hds,secs);
-	if(r || *hds > 255 || *secs > 63) {
-		/* scsicam failed. Do megabytes anyways */
-		*cyls = capacity >> 11;
-		*hds  = 64;
-		*secs = 32;
-		return;
-	}
-}
-
-
-static void usage(void)
-{
-	fprintf(stderr, 
-		"Mtools version %s, dated %s\n", mversion, mdate);
-	fprintf(stderr, 
-		"Usage: %s [-pradcv] [-I [-B bootsect-template] [-s sectors] "
-			"[-t cylinders] "
-		"[-h heads] [-T type] [-b begin] [-l length] "
-		"drive\n", progname);
-	exit(1);
-}
-
-void mpartition(int argc, char **argv, int dummy)
-{
-	Stream_t *Stream;
-	unsigned int dummy2;
-
-	int i,j;
-
-	int sec_per_cyl;
-	int doprint = 0;
-	int verbose = 0;
-	int create = 0;
-	int force = 0;
-	int length = 0;
-	int remove = 0;
-	int initialize = 0;
-	int tot_sectors=0;
-	int type = 0;
-	int begin_set = 0;
-	int size_set = 0;
-	int end_set = 0;
-	int last_end = 0;
-	int activate = 0;
-	int has_activated = 0;
-	int inconsistency=0;
-	int begin=0;
-	int end=0;
-	int sizetest=0;
-	int dirty = 0;
-	int open2flags = NO_OFFSET;
-	
-	int c;
-	struct device used_dev;
-	int argtracks, argheads, argsectors;
-
-	char *drive, name[EXPAND_BUF];
-	unsigned char buf[512];
-	struct partition *partTable=(struct partition *)(buf+ 0x1ae);
-	struct device *dev;
-	char errmsg[200];
-	char *bootSector=0;
-
-	argtracks = 0;
-	argheads = 0;
-	argsectors = 0;
-
-	/* get command line options */
-	while ((c = getopt(argc, argv, "adprcIT:t:h:s:fvpb:l:S:B:")) != EOF) {
-		switch (c) {
-			case 'B':
-				bootSector = optarg;
-				break;
-			case 'a':
-				/* no privs, as it could be abused to
-				 * make other partitions unbootable, or
-				 * to boot a rogue kernel from this one */
-				open2flags |= NO_PRIV;
-				activate = 1;
-				dirty = 1;
-				break;
-			case 'd':
-				activate = -1;
-				dirty = 1;
-				break;
-			case 'p':
-				doprint = 1;
-				break;
-			case 'r':
-				remove = 1;
-				dirty = 1;
-				break;
-			case 'I':
-				/* could be abused to nuke all other 
-				 * partitions */
-				open2flags |= NO_PRIV;
-				initialize = 1;
-				dirty = 1;
-				break;
-			case 'c':
-				create = 1;
-				dirty = 1;
-				break;
-
-			case 'T':
-				/* could be abused to "manually" create
-				 * extended partitions */
-				open2flags |= NO_PRIV;
-				type = strtoul(optarg,0,0);
-				break;
-
-			case 't':
-				argtracks = atoi(optarg);
-				break;
-			case 'h':
-				argheads = atoi(optarg);
-				break;
-			case 's':
-				argsectors = atoi(optarg);
-				break;
-
-			case 'f':
-				/* could be abused by creating overlapping
-				 * partitions and other such Snafu */
-				open2flags |= NO_PRIV;
-				force = 1;
-				break;
-
-			case 'v':
-				verbose++;
-				break;
-			case 'S':
-				/* testing only */
-				/* could be abused to create partitions
-				 * extending beyond the actual size of the
-				 * device */
-				open2flags |= NO_PRIV;
-				tot_sectors = strtoul(optarg,0,0);
-				sizetest = 1;
-				break;
-			case 'b':
-				begin_set = 1;
-				begin = atoi(optarg);
-				break;
-			case 'l':
-				size_set = 1;
-				length = atoi(optarg);
-				break;
-
-			default:
-				usage();
-		}
-	}
-
-	if (argc - optind != 1 || skip_drive(argv[optind]) == argv[optind])
-		usage();
-	
-	drive = get_drive(argv[optind], NULL);
-
-	/* check out a drive whose letter and parameters match */	
-	sprintf(errmsg, "Drive '%s:' not supported", drive);
-	Stream = 0;
-	for(dev=devices;dev->drive;dev++) {
-		FREE(&(Stream));
-		/* drive letter */
-		if (strcmp(dev->drive, drive) != 0)
-			continue;
-		if (dev->partition < 1 || dev->partition > 4) {
-			sprintf(errmsg, 
-				"Drive '%c:' is not a partition", 
-				drive);
-			continue;
-		}
-		used_dev = *dev;
-
-		SET_INT(used_dev.tracks, argtracks);
-		SET_INT(used_dev.heads, argheads);
-		SET_INT(used_dev.sectors, argsectors);
-		
-		expand(dev->name, name);
-		Stream = SimpleFileOpen(&used_dev, dev, name,
-					dirty ? O_RDWR : O_RDONLY, 
-					errmsg, open2flags, 1, 0);
-
-		if (!Stream) {
-#ifdef HAVE_SNPRINTF
-			snprintf(errmsg,199,"init: open: %s", strerror(errno));
-#else
-			sprintf(errmsg,"init: open: %s", strerror(errno));
-#endif
-			continue;
-		}			
-
-
-		/* try to find out the size */
-		if(!sizetest)
-			tot_sectors = 0;
-		if(IS_SCSI(dev)) {
-			unsigned char cmd[10];
-			unsigned char data[10];
-			cmd[0] = SCSI_READ_CAPACITY;
-			memset ((void *) &cmd[2], 0, 8);
-			memset ((void *) &data[0], 137, 10);
-			scsi_cmd(get_fd(Stream), cmd, 10, SCSI_IO_READ,
-				 data, 10, get_extra_data(Stream));
-			
-			tot_sectors = 1 +
-				(data[0] << 24) +
-				(data[1] << 16) +
-				(data[2] <<  8) +
-				(data[3]      );
-			if(verbose)
-				printf("%d sectors in total\n", tot_sectors);
-		}
-
-#ifdef OS_linux
-		if (tot_sectors == 0) {
-			ioctl(get_fd(Stream), BLKGETSIZE, &tot_sectors);
-		}
-#endif
-
-		/* read the partition table */
-		if (READS(Stream, (char *) buf, 0, 512) != 512) {
-#ifdef HAVE_SNPRINTF
-			snprintf(errmsg, 199,
-				"Error reading from '%s', wrong parameters?",
-				name);
-#else
-			sprintf(errmsg,
-				"Error reading from '%s', wrong parameters?",
-				name);
-#endif
-			continue;
-		}
-		if(verbose>=2)
-			print_sector("Read sector", buf, 512);
-		break;
-	}
-
-	/* print error msg if needed */	
-	if ( dev->drive == 0 ){
-		FREE(&Stream);
-		fprintf(stderr,"%s: %s\n", argv[0],errmsg);
-		exit(1);
-	}
-
-	if((used_dev.sectors || used_dev.heads) &&
-	   (!used_dev.sectors || !used_dev.heads)) {
-		fprintf(stderr,"You should either indicate both the number of sectors and the number of heads,\n");
-		fprintf(stderr," or none of them\n");
-		exit(1);
-	}
-
-	if(initialize) {
-		if (bootSector) {
-			int fd;
-			fd = open(bootSector, O_RDONLY);
-			if (fd < 0) {
-				perror("open boot sector");
-				exit(1);
-			}
-			read(fd, (char *) buf, 512);
-		}
-		memset((char *)(partTable+1), 0, 4*sizeof(*partTable));
-		set_dword(((unsigned char*)buf)+510, 0xaa55);
-	}
-
-	/* check for boot signature, and place it if needed */
-	if((buf[510] != 0x55) || (buf[511] != 0xaa)) {
-		fprintf(stderr,"Boot signature not set\n");
-		fprintf(stderr,
-			"Use the -I flag to initialize the partition table, and set the boot signature\n");
-		inconsistency = 1;
-	}
-	
-	if(remove){
-		if(!partTable[dev->partition].sys_ind)
-			fprintf(stderr,
-				"Partition for drive %c: does not exist\n",
-				drive);
-		if((partTable[dev->partition].sys_ind & 0x3f) == 5) {
-			fprintf(stderr,
-				"Partition for drive %c: may be an extended partition\n",
-				drive);
-			fprintf(stderr,
-				"Use the -f flag to remove it anyways\n");
-			inconsistency = 1;
-		}
-		memset(&partTable[dev->partition], 0, sizeof(*partTable));
-	}
-
-	if(create && partTable[dev->partition].sys_ind) {
-		fprintf(stderr,
-			"Partition for drive %c: already exists\n", drive);
-		fprintf(stderr,
-			"Use the -r flag to remove it before attempting to recreate it\n");
-	}
-
-
-	/* find out number of heads and sectors, and whether there is
-	* any activated partition */
-	has_activated = 0;
-	for(i=1; i<5; i++){
-		if(!partTable[i].sys_ind)
-			continue;
-		
-		if(partTable[i].boot_ind)
-			has_activated++;
-
-		/* set geometry from entry */
-		if (!used_dev.heads)
-			used_dev.heads = head(partTable[i].end)+1;
-		if(!used_dev.sectors)
-			used_dev.sectors = sector(partTable[i].end);
-		if(i<dev->partition && !begin_set)
-			begin = END(partTable[i]);
-		if(i>dev->partition && !end_set && !size_set) {
-			end = BEGIN(partTable[i]);
-			end_set = 1;
-		}
-	}
-
-#ifdef OS_linux
-	if(!used_dev.sectors && !used_dev.heads) {
-		if(!IS_SCSI(dev)) {
-			struct hd_geometry geom;
-			if(ioctl(get_fd(Stream), HDIO_GETGEO, &geom) == 0) {
-				used_dev.heads = geom.heads;
-				used_dev.sectors = geom.sectors;
-			}
-		}
-	}
-#endif
-
-	if(!used_dev.sectors && !used_dev.heads) {
-		if(tot_sectors)
-			setsize0(tot_sectors,&dummy2,&used_dev.heads,
-					 &used_dev.sectors);
-		else {
-			used_dev.heads = 64;
-			used_dev.sectors = 32;
-		}
-	}
-
-	if(verbose)
-		fprintf(stderr,"sectors: %d heads: %d %d\n",
-			used_dev.sectors, used_dev.heads, tot_sectors);
-
-	sec_per_cyl = used_dev.sectors * used_dev.heads;
-	if(create) {
-		if(!end_set && tot_sectors) {
-			end = tot_sectors - tot_sectors % sec_per_cyl;
-			end_set = 1;
-		}
-		
-		/* if the partition starts right at the beginning of
-		 * the disk, keep one track unused to allow place for
-		 * the master boot record */
-		if(!begin && !begin_set)
-			begin = used_dev.sectors;
-		if(!size_set && used_dev.tracks) {
-			size_set = 2;
-			length = sec_per_cyl * used_dev.tracks;
-
-			/*  round the size in order to take
-			 * into account any "hidden" sectors */
-
-			/* do we anchor this at the beginning ?*/
-			if(begin_set || dev->partition <= 2 || !end_set)
-				length -= begin % sec_per_cyl;
-			else if(end - length < begin)
-				/* truncate any overlap */
-				length = end - begin;
-		}
-		if(size_set) {
-			if(!begin_set && dev->partition >2 && end_set)
-				begin = end - length;
-			else
-				end = begin + length;
-		} else if(!end_set) {
-			fprintf(stderr,"Unknown size\n");
-			exit(1);
-		}
-
-		setBeginEnd(&partTable[dev->partition], begin, end,
-					used_dev.heads, used_dev.sectors, 
-					!has_activated, type);
-	}
-
-	if(activate) {
-		if(!partTable[dev->partition].sys_ind) {
-			fprintf(stderr,
-				"Partition for drive %c: does not exist\n",
-				drive);
-		} else {
-			switch(activate) {
-				case 1:
-					partTable[dev->partition].boot_ind=0x80;
-					break;
-				case -1:
-					partTable[dev->partition].boot_ind=0x00;
-					break;
-			}
-		}
-	}
-
-
-	inconsistency |= consistencyCheck(partTable, doprint, verbose,
-					  &has_activated, &last_end, &j,
-					  &used_dev, dev->partition);
-
-	if(doprint && !inconsistency && partTable[dev->partition].sys_ind) {
-		printf("The following command will recreate the partition for drive %c:\n", 
-		       drive);
-		used_dev.tracks = 
-			(_DWORD(partTable[dev->partition].nr_sects) +
-			 (BEGIN(partTable[dev->partition]) % sec_per_cyl)) / 
-			sec_per_cyl;
-		printf("mpartition -c -t %d -h %d -s %d -b %u %c:\n",
-		       used_dev.tracks, used_dev.heads, used_dev.sectors,
-		       BEGIN(partTable[dev->partition]), drive);
-	}
-
-	if(tot_sectors && last_end >tot_sectors) {
-		fprintf(stderr,
-			"Partition %d exceeds beyond end of disk\n",
-			j);
-		exit(1);
-	}
-
-	
-	switch(has_activated) {
-		case 0:
-			fprintf(stderr,
-				"Warning: no active (bootable) partition present\n");
-			break;
-		case 1:
-			break;
-		default:
-			fprintf(stderr,
-				"Warning: %d active (bootable) partitions present\n",
-				has_activated);
-			fprintf(stderr,
-				"Usually, a disk should have exactly one active partition\n");
-			break;
-	}
-	
-	if(inconsistency && !force) {
-		fprintf(stderr,
-			"inconsistency detected!\n" );
-		if(dirty)
-			fprintf(stderr,
-				"Retry with the -f switch to go ahead anyways\n");
-		exit(1);
-	}
-
-	if(dirty) {
-		/* write data back to the disk */
-		if(verbose>=2)
-			print_sector("Writing sector", buf, 512);
-		if (WRITES(Stream, (char *) buf, 0, 512) != 512) {
-			fprintf(stderr,"Error writing partition table");
-			exit(1);
-		}
-		if(verbose>=3)
-			print_sector("Sector written", buf, 512);
-		FREE(&Stream);
-	}
-	exit(0);
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/msdos.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/msdos.h	(revision 9)
+++ 	(revision )
@@ -1,237 +1,0 @@
-#ifndef MTOOLS_MSDOS_H
-#define MTOOLS_MSDOS_H
-
-/*
- * msdos common header file
- */
-
-#define MAX_SECTOR	8192   		/* largest sector size */
-#define MDIR_SIZE	32		/* MSDOS directory entry size in bytes*/
-#define MAX_CLUSTER	8192		/* largest cluster size */
-#define MAX_PATH	128		/* largest MSDOS path length */
-#define MAX_DIR_SECS	64		/* largest directory (in sectors) */
-#define MSECTOR_SIZE    msector_size
-
-#define NEW		1
-#define OLD		0
-
-#define _WORD(x) ((unsigned char)(x)[0] + (((unsigned char)(x)[1]) << 8))
-#define _DWORD(x) (_WORD(x) + (_WORD((x)+2) << 16))
-
-#define DELMARK ((char) 0xe5)
-
-struct directory {
-	char name[8];			/*  0 file name */
-	char ext[3];			/*  8 file extension */
-	unsigned char attr;		/* 11 attribute byte */
-	unsigned char Case;		/* 12 case of short filename */
-	unsigned char ctime_ms;		/* 13 creation time, milliseconds (?) */
-	unsigned char ctime[2];		/* 14 creation time */
-	unsigned char cdate[2];		/* 16 creation date */
-	unsigned char adate[2];		/* 18 last access date */
-	unsigned char startHi[2];	/* 20 start cluster, Hi */
-	unsigned char time[2];		/* 22 time stamp */
-	unsigned char date[2];		/* 24 date stamp */
-	unsigned char start[2];		/* 26 starting cluster number */
-	unsigned char size[4];		/* 28 size of the file */
-};
-
-#define EXTCASE 0x10
-#define BASECASE 0x8
-
-#define MAX32 0xffffffff
-#define MAX_SIZE 0x7fffffff
-
-#define FILE_SIZE(dir)  (_DWORD((dir)->size))
-#define START(dir) (_WORD((dir)->start))
-#define STARTHI(dir) (_WORD((dir)->startHi))
-
-/* ASSUMPTION: long is at least 32 bits */
-UNUSED(static inline void set_dword(unsigned char *data, unsigned long value))
-{
-	data[3] = (value >> 24) & 0xff;
-	data[2] = (value >> 16) & 0xff;
-	data[1] = (value >>  8) & 0xff;
-	data[0] = (value >>  0) & 0xff;
-}
-
-
-/* ASSUMPTION: short is at least 16 bits */
-UNUSED(static inline void set_word(unsigned char *data, unsigned short value))
-{
-	data[1] = (value >>  8) & 0xff;
-	data[0] = (value >>  0) & 0xff;
-}
-
-
-/*
- *	    hi byte     |    low byte
- *	|7|6|5|4|3|2|1|0|7|6|5|4|3|2|1|0|
- *  | | | | | | | | | | | | | | | | |
- *  \   7 bits    /\4 bits/\ 5 bits /
- *     year +80     month     day
- */
-#define	DOS_YEAR(dir) (((dir)->date[1] >> 1) + 1980)
-#define	DOS_MONTH(dir) (((((dir)->date[1]&0x1) << 3) + ((dir)->date[0] >> 5)))
-#define	DOS_DAY(dir) ((dir)->date[0] & 0x1f)
-
-/*
- *	    hi byte     |    low byte
- *	|7|6|5|4|3|2|1|0|7|6|5|4|3|2|1|0|
- *      | | | | | | | | | | | | | | | | |
- *      \  5 bits /\  6 bits  /\ 5 bits /
- *         hour      minutes     sec*2
- */
-#define	DOS_HOUR(dir) ((dir)->time[1] >> 3)
-#define	DOS_MINUTE(dir) (((((dir)->time[1]&0x7) << 3) + ((dir)->time[0] >> 5)))
-#define	DOS_SEC(dir) (((dir)->time[0] & 0x1f) * 2)
-
-
-typedef struct InfoSector_t {
-	unsigned char signature1[4];
-	unsigned char filler1[0x1e0];
-	unsigned char signature2[4];
-	unsigned char count[4];
-	unsigned char pos[4];
-	unsigned char filler2[14];
-	unsigned char signature3[2];
-} InfoSector_t;
-
-#define INFOSECT_SIGNATURE1 0x41615252
-#define INFOSECT_SIGNATURE2 0x61417272
-
-
-typedef struct label_blk_t {
-	unsigned char physdrive;	/* 36 physical drive ? */
-	unsigned char reserved;		/* 37 reserved */
-	unsigned char dos4;		/* 38 dos > 4.0 diskette */
-	unsigned char serial[4];       	/* 39 serial number */
-	char label[11];			/* 43 disk label */
-	char fat_type[8];		/* 54 FAT type */
-} label_blk_t;
-
-/* FAT32 specific info in the bootsector */
-typedef struct fat32_t {
-	unsigned char bigFat[4];	/* 36 nb of sectors per FAT */
-	unsigned char extFlags[2];     	/* 40 extension flags */
-	unsigned char fsVersion[2];	/* 42 ? */
-	unsigned char rootCluster[4];	/* 44 start cluster of root dir */
-	unsigned char infoSector[2];	/* 48 changeable global info */
-	unsigned char backupBoot[2];	/* 50 back up boot sector */
-	unsigned char reserved[6];	/* 52 ? */
-	unsigned char reserved2[6];	/* 52 ? */
-	struct label_blk_t labelBlock;
-} fat32; /* ends at 58 */
-
-typedef struct oldboot_t {
-	struct label_blk_t labelBlock;
-	unsigned char res_2m;		/* 62 reserved by 2M */
-	unsigned char CheckSum;		/* 63 2M checksum (not used) */
-	unsigned char fmt_2mf;		/* 64 2MF format version */
-	unsigned char wt;		/* 65 1 if write track after format */
-	unsigned char rate_0;		/* 66 data transfer rate on track 0 */
-	unsigned char rate_any;		/* 67 data transfer rate on track<>0 */
-	unsigned char BootP[2];		/* 68 offset to boot program */
-	unsigned char Infp0[2];		/* 70 T1: information for track 0 */
-	unsigned char InfpX[2];		/* 72 T2: information for track<>0 */
-	unsigned char InfTm[2];		/* 74 T3: track sectors size table */
-	unsigned char DateF[2];		/* 76 Format date */
-	unsigned char TimeF[2];		/* 78 Format time */
-	unsigned char junk[1024 - 80];	/* 80 remaining data */
-} oldboot_t;
-
-struct bootsector {
-	unsigned char jump[3];		/* 0  Jump to boot code */
-	char banner[8] PACKED;	       	/* 3  OEM name & version */
-	unsigned char secsiz[2] PACKED;	/* 11 Bytes per sector hopefully 512 */
-	unsigned char clsiz;    	/* 13 Cluster size in sectors */
-	unsigned char nrsvsect[2];	/* 14 Number of reserved (boot) sectors */
-	unsigned char nfat;		/* 16 Number of FAT tables hopefully 2 */
-	unsigned char dirents[2] PACKED;/* 17 Number of directory slots */
-	unsigned char psect[2] PACKED; 	/* 19 Total sectors on disk */
-	unsigned char descr;		/* 21 Media descriptor=first byte of FAT */
-	unsigned char fatlen[2];	/* 22 Sectors in FAT */
-	unsigned char nsect[2];		/* 24 Sectors/track */
-	unsigned char nheads[2];	/* 26 Heads */
-	unsigned char nhs[4];		/* 28 number of hidden sectors */
-	unsigned char bigsect[4];	/* 32 big total sectors */
-
-	union {
-		struct fat32_t fat32;
-		struct oldboot_t old;
-	} ext;
-};
-
-#define CHAR(x) (boot->x[0])
-#define WORD(x) (_WORD(boot->x))
-#define DWORD(x) (_DWORD(boot->x))
-#define OFFSET(x) (((char *) (boot->x)) - ((char *)(boot->jump)))
-
-
-extern struct OldDos_t {
-	int tracks;
-	int sectors;
-	int heads;
-	
-	int dir_len;
-	int cluster_size;
-	int fat_len;
-
-	int media;
-} old_dos[];
-
-#define FAT12 4085 /* max. number of clusters described by a 12 bit FAT */
-#define FAT16 65525
-
-#define ATTR_ARCHIVE 0x20
-#define ATTR_DIR 0x10
-#define ATTR_LABEL 0x8
-#define ATTR_SYSTEM 0x4
-#define ATTR_HIDDEN 0x2
-#define ATTR_READONLY 0x1
-
-#define HAS_BIT(entry,x) ((entry)->dir.attr & (x))
-
-#define IS_ARCHIVE(entry) (HAS_BIT((entry),ATTR_ARCHIVE))
-#define IS_DIR(entry) (HAS_BIT((entry),ATTR_DIR))
-#define IS_LABEL(entry) (HAS_BIT((entry),ATTR_LABEL))
-#define IS_SYSTEM(entry) (HAS_BIT((entry),ATTR_SYSTEM))
-#define IS_HIDDEN(entry) (HAS_BIT((entry),ATTR_HIDDEN))
-#define IS_READONLY(entry) (HAS_BIT((entry),ATTR_READONLY))
-
-
-#define MAX_SECT_PER_CLUSTER 64
-/* Experimentally, it turns out that DOS only accepts cluster sizes
- * which are powers of two, and less than 128 sectors (else it gets a
- * divide overflow) */
-
-
-#define FAT_SIZE(bits, sec_siz, clusters) \
-	((((clusters)+2) * ((bits)/4) - 1) / 2 / (sec_siz) + 1)
-
-#define NEEDED_FAT_SIZE(x) FAT_SIZE((x)->fat_bits, (x)->sector_size, \
-				    (x)->num_clus)
-
-/* disk size taken by FAT and clusters */
-#define DISK_SIZE(bits, sec_siz, clusters, n, cluster_size) \
-	((n) * FAT_SIZE(bits, sec_siz, clusters) + \
-	 (clusters) * (cluster_size))
-
-#define TOTAL_DISK_SIZE(bits, sec_siz, clusters, n, cluster_size) \
-	(DISK_SIZE(bits, sec_siz, clusters, n, cluster_size) + 2)
-/* approx. total disk size: assume 1 boot sector and one directory sector */
-
-extern const char *mversion;
-extern const char *mdate;
-
-extern char *Version;
-extern char *Date;
-
-
-int init(char drive, int mode);
-
-#define MT_READ 1
-#define MT_WRITE 2
-
-#endif
-
Index: trunk/minix/commands/i386/mtools-3.9.7/mshowfat.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mshowfat.c	(revision 9)
+++ 	(revision )
@@ -1,87 +1,0 @@
-/*
- * mcopy.c
- * Copy an MSDOS files to and from Unix
- *
- */
-
-
-#define LOWERCASE
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "vfat.h"
-#include "mainloop.h"
-#include "plain_io.h"
-#include "nameclash.h"
-#include "file.h"
-#include "fs.h"
-
-
-
-typedef struct Arg_t {
-	char *target;
-	MainParam_t mp;
-	ClashHandling_t ch;
-	Stream_t *sourcefile;
-} Arg_t;
-
-static int dos_showfat(direntry_t *entry, MainParam_t *mp)
-{
-	Stream_t *File=mp->File;
-
-	fprintPwd(stdout, entry,0);
-	putchar(' ');
-	printFat(File);
-	printf("\n");
-	return GOT_ONE;
-}
-
-static int unix_showfat(MainParam_t *mp)
-{
-	fprintf(stderr,"File does not reside on a Dos fs\n");
-	return ERROR_ONE;
-}
-
-
-static void usage(void)
-{
-	fprintf(stderr,
-		"Mtools version %s, dated %s\n", mversion, mdate);
-	fprintf(stderr,
-		"Usage: %s file ...\n", progname);
-	exit(1);
-}
-
-void mshowfat(int argc, char **argv, int mtype)
-{
-	Arg_t arg;
-	int c, ret;
-	
-	/* get command line options */
-
-	init_clash_handling(& arg.ch);
-
-	/* get command line options */
-	while ((c = getopt(argc, argv, "")) != EOF) {
-		switch (c) {
-			case '?':
-				usage();
-				break;
-		}
-	}
-
-	if (argc - optind < 1)
-		usage();
-
-	/* only 1 file to copy... */
-	init_mp(&arg.mp);
-	arg.mp.arg = (void *) &arg;
-
-	arg.mp.callback = dos_showfat;
-	arg.mp.unixcallback = unix_showfat;
-
-	arg.mp.lookupflags = ACCEPT_PLAIN | ACCEPT_DIR | DO_OPEN;
-	ret=main_loop(&arg.mp, argv + optind, argc - optind);
-	exit(ret);
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/mtools.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mtools.c	(revision 9)
+++ 	(revision )
@@ -1,186 +1,0 @@
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "partition.h"
-#include "vfat.h"
-
-const char *progname;
-
-static const struct dispatch {
-	const char *cmd;
-	void (*fn)(int, char **, int);
-	int type;
-} dispatch[] = {
-	{"attrib",mattrib, 0},
-	{"badblocks",mbadblocks, 0},
-	{"cat",mcat, 0},
-	{"cd",mcd, 0},
-	{"copy",mcopy, 0},
-	{"del",mdel, 0},
-	{"deltree",mdel, 2},
-	{"dir",mdir, 0},
-	{"doctorfat",mdoctorfat, 0},
-	{"du",mdu, 0},
-	{"format",mformat, 0},
-	{"info", minfo, 0},
-	{"label",mlabel, 0},
-	{"md",mmd, 0},
-	{"mkdir",mmd, 0},
-#ifdef OS_linux
-	{"mount",mmount, 0},
-#endif
-	{"partition",mpartition, 0},
-	{"rd",mdel, 1},
-	{"rmdir",mdel, 1},
-	{"read",mcopy, 0},
-	{"move",mmove, 0},
-	{"ren",mmove, 1},
-	{"showfat", mshowfat, 0},
-#ifndef NO_CONFIG
-	{"toolstest", mtoolstest, 0},
-#endif
-	{"type",mcopy, 1},
-	{"write",mcopy, 0},
-#ifndef OS_Minix
-	{"zip", mzip, 0}
-#endif
-};
-#define NDISPATCH (sizeof dispatch / sizeof dispatch[0])
-
-int main(int argc,char **argv)
-{
-	const char *name;
-	int i;
-
-	init_privs();
-#ifdef __EMX__
-	_wildcard(&argc,&argv);
-#endif
-
-/*#define PRIV_TEST*/
-
-#ifdef PRIV_TEST
-	{ 
-		int euid;
-		char command[100];
-	
-		printf("INIT: %d %d\n", getuid(), geteuid());
-		drop_privs();
-		printf("DROP: %d %d\n", getuid(), geteuid());
-		reclaim_privs();
-		printf("RECLAIM: %d %d\n", getuid(), geteuid());
-		euid = geteuid();
-		if(argc & 1) {
-			drop_privs();
-			printf("DROP: %d %d\n", getuid(), geteuid());
-		}
-		if(!((argc-1) & 2)) {
-			destroy_privs();
-			printf("DESTROY: %d %d\n", getuid(), geteuid());
-		}
-		sprintf(command, "a.out %d", euid);
-		system(command);
-		return 1;
-	}
-#endif
-
-
-#ifdef __EMX__
-       _wildcard(&argc,&argv);
-#endif 
-
-
-	/* check whether the compiler lays out structures in a sane way */
-	if(sizeof(struct partition) != 16 ||
-	   sizeof(struct directory) != 32 ||
-	   sizeof(struct vfat_subentry) !=32) {
-		fprintf(stderr,"Mtools has not been correctly compiled\n");
-		fprintf(stderr,"Recompile it using a more recent compiler\n");
-		return 137;
-	}
-
-#ifdef __EMX__
-       argv[0] = _getname(argv[0]); _remext(argv[0]); name = argv[0];
-#else  
-	name = _basename(argv[0]);
-#endif
-
-#if 0
-	/* this allows the different tools to be called as "mtools -c <command>"
-	** where <command> is mdir, mdel, mcopy etcetera
-	** Mainly done for the BeOS, which doesn't support links yet.
-	*/
-
-	if(argc >= 3 && 
-	   !strcmp(argv[1], "-c") &&
-	   !strcmp(name, "mtools")) {
-		argc-=2;
-		argv+=2;
-		name = argv[0];
-	}
-#endif
-
-	/* print the version */
-	if(argc >= 2 && 
-	   (strcmp(argv[1], "-V") == 0 || strcmp(argv[1], "--version") ==0)) {
-		printf("%c%s version %s, dated %s\n", 
-		       toupper(name[0]), name+1,
-		       mversion, mdate);
-		printf("configured with the following options: ");
-#ifdef USE_XDF
-		printf("enable-xdf ");
-#else
-		printf("disable-xdf ");
-#endif
-#ifdef USING_VOLD
-		printf("enable-vold ");
-#else
-		printf("disable-vold ");
-#endif
-#ifdef USING_NEW_VOLD
-		printf("enable-new-vold ");
-#else
-		printf("disable-new-vold ");
-#endif
-#ifdef DEBUG
-		printf("enable-debug ");
-#else
-		printf("disable-debug ");
-#endif
-#ifdef USE_RAWTERM
-		printf("enable-raw-term ");
-#else
-		printf("disable-raw-term ");
-#endif
-		printf("\n");
-		return 0;
-	}
-
-	if (argc >= 2 && strcmp(name, "mtools") == 0) {
-		/* mtools command ... */
-		argc--;
-		argv++;
-		name = argv[0];
-	}
-	progname = argv[0];
-
-	read_config();
-	setup_signal();
-	for (i = 0; i < NDISPATCH; i++) {
-		if (!strcmp(name,dispatch[i].cmd)
-		    || (name[0] == 'm' && !strcmp(name+1,dispatch[i].cmd)))
-			dispatch[i].fn(argc, argv, dispatch[i].type);
-	}
-	if (strcmp(name,"mtools"))
-		fprintf(stderr,"Unknown mtools command '%s'\n",name);
-	fprintf(stderr,"Usage: mtools [-V] command [-options] arguments ...\n");
-	fprintf(stderr,"Supported commands:");
-	for (i = 0; i < NDISPATCH; i++) {
-		fprintf(stderr, i%8 == 0 ? "\n\t" : ", ");
-		fprintf(stderr, "%s", dispatch[i].cmd);
-	}
-	putc('\n', stderr);
-	fprintf(stderr, "Use 'mtools command -?' for help per command\n");
-
-	return 1;
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/mtools.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mtools.h	(revision 9)
+++ 	(revision )
@@ -1,234 +1,0 @@
-#ifndef MTOOLS_MTOOLS_H
-#define MTOOLS_MTOOLS_H
-
-#include "msdos.h"
-
-#if defined(OS_sco3)
-#define MAXPATHLEN 1024
-#include <signal.h>
-extern int lockf(int, int, off_t);  /* SCO has no proper include file for lockf */
-#endif 
-
-#define SCSI_FLAG 1
-#define PRIV_FLAG 2
-#define NOLOCK_FLAG 4
-#define USE_XDF_FLAG 8
-#define MFORMAT_ONLY_FLAG 16
-#define VOLD_FLAG 32
-#define FLOPPYD_FLAG 64
-#define FILTER_FLAG 128
-
-#define IS_SCSI(x)  ((x) && ((x)->misc_flags & SCSI_FLAG))
-#define IS_PRIVILEGED(x) ((x) && ((x)->misc_flags & PRIV_FLAG))
-#define IS_NOLOCK(x) ((x) && ((x)->misc_flags & NOLOCK_FLAG))
-#define IS_MFORMAT_ONLY(x) ((x) && ((x)->misc_flags & MFORMAT_ONLY_FLAG))
-#define SHOULD_USE_VOLD(x) ((x)&& ((x)->misc_flags & VOLD_FLAG))
-#define SHOULD_USE_XDF(x) ((x)&& ((x)->misc_flags & USE_XDF_FLAG))
-
-typedef struct device {
-	const char *name;       /* full path to device */
-
-	char *drive;	   	    	/* the drive letter / device name */
-	int fat_bits;			/* FAT encoding scheme */
-
-	unsigned int mode;		/* any special open() flags */
-	unsigned int tracks;	/* tracks */
-	unsigned int heads;		/* heads */
-	unsigned int sectors;	/* sectors */
-	unsigned int hidden;	/* number of hidden sectors. Used for
-							 * mformatting partitioned devices */
-
-	off_t offset;	       	/* skip this many bytes */
-
-	unsigned int partition;
-
-	unsigned int misc_flags;
-
-	/* Linux only stuff */
-	unsigned int ssize;
-	unsigned int use_2m;
-
-	char *precmd;		/* command to be executed before opening
-						 * the drive */
-
-	/* internal variables */
-	int file_nr;		/* used during parsing */
-	int blocksize;	        /* size of disk block in bytes */
-
-	const char *cfg_filename; /* used for debugging purposes */
-} device_t;
-
-
-#ifndef OS_linux
-#define BOOTSIZE 512
-#else
-#define BOOTSIZE 256
-#endif
-
-#include "stream.h"
-
-
-extern const char *short_illegals, *long_illegals;
-
-#define maximize(target, max) do { \
-  if(max < 0) { \
-    if(target > 0) \
-      target = 0; \
-  } else if(target > max) { \
-    target = max; \
-  } \
-} while(0)
-
-#define minimize(target, min) do { \
-  if(target < min) \
-    target = min; \
-} while(0) 
-
-int init_geom(int fd, struct device *dev, struct device *orig_dev,
-	      struct stat *stat);
-
-int readwrite_sectors(int fd, /* file descriptor */
-		      int *drive,
-		      int rate,
-		      int seektrack,
-		      int track, int head, int sector, int size, /* address */
-		      char *data, 
-		      int bytes,
-		      int direction,
-		      int retries);
-
-int lock_dev(int fd, int mode, struct device *dev);
-
-char *unix_normalize (char *ans, char *name, char *ext);
-char *dos_name(char *filename, int verbose, int *mangled, char *buffer);
-struct directory *mk_entry(const char *filename, char attr,
-			   unsigned int fat, size_t size, time_t date,
-			   struct directory *ndir);
-int copyfile(Stream_t *Source, Stream_t *Target);
-int getfreeMinClusters(Stream_t *Stream, size_t ref);
-
-FILE *opentty(int mode);
-
-int is_dir(Stream_t *Dir, char *path);
-void bufferize(Stream_t **Dir);
-
-int dir_grow(Stream_t *Dir, int size);
-int match(const char *, const char *, char *, int, int);
-
-char *unix_name(char *name, char *ext, char Case, char *answer);
-void *safe_malloc(size_t size);
-Stream_t *open_filter(Stream_t *Next);
-
-extern int got_signal;
-/* int do_gotsignal(char *, int);
-#define got_signal do_gotsignal(__FILE__, __LINE__) */
-
-void setup_signal(void);
-
-
-#define SET_INT(target, source) \
-if(source)target=source
-
-
-UNUSED(static inline int compare (long ref, long testee))
-{
-	return (ref && ref != testee);
-}
-
-Stream_t *GetFs(Stream_t *Fs);
-
-char *label_name(char *filename, int verbose, 
-		 int *mangled, char *ans);
-
-/* environmental variables */
-extern unsigned int mtools_skip_check;
-extern unsigned int mtools_fat_compatibility;
-extern unsigned int mtools_ignore_short_case;
-extern unsigned int mtools_no_vfat;
-extern unsigned int mtools_numeric_tail;
-extern unsigned int mtools_dotted_dir;
-extern unsigned int mtools_twenty_four_hour_clock;
-extern char *mtools_date_string;
-extern unsigned int mtools_rate_0, mtools_rate_any;
-extern int mtools_raw_tty;
-
-extern int batchmode;
-
-void read_config(void);
-extern struct device *devices;
-extern struct device const_devices[];
-extern const int nr_const_devices;
-
-#define New(type) ((type*)(malloc(sizeof(type))))
-#define Grow(adr,n,type) ((type*)(realloc((char *)adr,n*sizeof(type))))
-#define Free(adr) (free((char *)adr));
-#define NewArray(size,type) ((type*)(calloc((size),sizeof(type))))
-
-void mattrib(int argc, char **argv, int type);
-void mbadblocks(int argc, char **argv, int type);
-void mcat(int argc, char **argv, int type);
-void mcd(int argc, char **argv, int type);
-void mcopy(int argc, char **argv, int type);
-void mdel(int argc, char **argv, int type);
-void mdir(int argc, char **argv, int type);
-void mdoctorfat(int argc, char **argv, int type);
-void mdu(int argc, char **argv, int type);
-void mformat(int argc, char **argv, int type);
-void minfo(int argc, char **argv, int type);
-void mlabel(int argc, char **argv, int type);
-void mmd(int argc, char **argv, int type);
-void mmount(int argc, char **argv, int type);
-void mmove(int argc, char **argv, int type);
-void mpartition(int argc, char **argv, int type);
-void mshowfat(int argc, char **argv, int mtype);
-void mtoolstest(int argc, char **argv, int type);
-void mzip(int argc, char **argv, int type);
-
-extern int noPrivileges;
-void init_privs(void);
-void reclaim_privs(void);
-void drop_privs(void);
-void destroy_privs(void);
-uid_t get_real_uid(void);
-void closeExec(int fd);
-
-extern const char *progname;
-
-void precmd(struct device *dev);
-
-void print_sector(char *message, unsigned char *data, int size);
-time_t getTimeNow(time_t *now);
-
-#ifdef USING_NEW_VOLD
-char *getVoldName(struct device *dev, char *name);
-#endif
-
-
-Stream_t *OpenDir(Stream_t *Parent, const char *filename);
-/* int unix_dir_loop(Stream_t *Stream, MainParam_t *mp); 
-int unix_loop(MainParam_t *mp, char *arg); */
-
-struct dirCache_t **getDirCacheP(Stream_t *Stream);
-int isRootDir(Stream_t *Stream);
-unsigned int getStart(Stream_t *Dir, struct directory *dir);
-unsigned int countBlocks(Stream_t *Dir, unsigned int block);
-char *getDrive(Stream_t *Stream);
-
-
-void printOom(void);
-int ask_confirmation(const char *, const char *, const char *);
-char *get_homedir(void);
-#define EXPAND_BUF 2048
-const char *expand(const char *, char *);
-const char *fix_mcwd(char *);
-FILE *open_mcwd(const char *mode);
-void unlink_mcwd(void);
-char *skip_drive(const char *path);
-char *get_drive(const char *path, const char *def);
-
-int safePopenOut(char **command, char *output, int len);
-
-#define ROUND_DOWN(value, grain) ((value) - (value) % (grain))
-#define ROUND_UP(value, grain) ROUND_DOWN((value) + (grain)-1, (grain))
-
-#endif
Index: trunk/minix/commands/i386/mtools-3.9.7/mtoolsDirent.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mtoolsDirent.h	(revision 9)
+++ 	(revision )
@@ -1,40 +1,0 @@
-#ifndef MTOOLS_DIRENTRY_H
-#define MTOOLS_DIRENTRY_H
-
-#include "sysincludes.h"
-#include "vfat.h"
-
-typedef struct direntry_t {
-	struct Stream_t *Dir;
-	/* struct direntry_t *parent; parent level */	
-	int entry; /* slot in parent directory (-3 if root) */
-	struct directory dir; /* descriptor in parent directory (random if 
-			       * root)*/
-	char name[MAX_VNAMELEN+1]; /* name in its parent directory, or 
-				    * NULL if root */
-	int beginSlot; /* begin and end slot, for delete */
-	int endSlot;
-} direntry_t;
-
-#include "stream.h"
-
-int vfat_lookup(direntry_t *entry, const char *filename, int length,
-		int flags, char *shortname, char *longname);
-
-struct directory *dir_read(direntry_t *entry, int *error);
-
-void initializeDirentry(direntry_t *entry, struct Stream_t *Dir);
-int isNotFound(direntry_t *entry);
-direntry_t *getParent(direntry_t *entry);
-void dir_write(direntry_t *entry);
-void low_level_dir_write(direntry_t *entry);
-int fatFreeWithDirentry(direntry_t *entry);
-int labelit(char *dosname,
-	    char *longname,
-	    void *arg0,
-	    direntry_t *entry);
-int isSubdirOf(Stream_t *inside, Stream_t *outside);
-char *getPwd(direntry_t *entry);
-void fprintPwd(FILE *f, direntry_t *entry, int escape);
-int write_vfat(Stream_t *, char *, char *, int, direntry_t *);
-#endif
Index: trunk/minix/commands/i386/mtools-3.9.7/mtoolsPaths.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/mtoolsPaths.h	(revision 9)
+++ 	(revision )
@@ -1,32 +1,0 @@
-/*
- * Paths of the configuration files.
- * This file may be changed by the user as needed.
- * There are three empty lines between each definition.
- * These ensure that "local" patches and official patches have
- * only a very low probability of conflicting.
- */
-
-
-#define CONF_FILE "/etc/mtools.conf"
-
-
-#define OLD_CONF_FILE "/etc/mtools"
-
-
-
-#define LOCAL_CONF_FILE "/etc/default/mtools.conf"
-/* Use this if you like to keep the configuration file in a non-standard
- * place such as /etc/default, /opt/etc, /usr/etc, /usr/local/etc ...
- */
-
-#define SYS_CONF_FILE SYSCONFDIR "/mtools.conf"
-
-#define OLD_LOCAL_CONF_FILE "/etc/default/mtools"
-
-
-
-#define CFG_FILE1 "/.mtoolsrc"
-
-
-
-/* END */
Index: trunk/minix/commands/i386/mtools-3.9.7/nameclash.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/nameclash.h	(revision 9)
+++ 	(revision )
@@ -1,57 +1,0 @@
-#ifndef MTOOLS_NAMECLASH_H
-#define MTOOLS_NAMECLASH_H
-
-#include "stream.h"
-
-typedef enum clash_action {
-	NAMEMATCH_NONE,
-	NAMEMATCH_AUTORENAME,
-	NAMEMATCH_QUIT,
-	NAMEMATCH_SKIP,
-	NAMEMATCH_RENAME,
-	NAMEMATCH_PRENAME, /* renaming of primary name */
-	NAMEMATCH_OVERWRITE,
-	NAMEMATCH_ERROR,
-	NAMEMATCH_SUCCESS,
-	NAMEMATCH_GREW
-} clash_action;
-
-/* clash handling structure */
-typedef struct ClashHandling_t {
-	clash_action action[2];
-	clash_action namematch_default[2];
-		
-	int nowarn;	/* Don't ask, just do default action if name collision*/
-	int got_slots;
-	int mod_time;
-	/* unsigned int dot; */
-	char *myname;
-	unsigned char *dosname;
-	int single;
-
-	int use_longname;
-	int ignore_entry;
-	int source; /* to prevent the source from overwriting itself */
-	int source_entry; /* to account for the space freed up by the original 
-					   * name */
-	char * (*name_converter)(char *filename, int verbose, 
-				 int *mangled, char *ans);
-} ClashHandling_t;
-
-/* write callback */
-typedef int (write_data_callback)(char *,char *, void *, struct direntry_t *);
-
-int mwrite_one(Stream_t *Dir,
-	       const char *argname,
-	       const char *shortname,
-	       write_data_callback *cb,
-	       void *arg,
-	       ClashHandling_t *ch);
-
-int handle_clash_options(ClashHandling_t *ch, char c);
-void init_clash_handling(ClashHandling_t *ch);
-Stream_t *createDir(Stream_t *Dir, const char *filename, ClashHandling_t *ch,
-		    unsigned char attr, time_t mtime);
-
-
-#endif
Index: trunk/minix/commands/i386/mtools-3.9.7/partition.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/partition.h	(revision 9)
+++ 	(revision )
@@ -1,31 +1,0 @@
-typedef struct hsc {
-	unsigned char byte0;
-	unsigned char head;		/* starting head */
-	unsigned char sector;		/* starting sector */
-	unsigned char cyl;		/* starting cylinder */
-} hsc;
-
-#define head(x) ((x).head)
-#define sector(x) ((x).sector & 0x3f)
-#define cyl(x) ((x).cyl | (((x).sector & 0xc0)<<2))
-
-#define BEGIN(p) _DWORD((p).start_sect)
-#define END(p) (_DWORD((p).start_sect)+(_DWORD((p).nr_sects)))
-
-
-struct partition {
-	hsc start;
-	hsc end;
-	unsigned char start_sect[4];	/* starting sector counting from 0 */
-	unsigned char nr_sects[4];     	/* nr of sectors in partition */
-};
-
-#define boot_ind start.byte0
-#define sys_ind end.byte0
-
-int consistencyCheck(struct partition *partTable, int doprint, int verbose,
-		     int *has_activated, int *last_end, int *j, 
-		     struct device *used_dev, int target_partition);
-
-void setBeginEnd(struct partition *partTable, int begin, int end,
-				 int heads, int sector, int activate, int type);
Index: trunk/minix/commands/i386/mtools-3.9.7/patchlevel.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/patchlevel.c	(revision 9)
+++ 	(revision )
@@ -1,2 +1,0 @@
-const char *mversion="3.9.7";
-const char *mdate = "1 jun 2000";
Index: trunk/minix/commands/i386/mtools-3.9.7/plain_io.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/plain_io.c	(revision 9)
+++ 	(revision )
@@ -1,749 +1,0 @@
-/*
- * Io to a plain file or device
- *
- * written by:
- *
- * Alain L. Knaff			
- * alain@linux.lu
- *
- */
-
-#include "sysincludes.h"
-#include "stream.h"
-#include "mtools.h"
-#include "msdos.h"
-#include "plain_io.h"
-#include "scsi.h"
-#include "partition.h"
-#include "llong.h"
-
-typedef struct SimpleFile_t {
-    Class_t *Class;
-    int refs;
-    Stream_t *Next;
-    Stream_t *Buffer;
-    struct stat stat;
-    int fd;
-    mt_off_t offset;
-    mt_off_t lastwhere;
-    int seekable;
-    int privileged;
-#ifdef OS_hpux
-    int size_limited;
-#endif
-    int scsi_sector_size;
-    void *extra_data; /* extra system dependant information for scsi */
-} SimpleFile_t;
-
-
-/*
- * Create an advisory lock on the device to prevent concurrent writes.
- * Uses either lockf, flock, or fcntl locking methods.  See the Makefile
- * and the Configure files for how to specify the proper method.
- */
-
-int lock_dev(int fd, int mode, struct device *dev)
-{
-#if (defined(HAVE_FLOCK) && defined (LOCK_EX) && defined(LOCK_NB))
-	/**/
-#else /* FLOCK */
-
-#if (defined(HAVE_LOCKF) && defined(F_TLOCK))
-	/**/
-#else /* LOCKF */
-
-#if (defined(F_SETLK) && defined(F_WRLCK))
-	struct flock flk;
-
-#endif /* FCNTL */
-#endif /* LOCKF */
-#endif /* FLOCK */
-
-	if(IS_NOLOCK(dev))
-		return 0;
-
-#if (defined(HAVE_FLOCK) && defined (LOCK_EX) && defined(LOCK_NB))
-	if (flock(fd, (mode ? LOCK_EX : LOCK_SH)|LOCK_NB) < 0)
-#else /* FLOCK */
-
-#if (defined(HAVE_LOCKF) && defined(F_TLOCK))
-	if (mode && lockf(fd, F_TLOCK, 0) < 0)
-#else /* LOCKF */
-
-#if (defined(F_SETLK) && defined(F_WRLCK))
-	flk.l_type = mode ? F_WRLCK : F_RDLCK;
-	flk.l_whence = 0;
-	flk.l_start = 0L;
-	flk.l_len = 0L;
-
-	if (fcntl(fd, F_SETLK, &flk) < 0)
-#endif /* FCNTL */
-#endif /* LOCKF */
-#endif /* FLOCK */
-	{
-		if(errno == EINVAL
-#ifdef  EOPNOTSUPP 
-		   || errno ==  EOPNOTSUPP
-#endif
-		  )
-			return 0;
-		else
-			return 1;
-	}
-	return 0;
-}
-
-typedef int (*iofn) (int, char *, int);
-
-
-
-static int file_io(Stream_t *Stream, char *buf, mt_off_t where, int len,
-				   iofn io)
-{
-	DeclareThis(SimpleFile_t);
-	int ret;
-
-	where += This->offset;
-
-	if (This->seekable && where != This->lastwhere ){
-		if(mt_lseek( This->fd, where, SEEK_SET) < 0 ){
-			perror("seek");
-			This->lastwhere = (mt_off_t) -1;
-			return -1;
-		}
-	}
-
-#ifdef OS_hpux
-	/*
-	 * On HP/UX, we can not write more than MAX_LEN bytes in one go.
-	 * If more are written, the write fails with EINVAL
-	 */
-	#define MAX_SCSI_LEN (127*1024)
-	if(This->size_limited && len > MAX_SCSI_LEN)
-		len = MAX_SCSI_LEN;
-#endif
-	ret = io(This->fd, buf, len);
-
-#ifdef OS_hpux
-	if (ret == -1 && 
-		errno == EINVAL && /* if we got EINVAL */
-		len > MAX_SCSI_LEN) {
-		This->size_limited = 1;
-		len = MAX_SCSI_LEN;
-		ret = io(This->fd, buf, len);
-	}
-#endif
-
-	if ( ret == -1 ){
-		perror("plain_io");
-		This->lastwhere = (mt_off_t) -1;
-		return -1;
-	}
-	This->lastwhere = where + ret;
-	return ret;
-}
-	
-
-
-static int file_read(Stream_t *Stream, char *buf, mt_off_t where, size_t len)
-{	
-	return file_io(Stream, buf, where, len, (iofn) read);
-}
-
-static int file_write(Stream_t *Stream, char *buf, mt_off_t where, size_t len)
-{
-	return file_io(Stream, buf, where, len, (iofn) write);
-}
-
-static int file_flush(Stream_t *Stream)
-{
-#if 0
-	DeclareThis(SimpleFile_t);
-
-	return fsync(This->fd);
-#endif
-	return 0;
-}
-
-static int file_free(Stream_t *Stream)
-{
-	DeclareThis(SimpleFile_t);
-
-	if (This->fd > 2)
-		return close(This->fd);
-	else
-		return 0;
-}
-
-static int file_geom(Stream_t *Stream, struct device *dev, 
-		     struct device *orig_dev,
-		     int media, struct bootsector *boot)
-{
-	int ret;
-	DeclareThis(SimpleFile_t);
-	size_t tot_sectors;
-	int BootP, Infp0, InfpX, InfTm;
-	int sectors, j;
-	unsigned char sum;
-	int sect_per_track;
-	struct label_blk_t *labelBlock;
-
-	dev->ssize = 2; /* allow for init_geom to change it */
-	dev->use_2m = 0x80; /* disable 2m mode to begin */
-
-	if(media == 0xf0 || media >= 0x100){		
-		dev->heads = WORD(nheads);
-		dev->sectors = WORD(nsect);
-		tot_sectors = DWORD(bigsect);
-		SET_INT(tot_sectors, WORD(psect));
-		sect_per_track = dev->heads * dev->sectors;
-		tot_sectors += sect_per_track - 1; /* round size up */
-		dev->tracks = tot_sectors / sect_per_track;
-
-		BootP = WORD(ext.old.BootP);
-		Infp0 = WORD(ext.old.Infp0);
-		InfpX = WORD(ext.old.InfpX);
-		InfTm = WORD(ext.old.InfTm);
-		
-		if(WORD(fatlen)) {
-			labelBlock = &boot->ext.old.labelBlock;
-		} else {
-			labelBlock = &boot->ext.fat32.labelBlock;
-		}
-
-		if (boot->descr >= 0xf0 &&
-		    labelBlock->dos4 == 0x29 &&
-		    strncmp( boot->banner,"2M", 2 ) == 0 &&
-		    BootP < 512 && Infp0 < 512 && InfpX < 512 && InfTm < 512 &&
-		    BootP >= InfTm + 2 && InfTm >= InfpX && InfpX >= Infp0 && 
-		    Infp0 >= 76 ){
-			for (sum=0, j=63; j < BootP; j++) 
-				sum += boot->jump[j];/* checksum */
-			dev->ssize = boot->jump[InfTm];
-			if (!sum && dev->ssize <= 7){
-				dev->use_2m = 0xff;
-				dev->ssize |= 0x80; /* is set */
-			}
-		}
-	} else if (media >= 0xf8){
-		media &= 3;
-		dev->heads = old_dos[media].heads;
-		dev->tracks = old_dos[media].tracks;
-		dev->sectors = old_dos[media].sectors;
-		dev->ssize = 0x80;
-		dev->use_2m = ~1;
-	} else {
-		fprintf(stderr,"Unknown media type\n");
-		exit(1);
-	}
-
-	sectors = dev->sectors;
-	dev->sectors = dev->sectors * WORD(secsiz) / 512;
-
-#ifdef JPD
-	printf("file_geom:media=%0X=>cyl=%d,heads=%d,sects=%d,ssize=%d,use2m=%X\n",
-	       media, dev->tracks, dev->heads, dev->sectors, dev->ssize,
-	       dev->use_2m);
-#endif
-	ret = init_geom(This->fd,dev, orig_dev, &This->stat);
-	dev->sectors = sectors;
-#ifdef JPD
-	printf("f_geom: after init_geom(), sects=%d\n", dev->sectors);
-#endif
-	return ret;
-}
-
-
-static int file_data(Stream_t *Stream, time_t *date, mt_size_t *size,
-		     int *type, int *address)
-{
-	DeclareThis(SimpleFile_t);
-
-	if(date)
-		*date = This->stat.st_mtime;
-	if(size)
-		*size = This->stat.st_size;
-	if(type)
-		*type = S_ISDIR(This->stat.st_mode);
-	if(address)
-		*address = 0;
-	return 0;
-}
-
-/* ZIP or other scsi device on Solaris or SunOS system.
-   Since Sun won't accept a non-Sun label on a scsi disk, we must
-   bypass Sun's disk interface and use low-level SCSI commands to read
-   or write the ZIP drive.  We thus replace the file_read and file_write
-   routines with our own scsi_read and scsi_write routines, that use the
-   uscsi ioctl interface.  By James Dugal, jpd@usl.edu, 11-96.  Tested
-   under Solaris 2.5 and SunOS 4.3.1_u1 using GCC.
-
-   Note: the mtools.conf entry for a ZIP drive would look like this:
-(solaris) drive C: file="/dev/rdsk/c0t5d0s2" partition=4  FAT=16 nodelay  exclusive scsi=&
-(sunos) drive C: file="/dev/rsd5c" partition=4  FAT=16 nodelay  exclusive scsi=1
-
-   Note 2: Sol 2.5 wants mtools to be suid-root, to use the ioctl.  SunOS is
-   happy if we just have access to the device, so making mtools sgid to a
-   group called, say, "ziprw" which has rw permission on /dev/rsd5c, is fine.
- */
-
-#define MAXBLKSPERCMD 255
-
-static void scsi_init(SimpleFile_t *This)
-{
-   int fd = This->fd;
-   unsigned char cdb[10],buf[8];
-
-   memset(cdb, 0, sizeof cdb);
-   memset(buf,0, sizeof(buf));
-   cdb[0]=SCSI_READ_CAPACITY;
-   if (scsi_cmd(fd, (unsigned char *)cdb, 
-		sizeof(cdb), SCSI_IO_READ, buf, sizeof(buf), This->extra_data)==0)
-   {
-       This->scsi_sector_size=
-	       ((unsigned)buf[5]<<16)|((unsigned)buf[6]<<8)|(unsigned)buf[7];
-       if (This->scsi_sector_size != 512)
-	   fprintf(stderr,"  (scsi_sector_size=%d)\n",This->scsi_sector_size);
-   }
-}
-
-int scsi_io(Stream_t *Stream, char *buf,  mt_off_t where, size_t len, int rwcmd)
-{
-	unsigned int firstblock, nsect;
-	int clen,r,max;
-	off_t offset;
-	unsigned char cdb[10];
-	DeclareThis(SimpleFile_t);
-
-	firstblock=truncBytes32((where + This->offset)/This->scsi_sector_size);
-	/* 512,1024,2048,... bytes/sector supported */
-	offset=truncBytes32(where + This->offset - 
-						firstblock*This->scsi_sector_size);
-	nsect=(offset+len+This->scsi_sector_size-1)/ This->scsi_sector_size;
-#if defined(OS_sun) && defined(OS_i386)
-	if (This->scsi_sector_size>512)
-		firstblock*=This->scsi_sector_size/512; /* work around a uscsi bug */
-#endif /* sun && i386 */
-
-	if (len>512) {
-		/* avoid buffer overruns. The transfer MUST be smaller or
-		* equal to the requested size! */
-		while (nsect*This->scsi_sector_size>len)
-			--nsect;
-		if(!nsect) {			
-			fprintf(stderr,"Scsi buffer too small\n");
-			exit(1);
-		}
-		if(rwcmd == SCSI_IO_WRITE && offset) {
-			/* there seems to be no memmove before a write */
-			fprintf(stderr,"Unaligned write\n");
-			exit(1);
-		}
-		/* a better implementation should use bounce buffers.
-		 * However, in normal operation no buffer overruns or
-		 * unaligned writes should happen anyways, as the logical
-		 * sector size is (hopefully!) equal to the physical one
-		 */
-	}
-
-
-	max = scsi_max_length();
-	
-	if (nsect > max)
-		nsect=max;
-	
-	/* set up SCSI READ/WRITE command */
-	memset(cdb, 0, sizeof cdb);
-
-	switch(rwcmd) {
-		case SCSI_IO_READ:
-			cdb[0] = SCSI_READ;
-			break;
-		case SCSI_IO_WRITE:
-			cdb[0] = SCSI_WRITE;
-			break;
-	}
-
-	cdb[1] = 0;
-
-	if (firstblock > 0x1fffff || nsect > 0xff) {
-		/* I suspect that the ZIP drive also understands Group 1
-		 * commands. If that is indeed true, we may chose Group 1
-		 * more agressively in the future */
-
-		cdb[0] |= SCSI_GROUP1;
-		clen=10; /* SCSI Group 1 cmd */
-
-		/* this is one of the rare case where explicit coding is
-		 * more portable than macros... The meaning of scsi command
-		 * bytes is standardised, whereas the preprocessor macros
-		 * handling it might be not... */
-
-		cdb[2] = (unsigned char) (firstblock >> 24) & 0xff;
-		cdb[3] = (unsigned char) (firstblock >> 16) & 0xff;
-		cdb[4] = (unsigned char) (firstblock >> 8) & 0xff;
-		cdb[5] = (unsigned char) firstblock & 0xff;
-		cdb[6] = 0;
-		cdb[7] = (unsigned char) (nsect >> 8) & 0xff;
-		cdb[8] = (unsigned char) nsect & 0xff;
-		cdb[9] = 0;
-	} else {
-		clen = 6; /* SCSI Group 0 cmd */
-		cdb[1] |= (unsigned char) ((firstblock >> 16) & 0x1f);
-		cdb[2] = (unsigned char) ((firstblock >> 8) & 0xff);
-		cdb[3] = (unsigned char) firstblock & 0xff;
-		cdb[4] = (unsigned char) nsect;
-		cdb[5] = 0;
-	}
-	
-	if(This->privileged)
-		reclaim_privs();
-
-	r=scsi_cmd(This->fd, (unsigned char *)cdb, clen, rwcmd, buf,
-		   nsect*This->scsi_sector_size, This->extra_data);
-
-	if(This->privileged)
-		drop_privs();
-
-	if(r) {
-		perror(rwcmd == SCSI_IO_READ ? "SCMD_READ" : "SCMD_WRITE");
-		return -1;
-	}
-#ifdef JPD
-	printf("finished %u for %u\n", firstblock, nsect);
-#endif
-
-#ifdef JPD
-	printf("zip: read or write OK\n");
-#endif
-	if (offset>0) memmove(buf,buf+offset,nsect*This->scsi_sector_size-offset);
-	if (len==256) return 256;
-	else if (len==512) return 512;
-	else return nsect*This->scsi_sector_size-offset;
-}
-
-int scsi_read(Stream_t *Stream, char *buf, mt_off_t where, size_t len)
-{
-	
-#ifdef JPD
-	printf("zip: to read %d bytes at %d\n", len, where);
-#endif
-	return scsi_io(Stream, buf, where, len, SCSI_IO_READ);
-}
-
-int scsi_write(Stream_t *Stream, char *buf, mt_off_t where, size_t len)
-{
-#ifdef JPD
-	Printf("zip: to write %d bytes at %d\n", len, where);
-#endif
-	return scsi_io(Stream, buf, where, len, SCSI_IO_WRITE);
-}
-
-static Class_t ScsiClass = {
-	scsi_read, 
-	scsi_write,
-	file_flush,
-	file_free,
-	file_geom,
-	file_data,
-	0 /* pre-allocate */
-};
-
-
-static Class_t SimpleFileClass = {
-	file_read, 
-	file_write,
-	file_flush,
-	file_free,
-	file_geom,
-	file_data,
-	0 /* pre_allocate */
-};
-
-
-Stream_t *SimpleFileOpen(struct device *dev, struct device *orig_dev,
-			 const char *name, int mode, char *errmsg, 
-			 int mode2, int locked, mt_size_t *maxSize)
-{
-	SimpleFile_t *This;
-#ifdef __EMX__
-HFILE FileHandle;
-ULONG Action;
-APIRET rc;
-#endif
-	This = New(SimpleFile_t);
-	if (!This){
-		printOom();
-		return 0;
-	}
-	This->scsi_sector_size = 512;
-	This->seekable = 1;
-#ifdef OS_hpux
-	This->size_limited = 0;
-#endif
-	This->Class = &SimpleFileClass;
-	if (!name || strcmp(name,"-") == 0 ){
-		if (mode == O_RDONLY)
-			This->fd = 0;
-		else
-			This->fd = 1;
-		This->seekable = 0;
-		This->refs = 1;
-		This->Next = 0;
-		This->Buffer = 0;
-		if (fstat(This->fd, &This->stat) < 0) {
-		    Free(This);
-		    if(errmsg)
-#ifdef HAVE_SNPRINTF
-			snprintf(errmsg,199,"Can't stat -: %s", 
-				strerror(errno));   
-#else
-			sprintf(errmsg,"Can't stat -: %s", 
-				strerror(errno));
-#endif
-		    return NULL;
-		}
-
-		return (Stream_t *) This;
-	}
-
-	
-	if(dev) {
-		if(!(mode2 & NO_PRIV))
-			This->privileged = IS_PRIVILEGED(dev);
-		mode |= dev->mode;
-	}
-
-	precmd(dev);
-	if(IS_PRIVILEGED(dev) && !(mode2 & NO_PRIV))
-		reclaim_privs();
-
-#ifdef __EMX__
-#define DOSOPEN_FLAGS	(OPEN_FLAGS_DASD | OPEN_FLAGS_WRITE_THROUGH | \
-			OPEN_FLAGS_NOINHERIT | OPEN_FLAGS_RANDOM | \
-			OPEN_FLAGS_NO_CACHE)
-#define DOSOPEN_FD_ACCESS (OPEN_SHARE_DENYREADWRITE | OPEN_ACCESS_READWRITE)
-#define DOSOPEN_HD_ACCESS (OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY)
-
-	if (skip_drive(name) > name) {
-		rc = DosOpen(
-			name, &FileHandle, &Action, 0L, FILE_NORMAL,
-			OPEN_ACTION_OPEN_IF_EXISTS, DOSOPEN_FLAGS |
-			(IS_NOLOCK(dev)?DOSOPEN_HD_ACCESS:DOSOPEN_FD_ACCESS),
-			0L);
-#ifdef DEBUG
-		if (rc != NO_ERROR) fprintf (stderr, "DosOpen() returned %d\n", rc);
-#endif
-		if (!IS_NOLOCK(dev)) {
-			rc = DosDevIOCtl(
-			FileHandle, 0x08L, DSK_LOCKDRIVE, 0, 0, 0, 0, 0, 0);
-#ifdef DEBUG
-			if (rc != NO_ERROR) fprintf (stderr, "DosDevIOCtl() returned %d\n", rc);
-#endif
-		}
-		if (rc == NO_ERROR)
-			This->fd = _imphandle(FileHandle); else This->fd = -1;
-	} else
-#endif
-	    {
-		if (IS_SCSI(dev))
-		    This->fd = scsi_open(name, mode, IS_NOLOCK(dev)?0444:0666,
-					 &This->extra_data);
-		else
-		    This->fd = open(name, mode, IS_NOLOCK(dev)?0444:0666);
-	    }
-
-	if(IS_PRIVILEGED(dev) && !(mode2 & NO_PRIV))
-		drop_privs();
-		
-	if (This->fd < 0) {
-		Free(This);
-		if(errmsg)
-#ifdef HAVE_SNPRINTF
-			snprintf(errmsg, 199, "Can't open %s: %s",
-				name, strerror(errno));
-#else
-			sprintf(errmsg, "Can't open %s: %s",
-				name, strerror(errno));
-#endif
-		return NULL;
-	}
-
-	if(IS_PRIVILEGED(dev) && !(mode2 & NO_PRIV))
-		closeExec(This->fd);
-
-#ifdef __EMX__
-	if (*(name+1) != ':')
-#endif
-	if (fstat(This->fd, &This->stat) < 0){
-		Free(This);
-		if(errmsg) {
-#ifdef HAVE_SNPRINTF
-			snprintf(errmsg,199,"Can't stat %s: %s", 
-				name, strerror(errno));
-#else
-			if(strlen(name) > 50) {
-			    sprintf(errmsg,"Can't stat file: %s", 
-				    strerror(errno));
-			} else {
-			    sprintf(errmsg,"Can't stat %s: %s", 
-				name, strerror(errno));
-			}
-#endif
-		}
-		return NULL;
-	}
-#ifndef __EMX__
-	/* lock the device on writes */
-	if (locked && lock_dev(This->fd, mode == O_RDWR, dev)) {
-		if(errmsg)
-#ifdef HAVE_SNPRINTF
-			snprintf(errmsg,199,
-				"plain floppy: device \"%s\" busy (%s):",
-				dev ? dev->name : "unknown", strerror(errno));
-#else
-			sprintf(errmsg,
-				"plain floppy: device \"%s\" busy (%s):",
-				(dev && strlen(dev->name) < 50) ? 
-				 dev->name : "unknown", strerror(errno));
-#endif
-
-		close(This->fd);
-		Free(This);
-		return NULL;
-	}
-#endif
-	/* set default parameters, if needed */
-	if (dev){		
-		if ((IS_MFORMAT_ONLY(dev) || !dev->tracks) &&
-			init_geom(This->fd, dev, orig_dev, &This->stat)){
-			close(This->fd);
-			Free(This);
-			if(errmsg)
-				sprintf(errmsg,"init: set default params");
-			return NULL;
-		}
-		This->offset = (mt_off_t) dev->offset;
-	} else
-		This->offset = 0;
-
-	This->refs = 1;
-	This->Next = 0;
-	This->Buffer = 0;
-
-	if(maxSize) {
-		if (IS_SCSI(dev)) {
-			*maxSize = MAX_OFF_T_B(31+log_2(This->scsi_sector_size));
-		} else {
-			*maxSize = max_off_t_seek;
-		}
-		if(This->offset > *maxSize) {
-			close(This->fd);
-			Free(This);
-			if(errmsg)
-				sprintf(errmsg,"init: Big disks not supported");
-			return NULL;
-		}
-		
-		*maxSize -= This->offset;
-	}
-	/* partitioned drive */
-
-	/* jpd@usl.edu: assume a partitioned drive on these 2 systems is a ZIP*/
-	/* or similar drive that must be accessed by low-level scsi commands */
-	/* AK: introduce new "scsi=1" statement to specifically set
-	 * this option. Indeed, there could conceivably be partitioned
-	 * devices where low level scsi commands will not be needed */
-	if(IS_SCSI(dev)) {
-		This->Class = &ScsiClass;
-		if(This->privileged)
-			reclaim_privs();
-		scsi_init(This);
-		if(This->privileged)
-			drop_privs();
-	}
-	while(!(mode2 & NO_OFFSET) &&
-	      dev && dev->partition && dev->partition <= 4) {
-		int has_activated, last_end, j;
-		unsigned char buf[2048];
-		struct partition *partTable=(struct partition *)(buf+ 0x1ae);
-		size_t partOff;
-		
-		/* read the first sector, or part of it */
-		if (force_read((Stream_t *)This, (char*) buf, 0, 512) != 512)
-			break;
-		if( _WORD(buf+510) != 0xaa55)
-			break;
-
-		partOff = BEGIN(partTable[dev->partition]);
-		if (maxSize) {
-			if (partOff > *maxSize >> 9) {
-				close(This->fd);
-				Free(This);
-				if(errmsg)
-					sprintf(errmsg,"init: Big disks not supported");
-				return NULL;
-			}
-			*maxSize -= (mt_off_t) partOff << 9;
-		}
-			
-		This->offset += (mt_off_t) partOff << 9;
-		if(!partTable[dev->partition].sys_ind) {
-			if(errmsg)
-				sprintf(errmsg,
-					"init: non-existant partition");
-			close(This->fd);
-			Free(This);
-			return NULL;
-		}
-
-		if(!dev->tracks) {
-			dev->heads = head(partTable[dev->partition].end)+1;
-			dev->sectors = sector(partTable[dev->partition].end);
-			dev->tracks = cyl(partTable[dev->partition].end) -
-				cyl(partTable[dev->partition].start)+1;
-		}
-		dev->hidden=dev->sectors*head(partTable[dev->partition].start);
-		if(!mtools_skip_check &&
-		   consistencyCheck((struct partition *)(buf+0x1ae), 0, 0,
-				    &has_activated, &last_end, &j, dev, 0)) {
-			fprintf(stderr,
-				"Warning: inconsistent partition table\n");
-			fprintf(stderr,
-				"Possibly unpartitioned device\n");
-			fprintf(stderr,
-				"\n*** Maybe try without partition=%d in "
-				"device definition ***\n\n",
-				dev->partition);
-			fprintf(stderr,
-                                "If this is a PCMCIA card, or a disk "
-				"partitioned on another computer, this "
-				"message may be in error: add "
-				"mtools_skip_check=1 to your .mtoolsrc "
-				"file to suppress this warning\n");
-
-		}
-		break;
-		/* NOTREACHED */
-	}
-
-	This->lastwhere = -This->offset;
-	/* provoke a seek on those devices that don't start on a partition
-	 * boundary */
-
-	return (Stream_t *) This;
-}
-
-int get_fd(Stream_t *Stream)
-{
-	DeclareThis(SimpleFile_t);
-	
-	return This->fd;
-}
-
-void *get_extra_data(Stream_t *Stream)
-{
-	DeclareThis(SimpleFile_t);
-	
-	return This->extra_data;
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/plain_io.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/plain_io.h	(revision 9)
+++ 	(revision )
@@ -1,21 +1,0 @@
-#ifndef MTOOLS_PLAINIO_H
-#define MTOOLS_PLAINIO_H
-
-#include "stream.h"
-#include "msdos.h"
-#ifdef __EMX__
-#include <io.h>
-#endif
-
-/* plain io */
-#define NO_PRIV 1
-#define NO_OFFSET 2
-
-Stream_t *SimpleFileOpen(struct device *dev, struct device *orig_dev,
-			 const char *name, int mode, char *errmsg, int mode2,
-			 int locked, mt_size_t *maxSize);
-int check_parameters(struct device *ref, struct device *testee);
-
-int get_fd(Stream_t *Stream);
-void *get_extra_data(Stream_t *Stream);
-#endif
Index: trunk/minix/commands/i386/mtools-3.9.7/precmd.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/precmd.c	(revision 9)
+++ 	(revision )
@@ -1,31 +1,0 @@
-/*
- * Do filename expansion with the shell.
- */
-
-#define EXPAND_BUF	2048
-
-#include "sysincludes.h"
-#include "mtools.h"
-
-void precmd(struct device *dev)
-{
-	int status;
-	pid_t pid;
-
-	if(!dev || !dev->precmd)
-		return;
-	
-	switch((pid=fork())){
-		case -1:
-			perror("Could not fork");
-			exit(1);
-			break;
-		case 0: /* the son */
-			execl("/bin/sh", "sh", "-c", dev->precmd, 0);
-			break;
-		default:
-			wait(&status);
-			break;
-	}
-}
-		
Index: trunk/minix/commands/i386/mtools-3.9.7/privileges.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/privileges.c	(revision 9)
+++ 	(revision )
@@ -1,166 +1,0 @@
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-
-/*#define PRIV_DEBUG*/
-
-#if 0
-#undef HAVE_SETEUID
-#define HAVE_SETRESUID
-#include <asm/unistd.h>
-int setresuid(int a, int b, int c)
-{
-	syscall(164, a, b, c);
-
-}
-#endif
-
-static inline void print_privs(const char *message)
-{
-#ifdef PRIV_DEBUG
-	/* for debugging purposes only */
-	fprintf(stderr,"%s egid=%d rgid=%d\n", message, getegid(), getgid());
-	fprintf(stderr,"%s euid=%d ruid=%d\n", message, geteuid(), getuid());
-#endif
-}
-
-int noPrivileges=0;
-
-
-static gid_t rgid, egid;
-static uid_t ruid, euid;
-
-/* privilege management routines for SunOS and Solaris.  These are
- * needed in order to issue raw SCSI read/write ioctls.  Mtools drops
- * its privileges at the beginning, and reclaims them just for the
- * above-mentioned ioctl's.  Before popen(), exec() or system, it
- * drops its privileges completely, and issues a warning.
- */
-
-
-/* group id handling is lots easyer, as long as we don't use group 0.
- * If you want to use group id's, create a *new* group mtools or
- * floppy.  Chgrp any devices that you only want to be accessible to
- * mtools to this group, and give them the appropriate privs.  Make
- * sure this group doesn't own any other files: be aware that any user
- * with access to mtools may mformat these files!
- */
-
-
-static inline void Setuid(uid_t uid)
-{
-#if defined HAVE_SETEUID || defined HAVE_SETRESUID
-	if(euid == 0) {
-#ifdef HAVE_SETEUID
-		seteuid(uid);
-#else
-		setresuid(ruid, uid, euid);
-#endif
-	} else
-#endif
-		setuid(uid);
-}
-
-/* In reclaim_privs and drop privs, we have to manipulate group privileges
- * when having no root privileges, else we might lose them */
-
-void reclaim_privs(void)
-{
-	if(noPrivileges)
-		return;
-	setgid(egid);
-	Setuid(euid);
-	print_privs("after reclaim privs, both uids should be 0 ");
-}
-
-void drop_privs(void)
-{
-	Setuid(ruid);
-	setgid(rgid);
-	print_privs("after drop_privs, real should be 0, effective should not ");
-}
-
-void destroy_privs(void)
-{
-
-#if defined HAVE_SETEUID || defined HAVE_SETRESUID
-	if(euid == 0) {
-#ifdef HAVE_SETEUID
-		setuid(0); /* get the necessary privs to drop real root id */
-		setuid(ruid); /* this should be enough to get rid of the three
-			       * ids */
-		seteuid(ruid); /* for good measure... just in case we came
-				* accross a system which implemented sane
-				* semantics instead of POSIXly broken
-				* semantics for setuid */
-#else
-		setresuid(ruid, ruid, ruid);
-#endif
-	}
-#endif
-
-	/* we also destroy group privileges */
-	drop_privs();
-
-	/* saved set [ug]id will go away by itself on exec */
-
-	print_privs("destroy_privs, no uid should be zero  ");
-}
-
-
-uid_t get_real_uid(void)
-{
-	return ruid;
-}
-
-void init_privs(void)
-{
-	euid = geteuid();
-	ruid = getuid();
-	egid = getegid();
-	rgid = getgid();
-
-#ifndef F_SETFD
-	if(euid != ruid) {
-		fprintf(stderr,
-			"Setuid installation not supported on this platform\n");
-		fprintf(stderr,
-			"Missing F_SETFD");
-		exit(1);
-	}
-#endif
-	
-	if(euid == 0 && ruid != 0) {
-#ifdef HAVE_SETEUID
-		setuid(0); /* set real uid to 0 */
-#else
-#ifndef HAVE_SETRESUID
-		/* on this machine, it is not possible to reversibly drop
-		 * root privileges.  We print an error and quit */
-
-		/* BEOS is no longer a special case, as both euid and ruid
-		 * return 0, and thus we do not get any longer into this
-		 * branch */
-		fprintf(stderr,
-			"Seteuid call not supported on this architecture.\n");
-		fprintf(stderr,
-			"Mtools cannot be installed setuid root.\n");
-		fprintf(stderr,
-			"However, it can be installed setuid to a non root");
-		fprintf(stderr,
-			"user or setgid to any id.\n");
-		exit(1);
-#endif
-#endif
-	}
-	
-	drop_privs();
-	print_privs("after init, real should be 0, effective should not ");
-}
-
-void closeExec(int fd)
-{
-#ifdef F_SETFD
-	fcntl(fd, F_SETFD, 1);
-#endif
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/scsi.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/scsi.c	(revision 9)
+++ 	(revision )
@@ -1,274 +1,0 @@
-/*
- * scsi.c
- * Iomega Zip/Jaz drive tool
- * change protection mode and eject disk
- */
-
-/* scis.c by Markus Gyger <mgyger@itr.ch> */
-/* This code is based on ftp://gear.torque.net/pub/ziptool.c */
-/* by Grant R. Guenther with the following copyright notice: */
-
-/*  (c) 1996   Grant R. Guenther,  based on work of Itai Nahshon  */
-/*  http://www.torque.net/ziptool.html  */
-
-
-/* A.K. Moved this from mzip.c to a separate file in order to share with
- * plain_io.c */
-
-#include "sysincludes.h"
-#include "mtools.h"
-#include "scsi.h"
-
-#if defined OS_hpux
-#include <sys/scsi.h>
-#endif
-
-#ifdef OS_solaris
-#include <sys/scsi/scsi.h>
-#endif /* solaris */
-
-#ifdef OS_sunos
-#include <scsi/generic/commands.h>
-#include <scsi/impl/uscsi.h>
-#endif /* sunos */
-
-#ifdef sgi
-#include <sys/dsreq.h>
-#endif
-
-#ifdef OS_linux
-#define SCSI_IOCTL_SEND_COMMAND 1
-struct scsi_ioctl_command {
-    int  inlen;
-    int  outlen;
-    char cmd[5008];
-};
-#endif
-
-#ifdef _SCO_DS
-#include <sys/scsicmd.h>
-#endif
-
-#if (defined(OS_freebsd)) && (__FreeBSD__ >= 2)
-#include <camlib.h>
-#endif
-
-int scsi_max_length(void)
-{
-#ifdef OS_linux
-	return 8;
-#else
-	return 255;
-#endif
-}
-
-int scsi_open(const char *name, int flag, int mode, void **extra_data)
-{
-#if (defined(OS_freebsd)) && (__FreeBSD__ >= 2)
-    struct cam_device *cam_dev;
-    cam_dev = cam_open_device(name, O_RDWR);
-    *extra_data = (void *) cam_dev;
-    if (cam_dev)
-        return cam_dev->fd;
-    else
-        return -1;
-#else
-    return open(name, O_RDONLY
-#ifdef O_NDELAY
-		| O_NDELAY
-#endif
-	/* O_RDONLY  | dev->mode*/);
-#endif
-}
-
-int scsi_cmd(int fd, unsigned char *cdb, int cmdlen, scsi_io_mode_t mode,
-	     void *data, size_t len, void *extra_data)
-{
-#if defined OS_hpux
-	struct sctl_io sctl_io;
-	
-	memset(&sctl_io, 0, sizeof sctl_io);   /* clear reserved fields */
-	memcpy(sctl_io.cdb, cdb, cmdlen);      /* copy command */
-	sctl_io.cdb_length = cmdlen;           /* command length */
-	sctl_io.max_msecs = 2000;              /* allow 2 seconds for cmd */
-
-	switch (mode) {
-		case SCSI_IO_READ:
-			sctl_io.flags = SCTL_READ;
-			sctl_io.data_length = len;
-			sctl_io.data = data;
-			break;
-		case SCSI_IO_WRITE: 
-			sctl_io.flags = 0;
-			sctl_io.data_length = data ? len : 0;
-			sctl_io.data = len ? data : 0;
-			break;
-	}
-
-	if (ioctl(fd, SIOC_IO, &sctl_io) == -1) {
-		perror("scsi_io");
-		return -1;
-	}
-
-	return sctl_io.cdb_status;
-	
-#elif defined OS_sunos || defined OS_solaris
-	struct uscsi_cmd uscsi_cmd;
-	memset(&uscsi_cmd, 0, sizeof uscsi_cmd);
-	uscsi_cmd.uscsi_cdb = (char *)cdb;
-	uscsi_cmd.uscsi_cdblen = cmdlen;
-#ifdef OS_solaris
-	uscsi_cmd.uscsi_timeout = 20;  /* msec? */
-#endif /* solaris */
-	
-	uscsi_cmd.uscsi_buflen = (u_int)len;
-	uscsi_cmd.uscsi_bufaddr = data;
-
-	switch (mode) {
-		case SCSI_IO_READ:
-			uscsi_cmd.uscsi_flags = USCSI_READ;
-			break;
-		case SCSI_IO_WRITE:
-			uscsi_cmd.uscsi_flags = USCSI_WRITE;
-			break;
-	}
-
-	if (ioctl(fd, USCSICMD, &uscsi_cmd) == -1) {
-		perror("scsi_io");
-		return -1;
-	}
-
-	if(uscsi_cmd.uscsi_status) {
-		errno = 0;
-		fprintf(stderr,"scsi status=%x\n",  
-			(unsigned short)uscsi_cmd.uscsi_status);
-		return -1;
-	}
-	
-	return 0;
-	
-#elif defined OS_linux
-	struct scsi_ioctl_command scsi_cmd;
-
-
-	memcpy(scsi_cmd.cmd, cdb, cmdlen);        /* copy command */
-
-	switch (mode) {
-		case SCSI_IO_READ:
-			scsi_cmd.inlen = 0;
-			scsi_cmd.outlen = len;
-			break;
-		case SCSI_IO_WRITE:
-			scsi_cmd.inlen = len;
-			scsi_cmd.outlen = 0;
-			memcpy(scsi_cmd.cmd + cmdlen,data,len);
-			break;
-	}
-	
-	if (ioctl(fd, SCSI_IOCTL_SEND_COMMAND, &scsi_cmd) < 0) {
-		perror("scsi_io");
-		return -1;
-	}
-	
-	switch (mode) {
-		case SCSI_IO_READ:
-			memcpy(data, &scsi_cmd.cmd[0], len);
-			break;
-		case SCSI_IO_WRITE:
-			break;
-    }
-
-	return 0;  /* where to get scsi status? */
-
-#elif defined _SCO_DS
-	struct scsicmd scsi_cmd;
-
-	memset(scsi_cmd.cdb, 0, SCSICMDLEN);	/* ensure zero pad */
-	memcpy(scsi_cmd.cdb, cdb, cmdlen);
-	scsi_cmd.cdb_len = cmdlen;
-	scsi_cmd.data_len = len;
-	scsi_cmd.data_ptr = data;
-	scsi_cmd.is_write = mode == SCSI_IO_WRITE;
-	if (ioctl(fd,SCSIUSERCMD,&scsi_cmd) == -1) {
-		perror("scsi_io");
-		printf("scsi status: host=%x; target=%x\n",
-		(unsigned)scsi_cmd.host_sts,(unsigned)scsi_cmd.target_sts);
-		return -1;
-	}
-	return 0;
-#elif defined sgi
- 	struct dsreq scsi_cmd;
-
-	scsi_cmd.ds_cmdbuf = (char *)cdb;
-	scsi_cmd.ds_cmdlen = cmdlen;
-	scsi_cmd.ds_databuf = data;
-	scsi_cmd.ds_datalen = len;
-       	switch (mode) {
-	case SCSI_IO_READ:
-	  scsi_cmd.ds_flags = DSRQ_READ|DSRQ_SENSE;
-	  break;
-	case SCSI_IO_WRITE:
-	  scsi_cmd.ds_flags = DSRQ_WRITE|DSRQ_SENSE;
-	  break;
-        } 
-	scsi_cmd.ds_time = 10000;
-	scsi_cmd.ds_link = 0;
-	scsi_cmd.ds_synch =0;
-	scsi_cmd.ds_ret =0;
-	if (ioctl(fd, DS_ENTER, &scsi_cmd) == -1) {
-                perror("scsi_io");
-                return -1;
-        }
-
-        if(scsi_cmd.ds_status) {
-                errno = 0;
-                fprintf(stderr,"scsi status=%x\n",  
-                        (unsigned short)scsi_cmd.ds_status);
-                return -1;
-        }
-        
-        return 0;
-#elif (defined OS_freebsd) && (__FreeBSD__ >= 2)
-#define MSG_SIMPLE_Q_TAG 0x20 /* O/O */
-      union ccb *ccb;
-      int flags;
-      int r;
-      struct cam_device *cam_dev = (struct cam_device *) extra_data;
-
-
-      if (cam_dev==NULL || cam_dev->fd!=fd)
-      {
-                fprintf(stderr,"invalid file descriptor\n");
-              return -1;
-      }
-      ccb = cam_getccb(cam_dev);
-
-      bcopy(cdb, ccb->csio.cdb_io.cdb_bytes, cmdlen);
-
-      if (mode == SCSI_IO_READ)
-              flags = CAM_DIR_IN;
-      else if (data && len)
-              flags = CAM_DIR_OUT;
-      else
-              flags = CAM_DIR_NONE;
-      cam_fill_csio(&ccb->csio,
-                    /* retry */ 1,
-                    /* cbfcnp */ NULL,
-                    flags,
-                    /* tag_action */ MSG_SIMPLE_Q_TAG,
-                    /*data_ptr*/ len ? data : 0,
-                    /*data_len */ data ? len : 0,
-                    96,
-                    cmdlen,
-                    5000);
-                    
-      if (cam_send_ccb(cam_dev, ccb) < 0 ||
-	  (ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
-	  return -1;
-      }
-      return 0;
-#else
-      fprintf(stderr, "scsi_io not implemented\n");
-      return -1;
-#endif
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/scsi.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/scsi.h	(revision 9)
+++ 	(revision )
@@ -1,22 +1,0 @@
-#ifndef __mtools_scsi_h
-#define __mtools_scsi_h
-
-
-#define SCSI_READ 0x8
-#define SCSI_WRITE 0xA
-#define SCSI_IOMEGA 0xC
-#define SCSI_INQUIRY 0x12
-#define SCSI_MODE_SENSE 0x1a
-#define SCSI_START_STOP 0x1b
-#define SCSI_ALLOW_MEDIUM_REMOVAL 0x1e
-#define SCSI_GROUP1 0x20
-#define SCSI_READ_CAPACITY 0x25
-
-
-typedef enum { SCSI_IO_READ, SCSI_IO_WRITE } scsi_io_mode_t;
-int scsi_max_length(void);
-int scsi_cmd(int fd, unsigned char cdb[6], int clen, scsi_io_mode_t mode,
-	     void *data, size_t len, void *extra_data);
-int scsi_open(const char *name, int flags, int mode, void **extra_data);
-
-#endif /* __mtools_scsi_h */
Index: trunk/minix/commands/i386/mtools-3.9.7/signal.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/signal.c	(revision 9)
+++ 	(revision )
@@ -1,35 +1,0 @@
-#include "sysincludes.h"
-#include "mtools.h"
-
-#undef got_signal
-
-int got_signal = 0;
-
-void signal_handler(int dummy)
-{
-	got_signal = 1;
-#if 0
-	signal(SIGHUP, SIG_IGN);
-	signal(SIGINT, SIG_IGN);
-	signal(SIGTERM, SIG_IGN);
-	signal(SIGQUIT, SIG_IGN);
-#endif
-}
-
-#if 0
-int do_gotsignal(char *f, int n)
-{
-	if(got_signal)
-		fprintf(stderr, "file=%s line=%d\n", f, n);
-	return got_signal;
-}
-#endif
-
-void setup_signal(void)
-{
-	/* catch signals */
-	signal(SIGHUP, (SIG_CAST)signal_handler);
-	signal(SIGINT, (SIG_CAST)signal_handler);
-	signal(SIGTERM, (SIG_CAST)signal_handler);
-	signal(SIGQUIT, (SIG_CAST)signal_handler);
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/stream.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/stream.c	(revision 9)
+++ 	(revision )
@@ -1,65 +1,0 @@
-#include "sysincludes.h"
-#include "msdos.h"
-#include "stream.h"
-
-int batchmode = 0;
-
-int flush_stream(Stream_t *Stream)
-{
-	int ret=0;
-	if(!batchmode) {
-		if(Stream->Class->flush)
-			ret |= Stream->Class->flush(Stream);
-		if(Stream->Next)
-			ret |= flush_stream(Stream->Next);
-	}
-	return ret;
-}
-
-Stream_t *copy_stream(Stream_t *Stream)
-{
-	if(Stream)
-		Stream->refs++;
-	return Stream;
-}
-
-int free_stream(Stream_t **Stream)
-{
-	int ret=0;
-
-	if(!*Stream)
-		return -1;
-	if(! --(*Stream)->refs){
-		if((*Stream)->Class->flush)
-			ret |= (*Stream)->Class->flush(*Stream);
-		if((*Stream)->Class->freeFunc)
-			ret |= (*Stream)->Class->freeFunc(*Stream);
-		if((*Stream)->Next)
-			ret |= free_stream(&(*Stream)->Next);
-		Free(*Stream);
-	} else if ( (*Stream)->Next )
-		ret |= flush_stream((*Stream)->Next);		
-	*Stream = NULL;
-	return ret;
-}
-
-
-#define GET_DATA(stream, date, size, type, address) \
-(stream)->Class->get_data( (stream), (date), (size), (type), (address) )
-
-
-int get_data_pass_through(Stream_t *Stream, time_t *date, mt_size_t *size,
-			  int *type, int *address)
-{
-       return GET_DATA(Stream->Next, date, size, type, address);
-}
-
-int read_pass_through(Stream_t *Stream, char *buf, mt_off_t start, size_t len)
-{
-	return READS(Stream->Next, buf, start, len);
-}
-
-int write_pass_through(Stream_t *Stream, char *buf, mt_off_t start, size_t len)
-{
-	return WRITES(Stream->Next, buf, start, len);
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/stream.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/stream.h	(revision 9)
+++ 	(revision )
@@ -1,71 +1,0 @@
-#ifndef MTOOLS_STREAM_H
-#define MTOOLS_STREAM_H
-
-typedef struct Stream_t {
-	struct Class_t *Class;
-	int refs;
-	struct Stream_t *Next;
-	struct Stream_t *Buffer;
-} Stream_t;
-
-#include "mtools.h"
-#include "msdos.h"
-
-#include "llong.h"
-
-typedef struct Class_t {
-	int (*read)(Stream_t *, char *, mt_off_t, size_t);
-	int (*write)(Stream_t *, char *, mt_off_t, size_t);
-	int (*flush)(Stream_t *);
-	int (*freeFunc)(Stream_t *);
-	int (*set_geom)(Stream_t *, device_t *, device_t *, int media,
-					struct bootsector *);
-	int (*get_data)(Stream_t *, time_t *, mt_size_t *, int *, int *);
-	int (*pre_allocate)(Stream_t *, mt_size_t);
-} Class_t;
-
-#define READS(stream, buf, address, size) \
-(stream)->Class->read( (stream), (char *) (buf), (address), (size) )
-
-#define WRITES(stream, buf, address, size) \
-(stream)->Class->write( (stream), (char *) (buf), (address), (size) )
-
-#define SET_GEOM(stream, dev, orig_dev, media, boot) \
-(stream)->Class->set_geom( (stream), (dev), (orig_dev), (media), (boot) )
-
-#define GET_DATA(stream, date, size, type, address) \
-(stream)->Class->get_data( (stream), (date), (size), (type), (address) )
-
-#define PRE_ALLOCATE(stream, size) \
-(stream)->Class->pre_allocate((stream), (size))
-
-int flush_stream(Stream_t *Stream);
-Stream_t *copy_stream(Stream_t *Stream);
-int free_stream(Stream_t **Stream);
-
-#define FLUSH(stream) \
-flush_stream( (stream) )
-
-#define FREE(stream) \
-free_stream( (stream) )
-
-#define COPY(stream) \
-copy_stream( (stream) )
-
-
-#define DeclareThis(x) x *This = (x *) Stream
-
-int force_write(Stream_t *Stream, char *buf, mt_off_t start, size_t len);
-int force_read(Stream_t *Stream, char *buf, mt_off_t start, size_t len);
-
-extern struct Stream_t *default_drive;
-
-int get_data_pass_through(Stream_t *Stream, time_t *date, mt_size_t *size,
-						  int *type, int *address);
-
-int read_pass_through(Stream_t *Stream, char *buf, mt_off_t start, size_t len);
-int write_pass_through(Stream_t *Stream, char *buf, mt_off_t start, size_t len);
-
-
-#endif
-
Index: trunk/minix/commands/i386/mtools-3.9.7/streamcache.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/streamcache.c	(revision 9)
+++ 	(revision )
@@ -1,77 +1,0 @@
-/*
- * streamcache.c
- * Managing a cache of open disks
- */
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "vfat.h"
-#include "fs.h"
-#include "mainloop.h"
-#include "plain_io.h"
-#include "file.h"
-
-static int is_initialized = 0;
-static Stream_t *fss[256]; /* open drives */
-
-static void finish_sc(void)
-{
-	int i;
-
-	for(i=0; i<256; i++){
-		if(fss[i] && fss[i]->refs != 1 )
-			fprintf(stderr,"Streamcache allocation problem:%c %d\n",
-				i, fss[i]->refs);
-		FREE(&(fss[i]));
-	}
-}
-
-static void init_streamcache(void)
-{
-	int i;
-
-	if(is_initialized)
-		return;
-	is_initialized = 1;
-	for(i=0; i<256; i++)
-		fss[i]=0;
-	atexit(finish_sc);
-}
-
-Stream_t *open_root_dir(char *drive, int flags)
-{
-	Stream_t *Fs;
-	int i, k;
-
-	init_streamcache();
-
-	k = -1;
-	for(i=0; i<256; i++) {
-		if (fss[i] == NULL || strcmp(getDrive(fss[i]), drive) == 0) {
-			k = i;
-			break;
-		}
-	}
-
-	if(k == -1) {
-		fprintf(stderr, "Cannot initialize '%s:', out of table space\n",
-			drive);
-		return NULL;
-	}
-
-	/* open the drive */
-	if(fss[k])
-		Fs = fss[k];
-	else {
-		Fs = fs_init(drive, flags);
-		if (!Fs){
-			fprintf(stderr, "Cannot initialize '%s:'\n", drive);
-			return NULL;
-		}
-
-		fss[k] = Fs;
-	}
-
-	return OpenRoot(Fs);
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/subdir.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/subdir.c	(revision 9)
+++ 	(revision )
@@ -1,26 +1,0 @@
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "vfat.h"
-#include "file.h"
-#include "buffer.h"
-
-/*
- * Find the directory and load a new dir_chain[].  A null directory
- * is OK.  Returns a 1 on error.
- */
-
-
-void bufferize(Stream_t **Dir)
-{
-	Stream_t *BDir;
-
-	if(!*Dir)
-		return;
-	BDir = buf_init(*Dir, 64*16384, 512, MDIR_SIZE);
-	if(!BDir){
-		FREE(Dir);
-		*Dir = NULL;
-	} else
-		*Dir = BDir;
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/sysincludes.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/sysincludes.h	(revision 9)
+++ 	(revision )
@@ -1,518 +1,0 @@
-/* System includes for mtools */
-
-#ifndef SYSINCLUDES_H
-#define SYSINCLUDES_H
-
-#include "config.h"
-
-/* OS/2 needs __inline__, but for some reason is not autodetected */
-#ifdef __EMX__
-# ifndef inline
-#  define inline __inline__
-# endif
-#endif
-
-/***********************************************************************/
-/*                                                                     */
-/* OS dependancies which cannot be covered by the autoconfigure script */
-/*                                                                     */
-/***********************************************************************/
-
-
-#ifdef OS_aux
-/* A/UX needs POSIX_SOURCE, just as AIX does. Unlike SCO and AIX, it seems
- * to prefer TERMIO over TERMIOS */
-#ifndef _POSIX_SOURCE
-# define _POSIX_SOURCE
-#endif
-#ifndef POSIX_SOURCE
-# define POSIX_SOURCE
-#endif
-
-#endif
-
-
-/* On AIX, we have to prefer strings.h, as string.h lacks a prototype 
- * for strcasecmp. On most other architectures, it's string.h which seems
- * to be more complete */
-#if (defined OS_aix && defined HAVE_STRINGS_H)
-# undef HAVE_STRING_H
-#endif
-
-
-#ifdef OS_ultrix
-/* on ultrix, if termios present, prefer it instead of termio */
-# ifdef HAVE_TERMIOS_H
-#  undef HAVE_TERMIO_H
-# endif
-#endif
-
-#ifdef OS_linux_gnu
-/* RMS strikes again */
-# ifndef OS_linux
-#  define OS_linux
-# endif
-#endif
-
-#ifdef OS_Minix
-/* typedef unsigned char *caddr_t; */
-#endif
-
-
-/***********************************************************************/
-/*                                                                     */
-/* Compiler dependancies                                               */
-/*                                                                     */
-/***********************************************************************/
-
-
-#if defined __GNUC__ && defined __STDC__
-/* gcc -traditional doesn't have PACKED, UNUSED and NORETURN */
-# define PACKED __attribute__ ((packed))
-# if __GNUC__ == 2 && __GNUC_MINOR__ > 6 || __GNUC__ >= 3
-/* gcc 2.6.3 doesn't have "unused" */		/* mool */
-#  define UNUSED(x) x __attribute__ ((unused));x
-# else
-#  define UNUSED(x) x
-# endif
-# define NORETURN __attribute__ ((noreturn))
-#else
-# define UNUSED(x) x
-# define PACKED /* */
-# define NORETURN /* */
-#endif
-
-
-/***********************************************************************/
-/*                                                                     */
-/* Include files                                                       */
-/*                                                                     */
-/***********************************************************************/
-
-
-#include <sys/types.h>
-
-#ifdef OS_Minix
-typedef unsigned long uoff_t;
-#define off_t uoff_t
-#endif
-
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-
-#include <stdio.h>
-
-#ifndef OS_Minix
-# include <ctype.h>
-#else
-# ifdef __minix_vmd
-#  include <bsd/asciictype.h>	/* Minix-vmd: Ignore locales on purpose. */
-# else
-#  include <ctype.h>		/* Minix: What's that "locale" thing? */
-# endif
-#endif
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#ifdef HAVE_LINUX_UNISTD_H
-# include <linux/unistd.h>
-#endif
-
-#ifdef HAVE_LIBC_H
-# include <libc.h>
-#endif
-
-#ifdef HAVE_GETOPT_H
-# include <getopt.h>
-#else
-# ifndef OS_Minix
-int getopt();
-extern char *optarg;
-extern int optind, opterr;
-# endif
-#endif
-
-#ifdef HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
-#ifdef HAVE_LIMITS_H
-# include <limits.h>
-#endif
-
-#ifdef HAVE_SYS_FILE_H
-# include <sys/file.h>
-#endif
-
-#ifdef HAVE_SYS_IOCTL_H
-# ifndef sunos
-# include <sys/ioctl.h>
-#endif
-#endif
-/* if we don't have sys/ioctl.h, we rely on unistd to supply a prototype
- * for it. If it doesn't, we'll only get a (harmless) warning. The idea
- * is to get mtools compile on as many platforms as possible, but to not
- * suppress warnings if the platform is broken, as long as these warnings do
- * not prevent compilation */
-
-#ifdef TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# ifdef HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-
-#ifndef NO_TERMIO
-# ifdef HAVE_TERMIO_H
-#  include <termio.h>
-# elif defined HAVE_SYS_TERMIO_H
-#  include <sys/termio.h>
-# endif
-# if !defined OS_ultrix || !(defined HAVE_TERMIO_H || defined HAVE_TERMIO_H)
-/* on Ultrix, avoid double inclusion of both termio and termios */
-#  ifdef HAVE_TERMIOS_H
-#   include <termios.h>
-#  elif defined HAVE_SYS_TERMIOS_H
-#   include <sys/termios.h>
-#  endif
-# endif
-# ifdef HAVE_STTY_H
-#  include <sgtty.h>
-# endif
-#endif
-
-
-#if defined(OS_aux) && !defined(_SYSV_SOURCE)
-/* compiled in POSIX mode, this is left out unless SYSV */
-#define	NCC	8
-struct termio {
-	unsigned short	c_iflag;	/* input modes */
-	unsigned short	c_oflag;	/* output modes */
-	unsigned short	c_cflag;	/* control modes */
-	unsigned short	c_lflag;	/* line discipline modes */
-	char	c_line;			/* line discipline */
-	unsigned char	c_cc[NCC];	/* control chars */
-};
-extern int ioctl(int fildes, int request, void *arg);
-#endif
-
-
-#ifdef HAVE_MNTENT_H
-# include <mntent.h>
-#endif
-
-#ifdef HAVE_SYS_PARAM_H
-# include <sys/param.h>
-#endif
-
-/* Can only be done here, as BSD is defined in sys/param.h :-( */
-#if defined BSD || defined __BEOS__
-/* on BSD and on BEOS, we prefer gettimeofday, ... */
-# ifdef HAVE_GETTIMEOFDAY
-#  undef HAVE_TZSET
-# endif
-#else /* BSD */
-/* ... elsewhere we prefer tzset */
-# ifdef HAVE_TZSET
-#  undef HAVE_GETTIMEOFDAY
-# endif
-#endif
-
-
-#include <sys/stat.h>
-
-#include <errno.h>
-extern int errno;
-
-#include <pwd.h>
-
-
-#ifdef HAVE_STRING_H
-# include <string.h>
-#else
-# ifdef HAVE_STRINGS_H
-#  include <strings.h>
-# endif
-#endif
-
-#ifdef HAVE_MEMORY_H
-# include <memory.h>
-#endif
-
-#ifdef HAVE_MALLOC_H
-# include <malloc.h>
-#endif
-
-#ifdef HAVE_SIGNAL_H
-# include <signal.h>
-#else
-# ifdef HAVE_SYS_SIGNAL_H
-#  include <sys/signal.h>
-# endif
-#endif
-
-#ifdef HAVE_UTIME_H
-# include <utime.h>
-#endif
-
-#ifdef HAVE_SYS_WAIT_H
-# ifndef DONT_NEED_WAIT
-#  include <sys/wait.h>
-# endif
-#endif
-
-
-#ifdef USE_FLOPPYD
-
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-
-#ifdef HAVE_NETDB_H
-#include <netdb.h>
-#endif
-
-#ifdef HAVE_X11_XAUTH_H
-#include <X11/Xauth.h>
-#endif
-
-#ifdef HAVE_X11_XLIB_H
-#include <X11/Xlib.h>
-#endif
-
-#endif
-
-#ifndef INADDR_NONE
-#define INADDR_NONE (-1)
-#endif
-
-
-#ifdef sgi
-#define MSGIHACK __EXTENSIONS__
-#undef __EXTENSIONS__
-#endif
-#include <math.h>
-#ifdef sgi
-#define __EXTENSIONS__ MSGIHACK
-#undef MSGIHACK
-#endif
-
-/* missing functions */
-#ifndef HAVE_SRANDOM
-# define srandom srand48
-#endif
-
-#ifndef HAVE_RANDOM
-# define random (long)lrand48
-#endif
-
-#if __minix && !__minix_vmd
-# define srandom srand
-# define random rand
-#endif
-
-#ifndef HAVE_STRCHR
-# define strchr index
-#endif
-
-#ifndef HAVE_STRRCHR
-# define strrchr rindex
-#endif
-
-
-#define SIG_CAST RETSIGTYPE(*)()
-
-#ifndef HAVE_STRDUP
-extern char *strdup(const char *str);
-#endif /* HAVE_STRDUP */
-
-
-#ifndef HAVE_MEMCPY
-extern char *memcpy(char *s1, const char *s2, size_t n);
-#endif
-
-#ifndef HAVE_MEMSET
-extern char *memset(char *s, char c, size_t n);
-#endif /* HAVE_MEMSET */
-
-
-#ifndef HAVE_STRPBRK
-extern char *strpbrk(const char *string, const char *brkset);
-#endif /* HAVE_STRPBRK */
-
-
-#ifndef HAVE_STRTOUL
-unsigned long strtoul(const char *string, char **eptr, int base);
-#endif /* HAVE_STRTOUL */
-
-#ifndef HAVE_STRSPN
-size_t strspn(const char *s, const char *accept);
-#endif /* HAVE_STRSPN */
-
-#ifndef HAVE_STRCSPN
-size_t strcspn(const char *s, const char *reject);
-#endif /* HAVE_STRCSPN */
-
-#ifndef HAVE_STRERROR
-char *strerror(int errno);
-#endif
-
-#ifndef HAVE_ATEXIT
-int atexit(void (*function)(void)); 
-
-#ifndef HAVE_ON_EXIT
-void myexit(int code) NORETURN;
-#define exit myexit
-#endif
-
-#endif
-
-
-#ifndef HAVE_MEMMOVE
-# define memmove(DST, SRC, N) bcopy(SRC, DST, N)
-#endif
-
-#ifndef HAVE_STRCASECMP
-int strcasecmp(const char *s1, const char *s2);
-#endif
-
-#ifndef HAVE_STRNCASECMP
-int strncasecmp(const char *s1, const char *s2, size_t n);
-#endif
-
-#ifndef HAVE_GETPASS
-char *getpass(const char *prompt);
-#endif
-
-#if 0
-#ifndef HAVE_BASENAME
-const char *basename(const char *filename);
-#endif
-#endif
-
-const char *_basename(const char *filename);
-
-#ifndef __STDC__
-# ifndef signed
-#  define signed /**/
-# endif 
-#endif /* !__STDC__ */
-
-
-
-/***************************************************************************/
-/*                                                                         */
-/* Prototypes for systems where the functions exist but not the prototypes */
-/*                                                                         */
-/***************************************************************************/
-
-
-
-/* prototypes which might be missing on some platforms, even if the functions
- * are present.  Do not declare argument types, in order to avoid conflict
- * on platforms where the prototypes _are_ correct.  Indeed, for most of
- * these, there are _several_ "correct" parameter definitions, and not all
- * platforms use the same.  For instance, some use the const attribute for
- * strings not modified by the function, and others do not.  By using just
- * the return type, which rarely changes, we avoid these problems.
- */
-
-/* Correction:  Now it seems that even return values are not standardized :-(
-  For instance  DEC-ALPHA, OSF/1 3.2d uses ssize_t as a return type for read
-  and write.  NextStep uses a non-void return value for exit, etc.  With the
-  advent of 64 bit system, we'll expect more of these problems in the future.
-  Better uncomment the lot, except on SunOS, which is known to have bad
-  incomplete files.  Add other OS'es with incomplete include files as needed
-  */
-#if (defined OS_sunos || defined OS_ultrix)
-int read();
-int write();
-int fflush();
-char *strdup();
-int strcasecmp();
-int strncasecmp();
-char *getenv();
-unsigned long strtoul();
-int pclose();
-void exit();
-char *getpass();
-int atoi();
-FILE *fdopen();
-FILE *popen();
-#endif
-
-#ifndef MAXPATHLEN
-# ifdef PATH_MAX
-#  define MAXPATHLEN PATH_MAX
-# else
-#  define MAXPATHLEN 1024
-# endif
-#endif
-
-
-#ifndef OS_linux
-# undef USE_XDF
-#endif
-
-#ifdef NO_XDF
-# undef USE_XDF
-#endif
-
-#ifdef __EMX__
-#define INCL_BASE
-#define INCL_DOSDEVIOCTL
-#include <os2.h>
-#endif
-
-#ifdef OS_nextstep
-/* nextstep doesn't have this.  Unfortunately, we cannot test its presence
-   using AC_EGREP_HEADER, as we don't know _which_ header to test, and in
-   the general case utime.h might be non-existent */
-struct utimbuf
-{
-  time_t actime,modtime;
-};
-#endif
-
-/* NeXTStep doesn't have these */
-#if !defined(S_ISREG) && defined (_S_IFMT) && defined (_S_IFREG)
-#define S_ISREG(mode)   (((mode) & (_S_IFMT)) == (_S_IFREG))
-#endif
-
-#if !defined(S_ISDIR) && defined (_S_IFMT) && defined (_S_IFDIR)
-#define S_ISDIR(mode)   (((mode) & (_S_IFMT)) == (_S_IFDIR))
-#endif
-
-
-#if 0
-
-#define malloc(x) mymalloc(x)
-#define calloc(x,y) mycalloc(x,y)
-#define free(x) myfree(x)
-#define realloc(x,y) myrealloc(x,y)
-#define strdup(a) mystrdup(a)
-
-void *mycalloc(size_t nmemb, size_t size);
-void *mymalloc(size_t size);
-void myfree(void *ptr);
-void *myrealloc(void *ptr, size_t size);
-char *mystrdup(char *a);
-
-#endif
-
-#endif
Index: trunk/minix/commands/i386/mtools-3.9.7/toupper.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/toupper.c	(revision 9)
+++ 	(revision )
@@ -1,491 +1,0 @@
-#include "codepage.h"
-
-/* MS-DOS doesn't use the same ASCII code as Unix does. The appearance
- * of the characters is defined using code pages. These code pages
- * aren't the same for all countries. For instance, some code pages
- * don't contain upper case accented characters. This affects two
- * things, relating to filenames:
-
- * 1. upper case characters. In short names, only upper case
- * characters are allowed.  This also holds for accented characters.
- * For instance, in a code page which doesn't contain accented
- * uppercase characters, the accented lowercase characters get
- * transformed into their unaccented counterparts. This is very bad
- * design. Indeed, stuff like national language support should never
- * affect filesystem integrity. And it does: A filename which is legal
- * in one country could be illegal in another one. Bad News for
- * frequent travellers.
-
- * 2. long file names: Micro$oft has finally come to their senses and
- * uses a more standard mapping for the long file names.  They use
- * Unicode, which is basically a 32 bit version of ASCII. Its first
- * 256 characters are identical to Unix ASCII. Thus, the code page
- * also affects the correspondence between the codes used in long
- * names and those used in short names.
-
- * Such a bad design is rather unbelievable. That's why I quoted the
- * translation tables. BEGIN FAIR USE EXCERPT:
- */
-
-unsigned char toucase[][128]={
-	/* 0 */
-	/* 437 German Umlauts upcased, French accents 
-	 * upcased and lose accent */
-	{ 0x80, 0x9a, 0x45, 0x41, 0x8e, 0x41, 0x8f, 0x80, 
-	  0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x8e, 0x8f, 
-	  0x90, 0x92, 0x92, 0x4f, 0x99, 0x4f, 0x55, 0x55, 
-	  0x59, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 
-	  0x41, 0x49, 0x4f, 0x55, 0xa5, 0xa5, 0xa6, 0xa7, 
-	  0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 
-	  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 
-	  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 
-	  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 
-	  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 
-	  0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 
-	  0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 
-	  0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 
-	  0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 
-	  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 
-	  0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
-
-	/* 1 */
-	{ 0x43, 0x55, 0x45, 0x41, 0x41, 0x41, 0x86, 0x43, 
-	  0x45, 0x45, 0x45, 0x49, 0x49, 0x8d, 0x41, 0x8f, 
-	  0x45, 0x45, 0x45, 0x4f, 0x45, 0x49, 0x55, 0x55, 
-	  0x98, 0x4f, 0x55, 0x9b, 0x9c, 0x55, 0x55, 0x9f, 
-	  0xa0, 0xa1, 0x4f, 0x55, 0xa4, 0xa5, 0xa6, 0xa7, 
-	  0x49, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 
-	  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 
-	  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 
-	  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 
-	  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 
-	  0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 
-	  0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 
-	  0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 
-	  0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 
-	  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 
-	  0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
-
-	/* 2 */
-	{ 0x80, 0x9a, 0x90, 0x41, 0x8e, 0x41, 0x8f, 0x80, 
-	  0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x8e, 0x8f, 
-	  0x90, 0x92, 0x92, 0x4f, 0x99, 0x4f, 0x55, 0x55, 
-	  0x59, 0x99, 0x9a, 0x9d, 0x9c, 0x9d, 0x9e, 0x9f, 
-	  0x41, 0x49, 0x4f, 0x55, 0xa5, 0xa5, 0xa6, 0xa7, 
-	  0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 
-	  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 
-	  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 
-	  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 
-	  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 
-	  0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 
-	  0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 
-	  0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 
-	  0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 
-	  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 
-	  0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
-
-	/* 3 */
-	{ 0x80, 0x9a, 0x90, 0x41, 0x8e, 0x41, 0x8f, 0x80, 
-	  0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x8e, 0x8f, 
-	  0x90, 0x92, 0x92, 0x4f, 0x99, 0x4f, 0x55, 0x55, 
-	  0x59, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 
-	  0x41, 0x49, 0x4f, 0x55, 0xa5, 0xa5, 0xa6, 0xa7, 
-	  0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 
-	  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 
-	  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 
-	  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 
-	  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 
-	  0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 
-	  0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 
-	  0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 
-	  0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 
-	  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 
-	  0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
-
-	/* 4 
-	 * 437: all accented characters lose their accent */
-	{ 0x80, 0x55, 0x45, 0x41, 0x41, 0x41, 0x8f, 0x80, 
-	  0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x41, 0x8f, 
-	  0x45, 0x92, 0x92, 0x4f, 0x4f, 0x4f, 0x55, 0x55, 
-	  0x98, 0x4f, 0x55, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 
-	  0x41, 0x49, 0x4f, 0x55, 0xa5, 0xa5, 0xa6, 0xa7, 
-	  0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 
-	  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 
-	  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 
-	  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 
-	  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 
-	  0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 
-	  0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 
-	  0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 
-	  0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 
-	  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 
-	  0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
-
-	/* 5 */
-	{ 0x80, 0x9a, 0x90, 0x8f, 0x8e, 0x91, 0x86, 0x80, 
-	  0x89, 0x89, 0x92, 0x8b, 0x8c, 0x98, 0x8e, 0x8f, 
-	  0x90, 0x91, 0x92, 0x8c, 0x99, 0xa9, 0x96, 0x9d, 
-	  0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 
-	  0x86, 0x8b, 0x9f, 0x96, 0xa5, 0xa5, 0xa6, 0xa7, 
-	  0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 
-	  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 
-	  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 
-	  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 
-	  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 
-	  0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 
-	  0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 
-	  0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 
-	  0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 
-	  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 
-	  0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
-
-	/* 6 All accented characters lose their accent
-	   when upcased. C loses cedilla. æ upcased. ø
-	   loses slash. Ð, ñ, ß intact */
-	{ 0x43, 0x55, 0x45, 0x41, 0x41, 0x41, 0x41, 0x43, 
-	  0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x41, 0x41, 
-	  0x45, 0x92, 0x92, 0x4f, 0x4f, 0x4f, 0x55, 0x55, 
-	  0x59, 0x4f, 0x55, 0x4f, 0x9c, 0x4f, 0x9e, 0x9f, 
-	  0x41, 0x49, 0x4f, 0x55, 0xa5, 0xa5, 0xa6, 0xa7, 
-	  0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 
-	  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0x41, 0x41, 0x41, 
-	  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 
-	  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0x41, 0x41, 
-	  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 
-	  0xd1, 0xd1, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 
-	  0x49, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0x49, 0xdf, 
-	  0x4f, 0xe1, 0x4f, 0x4f, 0x4f, 0x4f, 0xe6, 0xe8, 
-	  0xe8, 0x55, 0x55, 0x55, 0x59, 0x59, 0xee, 0xef, 
-	  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 
-	  0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
-
-	/* 7: As 6, but German Umlauts keep their Umlaut */
-	{ 0x43, 0x9a, 0x45, 0x41, 0x8e, 0x41, 0x41, 0x43, 
-	  0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x8e, 0x41, 
-	  0x45, 0x92, 0x92, 0x4f, 0x99, 0x4f, 0x55, 0x55, 
-	  0x59, 0x99, 0x9a, 0x4f, 0x9c, 0x4f, 0x9e, 0x9f, 
-	  0x41, 0x49, 0x4f, 0x55, 0xa5, 0xa5, 0xa6, 0xa7, 
-	  0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 
-	  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0x41, 0x41, 0x41, 
-	  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 
-	  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0x41, 0x41, 
-	  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 
-	  0xd1, 0xd1, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 
-	  0x49, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0x49, 0xdf, 
-	  0x4f, 0xe1, 0x4f, 0x4f, 0x4f, 0x4f, 0xe6, 0xe8, 
-	  0xe8, 0x55, 0x55, 0x55, 0x59, 0x59, 0xee, 0xef, 
-	  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 
-	  0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
-
-	/* 8: All characters except ÿ keep their accent
-	 */
-	{ 0x80, 0x9a, 0x90, 0xb6, 0x8e, 0xb7, 0x8f, 0x80, 
-	  0xd2, 0xd3, 0xd4, 0xd8, 0xd7, 0xde, 0x8e, 0x8f, 
-	  0x90, 0x92, 0x92, 0xe2, 0x99, 0xe3, 0xea, 0xeb, 
-	  0x59, 0x99, 0x9a, 0x9d, 0x9c, 0x9d, 0x9e, 0x9f, 
-	  0xb5, 0xd6, 0xe0, 0xe9, 0xa5, 0xa5, 0xa6, 0xa7, 
-	  0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 
-	  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 
-	  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 
-	  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc7, 0xc7, 
-	  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 
-	  0xd1, 0xd1, 0xd2, 0xd3, 0xd4, 0x49, 0xd6, 0xd7, 
-	  0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 
-	  0xe0, 0xe1, 0xe2, 0xe3, 0xe5, 0xe5, 0xe6, 0xe8, 
-	  0xe8, 0xe9, 0xea, 0xeb, 0xed, 0xed, 0xee, 0xef, 
-	  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 
-	  0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
-
-	/* 9: As 6, but Ç and Å preserved */
-	{ 0x80, 0x55, 0x45, 0x41, 0x41, 0x41, 0x8f, 0x80, 
-	  0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x41, 0x8f, 
-	  0x45, 0x92, 0x92, 0x4f, 0x4f, 0x4f, 0x55, 0x55, 
-	  0x98, 0x4f, 0x55, 0x4f, 0x9c, 0x4f, 0x9e, 0x9f, 
-	  0x41, 0x49, 0x4f, 0x55, 0xa5, 0xa5, 0xa6, 0xa7, 
-	  0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 
-	  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0x41, 0x41, 0x41, 
-	  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 
-	  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0x41, 0x41, 
-	  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 
-	  0xd1, 0xd1, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 
-	  0x49, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0x49, 0xdf, 
-	  0x4f, 0xe1, 0x4f, 0x4f, 0x4f, 0x4f, 0xe6, 0xe8, 
-	  0xe8, 0x55, 0x55, 0x55, 0x59, 0x59, 0xee, 0xef, 
-	  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 
-	  0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
-
-	/* 10: every accented character keeps its accent */
-	{ 0x80, 0x9a, 0x90, 0xb6, 0x8e, 0xb7, 0x8f, 0x80, 
-	  0xd2, 0xd3, 0xd4, 0xd8, 0xd7, 0xde, 0x8e, 0x8f, 
-	  0x90, 0x92, 0x92, 0xe2, 0x99, 0xe3, 0xea, 0xeb, 
-	  0x98, 0x99, 0x9a, 0x9d, 0x9c, 0x9d, 0x9e, 0x9f, 
-	  0xb5, 0xd6, 0xe0, 0xe9, 0xa5, 0xa5, 0xa6, 0xa7, 
-	  0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 
-	  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 
-	  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 
-	  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc7, 0xc7, 
-	  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 
-	  0xd1, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 
-	  0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 
-	  0xe0, 0xe1, 0xe2, 0xe3, 0xe5, 0xe5, 0xe6, 0xe8, 
-	  0xe8, 0xe9, 0xea, 0xeb, 0xed, 0xed, 0xee, 0xef, 
-	  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 
-	  0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
-
-	/* 11 */
-	{ 0x80, 0x9a, 0x90, 0xb6, 0x8e, 0xde, 0x8f, 0x80, 
-	  0x9d, 0xd3, 0x8a, 0x8a, 0xd7, 0x8d, 0x8e, 0x8f, 
-	  0x90, 0x91, 0x91, 0xe2, 0x99, 0x95, 0x95, 0x97, 
-	  0x97, 0x99, 0x9a, 0x9b, 0x9b, 0x9d, 0x9e, 0xac, 
-	  0xb5, 0xd6, 0xe0, 0xe9, 0xa4, 0xa4, 0xa6, 0xa6, 
-	  0xa8, 0xa8, 0xaa, 0x8d, 0xac, 0xb8, 0xae, 0xaf, 
-	  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 
-	  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbd, 0xbf, 
-	  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc6, 
-	  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 
-	  0xd1, 0xd1, 0xd2, 0xd3, 0xd2, 0xd5, 0xd6, 0xd7, 
-	  0xb7, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 
-	  0xe0, 0xe1, 0xe2, 0xe3, 0xe3, 0xd5, 0xe6, 0xe6, 
-	  0xe8, 0xe9, 0xe8, 0xeb, 0xed, 0xed, 0xdd, 0xef, 
-	  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 
-	  0xf8, 0xf9, 0xfa, 0xeb, 0xfc, 0xfc, 0xfe, 0xff },
-
-
-	/* 14 All accented characters lose their accent, C loses cedilla,
-	 * ø loses slash.  æ upcased. Ð, ñ, ß intact */
-	{ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
-	  0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
-
-	  0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
-	  0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
-
-	  0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
-	  0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
-
-	  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
-	  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
-
-	  0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0xc6, 0x43,
-	  0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49,
-
-	  0xd0, 0xd1, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0xd7,
-	  0x4f, 0x55, 0x55, 0x55, 0x55, 0x59, 0xde, 0xdf,
-
-	  0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0xc6, 0x43,
-	  0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49,
-
-	  0xd0, 0xd1, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0xf7,
-	  0x4f, 0x55, 0x55, 0x55, 0x55, 0x59, 0xde, 0x59  },
-
-
-
-	/* 15 as 14, but German Umlauts (ä, ö, ü) keep their Umlaut when
-	   upcased */
-	{ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
-	  0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
-
-	  0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
-	  0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
-
-	  0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
-	  0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
-
-	  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
-	  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
-
-	  0x41, 0x41, 0x41, 0x41, 0xc4, 0x41, 0xc6, 0x43,
-	  0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49,
-
-	  0xd0, 0xd1, 0x4f, 0x4f, 0x4f, 0x4f, 0xd6, 0xd7,
-	  0x4f, 0x55, 0x55, 0x55, 0xdc, 0x59, 0xde, 0xdf,
-
-	  0x41, 0x41, 0x41, 0x41, 0xc4, 0x41, 0xc6, 0x43,
-	  0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49,
-
-	  0xd0, 0xd1, 0x4f, 0x4f, 0x4f, 0x4f, 0xd6, 0xf7,
-	  0x4f, 0x55, 0x55, 0x55, 0xdc, 0x59, 0xde, 0x59  },
-
-
-	/* 16 every accented character except ÿ keeps its accent */
-	{ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
-	  0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
-
-	  0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
-	  0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
-
-	  0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
-	  0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
-
-	  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
-	  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
-
-	  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
-	  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
-
-	  0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
-	  0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
-
-	  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
-	  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
-
-	  0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xf7,
-	  0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0x59 },
-
-
-
-	/* 17: As 6, but Ç, Å and ÿ preserved */
-	{ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
-	  0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
-
-	  0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
-	  0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
-
-	  0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
-	  0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
-
-	  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
-	  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
-
-	  0x41, 0x41, 0x41, 0x41, 0x41, 0xc5, 0xc6, 0xc7,
-	  0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49,
-
-	  0xd0, 0xd1, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0xd7,
-	  0x4f, 0x55, 0x55, 0x55, 0x55, 0x59, 0xde, 0xdf,
-
-	  0x41, 0x41, 0x41, 0x41, 0x41, 0xc5, 0xc6, 0xc7,
-	  0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49,
-
-	  0xd0, 0xd1, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0xf7,
-	  0x4f, 0x55, 0x55, 0x55, 0x55, 0x59, 0xde, 0xff  },
-
-
-	/* 18 every accented character keeps its accent */
-	{ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
-	  0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
-
-	  0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
-	  0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
-
-	  0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
-	  0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
-
-	  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
-	  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
-
-	  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
-	  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
-
-	  0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
-	  0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
-
-	  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
-	  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
-
-	  0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xf7,
-	  0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xff },
-
-
-	/* 19 */
-	{ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
-	  0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
-	  0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
-	  0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
-	  0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
-	  0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
-	  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
-	  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
-	  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
-	  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
-	  0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
-	  0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
-	  0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
-	  0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
-	  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
-	  0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
-
-};
-
-country_t countries[]={
-	{   1, 437, 437,   0 },
-	{   1, 850, 437,   6 },
-	{   1, 819, 437,  14 },
-	{  44, 437, 437,   0 },
-	{  44, 850, 437,   6 },
-	{  44, 819, 437,  14 },
-	{  33, 437, 437,   0 },
-	{  33, 850, 437,   6 },
-	{  33, 819, 437,  14 },
-	{  49, 437, 437,   0 },
-	{  49, 850, 437,   7 },
-	{  49, 819, 437,  15 },
-	{  34, 850, 437,   8 },
-	{  34, 819, 437,  16 },
-	{  34, 437, 437,   0 },
-	{  39, 437, 437,   0 },
-	{  39, 850, 437,   6 },
-	{  39, 819, 437,  14 },
-	{  46, 437, 437,   3 },
-	{  46, 850, 437,   8 },
-	{  46, 819, 437,  16 },
-	{  45, 850, 865,   8 },
-	{  45, 819, 865,  16 },
-	{  45, 865, 865,   2 },
-	{  41, 850, 437,   8 },
-	{  41, 819, 437,  16 },
-	{  41, 437, 437,   3 },
-	{  47, 850, 865,   8 },
-	{  47, 819, 865,  16 },
-	{  47, 865, 865,   2 },
-	{  31, 437, 437,   4 },
-	{  31, 850, 437,   9 },
-	{  31, 819, 437,  17 },
-	{  32, 850, 437,   8 },
-	{  32, 819, 437,  16 },
-	{  32, 437, 437,   3 },
-	{ 358, 850, 437,   8 },
-	{ 358, 819, 437,  16 },
-	{ 358, 437, 437,   3 },
-	{   2, 863, 863,   1 },
-	{   2, 850, 863,   6 },
-	{   2, 819, 863,  14 },
-	{ 351, 850, 860,   6 },
-	{ 351, 819, 860,  14 },
-	{ 351, 860, 860,   5 },
-	{   3, 850, 437,   8 },
-	{   3, 819, 437,  16 },
-	{   3, 437, 437,   0 },
-	{  61, 437, 437,   0 },
-	{  61, 850, 437,   6 },
-	{  61, 819, 437,  16 },
-	{  81, 437, 437,   0 },
-	{  81, 819, 437,  14 },
-	{  82, 437, 437,   0 },
-	{  82, 819, 437,  14 },
-	{  86, 437, 437,   0 },
-	{  86, 819, 437,  14 },
-	{  88, 437, 437,   0 },
-	{  88, 819, 437,  14 },
-	{  55, 850, 850,  10 },
-	{  55, 819, 850,  18 },
-	{  55, 437, 850,   0 },
-	{ 354, 850, 850,  10 },
-	{ 354, 819, 850,  18 },
-	{  90, 850, 850,  10 },
-	{  90, 819, 850,  18 },
-	{  38, 852, 852,  11 },
-	{  38, 850, 852,  10 },
-	{  38, 819, 852,  18 },
-	{  42, 852, 852,  11 },
-	{  42, 850, 852,  10 },
-	{  42, 819, 852,  18 },
-	{  48, 852, 852,  11 },
-	{  48, 850, 852,  10 },
-	{  48, 819, 852,  18 },
-	{  36, 852, 852,  11 },
-	{  36, 850, 852,  10 },
-	{  36, 819, 852,  18 },
-	{ 886, 950, 950,  19 }, 	/* for Taiwan support (Country code) */
-	{   0,   0,   0,   0 }
-};
-
-/* END FAIR USE EXCERPT */
Index: trunk/minix/commands/i386/mtools-3.9.7/tty.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/tty.c	(revision 9)
+++ 	(revision )
@@ -1,201 +1,0 @@
-#include "sysincludes.h"
-#include "mtools.h"
-
-static FILE *tty=NULL;
-static int notty=0;	
-static int ttyfd=-1;
-#ifdef USE_RAWTERM
-int	mtools_raw_tty = 1;
-#else
-int	mtools_raw_tty = 0;
-#endif
-
-#ifdef USE_RAWTERM
-# if defined TCSANOW && defined HAVE_TCSETATTR
-/* we have tcsetattr & tcgetattr. Good */
-typedef struct termios Terminal;
-#  define stty(a,b)        (void)tcsetattr(a,TCSANOW,b)
-#  define gtty(a,b)        (void)tcgetattr(a,b)
-#  define USE_TCIFLUSH
-
-# elif defined TCSETS && defined TCGETS
-typedef struct termios Terminal;
-#  define stty(a,b) (void)ioctl(a,TCSETS,(char *)b)
-#  define gtty(a,b) (void)ioctl(a,TCGETS,(char *)b)
-#  define USE_TCIFLUSH
-
-# elif defined TCSETA && defined TCGETA
-typedef struct termio Terminal;
-#  define stty(a,b) (void)ioctl(a,TCSETA,(char *)b)
-#  define gtty(a,b) (void)ioctl(a,TCGETA,(char *)b)
-#  define USE_TCIFLUSH
-
-# elif defined(HAVE_SGTTY_H) && defined(TIOCSETP) && defined(TIOCGETP)
-typedef struct sgttyb Terminal;
-#  define stty(a,b) (void)ioctl(a,TIOCSETP,(char *)b)
-#  define gtty(a,b) (void)ioctl(a,TIOCGETP,(char *)b)
-#  define USE_SGTTY
-#  define discard_input(a) /**/
-
-# else
-/* no way to use raw terminal */
-/*
-#  warning Cannot use raw terminal code (disabled)
-*/
-#  undef USE_RAWTERM
-# endif
-
-#endif
-
-#ifdef USE_TCIFLUSH
-# if defined TCIFLUSH && defined HAVE_TCFLUSH
-#  define discard_input(a) tcflush(a,TCIFLUSH)
-# else
-#  define discard_input(a) /**/
-# endif
-#endif
-
-#ifdef USE_RAWTERM
-
-static int tty_mode = -1; /* 1 for raw, 0 for cooked, -1 for initial */
-static int need_tty_reset = 0;
-static int handlerIsSet = 0;
-
-#define restore_tty(a) stty(STDIN,a)
-
-
-#define STDIN ttyfd
-#define FAIL (-1)
-#define DONE 0
-static Terminal in_orig;
-
-/*--------------- Signal Handler routines -------------*/
-
-static void tty_time_out(void)
-{
-	int exit_code;
-	signal(SIGALRM, SIG_IGN);
-	if(tty && need_tty_reset)
-		restore_tty (&in_orig);	
-#if future
-	if (fail_on_timeout)
-		exit_code=SHFAIL;
-	else {
-		if (default_choice && mode_defined) {
-			if (yes_no) {
-				if ('Y' == default_choice)
-					exit_code=0;
-				else
-					exit_code=1;
-			} else
-				exit_code=default_choice-minc+1;
-		} else
-			exit_code=DONE;
-	}
-#else
-	exit_code = DONE;
-#endif
-	exit(exit_code);
-}
-
-static void cleanup_tty(void)
-{ 
-	if(tty && need_tty_reset) {
-		restore_tty (&in_orig);
-		setup_signal();
-	}
-}
-
-static void set_raw_tty(int mode)
-{
-	Terminal in_raw;
-
-	if(mode != tty_mode && mode != -1) {
-		if(!handlerIsSet) {
-			/* Determine existing TTY settings */
-			gtty (STDIN, &in_orig);
-			need_tty_reset = 1;
-
-			/* Restore original TTY settings on exit */
-			atexit(cleanup_tty);
-			handlerIsSet = 1;
-		}
-
-
-		setup_signal();
-		signal (SIGALRM, (SIG_CAST) tty_time_out);
-	
-		/* Change STDIN settings to raw */
-
-		gtty (STDIN, &in_raw);
-		if(mode) {
-#ifdef USE_SGTTY
-			in_raw.sg_flags |= CBREAK;
-#else
-			in_raw.c_lflag &= ~ICANON;
-			in_raw.c_cc[VMIN]=1;
-			in_raw.c_cc[VTIME]=0;			
-#endif
-			stty (STDIN, &in_raw);
-		} else {
-#ifdef USE_SGTTY
-			in_raw.sg_flags &= ~CBREAK;
-#else
-			in_raw.c_lflag |= ICANON;
-#endif
-			stty (STDIN, &in_raw);
-		}
-		tty_mode = mode;
-		discard_input(STDIN);
-	}
-}
-#endif
-
-FILE *opentty(int mode)
-{
-	if(notty)
-		return NULL;
-	if (tty == NULL) {
-		ttyfd = open("/dev/tty", O_RDONLY);
-		if(ttyfd >= 0) {
-			tty = fdopen(ttyfd, "r");
-		}
-	}
-	if  (tty == NULL){
-		if ( !isatty(0) ){
-			notty = 1;
-			return NULL;
-		}
-		ttyfd = 0;
-		tty = stdin;
-	}
-#ifdef USE_RAWTERM
-	if(mtools_raw_tty)
-		set_raw_tty(mode);
-#endif
-	return tty;
-}
-
-int ask_confirmation(const char *format, const char *p1, const char *p2)
-{
-	char ans[10];
-
-	if(!opentty(-1))
-		return 0;
-
-	while (1) {
-		fprintf(stderr, format, p1, p2);
-		fflush(stderr);
-		fflush(opentty(-1));
-		if (mtools_raw_tty) {
-			ans[0] = fgetc(opentty(1));
-			fputs("\n", stderr);
-		} else {
-			fgets(ans,9, opentty(0));
-		}
-		if (ans[0] == 'y' || ans[0] == 'Y')
-			return 0;
-		if (ans[0] == 'n' || ans[0] == 'N')
-			return -1;
-	}
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/unixdir.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/unixdir.c	(revision 9)
+++ 	(revision )
@@ -1,144 +1,0 @@
-#include "sysincludes.h"
-#include "msdos.h"
-#include "stream.h"
-#include "mtools.h"
-#include "fsP.h"
-#include "file.h"
-#include "htable.h"
-#include "mainloop.h"
-#include <dirent.h>
-
-typedef struct Dir_t {
-	Class_t *Class;
-	int refs;
-	Stream_t *Next;
-	Stream_t *Buffer;
-
-	struct stat stat;
-	char *pathname;
-	DIR *dir;
-#ifdef HAVE_FCHDIR
-	int fd;
-#endif
-} Dir_t;
-
-/*#define FCHDIR_MODE*/
-
-static int get_dir_data(Stream_t *Stream, time_t *date, mt_size_t *size,
-			int *type, int *address)
-{
-	DeclareThis(Dir_t);
-
-	if(date)
-		*date = This->stat.st_mtime;
-	if(size)
-		*size = (mt_size_t) This->stat.st_size;
-	if(type)
-		*type = 1;
-	if(address)
-		*address = 0;
-	return 0;
-}
-
-static int dir_free(Stream_t *Stream)
-{
-	DeclareThis(Dir_t);
-
-	Free(This->pathname);
-	closedir(This->dir);
-	return 0;
-}
-
-static Class_t DirClass = { 
-	0, /* read */
-	0, /* write */
-	0, /* flush */
-	dir_free, /* free */
-	0, /* get_geom */
-	get_dir_data ,
-	0 /* pre-allocate */
-};
-
-#ifdef HAVE_FCHDIR
-#define FCHDIR_MODE
-#endif
-
-int unix_dir_loop(Stream_t *Stream, MainParam_t *mp); 
-int unix_loop(Stream_t *Stream, MainParam_t *mp, char *arg, 
-	      int follow_dir_link);
-
-int unix_dir_loop(Stream_t *Stream, MainParam_t *mp)
-{
-	DeclareThis(Dir_t);
-	struct dirent *entry;
-	char *newName;
-	int ret=0;
-
-#ifdef FCHDIR_MODE
-	int fd;
-
-	fd = open(".", O_RDONLY);
-	chdir(This->pathname);
-#endif
-	while((entry=readdir(This->dir)) != NULL) {
-		if(got_signal)
-			break;
-		if(isSpecial(entry->d_name))
-			continue;
-#ifndef FCHDIR_MODE
-		newName = malloc(strlen(This->pathname) + 1 + 
-				 strlen(entry->d_name) + 1);
-		if(!newName) {
-			ret = ERROR_ONE;
-			break;
-		}
-		strcpy(newName, This->pathname);
-		strcat(newName, "/");
-		strcat(newName, entry->d_name);
-#else
-		newName = entry->d_name;
-#endif
-		ret |= unix_loop(Stream, mp, newName, 0);
-#ifndef FCHDIR_MODE
-		free(newName);
-#endif
-	}
-#ifdef FCHDIR_MODE
-	fchdir(fd);
-	close(fd);
-#endif
-	return ret;
-}
-
-Stream_t *OpenDir(Stream_t *Stream, const char *filename)
-{
-	Dir_t *This;
-
-	This = New(Dir_t);
-	
-	This->Class = &DirClass;
-	This->Next = 0;
-	This->refs = 1;
-	This->Buffer = 0;
-	This->pathname = malloc(strlen(filename)+1);
-	if(This->pathname == NULL) {
-		Free(This);
-		return NULL;
-	}
-	strcpy(This->pathname, filename);
-
-	if(stat(filename, &This->stat) < 0) {
-		Free(This->pathname);
-		Free(This);
-		return NULL;
-	}
-
-	This->dir = opendir(filename);
-	if(!This->dir) {
-		Free(This->pathname);
-		Free(This);
-		return NULL;
-	}
-
-	return (Stream_t *) This;
-}
Index: trunk/minix/commands/i386/mtools-3.9.7/vfat.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/vfat.c	(revision 9)
+++ 	(revision )
@@ -1,748 +1,0 @@
-/* vfat.c
- *
- * Miscellaneous VFAT-related functions
- */
-
-#include "sysincludes.h"
-#include "msdos.h"
-#include "mtools.h"
-#include "vfat.h"
-#include "file.h"
-#include "dirCache.h"
-
-/* #define DEBUG */
-
-const char *short_illegals=";+=[]',\"*\\<>/?:|";
-const char *long_illegals = "\"*\\<>/?:|\005";
-
-/* Automatically derive a new name */
-static void autorename(char *name,
-		       char tilda, char dot, const char *illegals,
-		       int limit, int bump)
-{
-	int tildapos, dotpos;
-	unsigned int seqnum=0, maxseq=0;
-	char tmp;
-	char *p;
-	
-#ifdef DEBUG
-	printf("In autorename for name=%s.\n", name);
-#endif
-	tildapos = -1;
-
-	for(p=name; *p ; p++)
-		if((*p < ' ' && *p != '\005') || strchr(illegals, *p)) {
-			*p = '_';
-			bump = 0;
-		}
-
-	for(dotpos=0;
-	    name[dotpos] && dotpos < limit && name[dotpos] != dot ;
-	    dotpos++) {
-		if(name[dotpos] == tilda) {
-			tildapos = dotpos;
-			seqnum = 0;
-			maxseq = 1;
-		} else if (name[dotpos] >= '0' && name[dotpos] <= '9') {
-			seqnum = seqnum * 10 + name[dotpos] - '0';
-			maxseq = maxseq * 10;
-		} else
-			tildapos = -1; /* sequence number interrupted */
-	}
-	if(tildapos == -1) {
-		/* no sequence number yet */
-		if(dotpos > limit - 2) {
-			tildapos = limit - 2;
-			dotpos = limit;
-		} else {
-			tildapos = dotpos;
-			dotpos += 2;
-		}
-		seqnum = 1;
-	} else {
-		if(bump)
-			seqnum++;
-		if(seqnum > 999999) {
-			seqnum = 1;
-			tildapos = dotpos - 2;
-			/* this matches Win95's behavior, and also guarantees
-			 * us that the sequence numbers never get shorter */
-		}
-		if (seqnum == maxseq) {
-		    if(dotpos >= limit)
-			tildapos--;
-		    else
-			dotpos++;
-		}
-	}
-
-	tmp = name[dotpos];
-	if((bump && seqnum == 1) || seqnum > 1 || mtools_numeric_tail)
-		sprintf(name+tildapos,"%c%d",tilda, seqnum);
-	if(dot)
-	    name[dotpos]=tmp;
-	/* replace the character if it wasn't a space */
-}
-
-
-void autorename_short(char *name, int bump)
-{
-	autorename(name, '~', ' ', short_illegals, 8, bump);
-}
-
-void autorename_long(char *name, int bump)
-{
-	autorename(name, '-', '\0', long_illegals, 255, bump);
-}
-
-
-static inline int unicode_read(struct unicode_char *in, char *out, int num)
-{
-	char *end_out = out+num;
-
-	while(out < end_out) {
-		if (in->uchar)
-			*out = '_';
-		else
-			*out = in->lchar;
-		++out;
-		++in;
-	}
-	return num;
-}
-
-
-void clear_vfat(struct vfat_state *v)
-{
-	v->subentries = 0;
-	v->status = 0;
-	v->present = 0;
-}
-
-
-/* sum_shortname
- *
- * Calculate the checksum that results from the short name in *dir.
- *
- * The sum is formed by circularly right-shifting the previous sum
- * and adding in each character, from left to right, padding both
- * the name and extension to maximum length with spaces and skipping
- * the "." (hence always summing exactly 11 characters).
- * 
- * This exact algorithm is required in order to remain compatible
- * with Microsoft Windows-95 and Microsoft Windows NT 3.5.
- * Thanks to Jeffrey Richter of Microsoft Systems Journal for
- * pointing me to the correct algorithm.
- *
- * David C. Niemi (niemi@tux.org) 95.01.19
- */
-static inline unsigned char sum_shortname(char *name)
-{
-	unsigned char sum;
-	char *end = name+11;
-
-	for (sum=0; name<end; ++name)
-		sum = ((sum & 1) ? 0x80 : 0) + (sum >> 1) 
-		  + (*name ? *name : ' ');
-	return(sum);
-}
-
-/* check_vfat
- *
- * Inspect a directory and any associated VSEs.
- * Return 1 if the VSEs comprise a valid long file name,
- * 0 if not.
- */
-static inline void check_vfat(struct vfat_state *v, struct directory *dir)
-{
-	char name[12];
-
-	if (! v->subentries) {
-#ifdef DEBUG
-		fprintf(stderr, "check_vfat: no VSEs.\n");
-#endif
-		return;
-	}
-
-	strncpy((char *)name, (char *)dir->name, 8);
-	strncpy((char *)name + 8, (char *)dir->ext, 3);
-	name[11] = '\0';
-
-	if (v->sum != sum_shortname(name))
-		return;
-	
-	if( (v->status & ((1<<v->subentries) - 1)) != (1<<v->subentries) - 1)
-		return; /* missing entries */
-
-	/* zero out byte following last entry, for good measure */
-	v->name[VSE_NAMELEN * v->subentries] = 0;
-	v->present = 1;
-}
-
-
-int clear_vses(Stream_t *Dir, int entrySlot, size_t last)
-{
-	direntry_t entry;
-	dirCache_t *cache;
-	int error;
-
-	entry.Dir = Dir;
-	entry.entry = entrySlot;
-
-	/*maximize(last, entry.entry + MAX_VFAT_SUBENTRIES);*/
-	cache = allocDirCache(Dir, last);
-	if(!cache) {
-		fprintf(stderr, "Out of memory error in clear_vses\n");
-		exit(1);
-	}
-	addFreeEntry(cache, entry.entry, last);
-	for (; entry.entry < last; ++entry.entry) {
-#ifdef DEBUG
-		fprintf(stderr,"Clearing entry %d.\n", entry.entry);
-#endif
-		dir_read(&entry, &error);
-		if(error)
-		    return error;
-		if(!entry.dir.name[0] || entry.dir.name[0] == DELMARK)
-			break;
-		entry.dir.name[0] = DELMARK;
-		if (entry.dir.attr == 0xf)
-			entry.dir.attr = '\0';
-		low_level_dir_write(&entry);
-	}
-	return 0;
-}
-
-int write_vfat(Stream_t *Dir, char *shortname, char *longname, int start,
-	       direntry_t *mainEntry)
-{
-	struct vfat_subentry *vse;
-	int vse_id, num_vses;
-	char *c;
-	direntry_t entry;
-	dirCache_t *cache;
-	char unixyName[13];
-	
-	if(longname) {
-#ifdef DEBUG
-		printf("Entering write_vfat with longname=\"%s\", start=%d.\n",
-		       longname,start);
-#endif
-		entry.Dir = Dir;
-		vse = (struct vfat_subentry *) &entry.dir;
-		/* Fill in invariant part of vse */
-		vse->attribute = 0x0f;
-		vse->hash1 = vse->sector_l = vse->sector_u = 0;
-		vse->sum = sum_shortname(shortname);
-#ifdef DEBUG
-		printf("Wrote checksum=%d for shortname %s.\n", 
-		       vse->sum,shortname);
-#endif
-		num_vses = strlen(longname)/VSE_NAMELEN + 1;
-		for (vse_id = num_vses; vse_id; --vse_id) {
-			int end = 0;
-			
-			c = longname + (vse_id - 1) * VSE_NAMELEN;
-			
-			c += unicode_write(c, vse->text1, VSE1SIZE, &end);
-			c += unicode_write(c, vse->text2, VSE2SIZE, &end);
-			c += unicode_write(c, vse->text3, VSE3SIZE, &end);
-
-			vse->id = (vse_id == num_vses) ? (vse_id | VSE_LAST) : vse_id;
-#ifdef DEBUG
-			printf("Writing longname=(%s), VSE %d (%13s) at %d, end = %d.\n",
-			       longname, vse_id, longname + (vse_id-1) * VSE_NAMELEN,
-			       start + num_vses - vse_id, start + num_vses);
-#endif
-			
-			entry.entry = start + num_vses - vse_id;
-			low_level_dir_write(&entry);
-		}
-	} else
-		num_vses = 0;
-	cache = allocDirCache(Dir, start + num_vses + 1);
-	if(!cache) {
-		fprintf(stderr, "Out of memory error\n");
-		exit(1);
-	}
-	unix_name(shortname, shortname+8, 0, unixyName);
-	addUsedEntry(cache, start, start + num_vses + 1, longname, unixyName,
-		     &mainEntry->dir);
-	low_level_dir_write(mainEntry);
-	return start + num_vses;
-}
-
-void dir_write(direntry_t *entry)
-{
-	dirCacheEntry_t *dce;
-	dirCache_t *cache;
-
-	if(entry->entry == -3) {
-		fprintf(stderr, "Attempt to write root directory pointer\n");
-		exit(1);
-	}
-
-	cache = allocDirCache(entry->Dir, entry->entry + 1);
-	if(!cache) {
-		fprintf(stderr, "Out of memory error in dir_write\n");
-		exit(1);
-	}
-	dce = cache->entries[entry->entry];
-	if(dce) {
-		if(entry->dir.name[0] == DELMARK) {
-			addFreeEntry(cache, dce->beginSlot, dce->endSlot);
-		} else {
-			dce->dir = entry->dir;
-		}
-	}
-	low_level_dir_write(entry);
-}
-
-
-/* 
- * The following function translates a series of vfat_subentries into
- * data suitable for a dircache entry
- */
-static inline void parse_vses(direntry_t *entry,			      
-			      struct vfat_state *v)
-{
-	struct vfat_subentry *vse;
-	unsigned char id, last_flag;
-	char *c;
-	
-	vse = (struct vfat_subentry *) &entry->dir;
-	
-	id = vse->id & VSE_MASK;
-	last_flag = (vse->id & VSE_LAST);
-	if (id > MAX_VFAT_SUBENTRIES) {
-		fprintf(stderr, "parse_vses: invalid VSE ID %d at %d.\n",
-			id, entry->entry);
-		return;
-	}
-	
-/* 950819: This code enforced finding the VSEs in order.  Well, Win95
- * likes to write them in *reverse* order for some bizarre reason!  So
- * we pretty much have to tolerate them coming in any possible order.
- * So skip this check, we'll do without it (What does this do, Alain?).
- *
- * 950820: Totally rearranged code to tolerate any order but to warn if
- * they are not in reverse order like Win95 uses.
- *
- * 950909: Tolerate any order. We recognize new chains by mismatching
- * checksums. In the event that the checksums match, new entries silently
- * overwrite old entries of the same id. This should accept all valid
- * entries, but may fail to reject invalid entries in some rare cases.
- */
-
-	/* bad checksum, begin new chain */
-	if(v->sum != vse->sum) {
-		clear_vfat(v);
-		v->sum = vse->sum;
-	}
-	
-#ifdef DEBUG
-	if(v->status & (1 << (id-1)))
-		fprintf(stderr,
-			"parse_vses: duplicate VSE %d\n", vse->id);
-#endif
-	
-	v->status |= 1 << (id-1);
-	if(last_flag)
-		v->subentries = id;
-	
-#ifdef DEBUG
-	if (id > v->subentries)
-		/* simple test to detect entries preceding
-		 * the "last" entry (really the first) */
-		fprintf(stderr,
-			"parse_vses: new VSE %d sans LAST flag\n",
-			vse->id);
-#endif
-
-	c = &(v->name[VSE_NAMELEN * (id-1)]);
-	c += unicode_read(vse->text1, c, VSE1SIZE);
-	c += unicode_read(vse->text2, c, VSE2SIZE);
-	c += unicode_read(vse->text3, c, VSE3SIZE);
-#ifdef DEBUG
-	printf("Read VSE %d at %d, subentries=%d, = (%13s).\n",
-	       id,entry->entry,v->subentries,&(v->name[VSE_NAMELEN * (id-1)]));
-#endif		
-	if (last_flag)
-		*c = '\0';	/* Null terminate long name */
-}
-
-
-static dirCacheEntry_t *vfat_lookup_loop_common(direntry_t *direntry,
-						dirCache_t *cache,
-						int lookForFreeSpace,
-						int *io_error)
-{
-	char newfile[13];
-	int initpos = direntry->entry + 1;
-	struct vfat_state vfat;
-	char *longname;
-	int error;
-
-	/* not yet cached */
-	*io_error = 0;
-	clear_vfat(&vfat);
-	while(1) {
-		++direntry->entry;
-		if(!dir_read(direntry, &error)){
-			if(error) {
-			    *io_error = error;
-			    return NULL;
-			}
-			addFreeEntry(cache, initpos, direntry->entry);
-			return addEndEntry(cache, direntry->entry);
-		}
-		
-		if (direntry->dir.name[0] == '\0'){
-				/* the end of the directory */
-			if(lookForFreeSpace)
-				continue;
-			return addEndEntry(cache, direntry->entry);
-		}
-		if(direntry->dir.name[0] != DELMARK &&
-		   direntry->dir.attr == 0x0f)
-			parse_vses(direntry, &vfat);
-		else
-			/* the main entry */
-			break;
-	}
-	
-	/* If we get here, it's a short name FAT entry, maybe erased.
-	 * thus we should make sure that the vfat structure will be
-	 * cleared before the next loop run */
-	
-	/* deleted file */
-	if (direntry->dir.name[0] == DELMARK) {
-		return addFreeEntry(cache, initpos, 
-				    direntry->entry + 1);
-	}
-	
-	check_vfat(&vfat, &direntry->dir);
-	if(!vfat.present)
-		vfat.subentries = 0;
-	
-	/* mark space between last entry and this one as free */
-	addFreeEntry(cache, initpos, 
-		     direntry->entry - vfat.subentries);
-	
-	if (direntry->dir.attr & 0x8){
-		strncpy(newfile, direntry->dir.name,8);
-		newfile[8]='\0';
-		strncat(newfile, direntry->dir.ext,3);
-		newfile[11]='\0';
-	} else
-		unix_name(direntry->dir.name, 
-			  direntry->dir.ext, 
-			  direntry->dir.Case, 
-			  newfile);
-
-	if(vfat.present)
-		longname = vfat.name;
-	else
-		longname = 0;
-
-	return addUsedEntry(cache, direntry->entry - vfat.subentries,
-			    direntry->entry + 1, longname, 
-			    newfile, &direntry->dir);
-}
-
-static inline dirCacheEntry_t *vfat_lookup_loop_for_read(direntry_t *direntry,
-							 dirCache_t *cache,
-							 int *io_error)
-{
-	int initpos = direntry->entry + 1;
-	dirCacheEntry_t *dce;
-
-	*io_error = 0;
-	dce = cache->entries[initpos];
-	if(dce) {
-		direntry->entry = dce->endSlot - 1;
-		return dce;
-	} else {
-		return vfat_lookup_loop_common(direntry, cache, 0, io_error);
-	}
-}
-
-
-typedef enum result_t {
-	RES_NOMATCH,
-	RES_MATCH,
-	RES_END,
-	RES_ERROR
-} result_t;
-
-
-/* 
- * 0 does not match
- * 1 matches
- * 2 end
- */
-static result_t checkNameForMatch(struct direntry_t *direntry, 
-				  dirCacheEntry_t *dce,
-				  const char *filename,
-				  char *longname,
-				  char *shortname,
-				  int length,
-				  int flags)
-{
-	switch(dce->type) {
-		case DCET_FREE:
-			return RES_NOMATCH;
-		case DCET_END:
-			return RES_END;
-		case DCET_USED:
-			break;
-		default:
-			fprintf(stderr, "Unexpected entry type %d\n",
-				dce->type);
-			return RES_ERROR;
-	}
-
-	direntry->dir = dce->dir;
-
-	/* make sure the entry is of an accepted type */
-	if((direntry->dir.attr & 0x8) && !(flags & ACCEPT_LABEL))
-		return RES_NOMATCH;
-
-
-	/*---------- multiple files ----------*/
-	if(!((flags & MATCH_ANY) ||
-	     (dce->longName && 
-	      match(dce->longName, filename, direntry->name, 0, length)) ||
-	     match(dce->shortName, filename, direntry->name, 1, length))) {
-
-		return RES_NOMATCH;
-	}
-
-	/* entry of non-requested type, has to come after name
-	 * checking because of clash handling */
-	if(IS_DIR(direntry) && !(flags & ACCEPT_DIR)) {
-		if(!(flags & (ACCEPT_LABEL|MATCH_ANY|NO_MSG)))
-			fprintf(stderr,
-				"Skipping \"%s\", is a directory\n",
-				dce->shortName);
-		return RES_NOMATCH;
-	}
-
-	if(!(direntry->dir.attr & (ATTR_LABEL | ATTR_DIR)) && 
-	   !(flags & ACCEPT_PLAIN)) {
-		if(!(flags & (ACCEPT_LABEL|MATCH_ANY|NO_MSG)))
-			fprintf(stderr,
-				"Skipping \"%s\", is not a directory\n",
-				dce->shortName);
-		return RES_NOMATCH;
-	}
-
-	return RES_MATCH;
-}
-
-
-/*
- * vfat_lookup looks for filenames in directory dir.
- * if a name if found, it is returned in outname
- * if applicable, the file is opened and its stream is returned in File
- */
-
-int vfat_lookup(direntry_t *direntry, const char *filename, int length,
-		int flags, char *shortname, char *longname)
-{
-	dirCacheEntry_t *dce;
-	result_t result;
-	dirCache_t *cache;
-	int io_error;
-
-	if(length == -1 && filename)
-		length = strlen(filename);
-
-	if (direntry->entry == -2)
-		return -1;
-
-	cache = allocDirCache(direntry->Dir, direntry->entry+1);
-	if(!cache) {
-		fprintf(stderr, "Out of memory error in vfat_lookup [0]\n");
-		exit(1);
-	}
-
-	do {
-		dce = vfat_lookup_loop_for_read(direntry, cache, &io_error);
-		if(!dce) {
-			if (io_error)
-				return -2;
-			fprintf(stderr, "Out of memory error in vfat_lookup\n");
-			exit(1);
-		}
-		result = checkNameForMatch(direntry, dce,
-					   filename, 
-					   longname, shortname,
-					   length, flags);
-	} while(result == RES_NOMATCH);
-
-	if(result == RES_MATCH){
-		if(longname){
-			if(dce->longName)
-				strcpy(longname, dce->longName);
-			else
-				*longname ='\0';
-		}
-		if(shortname)
-			strcpy(shortname, dce->shortName);
-		direntry->beginSlot = dce->beginSlot;
-		direntry->endSlot = dce->endSlot-1;
-		return 0; /* file found */
-	} else {
-		direntry->entry = -2;
-		return -1; /* no file found */
-	}
-}
-
-static inline dirCacheEntry_t *vfat_lookup_loop_for_insert(direntry_t *direntry,
-							   int initpos,
-							   dirCache_t *cache)
-{
-	dirCacheEntry_t *dce;
-	int io_error;
-
-	dce = cache->entries[initpos];
-	if(dce && dce->type != DCET_END) {
-		return dce;
-	} else {
-		direntry->entry = initpos - 1;
-		dce = vfat_lookup_loop_common(direntry, cache, 1, &io_error);
-		if(!dce) {
-			if (io_error) {
-				return NULL;
-			}
-			fprintf(stderr, 
-				"Out of memory error in vfat_lookup_loop\n");
-			exit(1);
-		}
-		return cache->entries[initpos];
-	}
-}
-
-static void accountFreeSlots(struct scan_state *ssp, dirCacheEntry_t *dce)
-{
-	if(ssp->got_slots)
-		return;
-
-	if(ssp->free_end != dce->beginSlot) {
-		ssp->free_start = dce->beginSlot;
-	}
-	ssp->free_end = dce->endSlot;
-
-	if(ssp->free_end - ssp->free_start >= ssp->size_needed) {
-		ssp->got_slots = 1;
-		ssp->slot = ssp->free_start + ssp->size_needed - 1;
-	}
-}
-
-/* lookup_for_insert replaces the old scandir function.  It directly
- * calls into vfat_lookup_loop, thus eliminating the overhead of the
- * normal vfat_lookup
- */
-int lookupForInsert(Stream_t *Dir,
-					char *dosname,
-					char *longname,
-					struct scan_state *ssp, 
-					int ignore_entry,
-					int source_entry,
-					int pessimisticShortRename)
-{
-	direntry_t entry;
-	int ignore_match;
-	dirCacheEntry_t *dce;
-	dirCache_t *cache;
-	int pos; /* position _before_ the next answered entry */
-	char shortName[13];
-
-	ignore_match = (ignore_entry == -2 );
-
-	initializeDirentry(&entry, Dir);
-	ssp->match_free = 0;
-
-	/* hash bitmap of already encountered names.  Speeds up batch appends
-	 * to huge directories, because in the best case, we only need to scan
-	 * the new entries rather than the whole directory */
-	cache = allocDirCache(Dir, 1);
-	if(!cache) {
-		fprintf(stderr, "Out of memory error in lookupForInsert\n");
-		exit(1);
-	}
-
-	if(!ignore_match)
-		unix_name(dosname, dosname + 8, 0, shortName);
-
-	pos = cache->nrHashed;
-	if(source_entry >= 0 ||
-	   (pos && isHashed(cache, longname))) {
-		pos = 0;
-	} else if(pos && !ignore_match && isHashed(cache, shortName)) {
-		if(pessimisticShortRename) {
-			ssp->shortmatch = -2;
-			return 1;
-		}
-		pos = 0;
-	} else if(growDirCache(cache, pos) < 0) {
-		fprintf(stderr, "Out of memory error in vfat_looup [0]\n");
-		exit(1);
-	}
-	do {
-		dce = vfat_lookup_loop_for_insert(&entry, pos, cache);
-		switch(dce->type) {
-			case DCET_FREE:
-				accountFreeSlots(ssp, dce);
-				break;
-			case DCET_USED:
-				if(!(dce->dir.attr & 0x8) &&
-				   dce->endSlot - 1 == source_entry)
-				   accountFreeSlots(ssp, dce);
-
-				/* labels never match, neither does the 
-				 * ignored entry */
-				if( (dce->dir.attr & 0x8) ||
-				    (dce->endSlot - 1 == ignore_entry) )
-					break;
-
-				/* check long name */
-				if((dce->longName && 
-				    !strcasecmp(dce->longName, longname)) ||
-				   (dce->shortName &&
-				    !strcasecmp(dce->shortName, longname))) {
-					ssp->longmatch = dce->endSlot - 1;
-					/* long match is a reason for
-					 * immediate stop */
-					return 1;
-				}
-
-				/* Long name or not, always check for 
-				 * short name match */
-				if (!ignore_match &&
-				    !strcasecmp(shortName, dce->shortName))
-					ssp->shortmatch = dce->endSlot - 1;
-				break;
-			case DCET_END:
-				break;
-		}
-		pos = dce->endSlot;
-	} while(dce->type != DCET_END);
-	if (ssp->shortmatch > -1)
-		return 1;
-	ssp->max_entry = dce->beginSlot;
-	if (ssp->got_slots)
-		return 6;	/* Success */
-
-	/* Need more room.  Can we grow the directory? */
-	if(!isRootDir(Dir))		
-		return 5;	/* OK, try to grow the directory */
-
-	fprintf(stderr, "No directory slots\n");
-	return -1;
-}
-
-
-
-/* End vfat.c */
Index: trunk/minix/commands/i386/mtools-3.9.7/vfat.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/vfat.h	(revision 9)
+++ 	(revision )
@@ -1,100 +1,0 @@
-#ifndef MTOOLS_VFAT_H
-#define MTOOLS_VFAT_H
-
-#include "msdos.h"
-
-/*
- * VFAT-related common header file
- */
-#define VFAT_SUPPORT
-
-struct unicode_char {
-	char lchar;
-	char uchar;
-};
-
-
-/* #define MAX_VFAT_SUBENTRIES 32 */ /* Theoretical max # of VSEs */
-#define MAX_VFAT_SUBENTRIES 20		/* Max useful # of VSEs */
-#define VSE_NAMELEN 13
-
-#define VSE1SIZE 5
-#define VSE2SIZE 6
-#define VSE3SIZE 2
-
-#include "stream.h"
-
-struct vfat_subentry {
-	unsigned char id;		/* 0x40 = last; & 0x1f = VSE ID */
-	struct unicode_char text1[VSE1SIZE] PACKED;
-	unsigned char attribute;	/* 0x0f for VFAT */
-	unsigned char hash1;		/* Always 0? */
-	unsigned char sum;		/* Checksum of short name */
-	struct unicode_char text2[VSE2SIZE] PACKED;
-	unsigned char sector_l;		/* 0 for VFAT */
-	unsigned char sector_u;		/* 0 for VFAT */
-	struct unicode_char text3[VSE3SIZE] PACKED;
-};
-
-/* Enough size for a worst case number of full VSEs plus a null */
-#define VBUFSIZE ((MAX_VFAT_SUBENTRIES*VSE_NAMELEN) + 1)
-
-/* Max legal length of a VFAT long name */
-#define MAX_VNAMELEN (255)
-
-#define VSE_PRESENT 0x01
-#define VSE_LAST 0x40
-#define VSE_MASK 0x1f
-
-struct vfat_state {
-	char name[VBUFSIZE];
-	int status; /* is now a bit map of 32 bits */
-	int subentries;
-	unsigned char sum; /* no need to remember the sum for each entry,
-			    * it is the same anyways */
-	int present;
-};
-
-
-struct scan_state {
-	int match_free;
-	int shortmatch;
-	int longmatch;
-	int free_start;
-	int free_end;
-	int slot;
-	int got_slots;
-	int size_needed;
-	int max_entry;
-};
-
-#include "mtoolsDirent.h"
-
-void clear_vfat(struct vfat_state  *);
-int unicode_write(char *, struct unicode_char *, int num, int *end);
-
-int clear_vses(Stream_t *, int, size_t);
-void autorename_short(char *, int);
-void autorename_long(char *, int);
-
-int lookupForInsert(Stream_t *Dir,
-					char *dosname,
-					char *longname,
-					struct scan_state *ssp, 
-					int ignore_entry,
-					int source_entry,
-					int pessimisticShortRename);
-
-#define DO_OPEN 1 /* open all files that are found */
-#define ACCEPT_LABEL 0x08
-#define ACCEPT_DIR 0x10
-#define ACCEPT_PLAIN 0x20
-#define MATCH_ANY 0x40
-#define NO_MSG 0x80
-#define NO_DOTS 0x100 /* accept no dots if matched by wildcard */
-#define DO_OPEN_DIRS 0x400 /* open all directories that are found */
-#define OPEN_PARENT 0x1000  /* in target lookup, open parent
-			     * instead of file itself */
-#define NO_UNIX 0x2000 /* in target lookup, consider all files to reside on
-			* the DOS fs */
-#endif
Index: trunk/minix/commands/i386/mtools-3.9.7/xdf_io.c
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/xdf_io.c	(revision 9)
+++ 	(revision )
@@ -1,696 +1,0 @@
-/*
- * Io to an xdf disk
- *
- * written by:
- *
- * Alain L. Knaff
- * alain@linux.lu
- *
- */
-
-
-#include "sysincludes.h"
-#ifdef OS_linux
-#include "msdos.h"
-#include "mtools.h"
-#include "devices.h"
-#include "xdf_io.h"
-
-extern int errno;
-
-/* Algorithms can't be patented */
-
-typedef struct sector_map {
-	unsigned int head:1;
-	unsigned int size:7;
-} sector_map_t;
-
-
-struct {
-  unsigned char track_size;
-  unsigned int track0_size:7;
-  unsigned int rootskip:1;
-  unsigned char rate;
-  sector_map_t map[9];
-} xdf_table[]= {
-  {
-    19, 16, 0, 0,
-    {	{0,3},	{0,6},	{1,2},	{0,2},	{1,6},	{1,3},	{0,0} }
-  },
-  {
-    23, 19, 0, 0,
-    {	{0,3},	{0,4},	{1,6},	{0,2},	{1,2},	{0,6},	{1,4},	{1,3},	{0,0} }
-  },
-  {
-    46, 37, 0x43, 1,
-    {	{0,3},	{0,4},	{0,5},	{0,7},	{1,3},	{1,4},	{1,5},	{1,7},	{0,0} }
-  },
-  {
-    24, 20, 0, 1,
-    {	{0,5},	{1,6},	{0,6},	{1, 5} }
-  },
-  {
-    48, 41, 0, 1,
-    {	{0,6},	{1,7},	{0,7},	{1, 6} }
-  }
-};
-
-#define NUMBER(x) (sizeof(x)/sizeof(x[0]))
-
-typedef struct {
-	unsigned char begin; /* where it begins */
-	unsigned char end;       
-	unsigned char sector;
-	unsigned char sizecode;
-
-	unsigned int dirty:1;
-	unsigned int phantom:2;
-	unsigned int valid:1;
-	unsigned int head:1;
-} TrackMap_t;
-
-
-
-typedef struct Xdf_t {
-	Class_t *Class;
-	int refs;
-	Stream_t *Next;
-	Stream_t *Buffer;
-
-	int fd;
-	char *buffer;
-	
-	int current_track;
-	
-	sector_map_t *map;
-
-	int track_size;
-	int track0_size;
-	int sector_size;
-	int FatSize;
-	int RootDirSize;
-	TrackMap_t *track_map;
-
-	unsigned char last_sector;
-	unsigned char rate;
-
-	unsigned int stretch:1;
-	unsigned int rootskip:1;
-	signed  int drive:4;
-} Xdf_t;
-
-typedef struct {
-	unsigned char head;
-	unsigned char sector;
-	unsigned char ptr;
-} Compactify_t;
-
-
-static int analyze_reply(RawRequest_t *raw_cmd, int do_print)
-{
-	int ret, bytes, newbytes;
-
-	bytes = 0;
-	while(1) {
-		ret = analyze_one_reply(raw_cmd, &newbytes, do_print);
-		bytes += newbytes;
-		switch(ret) {
-			case 0:
-				return bytes;
-			case 1:
-				raw_cmd++;
-				break;
-			case -1:
-				if(bytes)
-					return bytes;
-				else
-					return 0;
-		}
-	}
-}
-				
-
-
-static int send_cmd(int fd, RawRequest_t *raw_cmd, int nr,
-		    const char *message, int retries)
-{
-	int j;
-	int ret=-1;
-	
-	if(!nr)
-		return 0;
-	for (j=0; j< retries; j++){
-		switch(send_one_cmd(fd, raw_cmd, message)) {
-			case -1:
-				return -1;
-			case 1:
-				j++;
-				continue;
-			case 0:
-				break;
-		}
-		if((ret=analyze_reply(raw_cmd, j)) > 0)
-			return ret; /* ok */
-	}
-	if(j > 1 && j == retries) {
-		fprintf(stderr,"Too many errors, giving up\n");
-		return 0;
-	}
-	return -1;
-}
-
-
-
-#define REC (This->track_map[ptr])
-#define END(x) (This->track_map[(x)].end)
-#define BEGIN(x) (This->track_map[(x)].begin)
-
-static int add_to_request(Xdf_t *This, int ptr,
-			  RawRequest_t *request, int *nr,
-			  int direction, Compactify_t *compactify)
-{
-#if 0
-	if(direction == MT_WRITE) {
-		printf("writing %d: %d %d %d %d [%02x]\n", 
-		       ptr, This->current_track,
-		       REC.head, REC.sector, REC.sizecode,
-		       *(This->buffer + ptr * This->sector_size));
-	} else
-			printf(" load %d.%d\n", This->current_track, ptr);
-#endif
-	if(REC.phantom) {
-		if(direction== MT_READ)			
-			memset(This->buffer + ptr * This->sector_size, 0,
-			       128 << REC.sizecode);
-		return 0;
-	}
-	
-	if(*nr &&
-	   RR_SIZECODE(request+(*nr)-1) == REC.sizecode &&	   
-	   compactify->head == REC.head &&
-	   compactify->ptr + 1 == ptr &&
-	   compactify->sector +1 == REC.sector) {
-		RR_SETSIZECODE(request+(*nr)-1, REC.sizecode);
-	} else {
-		if(*nr)
-			RR_SETCONT(request+(*nr)-1);
-		RR_INIT(request+(*nr));
-		RR_SETDRIVE(request+(*nr), This->drive);
-		RR_SETRATE(request+(*nr), This->rate);
-		RR_SETTRACK(request+(*nr), This->current_track);
-		RR_SETPTRACK(request+(*nr), 
-			     This->current_track << This->stretch);
-		RR_SETHEAD(request+(*nr), REC.head);
-		RR_SETSECTOR(request+(*nr), REC.sector);
-		RR_SETSIZECODE(request+(*nr), REC.sizecode);
-		RR_SETDIRECTION(request+(*nr), direction);
-		RR_SETDATA(request+(*nr),
-			   (caddr_t) This->buffer + ptr * This->sector_size);
-		(*nr)++;
-	}
-	compactify->ptr = ptr;
-	compactify->head = REC.head;
-	compactify->sector = REC.sector;
-	return 0;
-}
-
-
-static void add_to_request_if_invalid(Xdf_t *This, int ptr,
-				     RawRequest_t *request, int *nr,
-				     Compactify_t *compactify)
-{
-	if(!REC.valid)
-		add_to_request(This, ptr, request, nr, MT_READ, compactify);
-
-}
-
-
-static void adjust_bounds(Xdf_t *This, off_t *begin, off_t *end)
-{
-	/* translates begin and end from byte to sectors */
-	*begin = *begin / This->sector_size;
-	*end = (*end + This->sector_size - 1) / This->sector_size;
-}
-
-
-static inline int try_flush_dirty(Xdf_t *This)
-{
-	int ptr, nr, bytes;
-	RawRequest_t requests[100];
-	Compactify_t compactify;
-
-	if(This->current_track < 0)
-		return 0;
-	
-	nr = 0;
-	for(ptr=0; ptr < This->last_sector; ptr=REC.end)
-		if(REC.dirty)
-			add_to_request(This, ptr,
-				       requests, &nr,
-				       MT_WRITE, &compactify);
-#if 1
-	bytes = send_cmd(This->fd,requests, nr, "writing", 4);
-	if(bytes < 0)
-		return bytes;
-#else
-	bytes = 0xffffff;
-#endif
-	for(ptr=0; ptr < This->last_sector; ptr=REC.end)
-		if(REC.dirty) {
-			if(bytes >= REC.end - REC.begin) {
-				bytes -= REC.end - REC.begin;
-				REC.dirty = 0;
-			} else
-				return 1;
-		}
-	return 0;
-}
-
-
-
-static int flush_dirty(Xdf_t *This)
-{	
-	int ret;
-
-	while((ret = try_flush_dirty(This))) {
-		if(ret < 0)		       
-			return ret;
-	}
-	return 0;
-}
-
-
-static int load_data(Xdf_t *This, off_t begin, off_t end, int retries)
-{
-	int ptr, nr, bytes;
-	RawRequest_t requests[100];
-	Compactify_t compactify;
-
-	adjust_bounds(This, &begin, &end);
-	
-	ptr = begin;
-	nr = 0;
-	for(ptr=REC.begin; ptr < end ; ptr = REC.end)
-		add_to_request_if_invalid(This, ptr, requests, &nr,
-					  &compactify);
-	bytes = send_cmd(This->fd,requests, nr, "reading", retries);
-	if(bytes < 0)
-		return bytes;
-	ptr = begin;
-	for(ptr=REC.begin; ptr < end ; ptr = REC.end) {
-		if(!REC.valid) {
-			if(bytes >= REC.end - REC.begin) {
-				bytes -= REC.end - REC.begin;
-				REC.valid = 1;
-			} else if(ptr > begin)
-				return ptr * This->sector_size;
-			else
-				return -1;
-		}
-	}
-	return end * This->sector_size;
-}
-
-static void mark_dirty(Xdf_t *This, off_t begin, off_t end)
-{
-	int ptr;
-
-	adjust_bounds(This, &begin, &end);
-	
-	ptr = begin;
-	for(ptr=REC.begin; ptr < end ; ptr = REC.end) {
-		REC.valid = 1;
-		if(!REC.phantom)
-			REC.dirty = 1;
-	}
-}
-
-
-static int load_bounds(Xdf_t *This, off_t begin, off_t end)
-{
-	off_t lbegin, lend;
-	int endp1, endp2;
-
-	lbegin = begin;
-	lend = end;
-
-	adjust_bounds(This, &lbegin, &lend);	
-
-	if(begin != BEGIN(lbegin) * This->sector_size &&
-	   end != BEGIN(lend) * This->sector_size &&
-	   lend < END(END(lbegin)))
-		/* contiguous end & begin, load them in one go */
-		return load_data(This, begin, end, 4);
-
-	if(begin != BEGIN(lbegin) * This->sector_size) {
-		endp1 = load_data(This, begin, begin, 4);
-		if(endp1 < 0)
-			return endp1;
-	}
-
-	if(end != BEGIN(lend) * This->sector_size) {
-		endp2 = load_data(This, end, end, 4);
-		if(endp2 < 0)
-			return BEGIN(lend) * This->sector_size;
-	}
-	return lend * This->sector_size;
-}
-
-
-static int fill_t0(Xdf_t *This, int ptr, int size, int *sector, int *head)
-{
-	int n;
-
-	for(n = 0; n < size; ptr++,n++) {
-		REC.head = *head;
-		REC.sector = *sector + 129;
-		REC.phantom = 0;
-		(*sector)++;
-		if(!*head && *sector >= This->track0_size - 8) {
-			*sector = 0;
-			*head = 1;
-		}
-	}
-	return ptr;
-}
-
-
-static int fill_phantoms(Xdf_t *This, int ptr, int size)
-{
-	int n;
-
-	for(n = 0; n < size; ptr++,n++)
-		REC.phantom = 1;
-	return ptr;
-}
-
-static void decompose(Xdf_t *This, int where, int len, off_t *begin, 
-					  off_t *end, int boot)
-{
-	int ptr, track;
-	sector_map_t *map;
-	int lbegin, lend;
-	
-	track = where / This->track_size / 1024;
-	
-	*begin = where - track * This->track_size * 1024;
-	*end = where + len - track * This->track_size * 1024;
-	maximize(*end, This->track_size * 1024);
-
-	if(This->current_track == track && !boot)
-		/* already OK, return immediately */
-		return;
-	if(!boot)
-		flush_dirty(This);
-	This->current_track = track;
-
-	if(track) {
-		for(ptr=0, map=This->map; map->size; map++) {
-			/* iterate through all sectors */
-			lbegin = ptr;
-			lend = ptr + (128 << map->size) / This->sector_size;
-			for( ; ptr < lend ; ptr++) {
-				REC.begin = lbegin;
-				REC.end = lend;
-				
-				REC.head = map->head;
-				REC.sector = map->size + 128;
-				REC.sizecode = map->size;
-				
-				REC.valid = 0;
-				REC.dirty = 0;
-				REC.phantom = 0;
-			}
-		}
-		REC.begin = REC.end = ptr;
-	} else {
-		int sector, head;
-
-		head = 0;
-		sector = 0;
-
-		for(ptr=boot; ptr < 2 * This->track_size; ptr++) {
-			REC.begin = ptr;
-			REC.end = ptr+1;
-			
-			REC.sizecode = 2;
-			
-			REC.valid = 0;
-			REC.dirty = 0;
-		}
-
-		/* boot & 1st fat */
-		ptr=fill_t0(This, 0, 1 + This->FatSize, &sector, &head);
-
-		/* second fat */
-		ptr=fill_phantoms(This, ptr, This->FatSize);
-
-		/* root dir */
-		ptr=fill_t0(This, ptr, This->RootDirSize, &sector, &head);
-		
-		/* "bad sectors" at the beginning of the fs */
-		ptr=fill_phantoms(This, ptr, 5);
-
-		if(This->rootskip)
-			sector++;
-
-		/* beginning of the file system */
-		ptr = fill_t0(This, ptr,
-			      (This->track_size - This->FatSize) * 2 -
-			      This->RootDirSize - 6,
-			      &sector, &head);
-	}
-	This->last_sector = ptr;
-}
-
-
-static int xdf_read(Stream_t *Stream, char *buf, mt_off_t where, size_t len)
-{	
-	off_t begin, end;
-	size_t len2;
-	DeclareThis(Xdf_t);
-
-	decompose(This, truncBytes32(where), len, &begin, &end, 0);
-	len2 = load_data(This, begin, end, 4);
-	if(len2 < 0)
-		return len2;
-	len2 -= begin;
-	maximize(len, len2);
-	memcpy(buf, This->buffer + begin, len);
-	return end - begin;
-}
-
-static int xdf_write(Stream_t *Stream, char *buf, mt_off_t where, size_t len)
-{	
-	off_t begin, end;
-	size_t len2;
-	DeclareThis(Xdf_t);
-
-	decompose(This, truncBytes32(where), len, &begin, &end, 0);
-	len2 = load_bounds(This, begin, end);
-	if(len2 < 0)
-		return len2;
-	maximize(end, len2);
-	len2 -= begin;
-	maximize(len, len2);
-	memcpy(This->buffer + begin, buf, len);
-	mark_dirty(This, begin, end);
-	return end - begin;
-}
-
-static int xdf_flush(Stream_t *Stream)
-{
-	DeclareThis(Xdf_t);
-
-	return flush_dirty(This);       
-}
-
-static int xdf_free(Stream_t *Stream)
-{
-	DeclareThis(Xdf_t);
-	Free(This->track_map);
-	Free(This->buffer);
-	return close(This->fd);
-}
-
-
-static int check_geom(struct device *dev, int media, struct bootsector *boot)
-{
-	int sect;
-
-	if(media >= 0xfc && media <= 0xff)
-		return 1; /* old DOS */
-
-	if (!IS_MFORMAT_ONLY(dev)) {
-	    if(compare(dev->sectors, 19) &&
-	       compare(dev->sectors, 23) &&
-	       compare(dev->sectors, 24) &&
-	       compare(dev->sectors, 46) &&
-	       compare(dev->sectors, 48))
-		return 1;
-	    
-	    /* check against contradictory info from configuration file */
-	    if(compare(dev->heads, 2))
-		return 1;
-	}
-
-	/* check against info from boot */
-	if(boot) {
-		sect = WORD(nsect);
-		if((sect != 19 && sect != 23 && sect != 24 &&
-		    sect != 46 && sect != 48) ||
-		   (!IS_MFORMAT_ONLY(dev) && compare(dev->sectors, sect)) || 
-		   WORD(nheads) !=2)
-		    return 1;
-	}
-	return 0;
-}
-
-static void set_geom(struct bootsector *boot, struct device *dev)
-{
-	/* fill in config info to be returned to user */
-	dev->heads = 2;
-	dev->use_2m = 0xff;
-	if(boot) {
-		dev->sectors = WORD(nsect);
-		if(WORD(psect))
-			dev->tracks = WORD(psect) / dev->sectors / 2;
-	}
-}
-
-static int config_geom(Stream_t *Stream, struct device *dev, 
-		       struct device *orig_dev, int media,
-		       struct bootsector *boot)
-{
-	if(check_geom(dev, media, boot))
-		return 1;
-	set_geom(boot,dev);
-	return 0;
-}
-
-static Class_t XdfClass = {
-	xdf_read, 
-	xdf_write, 
-	xdf_flush, 
-	xdf_free, 
-	config_geom, 
-	0, /* get_data */
-	0 /* pre-allocate */
-};
-
-Stream_t *XdfOpen(struct device *dev, char *name,
-		  int mode, char *errmsg, struct xdf_info *info)
-{
-	Xdf_t *This;
-	off_t begin, end;
-	struct bootsector *boot;
-	int type;
-
-	if(dev && (!SHOULD_USE_XDF(dev) || check_geom(dev, 0, 0)))
-		return NULL;
-
-	This = New(Xdf_t);
-	if (!This)
-		return NULL;
-
-	This->Class = &XdfClass;
-	This->sector_size = 512;
-	This->stretch = 0;
-
-	precmd(dev);
-	This->fd = open(name, mode | dev->mode | O_EXCL | O_NDELAY);
-	if(This->fd < 0) {
-#ifdef HAVE_SNPRINTF
-		snprintf(errmsg,199,"xdf floppy: open: \"%s\"", strerror(errno));
-#else
-		sprintf(errmsg,"xdf floppy: open: \"%s\"", strerror(errno));
-#endif
-		goto exit_0;
-	}
-	closeExec(This->fd);
-
-	This->drive = GET_DRIVE(This->fd);
-	if(This->drive < 0)
-		goto exit_1;
-
-	/* allocate buffer */
-	This->buffer = (char *) malloc(96 * 512);
-	if (!This->buffer)
-		goto exit_1;
-
-	This->current_track = -1;
-	This->track_map = (TrackMap_t *)
-		calloc(96, sizeof(TrackMap_t));
-	if(!This->track_map)
-		goto exit_2;
-
-	/* lock the device on writes */
-	if (lock_dev(This->fd, mode == O_RDWR, dev)) {
-#ifdef HAVE_SNPRINTF
-		snprintf(errmsg,199,"xdf floppy: device \"%s\" busy:", 
-			dev->name);
-#else
-		sprintf(errmsg,"xdf floppy: device \"%s\" busy:", 
-			dev->name);
-#endif
-		goto exit_3;
-	}
-
-	/* Before reading the boot sector, assume dummy values suitable
-	 * for reading at least the boot sector */
-	This->track_size = 11;
-	This->track0_size = 6;
-	This->rate = 0;
-	This->FatSize = 9;
-	This->RootDirSize = 1;
-	decompose(This, 0, 512, &begin, &end, 0);
-	if (load_data(This, 0, 1, 1) < 0 ) {
-		This->rate = 0x43;
-		if(load_data(This, 0, 1, 1) < 0)
-			goto exit_3;
-	}
-
-	boot = (struct bootsector *) This->buffer;
-	This->FatSize = WORD(fatlen);
-	This->RootDirSize = WORD(dirents)/16;
-	This->track_size = WORD(nsect);
-	for(type=0; type < NUMBER(xdf_table); type++) {
-		if(xdf_table[type].track_size == This->track_size) {
-			This->map = xdf_table[type].map;
-			This->track0_size = xdf_table[type].track0_size;
-			This->rootskip = xdf_table[type].rootskip;
-			break;
-		}
-	}
-	if(type == NUMBER(xdf_table))
-		goto exit_3;
-
-	if(info) {
-		info->RootDirSize = This->RootDirSize;
-		info->FatSize = This->FatSize;
-		info->BadSectors = 5;
-	}
-	decompose(This, 0, 512, &begin, &end, 1);
-
-	This->refs = 1;
-	This->Next = 0;
-	This->Buffer = 0;
-	if(dev)
-		set_geom(boot, dev);
-	return (Stream_t *) This;
-
-exit_3:
-	Free(This->track_map);
-exit_2:
-	Free(This->buffer);
-exit_1:
-	close(This->fd);
-exit_0:
-	Free(This);
-	return NULL;
-}
-
-#endif
-
-/* Algorithms can't be patented */
-
Index: trunk/minix/commands/i386/mtools-3.9.7/xdf_io.h
===================================================================
--- trunk/minix/commands/i386/mtools-3.9.7/xdf_io.h	(revision 9)
+++ 	(revision )
@@ -1,16 +1,0 @@
-#ifndef MTOOLS_XDFIO_H
-#define MTOOLS_XDFIO_H
-
-#include "msdos.h"
-#include "stream.h"
-
-struct xdf_info {
-  int FatSize;
-  int RootDirSize;
-  int BadSectors;
-};
-
-Stream_t *XdfOpen(struct device *dev, char *name,
-		  int mode, char *errmsg, struct xdf_info *info);
-
-#endif
