While harmless it seesm pointless to create a filesystem that generates
warnings when fsck'd.
So check for -1 (an allowed value) in FSFree and FSNext fields, and
set FSNext to -1 in newfs_msdos, rather than setting it to a
value sure to be not a free cluster.
Anybody know of reasons to not do this?
.... Ken
Index: fsck_msdos/fat.c
===================================================================
RCS file: /cvs/src/sbin/fsck_msdos/fat.c,v
retrieving revision 1.18
diff -u -p -r1.18 fat.c
--- fsck_msdos/fat.c 27 Oct 2009 23:59:33 -0000 1.18
+++ fsck_msdos/fat.c 21 Oct 2013 09:53:56 -0000
@@ -527,7 +527,7 @@ checklost(int dosfs, struct bootblock *b
if (boot->FSInfo) {
ret = 0;
- if (boot->FSFree != boot->NumFree) {
+ if (boot->FSFree != -1 && boot->FSFree != boot->NumFree) {
pwarn("Free space in FSInfo block (%d) not correct
(%d)\n",
boot->FSFree, boot->NumFree);
if (ask(1, "fix")) {
@@ -535,7 +535,8 @@ checklost(int dosfs, struct bootblock *b
ret = 1;
}
}
- if (boot->NumFree && fat[boot->FSNext].next != CLUST_FREE) {
+ if (boot->NumFree && boot->FSNext != -1 &&
+ fat[boot->FSNext].next != CLUST_FREE) {
pwarn("Next free cluster in FSInfo block (%u) not
free\n",
boot->FSNext);
if (ask(1, "fix"))
Index: newfs_msdos/newfs_msdos.c
===================================================================
RCS file: /cvs/src/sbin/newfs_msdos/newfs_msdos.c,v
retrieving revision 1.20
diff -u -p -r1.20 newfs_msdos.c
--- newfs_msdos/newfs_msdos.c 18 May 2010 04:41:14 -0000 1.20
+++ newfs_msdos/newfs_msdos.c 21 Oct 2013 09:48:48 -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) %