Restore the ability of checking and fixing next free

cluster in FSINFO that was lost in r203872.

Obtained from:	NetBSD
MFC after:	2 weeks
This commit is contained in:
Xin LI 2019-04-04 23:16:36 +00:00
parent 6a2d6673e6
commit 2bf0ee64f9

View File

@ -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);
}