Index: include/biosdefs.h
===================================================================
--- include/biosdefs.h	(revision bf89cfbcf78fe3cb5c96d5d735872139aa14889a)
+++ include/biosdefs.h	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -64,18 +64,18 @@
 struct bpb {			/* BIOS parameter block returned by B_GBPB */
 
-	uint16_t	recsiz;		/* physical sector size in bytes */
-	uint16_t	clsiz;		/* cluster size in sectors */
-	uint16_t	clsizb;		/* cluster size in bytes */
-	uint16_t	rdlen;		/* root directory length in sectors */
-	uint16_t	fsiz;		/* FAT size in sectors */
-	uint16_t	fatrec;		/* sector number of 1st sector of 2nd FAT */
-	uint16_t	datrec;		/* sector number of 1st data sector */
-	uint16_t	numcl;		/* number of data clusters on disk */
+	int16_t		recsiz;		/* physical sector size in bytes */
+	int16_t		clsiz;		/* cluster size in sectors */
+	int16_t		clsizb;		/* cluster size in bytes */
+	int16_t		rdlen;		/* root directory length in sectors */
+	int16_t		fsiz;		/* FAT size in sectors */
+	int16_t		fatrec;		/* sector number of 1st sector of 2nd FAT */
+	int16_t		datrec;		/* sector number of 1st data sector */
+	int16_t		numcl;		/* number of data clusters on disk */
 	uint16_t	bflags;		/* flags */
-	uint16_t	ntracks;	/* number of tracks */
-	uint16_t	nsides;		/* number of sides (heads) */
-	uint16_t	dspc;		/* sectors per cylinder */
-	uint16_t	dspt;		/* sectors per track */
-	uint16_t	hidden;		/* number of hidden files */
+	int16_t		ntracks;	/* number of tracks */
+	int16_t		nsides;		/* number of sides (heads) */
+	int16_t		dspc;		/* sectors per cylinder */
+	int16_t		dspt;		/* sectors per track */
+	int16_t		hidden;		/* number of hidden files */
 	int8_t	serno[3];		/* disk serial number */
 	int8_t	nada;			/* --- filler - nothing here --- */
@@ -84,5 +84,5 @@
 #define	BPBSIZE	32		/* length of a BPB */
 
-#define	B_FAT16	0x0001		/* flag for using 16 bit FAT entries */
+#define	B_FAT16	0x0001u		/* flag for using 16 bit FAT entries */
 
 /*
@@ -94,22 +94,22 @@
 struct dirent {			/* Directory entry */
 
-	int8_t	fname[8];		/* file name */
-	int8_t	fext[3];		/* file extension */
-	int8_t	atrib;			/* attribute byte */
-	int8_t	unused[10];		/* unused space */
-	uint16_t	crtime;		/* 'LLHH' creation time */
-	uint16_t	crdate;		/* 'LLHH' creation date */
-	uint16_t	bclust;		/* 'LLHH' starting cluster number */
-	int32_t	flen;			/* 'LLHH' file length */
+	int8_t	fname[8];	/* file name */
+	int8_t	fext[3];	/* file extension */
+	uint8_t	atrib;		/* attribute byte */
+	int8_t	unused[10];	/* unused space */
+	uint16_t	crtime;	/* 'LLHH' creation time */
+	uint16_t	crdate;	/* 'LLHH' creation date */
+	uint16_t	bclust;	/* 'LLHH' starting cluster number */
+	uint32_t	flen;	/* 'LLHH' file length */
 };
 
 #define	DENTSIZE	(sizeof (struct dirent))
 
-#define	F_RDONLY	0x01	/* Read only file */
-#define	F_HIDDEN	0x02	/* Hidden file */
-#define	F_SYSTEM	0x04	/* System file */
-#define	F_VOLUME	0x08	/* Volume label */
-#define	F_SUBDIR	0x10	/* Sub-directory */
-#define	F_ARCHIV	0x20	/* Archived */
+#define	F_RDONLY	0x01u	/* Read only file */
+#define	F_HIDDEN	0x02u	/* Hidden file */
+#define	F_SYSTEM	0x04u	/* System file */
+#define	F_VOLUME	0x08u	/* Volume label */
+#define	F_SUBDIR	0x10u	/* Sub-directory */
+#define	F_ARCHIV	0x20u	/* Archived */
 
 /*
@@ -123,27 +123,27 @@
 	struct	dirent	de;	/* directory entry image for file */
 	uint16_t	modefl;	/* fcb flags */
