exfat icon indicating copy to clipboard operation
exfat copied to clipboard

exfatfsck doesn't report error on shrunk device

Open dxdxdt opened this issue 7 years ago • 4 comments

I was curious as to what happens if you accidentally shrink file systems. So far, I've found that the developers of btrfs, exfat, and vfat didn't think this through.

truncate -s 1G a
mkfs.exfat a
fsck.exfat a

truncate -s 1073733632 a
fsck.exfat a

output

exfatfsck 1.2.8
WARN: file system in sectors is larger than device: 2097152 * 512 > 1073733632.
Checking file system on a.
File system version           1.0
Sector size                 512 bytes
Cluster size                 32 KB
Volume size                   1 GB
Used space                  288 KB
Available space               1 GB
Totally 0 directories and 0 files.
File system checking finished. No errors found.

(exit code 0)

I assume the "WARN: " line is from mount.c:293. Shouldn't it be an error?

dxdxdt avatar Sep 25 '18 11:09 dxdxdt

Note that fsck.extN/xfs/cramfs reports this case as error.

dxdxdt avatar Sep 25 '18 11:09 dxdxdt

It used to be an error, but several users with buggy cameras were unhappy with that: https://github.com/relan/exfat/commit/fcba4d92e7a78feb263f8ee0374ec5277341cdd3

relan avatar Sep 25 '18 11:09 relan

It used to be an error, but several users with buggy cameras were unhappy with that: fcba4d9

yes, I saw the comment. But fsck'ing is a different thing? Using shrunk fs is dangerous. It's obvious that using the fs will fail at some point. Isn't that why people run fsck? If main users of this software use exfat for broken cameras and run fsck for other problems than this, fair enough. I admit that the case is pretty rare but can happen.

Your project, your decision.

dxdxdt avatar Sep 25 '18 11:09 dxdxdt

fsck should probably mark clusters beyond the end as bad. This way, the warning can be turned into an error again.

relan avatar Sep 25 '18 12:09 relan