Hi,
ran into this problem that NetBSD fixed a few months ago, which
means that this diff is a "NetBSD merge":
Our newfs_msdos creates an invalid FAT32 file system. The "first
free cluster" of FSinfo points to cluster #2, which is used by the
root directory.
Next to that, fsck_msdos is a bit too strict about handling the
valid 0xFFFFFFFF value for "next free cluster" and "free clusters"
of FSinfo. It just means it is not initialized, which is per se no
error that would have to be fixed.
Tobias
Index: sbin/fsck_msdos/fat.c
===================================================================
RCS file: /cvs/src/sbin/fsck_msdos/fat.c,v
retrieving revision 1.22
diff -u -p -r1.22 fat.c
--- sbin/fsck_msdos/fat.c 14 Jun 2014 19:32:25 -0000 1.22
+++ sbin/fsck_msdos/fat.c 16 Jun 2014 16:46:13 -0000
@@ -537,15 +537,17 @@ checklost(int dosfs, struct bootblock *b
if (boot->FSInfo) {
ret = 0;
- if (boot->FSFree != boot->NumFree) {
- pwarn("Free space in FSInfo block (%d) not correct
(%d)\n",
+ if (boot->FSFree != 0xffffffff &&
+ 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;
ret = 1;
}
}
- if (boot->NumFree && (boot->FSNext >= boot->NumClusters ||
+ if (boot->FSNext != 0xffffffff &&
+ boot->NumFree && (boot->FSNext >= boot->NumClusters ||
fat[boot->FSNext].next != CLUST_FREE)) {
pwarn("Next free cluster in FSInfo block (%u) not
free\n",
boot->FSNext);
Index: sbin/newfs_msdos/newfs_msdos.c
===================================================================
RCS file: /cvs/src/sbin/newfs_msdos/newfs_msdos.c,v
retrieving revision 1.22
diff -u -p -r1.22 newfs_msdos.c
--- sbin/newfs_msdos/newfs_msdos.c 22 Nov 2013 04:14:01 -0000 1.22
+++ sbin/newfs_msdos/newfs_msdos.c 16 Jun 2014 16:46:14 -0000
@@ -626,7 +626,7 @@ main(int argc, char *argv[])
mk4(img, 0x41615252);
mk4(img + bpb.bps - 28, 0x61417272);
mk4(img + bpb.bps - 24, 0xffffffff);
- mk4(img + bpb.bps - 20, bpb.rdcl);
+ mk4(img + bpb.bps - 20, 0xffffffff);
mk2(img + bpb.bps - 2, DOSMAGIC);
} else if (lsn >= bpb.res && lsn < dir &&
!((lsn - bpb.res) %