-	uint16_t	clsec;	/* current sector in cluster */
-	uint16_t	curcls;	/* current cluster */
-	uint16_t	offset;	/* current offset into sector */
-	int32_t	curlsn;		/* current logical sector number in file */
-	int32_t	curdsn;		/* current logical sector number on disk */
+	int16_t	clsec;		/* current sector in cluster */
+	int16_t	curcls;		/* current cluster */
+	int16_t	offset;		/* current offset into sector */
+	int16_t	curlsn;		/* current logical sector number in file */
+	int16_t	curdsn;		/* current logical sector number on disk */
 	int32_t	curlen;		/* current file length in bytes */
-	int32_t	asects;		/* allocated file length in sectors */
+	int16_t	asects;		/* allocated file length in sectors */
 };
 
-#define	FC_EOF	0x8000		/* end of file */
-#define	FC_BAD	0x4000		/* bad FAT entry encountered */
-#define	FC_ERR	0x2000		/* error encountered */
-#define	FC_OPN	0x1000		/* file open */
+#define	FC_EOF	0x8000u		/* end of file */
+#define	FC_BAD	0x4000u		/* bad FAT entry encountered */
+#define	FC_ERR	0x2000u		/* error encountered */
+#define	FC_OPN	0x1000u		/* file open */
 
-#define	FC_CR	0x0800		/* create mode */
-#define	FC_AP	0x0400		/* append mode */
-#define	FC_WR	0x0200		/* write mode */
-#define	FC_RD	0x0100		/* read mode */
+#define	FC_CR	0x0800u		/* create mode */
+#define	FC_AP	0x0400u		/* append mode */
+#define	FC_WR	0x0200u		/* write mode */
+#define	FC_RD	0x0100u		/* read mode */
 
-#define	FC_EX	0x0080		/* exclusive mode */
-#define	FC_TR	0x0040		/* truncate mode */
-#define	FC_NB	0x0020		/* non-blocking mode */
-#define	FC_BF	0x0010		/* binary file mode */
+#define	FC_EX	0x0080u		/* exclusive mode */
+#define	FC_TR	0x0040u		/* truncate mode */
+#define	FC_NB	0x0020u		/* non-blocking mode */
+#define	FC_BF	0x0010u		/* binary file mode */
 
 #define	FC_RW	(FC_RD | FC_WR)	/* read-write mode */
Index: include/fcntl.h
===================================================================
--- include/fcntl.h	(revision bf89cfbcf78fe3cb5c96d5d735872139aa14889a)
+++ include/fcntl.h	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -15,16 +15,16 @@
 */
 
-#define	O_RDONLY	0x0000	/* Read-only value  */
-#define	O_WRONLY	0x0001	/* Write-only value */
-#define	O_RDWR		0x0002	/* Read-write value */
+#define	O_RDONLY	0x0000u	/* Read-only value  */
+#define	O_WRONLY	0x0001u	/* Write-only value */
+#define	O_RDWR		0x0002u	/* Read-write value */
 
-#define O_NDELAY	0x0004	/* Non-blocking I/O flag */
-#define O_APPEND	0x0008	/* Append mode flag (write only at end) */
+#define O_NDELAY	0x0004u	/* Non-blocking I/O flag */
+#define O_APPEND	0x0008u	/* Append mode flag (write only at end) */
 
-#define O_CREAT		0x0100	/* File creation flag (uses 3rd argument) */
-#define O_TRUNC		0x0200	/* File truncation flag */
-#define O_EXCL		0x0400	/* Exclusive access flag */
+#define O_CREAT		0x0100u	/* File creation flag (uses 3rd argument) */
+#define O_TRUNC		0x0200u	/* File truncation flag */
+#define O_EXCL		0x0400u	/* Exclusive access flag */
 
-#define	O_RAW		0x8000	/* Raw (binary) I/O flag for getc and putc */
+#define	O_RAW		0x8000u	/* Raw (binary) I/O flag for getc and putc */
 
 /*
Index: include/fspars.h
===================================================================
--- include/fspars.h	(revision bf89cfbcf78fe3cb5c96d5d735872139aa14889a)
+++ include/fspars.h	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -24,5 +24,4 @@
 
 #define	MAXFAT		7	/* maximum number of fat sectors */
