aboutsummaryrefslogtreecommitdiff
path: root/sbin/fsck_msdosfs
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2019-04-04 23:16:36 +0000
committerXin LI <delphij@FreeBSD.org>2019-04-04 23:16:36 +0000
commit2bf0ee64f96f0206d292d9b2e39d547f741011eb (patch)
tree3c6ea3bc454e336ead47aeb9eea6cb5f1063a91b /sbin/fsck_msdosfs
parent6a2d6673e6e5856a8f2bce1f11db6b2ca8e1c27e (diff)
Notes
Diffstat (limited to 'sbin/fsck_msdosfs')
-rw-r--r--sbin/fsck_msdosfs/fat.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/sbin/fsck_msdosfs/fat.c b/sbin/fsck_msdosfs/fat.c
index 8a548379b405..7ea027443d01 100644
--- a/sbin/fsck_msdosfs/fat.c
+++ b/sbin/fsck_msdosfs/fat.c
@@ -705,6 +705,20 @@ checklost(int dosfs, struct bootblock *boot, struct fatEntry *fat)
ret = 1;
}
}
+ if (boot->FSNext != 0xffffffffU &&
+ (boot->FSNext >= boot->NumClusters ||
+ (boot->NumFree && fat[boot->FSNext].next != CLUST_FREE))) {
+ pwarn("Next free cluster in FSInfo block (%u) %s\n",
+ boot->FSNext,
+ (boot->FSNext >= boot->NumClusters) ? "invalid" : "not free");
+ if (ask(1, "fix"))
+ for (head = CLUST_FIRST; head < boot->NumClusters; head++)
+ if (fat[head].next == CLUST_FREE) {
+ boot->FSNext = head;
+ ret = 1;
+ break;
+ }
+ }
if (ret)
mod |= writefsinfo(dosfs, boot);
}