diff options
author | pfg <pfg@FreeBSD.org> | 2014-07-17 02:33:40 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2014-07-17 02:33:40 +0000 |
commit | 4643efbd28426df43c1d3040e4eaab0e1d8b52aa (patch) | |
tree | 9921973a7818c2be4def4db4ea14b5b8d3bfc7b2 /sbin | |
parent | 30eedb40f8116d0b9e1474448737253ee214d44a (diff) | |
download | FreeBSD-src-4643efbd28426df43c1d3040e4eaab0e1d8b52aa.zip FreeBSD-src-4643efbd28426df43c1d3040e4eaab0e1d8b52aa.tar.gz |
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)
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fsck_msdosfs/check.c | 2 | ||||
-rw-r--r-- | sbin/fsck_msdosfs/ext.h | 6 | ||||
-rw-r--r-- | sbin/fsck_msdosfs/fat.c | 11 |
3 files changed, 10 insertions, 9 deletions
diff --git a/sbin/fsck_msdosfs/check.c b/sbin/fsck_msdosfs/check.c index 1fb005d..083389e 100644 --- a/sbin/fsck_msdosfs/check.c +++ b/sbin/fsck_msdosfs/check.c @@ -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) diff --git a/sbin/fsck_msdosfs/ext.h b/sbin/fsck_msdosfs/ext.h index 681cde9..df0d324 100644 --- a/sbin/fsck_msdosfs/ext.h +++ b/sbin/fsck_msdosfs/ext.h @@ -26,7 +26,7 @@ */ #ifndef EXT_H -#define EXT_H +#define EXT_H #include <sys/types.h> @@ -71,8 +71,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 diff --git a/sbin/fsck_msdosfs/fat.c b/sbin/fsck_msdosfs/fat.c index d2d1444..8db861a 100644 --- a/sbin/fsck_msdosfs/fat.c +++ b/sbin/fsck_msdosfs/fat.c @@ -242,7 +242,7 @@ readfat(int fs, struct bootblock *boot, u_int no, struct fatEntry **fp) 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", @@ -262,7 +262,7 @@ readfat(int fs, struct bootblock *boot, u_int no, struct fatEntry **fp) break; } - + if (ask(1, "Correct")) ret |= FSFIXFAT; } @@ -653,7 +653,7 @@ checklost(int dosfs, struct bootblock *boot, struct fatEntry *fat) 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 @@ -677,8 +677,9 @@ checklost(int dosfs, struct bootblock *boot, struct fatEntry *fat) 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; |