Repository navigation
Fix incomplete FAT32 initialization leaving stale allocations on Windows - #37
Merged
Sundownersport merged 1 commit intoOct 27, 2026
Conversation
Member
|
Oooooo this might be the solution to a long standing bug! I’ll take a look thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Freshly formatting a previously used SD card can leave tens of GB marked occupied because the Windows FAT32 formatter initializes only the first 16 sectors of each FAT. On a 256 GB card, a fresh spruceOS installation showed about 33.7 GiB used for approximately 3.5 GiB of files; CHKDSK reclaimed 31,037,760 KiB of orphaned allocations.
Preserve the media descriptor, reserved end-of-chain marker and root-directory allocation. Use the same writer in production and regression tests, and propagate failed or short writes. Add Linux/Windows CI that tests this writer without accessing a physical disk.
Evidence
After: both regression tests pass, including large prefilled tables, the old cutoff, chunk/tail boundaries, reserved entries, surrounding-data preservation, alignment, and write failures in either FAT.
cargo +1.99.1 test --no-default-features. The existing manifest requires regenerating the upstream lockfile locally; that dependency-only change is excluded.windows = 0.58. A full Windows application cross-check was blocked by the unavailable MinGW C compiler.Merge Danger
Door: two-way for the code change. Formatting remains an inherently destructive operation; this patch does not repair already-formatted cards.
Blast Radius: Windows custom FAT32 formatting. Both FATs are fully initialized before the root directory is written; writes stop on the first error.