Skip to content

fs: Report corrupted exFAT as not clean instead of failing - #1

Closed
davidvornholt wants to merge 1 commit into
masterfrom
exfat-check-exit-code-4
Closed

davidvornholt wants to merge 1 commit into
masterfrom
exfat-check-exit-code-4

Conversation

@davidvornholt

Copy link
Copy Markdown
Owner

Hi! bd_fs_exfat_check fails with an error on a corrupted exFAT file system instead of returning FALSE. fsck.exfat from exfatprogs exits with 4 (FSCK_EXIT_ERRORS_LEFT) whenever it finds errors it didn't fix, which with -n means any error, but the check only cleared the error for exit code 1. udisks passes that error on, so Filesystem.Check fails with "Error checking filesystem" instead of returning false. The ext check already treats exit code 4 this way.

The new test zeroes the checksum sector of the main boot region, then expects the check to return FALSE, the repair to succeed and a second check to return TRUE. Without the fix it fails with "Process reported exit code 4".

I ran ExfatTestCheck and ExfatTestRepair with exfatprogs 1.4.4 on plain image files instead of LIO devices, because I can't run the suite as root here. While doing that I noticed that exfatprogs 1.4.4 prints its version to stderr, so _get_exfatprogs_version in exfat_test.py doesn't find it. I worked around that locally and left it out of this PR.

I used Claude Code (Claude Opus 5.5) to investigate, write and test this change and this description, and reviewed both myself.

fsck.exfat from exfatprogs exits with 4 when it finds errors it didn't
fix, which is always the case with "-n". bd_fs_exfat_check only cleared
the error for exit code 1, so checking a corrupted exFAT file system
failed with an error instead of returning FALSE. The ext check already
handles exit code 4 the same way.

Assisted-by: Claude Code (Claude Opus 5.5)
@davidvornholt

Copy link
Copy Markdown
Owner Author

Review and fix

Review Reviewed Reviewers Findings Outcome
1 ced1904d..6f8168e7 Behavior, premise (GPT-6 Astra, high) 0 block, 1 defer, 0 ask No blockers; no code changes
2 Fix commits — — Skipped: no fix commits

Gate: libblockdev builds with nix, and ExfatTestCheck, ExfatTestRepair and ExfatTestMkfs pass on plain image files (LIO helpers monkeypatched, exfatprogs version helper stubbed because of storaged-project#1225). Without the fix, test_exfat_check_corrupted fails with "Process reported exit code 4". Total time: 3 minutes.

Finding What goes wrong Reported by Label Resolution
src/plugins/fs/exfat.c:215 exfatprogs 1.3.2 turns a read error in the root directory into exit code 4, so with that version the check now returns FALSE without an error instead of failing. exfatprogs 1.4.4 exits with 8 for the same injected read error, which still fails. Behavior defer Not fixed: the cause is in older exfatprogs, and "not clean" is a reasonable answer for a device that can't be read. Mentioned in the upstream PR description.

The premise reviewer found upstream issue storaged-project#1225 for the version-helper problem; the upstream PR description links it.

Remaining risk: the change wasn't run in the upstream suite as root on LIO devices. Upstream CI covers that once the PR is opened there.

@davidvornholt

Copy link
Copy Markdown
Owner Author

Sent upstream as storaged-project#1226.

@davidvornholt
davidvornholt deleted the exfat-check-exit-code-4 branch November 16, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant