Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Apr 2019 23:16:36 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r345894 - head/sbin/fsck_msdosfs
Message-ID:  <201904042316.x34NGabE018481@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904042316.x34NGabE018481>