diff options
| author | Xin LI <delphij@FreeBSD.org> | 2019-04-04 23:16:36 +0000 |
|---|---|---|
| committer | Xin LI <delphij@FreeBSD.org> | 2019-04-04 23:16:36 +0000 |
| commit | 2bf0ee64f96f0206d292d9b2e39d547f741011eb (patch) | |
| tree | 3c6ea3bc454e336ead47aeb9eea6cb5f1063a91b /sbin/fsck_msdosfs | |
| parent | 6a2d6673e6e5856a8f2bce1f11db6b2ca8e1c27e (diff) | |
Notes
Diffstat (limited to 'sbin/fsck_msdosfs')
| -rw-r--r-- | sbin/fsck_msdosfs/fat.c | 14 |
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); } |
