svn commit: r203912 - in user/imp/tbemd: release/picobsd/build release/picobsd/tinyware/login sbin/fsck_msdosfs sbin/newfs_msdos sys/arm/include sys/conf sys/dev/aac sys/dev/ahci sys/dev/ath/ath_ha...

Warner Losh imp at FreeBSD.org
Mon Feb 15 07:41:16 UTC 2010


Author: imp
Date: Mon Feb 15 07:41:16 2010
New Revision: 203912
URL: http://svn.freebsd.org/changeset/base/203912

Log:
  Sync to head at about 203911.

Added:
  user/imp/tbemd/sys/sparc64/sparc64/ssm.c
     - copied unchanged from r203911, head/sys/sparc64/sparc64/ssm.c
Modified:
  user/imp/tbemd/release/picobsd/build/picobsd
  user/imp/tbemd/release/picobsd/tinyware/login/pico-login.c
  user/imp/tbemd/sbin/fsck_msdosfs/boot.c
  user/imp/tbemd/sbin/fsck_msdosfs/check.c
  user/imp/tbemd/sbin/fsck_msdosfs/dir.c
  user/imp/tbemd/sbin/fsck_msdosfs/dosfs.h
  user/imp/tbemd/sbin/fsck_msdosfs/ext.h
  user/imp/tbemd/sbin/fsck_msdosfs/fat.c
  user/imp/tbemd/sbin/fsck_msdosfs/fsck_msdosfs.8
  user/imp/tbemd/sbin/fsck_msdosfs/main.c
  user/imp/tbemd/sbin/newfs_msdos/newfs_msdos.8
  user/imp/tbemd/sbin/newfs_msdos/newfs_msdos.c
  user/imp/tbemd/sys/arm/include/armreg.h
  user/imp/tbemd/sys/conf/files
  user/imp/tbemd/sys/conf/files.sparc64
  user/imp/tbemd/sys/dev/aac/aac.c
  user/imp/tbemd/sys/dev/aac/aac_cam.c
  user/imp/tbemd/sys/dev/aac/aacreg.h
  user/imp/tbemd/sys/dev/aac/aacvar.h
  user/imp/tbemd/sys/dev/ahci/ahci.c
  user/imp/tbemd/sys/dev/ahci/ahci.h
  user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c
  user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c
  user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar5416_cal.h
  user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c
  user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar9160_attach.c
  user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar9280.c
  user/imp/tbemd/sys/dev/ath/ath_hal/ar5416/ar9280_attach.c
  user/imp/tbemd/sys/dev/siis/siis.c
  user/imp/tbemd/sys/dev/usb/input/ukbd.c
  user/imp/tbemd/sys/dev/usb/quirk/usb_quirk.c
  user/imp/tbemd/sys/dev/usb/quirk/usb_quirk.h
  user/imp/tbemd/sys/dev/usb/serial/u3g.c
  user/imp/tbemd/sys/dev/usb/serial/uftdi.c
  user/imp/tbemd/sys/dev/usb/serial/umodem.c
  user/imp/tbemd/sys/dev/usb/usb_msctest.c
  user/imp/tbemd/sys/dev/usb/usb_msctest.h
  user/imp/tbemd/sys/dev/usb/usbdevs
  user/imp/tbemd/sys/fs/msdosfs/msdosfs_fat.c
  user/imp/tbemd/sys/fs/nfsserver/nfs_nfsdcache.c
  user/imp/tbemd/sys/fs/nfsserver/nfs_nfsdstate.c
  user/imp/tbemd/sys/ia64/acpica/madt.c
  user/imp/tbemd/sys/ia64/ia64/bus_machdep.c
  user/imp/tbemd/sys/ia64/ia64/efi.c
  user/imp/tbemd/sys/ia64/ia64/interrupt.c
  user/imp/tbemd/sys/ia64/ia64/machdep.c
  user/imp/tbemd/sys/ia64/ia64/mp_machdep.c
  user/imp/tbemd/sys/ia64/ia64/pmap.c
  user/imp/tbemd/sys/ia64/ia64/sapic.c
  user/imp/tbemd/sys/ia64/include/bus.h
  user/imp/tbemd/sys/ia64/include/intr.h
  user/imp/tbemd/sys/ia64/include/md_var.h
  user/imp/tbemd/sys/ia64/include/pci_cfgreg.h
  user/imp/tbemd/sys/ia64/include/pmap.h
  user/imp/tbemd/sys/ia64/include/vmparam.h
  user/imp/tbemd/sys/kern/kern_event.c
  user/imp/tbemd/sys/netinet/sctp_header.h
  user/imp/tbemd/sys/sparc64/include/asmacros.h
  user/imp/tbemd/sys/sys/timeb.h
  user/imp/tbemd/usr.bin/find/function.c
Directory Properties:
  user/imp/tbemd/   (props changed)

