#1122126 fsck: fat recover logic can't handle recovering from power loss during write to FAT

Package:
dosfstools
Source:
dosfstools
Description:
utilities for making and checking MS-DOS FAT filesystems
Submitter:
Joshua
Date:
2025-12-07 17:35:03 UTC
Severity:
normal
Tags:
#1122126#5
Date:
2025-12-07 17:33:51 UTC
From:
To:
Dear Maintainer,

The primary case of dosfsck is repairing damage due to power loss. This means
the most important checks are these:
* Check for damaged FAT due to power loss
* Check for lost clusters (possibly file not saved to directory)
* Check for extra clusters (probably file grew)

However, the damaged FAT check is completely broken in dosfsck. I haven't
been able to tell exactly what the problem is, but the sector-by-sector
comparitor is definitely not present. It's trying some sense over the whole
FAT that doesn't actually work.

This is a unit test for a more powerful algorithm that weighs the FAT
sectors, but it definitely displays the problem. dosfsck guesses wrong and
thinks the first FAT is correct without prompting. In any case, dosfsck
completely can't handle the situation and even if it got to the prompt case,
there's just not enough information to proceed.

https://github.com/joshudson/dossuperfloppy/raw/refs/heads/master/scantests/basefat16.img.bz2

This is a full disk image, the filesystem starts at sector 7.