Skip to content

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

Merged
vojtechtrefny merged 1 commit into
storaged-project:masterfrom
davidvornholt:exfat-check-exit-code-4
Nov 14, 2026
Merged

vojtechtrefny merged 1 commit into
storaged-project:masterfrom
davidvornholt:exfat-check-exit-code-4

Conversation

@davidvornholt

@davidvornholt davidvornholt commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

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.

One edge case: exfatprogs 1.3.2 also exits with 4 when reading the root directory fails, so with that version such a read error now comes back as "not clean" instead of as an error. exfatprogs 1.4.4 exits with 8 there, which is still reported as an error.

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 (#1225). 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.

I reviewed this first in my fork, in davidvornholt#1. The code is unchanged since then.

Summary by CodeRabbit

  • Bug Fixes
    • Improved exFAT filesystem check reporting for additional checker outcomes. Checks can now distinguish a filesystem’s reported condition from whether the check command itself ran successfully.
    • Added coverage confirming that a corrupted exFAT filesystem is reported as not clean and that a subsequent check succeeds after repair.

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)
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

bd_fs_exfat_check now clears the reported error for return status 4 as well as status 1. A new test verifies that the check detects a corrupted exFAT boot-region checksum sector, and that repair restores a successful check.

Changes: exFAT Check

Layer / File(s) Summary
Check and repair behavior
src/plugins/fs/exfat.c, tests/fs_tests/exfat_test.py
bd_fs_exfat_check clears the reported error for statuses 1 and 4. The test verifies detection of a corrupted checksum sector, repair, and a successful follow-up check.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: Minimal · up to 6f816

A corrupted exFAT filesystem is now reported as not clean instead of raising an error, which is consistent with the ext check. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main behavioral change: a corrupted exFAT filesystem is now reported as not clean (returns FALSE) instead of an error. The raw summary and objectives confirm the check now clears t…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main behavioral change: a corrupted exFAT filesystem is now reported as not clean (returns FALSE) instead of an error. The raw summary and objectives confirm the check now clears the error for fsck.exfat exit code 4 as well as 1, and a new test covers the corrupted-then-repaired flow. The title is specific and matches the changeset.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ced1904 and 6f8168e.

Files selected for processing: 2

  • src/plugins/fs/exfat.c
  • tests/fs_tests/exfat_test.py

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@vojtechtrefny vojtechtrefny left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thank you.

@vojtechtrefny
vojtechtrefny merged commit 282f3a6 into storaged-project:master Nov 14, 2026
36 of 41 checks passed
@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.

2 participants