Modified: user/imp/tbemd/release/picobsd/build/picobsd
==============================================================================
--- user/imp/tbemd/release/picobsd/build/picobsd	Mon Feb 15 05:44:43 2010	(r203911)
+++ user/imp/tbemd/release/picobsd/build/picobsd	Mon Feb 15 07:41:16 2010	(r203912)
@@ -889,7 +889,7 @@ fill_floppy_image() {
     if [ ${mfs_start} -gt 0 -a ${mfs_size} -ge ${imgsize} ] ; then
 	mfs_ofs=$((${mfs_start} + 8192))
 	log "Preload kernel with file ${c_fs} at ${mfs_ofs}"
-	logverbose "`ls -l ${c_fs}` to fit in ${mfs_size}"
+	log "`ls -l ${c_fs}` to fit in ${mfs_size}"
 	dd if=${c_fs} ibs=8192 iseek=1 of=kernel obs=${mfs_ofs} \
 	    oseek=1 conv=notrunc # 2> /dev/null
     else
@@ -944,7 +944,7 @@ fill_floppy_image() {
 
     ls -l ${c_img}
     ${c_label} -f `pwd`/${c_img}
-    logverbose "after disklabel"
+    log "after disklabel"
     )
 
     echo "BUILDDIR ${BUILDDIR}"
@@ -958,7 +958,7 @@ fill_floppy_image() {
 
     dd if=${b2} iseek=1 ibs=276 2> /dev/null | \
 	dd of=${BUILDDIR}/${c_img} oseek=1 obs=788 conv=notrunc 2>/dev/null
-    logverbose "done floppy image"
+    log "done disk image"
     # XXX (log "Fixing permissions"; cd ${dst}; chown -R root *)
     rm -rf ${BUILDDIR}/floppy.tree || true # cleanup
     # df -ik ${dst} | colrm 70 > .build.reply

Modified: user/imp/tbemd/release/picobsd/tinyware/login/pico-login.c
==============================================================================
--- user/imp/tbemd/release/picobsd/tinyware/login/pico-login.c	Mon Feb 15 05:44:43 2010	(r203911)
+++ user/imp/tbemd/release/picobsd/tinyware/login/pico-login.c	Mon Feb 15 07:41:16 2010	(r203912)
@@ -76,7 +76,7 @@ static const char rcsid[] =
 #include <syslog.h>
 #include <ttyent.h>
 #include <unistd.h>
-#include <utmp.h>
+#include <utmpx.h>
 
 #ifdef USE_PAM
 #include <security/pam_appl.h>
@@ -119,7 +119,6 @@ static char **environ_pam;
 #endif
 
 static int auth_traditional(void);
-extern void login(struct utmp *);
 static void usage(void);
 
 #define	TTYGRPNAME	"tty"		/* name of group to own ttys */
@@ -152,7 +151,7 @@ main(argc, argv)
 	struct group *gr;
 	struct stat st;
 	struct timeval tp;
-	struct utmp utmp;
+	struct utmpx utmp;
 	int rootok, retries, backoff;
 	int ask, ch, cnt, fflag, hflag, pflag, quietlog, rootlogin, rval;
 	int changepass;
@@ -164,6 +163,8 @@ main(argc, argv)
 	char tname[sizeof(_PATH_TTY) + 10];
 	const char *shell = NULL;
 	login_cap_t *lc = NULL;
+	int UT_HOSTSIZE = sizeof(utmp.ut_host);
+	int UT_NAMESIZE = sizeof(utmp.ut_user);
 #ifdef USE_PAM
 	pid_t pid;
 	int e;
@@ -508,14 +509,18 @@ main(argc, argv)
 		refused("Permission denied", "ACCESS", 1);
 #endif /* LOGIN_ACCESS */
 
+#if 1
+	ulog_login(tty, username, hostname);
+#else
 	/* Nothing else left to fail -- really log in. */
 	memset((void *)&utmp, 0, sizeof(utmp));
-	(void)time(&utmp.ut_time);
-	(void)strncpy(utmp.ut_name, username, sizeof(utmp.ut_name));
+	(void)gettimeofday(&utmp.ut_tv, NULL);
+	(void)strncpy(utmp.ut_user, username, sizeof(utmp.ut_user));
 	if (hostname)
 		(void)strncpy(utmp.ut_host, hostname, sizeof(utmp.ut_host));
 	(void)strncpy(utmp.ut_line, tty, sizeof(utmp.ut_line));
 	login(&utmp);
+#endif
 
 	dolastlog(quietlog);
 
@@ -903,7 +908,7 @@ usage()
  * Allow for authentication style and/or kerberos instance
  */
 
-#define	NBUFSIZ		UT_NAMESIZE + 64
+#define	NBUFSIZ		128	// XXX was UT_NAMESIZE + 64
 
 void
 getloginname()
@@ -985,6 +990,7 @@ void
 dolastlog(quiet)
 	int quiet;
 {
+#if 0	/* XXX not implemented after utmp->utmpx change */
 	struct lastlog ll;
 	int fd;
 
@@ -1016,6 +1022,7 @@ dolastlog(quiet)
 	} else {
 		syslog(LOG_ERR, "cannot open %s: %m", _PATH_LASTLOG);
 	}
+#endif
 }
 
 void

Modified: user/imp/tbemd/sbin/fsck_msdosfs/boot.c
==============================================================================
--- user/imp/tbemd/sbin/fsck_msdosfs/boot.c	Mon Feb 15 05:44:43 2010	(r203911)
+++ user/imp/tbemd/sbin/fsck_msdosfs/boot.c	Mon Feb 15 07:41:16 2010	(r203912)
@@ -10,13 +10,6 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by Martin Husemann
- *	and Wolfgang Solfrank.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@@ -40,7 +33,6 @@ static const char rcsid[] =
 
 #include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
 #include <stdio.h>
 #include <unistd.h>
 
@@ -48,16 +40,15 @@ static const char rcsid[] =
 #include "fsutil.h"
 
 int
-readboot(dosfs, boot)
-	int dosfs;
-	struct bootblock *boot;
+readboot(int dosfs, struct bootblock *boot)
 {
 	u_char block[DOSBOOTBLOCKSIZE];
 	u_char fsinfo[2 * DOSBOOTBLOCKSIZE];
 	u_char backup[DOSBOOTBLOCKSIZE];
 	int ret = FSOK;
+	int i;
 	
-	if (read(dosfs, block, sizeof block) < sizeof block) {
+	if ((size_t)read(dosfs, block, sizeof block) != sizeof block) {
 		perror("could not read boot block");
 		return FSFATAL;
 	}
@@ -71,22 +62,22 @@ readboot(dosfs, boot)
 	boot->ValidFat = -1;
 
 	/* decode bios parameter block */
-	boot->BytesPerSec = block[11] + (block[12] << 8);
-	boot->SecPerClust = block[13];
-	boot->ResSectors = block[14] + (block[15] << 8);
-	boot->FATs = block[16];
-	boot->RootDirEnts = block[17] + (block[18] << 8);
-	boot->Sectors = block[19] + (block[20] << 8);
-	boot->Media = block[21];
-	boot->FATsmall = block[22] + (block[23] << 8);
+	boot->bpbBytesPerSec = block[11] + (block[12] << 8);
+	boot->bpbSecPerClust = block[13];
+	boot->bpbResSectors = block[14] + (block[15] << 8);
+	boot->bpbFATs = block[16];
+	boot->bpbRootDirEnts = block[17] + (block[18] << 8);
+	boot->bpbSectors = block[19] + (block[20] << 8);
+	boot->bpbMedia = block[21];
+	boot->bpbFATsmall = block[22] + (block[23] << 8);
 	boot->SecPerTrack = block[24] + (block[25] << 8);
-	boot->Heads = block[26] + (block[27] << 8);
-	boot->HiddenSecs = block[28] + (block[29] << 8) + (block[30] << 16) + (block[31] << 24);
-	boot->HugeSectors = block[32] + (block[33] << 8) + (block[34] << 16) + (block[35] << 24);
+	boot->bpbHeads = block[26] + (block[27] << 8);
+	boot->bpbHiddenSecs = block[28] + (block[29] << 8) + (block[30] << 16) + (block[31] << 24);
+	boot->bpbHugeSectors = block[32] + (block[33] << 8) + (block[34] << 16) + (block[35] << 24);
 
-	boot->FATsecs = boot->FATsmall;
+	boot->FATsecs = boot->bpbFATsmall;
 
-	if (!boot->RootDirEnts)
+	if (!boot->bpbRootDirEnts)
 		boot->flags |= FAT32;
 	if (boot->flags & FAT32) {
 		boot->FATsecs = block[36] + (block[37] << 8)
@@ -101,13 +92,13 @@ readboot(dosfs, boot)
 			       block[43], block[42]);
 			return FSFATAL;
 		}
-		boot->RootCl = block[44] + (block[45] << 8)
+		boot->bpbRootClust = block[44] + (block[45] << 8)
 			       + (block[46] << 16) + (block[47] << 24);
-		boot->FSInfo = block[48] + (block[49] << 8);
-		boot->Backup = block[50] + (block[51] << 8);
+		boot->bpbFSInfo = block[48] + (block[49] << 8);
+		boot->bpbBackup = block[50] + (block[51] << 8);
 
-		if (lseek(dosfs, boot->FSInfo * boot->BytesPerSec, SEEK_SET)
-		    != boot->FSInfo * boot->BytesPerSec
+		if (lseek(dosfs, boot->bpbFSInfo * boot->bpbBytesPerSec, SEEK_SET)
+		    != boot->bpbFSInfo * boot->bpbBytesPerSec
 		    || read(dosfs, fsinfo, sizeof fsinfo)
 		    != sizeof fsinfo) {
 			perror("could not read fsinfo block");
@@ -133,18 +124,18 @@ readboot(dosfs, boot)
 				fsinfo[0x3fc] = fsinfo[0x3fd] = 0;
 				fsinfo[0x3fe] = 0x55;
 				fsinfo[0x3ff] = 0xaa;
-				if (lseek(dosfs, boot->FSInfo * boot->BytesPerSec, SEEK_SET)
-				    != boot->FSInfo * boot->BytesPerSec
+				if (lseek(dosfs, boot->bpbFSInfo * boot->bpbBytesPerSec, SEEK_SET)
+				    != boot->bpbFSInfo * boot->bpbBytesPerSec
 				    || write(dosfs, fsinfo, sizeof fsinfo)
 				    != sizeof fsinfo) {
-					perror("Unable to write FSInfo");
+					perror("Unable to write bpbFSInfo");
 					return FSFATAL;
 				}
 				ret = FSBOOTMOD;
 			} else
-				boot->FSInfo = 0;
+				boot->bpbFSInfo = 0;
 		}
-		if (boot->FSInfo) {
+		if (boot->bpbFSInfo) {
 			boot->FSFree = fsinfo[0x1e8] + (fsinfo[0x1e9] << 8)
 				       + (fsinfo[0x1ea] << 16)
 				       + (fsinfo[0x1eb] << 24);
@@ -153,44 +144,54 @@ readboot(dosfs, boot)
 				       + (fsinfo[0x1ef] << 24);
 		}
 
-		if (lseek(dosfs, boot->Backup * boot->BytesPerSec, SEEK_SET)
-		    != boot->Backup * boot->BytesPerSec
+		if (lseek(dosfs, boot->bpbBackup * boot->bpbBytesPerSec, SEEK_SET)
+		    != boot->bpbBackup * boot->bpbBytesPerSec
 		    || read(dosfs, backup, sizeof backup) != sizeof  backup) {
 			perror("could not read backup bootblock");
 			return FSFATAL;
 		}
 		backup[65] = block[65];				/* XXX */
 		if (memcmp(block + 11, backup + 11, 79)) {
-			/* Correct?					XXX */
-			pfatal("backup doesn't compare to primary bootblock");
-			if (alwaysno)
-				pfatal("\n");
-			else
-				return FSFATAL;
+			/*
+			 * XXX We require a reference that explains
+			 * that these bytes need to match, or should
+			 * drop the check.  gdt at NetBSD has observed
+			 * filesystems that work fine under Windows XP
+			 * and NetBSD that do not match, so the
+			 * requirement is suspect.  For now, just
+			 * print out useful information and continue.
+			 */
+			pfatal("backup (block %d) mismatch with primary bootblock:\n",
+			        boot->bpbBackup);
+			for (i = 11; i < 11 + 90; i++) {
+				if (block[i] != backup[i])
+					pfatal("\ti=%d\tprimary 0x%02x\tbackup 0x%02x\n",
+					       i, block[i], backup[i]);
+			}
 		}
-		/* Check backup FSInfo?					XXX */
+		/* Check backup bpbFSInfo?					XXX */
 	}
 
-	boot->ClusterOffset = (boot->RootDirEnts * 32 + boot->BytesPerSec - 1)
-	    / boot->BytesPerSec
-	    + boot->ResSectors
-	    + boot->FATs * boot->FATsecs
-	    - CLUST_FIRST * boot->SecPerClust;
+	boot->ClusterOffset = (boot->bpbRootDirEnts * 32 + boot->bpbBytesPerSec - 1)
+	    / boot->bpbBytesPerSec
+	    + boot->bpbResSectors
+	    + boot->bpbFATs * boot->FATsecs
+	    - CLUST_FIRST * boot->bpbSecPerClust;
 
-	if (boot->BytesPerSec % DOSBOOTBLOCKSIZE != 0) {
-		pfatal("Invalid sector size: %u", boot->BytesPerSec);
+	if (boot->bpbBytesPerSec % DOSBOOTBLOCKSIZE != 0) {
+		pfatal("Invalid sector size: %u", boot->bpbBytesPerSec);
 		return FSFATAL;
 	}
-	if (boot->SecPerClust == 0) {
-		pfatal("Invalid cluster size: %u", boot->SecPerClust);
+	if (boot->bpbSecPerClust == 0) {
+		pfatal("Invalid cluster size: %u", boot->bpbSecPerClust);
 		return FSFATAL;
 	}
-	if (boot->Sectors) {
-		boot->HugeSectors = 0;
-		boot->NumSectors = boot->Sectors;
+	if (boot->bpbSectors) {
+		boot->bpbHugeSectors = 0;
+		boot->NumSectors = boot->bpbSectors;
 	} else
-		boot->NumSectors = boot->HugeSectors;
-	boot->NumClusters = (boot->NumSectors - boot->ClusterOffset) / boot->SecPerClust;
+		boot->NumSectors = boot->bpbHugeSectors;
+	boot->NumClusters = (boot->NumSectors - boot->ClusterOffset) / boot->bpbSecPerClust;
 
 	if (boot->flags&FAT32)
 		boot->ClustMask = CLUST32_MASK;
@@ -206,13 +207,13 @@ readboot(dosfs, boot)
 
 	switch (boot->ClustMask) {
 	case CLUST32_MASK:
-		boot->NumFatEntries = (boot->FATsecs * boot->BytesPerSec) / 4;
+		boot->NumFatEntries = (boot->FATsecs * boot->bpbBytesPerSec) / 4;
 		break;
 	case CLUST16_MASK:
-		boot->NumFatEntries = (boot->FATsecs * boot->BytesPerSec) / 2;
+		boot->NumFatEntries = (boot->FATsecs * boot->bpbBytesPerSec) / 2;
 		break;
 	default:
-		boot->NumFatEntries = (boot->FATsecs * boot->BytesPerSec * 2) / 3;
+		boot->NumFatEntries = (boot->FATsecs * boot->bpbBytesPerSec * 2) / 3;
 		break;
 	}
 
@@ -221,7 +222,7 @@ readboot(dosfs, boot)
 		       boot->NumClusters, boot->FATsecs);
 		return FSFATAL;
 	}
-	boot->ClusterSize = boot->BytesPerSec * boot->SecPerClust;
+	boot->ClusterSize = boot->bpbBytesPerSec * boot->bpbSecPerClust;
 
 	boot->NumFiles = 1;
 	boot->NumFree = 0;
@@ -230,14 +231,12 @@ readboot(dosfs, boot)
 }
 
 int
-writefsinfo(dosfs, boot)
-	int dosfs;
-	struct bootblock *boot;
+writefsinfo(int dosfs, struct bootblock *boot)
 {
 	u_char fsinfo[2 * DOSBOOTBLOCKSIZE];
 
-	if (lseek(dosfs, boot->FSInfo * boot->BytesPerSec, SEEK_SET)
-	    != boot->FSInfo * boot->BytesPerSec
+	if (lseek(dosfs, boot->bpbFSInfo * boot->bpbBytesPerSec, SEEK_SET)
+	    != boot->bpbFSInfo * boot->bpbBytesPerSec
 	    || read(dosfs, fsinfo, sizeof fsinfo) != sizeof fsinfo) {
 		perror("could not read fsinfo block");
 		return FSFATAL;
@@ -250,11 +249,11 @@ writefsinfo(dosfs, boot)
 	fsinfo[0x1ed] = (u_char)(boot->FSNext >> 8);
 	fsinfo[0x1ee] = (u_char)(boot->FSNext >> 16);
 	fsinfo[0x1ef] = (u_char)(boot->FSNext >> 24);
-	if (lseek(dosfs, boot->FSInfo * boot->BytesPerSec, SEEK_SET)
-	    != boot->FSInfo * boot->BytesPerSec
+	if (lseek(dosfs, boot->bpbFSInfo * boot->bpbBytesPerSec, SEEK_SET)
+	    != boot->bpbFSInfo * boot->bpbBytesPerSec
 	    || write(dosfs, fsinfo, sizeof fsinfo)
 	    != sizeof fsinfo) {
-		perror("Unable to write FSInfo");
+		perror("Unable to write bpbFSInfo");
 		return FSFATAL;
 	}
 	/*

Modified: user/imp/tbemd/sbin/fsck_msdosfs/check.c
==============================================================================
--- user/imp/tbemd/sbin/fsck_msdosfs/check.c	Mon Feb 15 05:44:43 2010	(r203911)
+++ user/imp/tbemd/sbin/fsck_msdosfs/check.c	Mon Feb 15 07:41:16 2010	(r203912)
@@ -10,13 +10,6 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by Martin Husemann
- *	and Wolfgang Solfrank.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@@ -40,7 +33,6 @@ static const char rcsid[] =
 
 #include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -54,7 +46,8 @@ checkfilesys(const char *fname)
 	int dosfs;
 	struct bootblock boot;
 	struct fatEntry *fat = NULL;
-	int i, finish_dosdirsection=0;
+	int finish_dosdirsection=0;
+	u_int i;
 	int mod = 0;
 	int ret = 8;
 
@@ -105,7 +98,7 @@ checkfilesys(const char *fname)
 	}
 
 	if (boot.ValidFat < 0)
-		for (i = 1; i < (int)boot.FATs; i++) {
+		for (i = 1; i < (int)boot.bpbFATs; i++) {
 			struct fatEntry *currentFat;
 
 			mod |= readfat(dosfs, &boot, i, &currentFat);

Modified: user/imp/tbemd/sbin/fsck_msdosfs/dir.c
==============================================================================
--- user/imp/tbemd/sbin/fsck_msdosfs/dir.c	Mon Feb 15 05:44:43 2010	(r203911)
+++ user/imp/tbemd/sbin/fsck_msdosfs/dir.c	Mon Feb 15 07:41:16 2010	(r203912)
@@ -12,13 +12,6 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by Martin Husemann
- *	and Wolfgang Solfrank.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@@ -44,7 +37,6 @@ static const char rcsid[] =
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
-#include <stdio.h>
 #include <unistd.h>
 #include <time.h>
 
@@ -227,26 +219,38 @@ resetDosDirSection(struct bootblock *boo
 	cl_t cl;
 	int ret = FSOK;
 
-	b1 = boot->RootDirEnts * 32;
-	b2 = boot->SecPerClust * boot->BytesPerSec;
+	b1 = boot->bpbRootDirEnts * 32;
+	b2 = boot->bpbSecPerClust * boot->bpbBytesPerSec;
 
-	if (!(buffer = malloc(b1 > b2 ? b1 : b2))
-	    || !(delbuf = malloc(b2))
-	    || !(rootDir = newDosDirEntry())) {
-		perror("No space for directory");
+	if ((buffer = malloc( b1 > b2 ? b1 : b2)) == NULL) {
+		perror("No space for directory buffer");
 		return FSFATAL;
 	}
+
+	if ((delbuf = malloc(b2)) == NULL) {
+		free(buffer);
+		perror("No space for directory delbuf");
+		return FSFATAL;
+	}
+
+	if ((rootDir = newDosDirEntry()) == NULL) {
+		free(buffer);
+		free(delbuf);
+		perror("No space for directory entry");
+		return FSFATAL;
+	}
+
 	memset(rootDir, 0, sizeof *rootDir);
 	if (boot->flags & FAT32) {
-		if (boot->RootCl < CLUST_FIRST || boot->RootCl >= boot->NumClusters) {
+		if (boot->bpbRootClust < CLUST_FIRST || boot->bpbRootClust >= boot->NumClusters) {
 			pfatal("Root directory starts with cluster out of range(%u)",
-			       boot->RootCl);
+			       boot->bpbRootClust);
 			return FSFATAL;
 		}
-		cl = fat[boot->RootCl].next;
+		cl = fat[boot->bpbRootClust].next;
 		if (cl < CLUST_FIRST
 		    || (cl >= CLUST_RSRVD && cl< CLUST_EOFS)
-		    || fat[boot->RootCl].head != boot->RootCl) {
+		    || fat[boot->bpbRootClust].head != boot->bpbRootClust) {
 			if (cl == CLUST_FREE)
 				pwarn("Root directory starts with free cluster\n");
 			else if (cl >= CLUST_RSRVD)
@@ -257,14 +261,14 @@ resetDosDirSection(struct bootblock *boo
 				return FSFATAL;
 			}
 			if (ask(1, "Fix")) {
-				fat[boot->RootCl].next = CLUST_FREE;
+				fat[boot->bpbRootClust].next = CLUST_FREE;
 				ret = FSFATMOD;
 			} else
 				ret = FSFATAL;
 		}
 
-		fat[boot->RootCl].flags |= FAT_USED;
-		rootDir->head = boot->RootCl;
+		fat[boot->bpbRootClust].flags |= FAT_USED;
+		rootDir->head = boot->bpbRootClust;
 	}
 
 	return ret;
@@ -309,7 +313,7 @@ delete(int f, struct bootblock *boot, st
 {
 	u_char *s, *e;
 	off_t off;
-	int clsz = boot->SecPerClust * boot->BytesPerSec;
+	int clsz = boot->bpbSecPerClust * boot->bpbBytesPerSec;
 
 	s = delbuf + startoff;
 	e = delbuf + clsz;
@@ -319,8 +323,8 @@ delete(int f, struct bootblock *boot, st
 				break;
 			e = delbuf + endoff;
 		}
-		off = startcl * boot->SecPerClust + boot->ClusterOffset;
-		off *= boot->BytesPerSec;
+		off = startcl * boot->bpbSecPerClust + boot->ClusterOffset;
+		off *= boot->bpbBytesPerSec;
 		if (lseek(f, off, SEEK_SET) != off
 		    || read(f, delbuf, clsz) != clsz) {
 			perror("Unable to read directory");
@@ -367,7 +371,8 @@ removede(int f, struct bootblock *boot, 
 				return FSFATAL;
 			start = buffer;
 		}
-		if (endcl == curcl)
+		/* startcl is < CLUST_FIRST for !fat32 root */
+		if ((endcl == curcl) || (startcl < CLUST_FIRST))
 			for (; start < end; start += 32)
 				*start = SLOT_DELETED;
 		return FSDIRMOD;
@@ -385,7 +390,7 @@ checksize(struct bootblock *boot, struct
 	/*
 	 * Check size on ordinary files
 	 */
-	int32_t physicalSize;
+	u_int32_t physicalSize;
 
 	if (dir->head == CLUST_FREE)
 		physicalSize = 0;
@@ -456,14 +461,14 @@ readDosDirSection(int f, struct bootbloc
 	vallfn = invlfn = empty = NULL;
 	do {
 		if (!(boot->flags & FAT32) && !dir->parent) {
-			last = boot->RootDirEnts * 32;
-			off = boot->ResSectors + boot->FATs * boot->FATsecs;
+			last = boot->bpbRootDirEnts * 32;
+			off = boot->bpbResSectors + boot->bpbFATs * boot->FATsecs;
 		} else {
-			last = boot->SecPerClust * boot->BytesPerSec;
-			off = cl * boot->SecPerClust + boot->ClusterOffset;
+			last = boot->bpbSecPerClust * boot->bpbBytesPerSec;
+			off = cl * boot->bpbSecPerClust + boot->ClusterOffset;
 		}
 
-		off *= boot->BytesPerSec;
+		off *= boot->bpbBytesPerSec;
 		if (lseek(f, off, SEEK_SET) != off
 		    || read(f, buffer, last) != last) {
 			perror("Unable to read directory");
@@ -644,7 +649,8 @@ readDosDirSection(int f, struct bootbloc
 				dirent.head |= (p[20] << 16) | (p[21] << 24);
 			dirent.size = p[28] | (p[29] << 8) | (p[30] << 16) | (p[31] << 24);
 			if (vallfn) {
-				strcpy(dirent.lname, longName);
+				strlcpy(dirent.lname, longName,
+				    sizeof(dirent.lname));
 				longName[0] = '\0';
 				shortSum = -1;
 			}
@@ -832,6 +838,10 @@ readDosDirSection(int f, struct bootbloc
 			}
 			boot->NumFiles++;
 		}
+
+		if (!(boot->flags & FAT32) && !dir->parent)
+			break;
+
 		if (mod & THISMOD) {
 			last *= 32;
 			if (lseek(f, off, SEEK_SET) != off
@@ -847,6 +857,19 @@ readDosDirSection(int f, struct bootbloc
 				invlfn ? invlfn : vallfn, p,
 				invlfn ? invcl : valcl, -1, 0,
 				fullpath(dir), 1);
+
+	/* The root directory of non fat32 filesystems is in a special
+	 * area and may have been modified above without being written out.
+	 */
+	if ((mod & FSDIRMOD) && !(boot->flags & FAT32) && !dir->parent) {
+		last *= 32;
+		if (lseek(f, off, SEEK_SET) != off
+		    || write(f, buffer, last) != last) {
+			perror("Unable to write directory");
+			return FSFATAL;
+		}
+		mod &= ~THISMOD;
+	}
 	return mod & ~THISMOD;
 }
 
@@ -934,9 +957,9 @@ reconnect(int dosfs, struct bootblock *b
 			return FSERROR;
 		}
 		lfoff = lfcl * boot->ClusterSize
-		    + boot->ClusterOffset * boot->BytesPerSec;
+		    + boot->ClusterOffset * boot->bpbBytesPerSec;
 		if (lseek(dosfs, lfoff, SEEK_SET) != lfoff
-		    || read(dosfs, lfbuf, boot->ClusterSize) != boot->ClusterSize) {
+		    || (size_t)read(dosfs, lfbuf, boot->ClusterSize) != boot->ClusterSize) {
 			perror("could not read LOST.DIR");
 			return FSFATAL;
 		}
@@ -966,7 +989,7 @@ reconnect(int dosfs, struct bootblock *b
 	p[31] = (u_char)(d.size >> 24);
 	fat[head].flags |= FAT_USED;
 	if (lseek(dosfs, lfoff, SEEK_SET) != lfoff
-	    || write(dosfs, lfbuf, boot->ClusterSize) != boot->ClusterSize) {
+	    || (size_t)write(dosfs, lfbuf, boot->ClusterSize) != boot->ClusterSize) {
 		perror("could not write LOST.DIR");
 		return FSFATAL;
 	}

Modified: user/imp/tbemd/sbin/fsck_msdosfs/dosfs.h
==============================================================================
--- user/imp/tbemd/sbin/fsck_msdosfs/dosfs.h	Mon Feb 15 05:44:43 2010	(r203911)
+++ user/imp/tbemd/sbin/fsck_msdosfs/dosfs.h	Mon Feb 15 07:41:16 2010	(r203912)
@@ -12,13 +12,6 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by Martin Husemann
- *	and Wolfgang Solfrank.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@@ -46,21 +39,21 @@ typedef	u_int32_t	cl_t;	/* type holding 
  * FAT boot block.
  */
 struct bootblock {
-	u_int	BytesPerSec;		/* bytes per sector */
-	u_int	SecPerClust;		/* sectors per cluster */
-	u_int	ResSectors;		/* number of reserved sectors */
-	u_int	FATs;			/* number of FATs */
-	u_int	RootDirEnts;		/* number of root directory entries */
-	u_int	Media;			/* media descriptor */
-	u_int	FATsmall;		/* number of sectors per FAT */
+	u_int	bpbBytesPerSec;		/* bytes per sector */
+	u_int	bpbSecPerClust;		/* sectors per cluster */
+	u_int	bpbResSectors;		/* number of reserved sectors */
+	u_int	bpbFATs;		/* number of bpbFATs */
+	u_int	bpbRootDirEnts;		/* number of root directory entries */
+	u_int32_t bpbSectors;		/* total number of sectors */
+	u_int	bpbMedia;		/* media descriptor */
+	u_int	bpbFATsmall;		/* number of sectors per FAT */
 	u_int	SecPerTrack;		/* sectors per track */
-	u_int	Heads;			/* number of heads */
-	u_int32_t Sectors;		/* total number of sectors */
-	u_int32_t HiddenSecs;		/* # of hidden sectors */
-	u_int32_t HugeSectors;		/* # of sectors if bpbSectors == 0 */
-	u_int	FSInfo;			/* FSInfo sector */
-	u_int	Backup;			/* Backup of Bootblocks */
-	cl_t	RootCl;			/* Start of Root Directory */
+	u_int	bpbHeads;		/* number of heads */
+	u_int32_t bpbHiddenSecs;	/* # of hidden sectors */
+	u_int32_t bpbHugeSectors;	/* # of sectors if bpbbpbSectors == 0 */
+	cl_t	bpbRootClust;		/* Start of Root Directory */
+	u_int	bpbFSInfo;		/* FSInfo sector */
+	u_int	bpbBackup;		/* Backup of Bootblocks */
 	cl_t	FSFree;			/* Number of free clusters acc. FSInfo */
 	cl_t	FSNext;			/* Next free cluster acc. FSInfo */
 

Modified: user/imp/tbemd/sbin/fsck_msdosfs/ext.h
==============================================================================
--- user/imp/tbemd/sbin/fsck_msdosfs/ext.h	Mon Feb 15 05:44:43 2010	(r203911)
+++ user/imp/tbemd/sbin/fsck_msdosfs/ext.h	Mon Feb 15 07:41:16 2010	(r203912)
@@ -10,13 +10,6 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by Martin Husemann
- *	and Wolfgang Solfrank.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@@ -77,12 +70,12 @@ int checkfilesys(const char *);
 #define	FSDIRMOD	2		/* Some directory was modified */
 #define	FSFATMOD	4		/* The FAT was modified */
 #define	FSERROR		8		/* Some unrecovered error remains */
-#define	FSFATAL		16		/* Some unrecoverable error occured */
+#define	FSFATAL		16		/* Some unrecoverable error occurred */
 #define FSDIRTY		32		/* File system is dirty */
 #define FSFIXFAT	64		/* Fix file system FAT */
 
 /*
- * read a boot block in a machine independend fashion and translate
+ * read a boot block in a machine independent fashion and translate
  * it into our struct bootblock.
  */
 int readboot(int, struct bootblock *);
@@ -96,13 +89,13 @@ int writefsinfo(int, struct bootblock *)
  * Read one of the FAT copies and return a pointer to the new
  * allocated array holding our description of it.
  */
-int readfat(int, struct bootblock *, int, struct fatEntry **);
+int readfat(int, struct bootblock *, u_int, struct fatEntry **);
 
 /*
  * Check two FAT copies for consistency and merge changes into the
- * first if neccessary.
+ * first if necessary.
  */
-int comparefat(struct bootblock *, struct fatEntry *, struct fatEntry *, int);
+int comparefat(struct bootblock *, struct fatEntry *, struct fatEntry *, u_int);
 
 /*
  * Check a FAT

Modified: user/imp/tbemd/sbin/fsck_msdosfs/fat.c
==============================================================================
--- user/imp/tbemd/sbin/fsck_msdosfs/fat.c	Mon Feb 15 05:44:43 2010	(r203911)
+++ user/imp/tbemd/sbin/fsck_msdosfs/fat.c	Mon Feb 15 07:41:16 2010	(r203912)
@@ -10,13 +10,6 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by Martin Husemann
- *	and Wolfgang Solfrank.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@@ -47,10 +40,10 @@ static const char rcsid[] =
 #include "ext.h"
 #include "fsutil.h"
 
-static int checkclnum(struct bootblock *, int, cl_t, cl_t *);
-static int clustdiffer(cl_t, cl_t *, cl_t *, int);
+static int checkclnum(struct bootblock *, u_int, cl_t, cl_t *);
+static int clustdiffer(cl_t, cl_t *, cl_t *, u_int);
 static int tryclear(struct bootblock *, struct fatEntry *, cl_t, cl_t *);
-static int _readfat(int, struct bootblock *, int, u_char **);
+static int _readfat(int, struct bootblock *, u_int, u_char **);
 
 /*-
  * The first 2 FAT entries contain pseudo-cluster numbers with the following
@@ -80,10 +73,10 @@ checkdirty(int fs, struct bootblock *boo
 	if (boot->ClustMask != CLUST16_MASK && boot->ClustMask != CLUST32_MASK)
 		return 0;
 
-	off = boot->ResSectors;
-	off *= boot->BytesPerSec;
+	off = boot->bpbResSectors;
+	off *= boot->bpbBytesPerSec;
 
-	buffer = malloc(boot->BytesPerSec);
+	buffer = malloc(boot->bpbBytesPerSec);
 	if (buffer == NULL) {
 		perror("No space for FAT");
 		return 1;
@@ -94,7 +87,7 @@ checkdirty(int fs, struct bootblock *boo
 		goto err;
 	}
 
-	if (read(fs, buffer, boot->BytesPerSec) != boot->BytesPerSec) {
+	if (read(fs, buffer, boot->bpbBytesPerSec) != boot->bpbBytesPerSec) {
 		perror("Unable to read FAT");
 		goto err;
 	}
@@ -103,7 +96,7 @@ checkdirty(int fs, struct bootblock *boo
 	 * If we don't understand the FAT, then the file system must be
 	 * assumed to be unclean.
 	 */
-	if (buffer[0] != boot->Media || buffer[1] != 0xff)
+	if (buffer[0] != boot->bpbMedia || buffer[1] != 0xff)
 		goto err;
 	if (boot->ClustMask == CLUST16_MASK) {
 		if ((buffer[2] & 0xf8) != 0xf8 || (buffer[3] & 0x3f) != 0x3f)
@@ -135,7 +128,7 @@ err:
  * Check a cluster number for valid value
  */
 static int
-checkclnum(struct bootblock *boot, int fat, cl_t cl, cl_t *next)
+checkclnum(struct bootblock *boot, u_int fat, cl_t cl, cl_t *next)
 {
 	if (*next >= (CLUST_RSRVD&boot->ClustMask))
 		*next |= ~boot->ClustMask;
@@ -166,26 +159,26 @@ checkclnum(struct bootblock *boot, int f
  * Read a FAT from disk. Returns 1 if successful, 0 otherwise.
  */
 static int
-_readfat(int fs, struct bootblock *boot, int no, u_char **buffer)
+_readfat(int fs, struct bootblock *boot, u_int no, u_char **buffer)
 {
 	off_t off;
 
-	*buffer = malloc(boot->FATsecs * boot->BytesPerSec);
+	*buffer = malloc(boot->FATsecs * boot->bpbBytesPerSec);
 	if (*buffer == NULL) {
 		perror("No space for FAT");
 		return 0;
 	}
 
-	off = boot->ResSectors + no * boot->FATsecs;
-	off *= boot->BytesPerSec;
+	off = boot->bpbResSectors + no * boot->FATsecs;
+	off *= boot->bpbBytesPerSec;
 
 	if (lseek(fs, off, SEEK_SET) != off) {
 		perror("Unable to read FAT");
 		goto err;
 	}
 
-	if (read(fs, *buffer, boot->FATsecs * boot->BytesPerSec)
-	    != boot->FATsecs * boot->BytesPerSec) {
+	if ((size_t)read(fs, *buffer, boot->FATsecs * boot->bpbBytesPerSec)
+	    != boot->FATsecs * boot->bpbBytesPerSec) {
 		perror("Unable to read FAT");
 		goto err;
 	}
@@ -201,26 +194,28 @@ _readfat(int fs, struct bootblock *boot,
  * Read a FAT and decode it into internal format
  */
 int
-readfat(int fs, struct bootblock *boot, int no, struct fatEntry **fp)
+readfat(int fs, struct bootblock *boot, u_int no, struct fatEntry **fp)
 {
 	struct fatEntry *fat;
 	u_char *buffer, *p;
 	cl_t cl;
 	int ret = FSOK;
+	size_t len;
 
 	boot->NumFree = boot->NumBad = 0;
 
 	if (!_readfat(fs, boot, no, &buffer))
 		return FSFATAL;
 		
-	fat = calloc(boot->NumClusters, sizeof(struct fatEntry));
+	fat = malloc(len = boot->NumClusters * sizeof(struct fatEntry));
 	if (fat == NULL) {
 		perror("No space for FAT");
 		free(buffer);
 		return FSFATAL;
 	}
+	(void)memset(fat, 0, len);
 
-	if (buffer[0] != boot->Media
+	if (buffer[0] != boot->bpbMedia
 	    || buffer[1] != 0xff || buffer[2] != 0xff
 	    || (boot->ClustMask == CLUST16_MASK && buffer[3] != 0xff)
 	    || (boot->ClustMask == CLUST32_MASK
@@ -234,7 +229,7 @@ readfat(int fs, struct bootblock *boot, 
 		 * file system is dirty if it doesn't reboot cleanly.
 		 * Check this special condition before errorring out.
 		 */
-		if (buffer[0] == boot->Media && buffer[1] == 0xff
+		if (buffer[0] == boot->bpbMedia && buffer[1] == 0xff
 		    && buffer[2] == 0xff
 		    && ((boot->ClustMask == CLUST16_MASK && buffer[3] == 0x7f)
 			|| (boot->ClustMask == CLUST32_MASK
@@ -311,7 +306,11 @@ readfat(int fs, struct bootblock *boot, 
 	}
 
 	free(buffer);
-	*fp = fat;
+	if (ret & FSFATAL) {
+		free(fat);
+		*fp = NULL;
+	} else
+		*fp = fat;
 	return ret;
 }
 
@@ -331,7 +330,7 @@ rsrvdcltype(cl_t cl)
 }
 
 static int
-clustdiffer(cl_t cl, cl_t *cp1, cl_t *cp2, int fatnum)
+clustdiffer(cl_t cl, cl_t *cp1, cl_t *cp2, u_int fatnum)
 {
 	if (*cp1 == CLUST_FREE || *cp1 >= CLUST_RSRVD) {
 		if (*cp2 == CLUST_FREE || *cp2 >= CLUST_RSRVD) {
@@ -346,13 +345,13 @@ clustdiffer(cl_t cl, cl_t *cp1, cl_t *cp
 				}
 				return FSFATAL;
 			}
-			pwarn("Cluster %u is marked %s in FAT 0, %s in FAT %d\n",
+			pwarn("Cluster %u is marked %s in FAT 0, %s in FAT %u\n",
 			      cl, rsrvdcltype(*cp1), rsrvdcltype(*cp2), fatnum);
 			if (ask(0, "Use FAT 0's entry")) {
 				*cp2 = *cp1;
 				return FSFATMOD;
 			}
-			if (ask(0, "Use FAT %d's entry", fatnum)) {
+			if (ask(0, "Use FAT %u's entry", fatnum)) {
 				*cp1 = *cp2;
 				return FSFATMOD;
 			}
@@ -360,7 +359,7 @@ clustdiffer(cl_t cl, cl_t *cp1, cl_t *cp
 		}
 		pwarn("Cluster %u is marked %s in FAT 0, but continues with cluster %u in FAT %d\n",
 		      cl, rsrvdcltype(*cp1), *cp2, fatnum);
-		if (ask(0, "Use continuation from FAT %d", fatnum)) {
+		if (ask(0, "Use continuation from FAT %u", fatnum)) {
 			*cp1 = *cp2;
 			return FSFATMOD;
 		}
@@ -371,7 +370,7 @@ clustdiffer(cl_t cl, cl_t *cp1, cl_t *cp
 		return FSFATAL;
 	}
 	if (*cp2 == CLUST_FREE || *cp2 >= CLUST_RSRVD) {
-		pwarn("Cluster %u continues with cluster %u in FAT 0, but is marked %s in FAT %d\n",
+		pwarn("Cluster %u continues with cluster %u in FAT 0, but is marked %s in FAT %u\n",
 		      cl, *cp1, rsrvdcltype(*cp2), fatnum);
 		if (ask(0, "Use continuation from FAT 0")) {
 			*cp2 = *cp1;
@@ -383,13 +382,13 @@ clustdiffer(cl_t cl, cl_t *cp1, cl_t *cp
 		}
 		return FSERROR;
 	}
-	pwarn("Cluster %u continues with cluster %u in FAT 0, but with cluster %u in FAT %d\n",
+	pwarn("Cluster %u continues with cluster %u in FAT 0, but with cluster %u in FAT %u\n",
 	      cl, *cp1, *cp2, fatnum);
 	if (ask(0, "Use continuation from FAT 0")) {
 		*cp2 = *cp1;
 		return FSFATMOD;
 	}
-	if (ask(0, "Use continuation from FAT %d", fatnum)) {
+	if (ask(0, "Use continuation from FAT %u", fatnum)) {
 		*cp1 = *cp2;
 		return FSFATMOD;
 	}
@@ -401,8 +400,8 @@ clustdiffer(cl_t cl, cl_t *cp1, cl_t *cp
  * into the first one.
  */
 int
-comparefat(struct bootblock *boot, struct fatEntry *first, 
-    struct fatEntry *second, int fatnum)
+comparefat(struct bootblock *boot, struct fatEntry *first,
+    struct fatEntry *second, u_int fatnum)
 {
 	cl_t cl;
 	int ret = FSOK;
@@ -542,12 +541,12 @@ writefat(int fs, struct bootblock *boot,
 {
 	u_char *buffer, *p;
 	cl_t cl;
-	int i;
-	u_int32_t fatsz;
+	u_int i;
+	size_t fatsz;
 	off_t off;
 	int ret = FSOK;
 
-	buffer = malloc(fatsz = boot->FATsecs * boot->BytesPerSec);
+	buffer = malloc(fatsz = boot->FATsecs * boot->bpbBytesPerSec);
 	if (buffer == NULL) {
 		perror("No space for FAT");
 		return FSFATAL;
@@ -556,7 +555,7 @@ writefat(int fs, struct bootblock *boot,
 	boot->NumFree = 0;
 	p = buffer;
 	if (correct_fat) {
-		*p++ = (u_char)boot->Media;
+		*p++ = (u_char)boot->bpbMedia;
 		*p++ = 0xff;
 		*p++ = 0xff;
 		switch (boot->ClustMask) {
@@ -629,11 +628,11 @@ writefat(int fs, struct bootblock *boot,
 			break;
 		}
 	}
-	for (i = 0; i < boot->FATs; i++) {
-		off = boot->ResSectors + i * boot->FATsecs;
-		off *= boot->BytesPerSec;
+	for (i = 0; i < boot->bpbFATs; i++) {
+		off = boot->bpbResSectors + i * boot->FATsecs;
+		off *= boot->bpbBytesPerSec;
 		if (lseek(fs, off, SEEK_SET) != off
-		    || write(fs, buffer, fatsz) != fatsz) {
+		    || (size_t)write(fs, buffer, fatsz) != fatsz) {
 			perror("Unable to write FAT");
 			ret = FSFATAL; /* Return immediately?		XXX */
 		}
@@ -673,7 +672,7 @@ checklost(int dosfs, struct bootblock *b
 	}
 	finishlf();
 

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-user mailing list