svn commit: r268785 - stable/9/sbin/fsck_msdosfs

Pedro F. Giffuni pfg at FreeBSD.org
Thu Jul 17 02:43:55 UTC 2014


Author: pfg
Date: Thu Jul 17 02:43:53 2014
New Revision: 268785
URL: http://svnweb.freebsd.org/changeset/base/268785

Log:
  MFC	r268628, r268631, r268635:
  
  Convert *rootDir from external to static.
  
  fsck_msdosfs: be a bit more permissive.
  
  The free space value in the FSInfo block is merely unitialized when it is
  0xffffffff. This fixes a bug found in NetBSD.
  
  Respect FSFIXFAT.
  
  Fix some whitespace issues while here.
  
  Obtained from:	NetBSD (CVS rev. 1.22, rev. 1.9), OpenBSD (misc)

Modified:
  stable/9/sbin/fsck_msdosfs/check.c
  stable/9/sbin/fsck_msdosfs/dir.c
  stable/9/sbin/fsck_msdosfs/ext.h
  stable/9/sbin/fsck_msdosfs/fat.c
Directory Properties:
  stable/9/sbin/fsck_msdosfs/   (props changed)

Modified: stable/9/sbin/fsck_msdosfs/check.c
==============================================================================
--- stable/9/sbin/fsck_msdosfs/check.c	Thu Jul 17 02:33:40 2014	(r268784)
+++ stable/9/sbin/fsck_msdosfs/check.c	Thu Jul 17 02:43:53 2014	(r268785)
@@ -142,7 +142,7 @@ checkfilesys(const char *fname)
 		goto out;
 
 	/* now write the FATs */
-	if (mod & FSFATMOD) {
+	if (mod & (FSFATMOD|FSFIXFAT)) {
 		if (ask(1, "Update FATs")) {
 			mod |= writefat(dosfs, &boot, fat, mod & FSFIXFAT);
 			if (mod & FSFATAL)

Modified: stable/9/sbin/fsck_msdosfs/dir.c
==============================================================================
--- stable/9/sbin/fsck_msdosfs/dir.c	Thu Jul 17 02:33:40 2014	(r268784)
+++ stable/9/sbin/fsck_msdosfs/dir.c	Thu Jul 17 02:43:53 2014	(r268785)
@@ -206,7 +206,7 @@ static char longName[DOSLONGNAMELEN] = "
 static u_char *buffer = NULL;
 static u_char *delbuf = NULL;
 
-struct dosDirEntry *rootDir;
+static struct dosDirEntry *rootDir;
 static struct dosDirEntry *lostDir;
 
 /*

Modified: stable/9/sbin/fsck_msdosfs/ext.h
==============================================================================
--- stable/9/sbin/fsck_msdosfs/ext.h	Thu Jul 17 02:33:40 2014	(r268784)
+++ stable/9/sbin/fsck_msdosfs/ext.h	Thu Jul 17 02:43:53 2014	(r268785)
@@ -26,7 +26,7 @@
  */
 
 #ifndef EXT_H
-#define EXT_H
+#define	EXT_H
 
 #include <sys/types.h>
 
@@ -43,8 +43,6 @@ extern int preen;	/* we are preening */
 extern int rdonly;	/* device is opened read only (supersedes above) */
 extern int skipclean;	/* skip clean file systems if preening */
 
-extern struct dosDirEntry *rootDir;
-
 /*
  * function declarations
  */
@@ -71,8 +69,8 @@ int checkfilesys(const char *);
 #define	FSFATMOD	4		/* The FAT was modified */
 #define	FSERROR		8		/* Some unrecovered error remains */
 #define	FSFATAL		16		/* Some unrecoverable error occurred */
-#define FSDIRTY		32		/* File system is dirty */
-#define FSFIXFAT	64		/* Fix file system FAT */
+#define	FSDIRTY		32		/* File system is dirty */
+#define	FSFIXFAT	64		/* Fix file system FAT */
 
 /*
  * read a boot block in a machine independent fashion and translate

Modified: stable/9/sbin/fsck_msdosfs/fat.c
==============================================================================
--- stable/9/sbin/fsck_msdosfs/fat.c	Thu Jul 17 02:33:40 2014	(r268784)
+++ stable/9/sbin/fsck_msdosfs/fat.c	Thu Jul 17 02:43:53 2014	(r268785)
@@ -240,7 +240,7 @@ readfat(int fs, struct bootblock *boot, 
 			ret |= FSDIRTY;
 		else {
 			/* just some odd byte sequence in FAT */
-				
+
 			switch (boot->ClustMask) {
 			case CLUST32_MASK:
 				pwarn("%s (%02x%02x%02x%02x%02x%02x%02x%02x)\n",
@@ -260,7 +260,7 @@ readfat(int fs, struct bootblock *boot, 
 				break;
 			}
 
-	
+
 			if (ask(1, "Correct"))
 				ret |= FSFIXFAT;
 		}
@@ -651,7 +651,7 @@ checklost(int dosfs, struct bootblock *b
 	cl_t head;
 	int mod = FSOK;
 	int ret;
-	
+
 	for (head = CLUST_FIRST; head < boot->NumClusters; head++) {
 		/* find next untravelled chain */
 		if (fat[head].head != head
@@ -675,8 +675,9 @@ checklost(int dosfs, struct bootblock *b
 
 	if (boot->bpbFSInfo) {
 		ret = 0;
-		if (boot->FSFree != boot->NumFree) {
-			pwarn("Free space in FSInfo block (%d) not correct (%d)\n",
+		if (boot->FSFree != 0xffffffffU &&
+		    boot->FSFree != boot->NumFree) {
+			pwarn("Free space in FSInfo block (%u) not correct (%u)\n",
 			      boot->FSFree, boot->NumFree);
 			if (ask(1, "Fix")) {
 				boot->FSFree = boot->NumFree;


More information about the svn-src-all mailing list