Author: delphij Date: Thu Apr 4 23:16:36 2019 New Revision: 345894 URL: https://svnweb.freebsd.org/changeset/base/345894
Log: Restore the ability of checking and fixing next free cluster in FSINFO that was lost in r203872. Obtained from: NetBSD MFC after: 2 weeks Modified: head/sbin/fsck_msdosfs/fat.c Modified: head/sbin/fsck_msdosfs/fat.c ============================================================================== --- head/sbin/fsck_msdosfs/fat.c Thu Apr 4 20:34:17 2019 (r345893) +++ head/sbin/fsck_msdosfs/fat.c Thu Apr 4 23:16:36 2019 (r345894) @@ -705,6 +705,20 @@ checklost(int dosfs, struct bootblock *boot, struct fa 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); } _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"