]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
fsck_msdosfs: truncate directory entry when the head pointer is invalid.
authorXin LI <delphij@FreeBSD.org>
Thu, 4 Nov 2021 05:09:32 +0000 (22:09 -0700)
committerXin LI <delphij@FreeBSD.org>
Thu, 4 Nov 2021 05:09:32 +0000 (22:09 -0700)
commit890cae197737b463e56d1cc5a3f61f84cb49c807
tree2d1d0b79692faa99eef2f8dab2aaec102ccf32f3
parent15bd9fa3bea794054b4a5bd2f4bb71b0ba3aa3ba
fsck_msdosfs: truncate directory entry when the head pointer is invalid.

As far as we know, there is no FAT implementation that supported hard
links, and our msdosfs driver assumed one cluster chain is only
referenced by one directory entry and clears it out when the file is
deleted.  On the other hand, the current code would proceed with
checkchain() when the directory entry's head cluster is a valid numbered
cluster without checking if it was a valid head node of a cluster chain.

So if the cluster do not being a chain (e.g. CLUST_FREE, CLUST_BAD),
or was already referenced by another directory entry, this would
trigger an assertion in check_chain() at a later time.

Fix this by giving the user an option to truncate the directory entry
when the head cluster is an invalid cluster, an visited head node,
or not a head node.

Reported by: NetApp (kevans@)
Reviewed by: kevans, emaste (no objection)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D32699
sbin/fsck_msdosfs/dir.c