-#define	WDPSEC		256	/* words per sector */
 #define	MAXDIRNT	224	/* maximum number of directory entries */
 
Index: include/io.h
===================================================================
--- include/io.h	(revision bf89cfbcf78fe3cb5c96d5d735872139aa14889a)
+++ include/io.h	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -15,12 +15,12 @@
 
 typedef int16_t (*chclo)(io_arg arg);
-typedef int16_t (*devop)(int8_t *name, int16_t flag, int16_t mode, struct channel *chp, struct devtabl *dp);
+typedef int16_t (*devop)(int8_t *name, uint16_t flag, struct channel *chp, struct devtabl *dp);
 
 struct channel {		/* channel table entry */
 
-	int8_t	c_read;		/* read routine index */
-	int8_t	c_write;	/* write routine index */
-	int8_t	c_ioctl;	/* ioctl routine index */
-	int8_t	c_seek;		/* seek routine index */
+	int16_t	c_read;		/* read routine index */
+	int16_t	c_write;	/* write routine index */
+	int16_t	c_ioctl;	/* ioctl routine index */
+	int16_t	c_seek;		/* seek routine index */
 	chclo	c_close;	/* close function pointer */
 	io_arg	c_arg;		/* argument to channel driver */
@@ -29,8 +29,8 @@
 struct device {			/* device control structure */
 
-	int8_t	d_read;		/* read routine code */
-	int8_t	d_write;	/* write routine code */
-	int8_t	d_ioctl;	/* ioctl routine code */
-	int8_t	d_seek;		/* seek routine code */
+	int16_t	d_read;		/* read routine code */
+	int16_t	d_write;	/* write routine code */
+	int16_t	d_ioctl;	/* ioctl routine code */
+	int16_t	d_seek;		/* seek routine code */
 	devop	d_open;		/* special open function */
 };
@@ -41,3 +41,4 @@
 	struct	device	*d_dev;	/* pointer to device structure */
 	io_arg	d_arg;		/* argument to device driver */
+	int16_t	d_kind;		/* kind of device */
 };
Index: include/stdio.h
===================================================================
--- include/stdio.h	(revision bf89cfbcf78fe3cb5c96d5d735872139aa14889a)
+++ include/stdio.h	(revision 8973acd23a70305139d469bac63060280979efcb)
@@ -16,9 +16,9 @@
 #define	fputc	putc
 
-#define	_BUSY	0x01
-#define	_ALLBUF	0x02
-#define	_DIRTY	0x04
-#define	_EOF	0x08
-#define	_IOERR	0x10
+#define	_BUSY	0x01u
+#define	_ALLBUF	0x02u
+#define	_DIRTY	0x04u
+#define	_EOF	0x08u
+#define	_IOERR	0x10u
 
 typedef struct {
@@ -27,6 +27,6 @@
 	int8_t	*_bend;		/* last character in buffer + 1 */
 	int8_t	*_buff;		/* address of buffer */
-	int8_t	_flags;		/* {_BUSY, _ALLBUF, _DIRTY, _EOF, _IOERR} */
-	int8_t	_unit;		/* fd token returned by open */
+	int16_t	_unit;		/* fd token returned by open */
+	uint8_t	_flags;		/* {_BUSY, _ALLBUF, _DIRTY, _EOF, _IOERR} */
 	int8_t	_bytbuf;	/* single byte buffer for unbuffered streams */
 	int8_t	_pad;		/* pad for alignment -- possibly use later */
@@ -45,15 +45,2 @@
 #define	clearerr(fp)	((fp)->_flags &= ~(_IOERR | _EOF))
 #define	fileno(fp)	((fp)->_unit)
-
-#define	O_RDONLY	0x0000	/* Read-only value  */
-#define	O_WRONLY	0x0001	/* Write-only value */
-#define	O_RDWR		0x0002	/* Read-write value */
-
-#define O_NDELAY	0x0004	/* Non-blocking I/O flag */
-#define O_APPEND	0x0008	/* Append mode flag (write only at end) */
-
-#define O_CREAT		0x0100	/* File creation flag (uses 3rd argument) */
-#define O_TRUNC		0x0200	/* File truncation flag */
-#define O_EXCL		0x0400	/* Exclusive access flag */
-
-#define	O_RAW		0x8000	/* Raw (binary) I/O flag for getc and putc */
