From 10d477ac7849eee1ce6ac82b73d6f02ff6db701c Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 9 May 2023 13:25:09 +0200 Subject: [PATCH] fsck: use BLKID_SUBLKS_BADCSUM We need to be a little bit more promiscuou in fsck to see also inconsistent superblocks. It would be possible to do not use libmount to ask for filesystem type and ask directly libblkid, but libmount is also used to parse fstab and search in the file and in this case it caches FS tags. It seems better to continue with libmount to reduce overhead and keep the code simple. Addresses: https://github.com/util-linux/util-linux/issues/2214 Signed-off-by: Karel Zak --- disk-utils/fsck.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c index 94e2d7c3e..1b11e8261 100644 --- a/disk-utils/fsck.c +++ b/disk-utils/fsck.c @@ -1630,6 +1630,16 @@ int main(int argc, char *argv[]) mnt_init_debug(0); /* init libmount debug mask */ mntcache = mnt_new_cache(); /* no fatal error if failed */ + if (mntcache) + /* Force libblkid to accept also filesystems with bad + * checksums. This feature is helpful for "fsck /dev/foo," but + * if it evaluates LABEL/UUIDs from fstab, then libmount may + * use cached data from udevd and udev accepts only properly + * detected filesystems. + */ + mnt_cache_set_sbprobe(mntcache, BLKID_SUBLKS_BADCSUM); + + parse_argv(argc, argv); if (!notitle)