813. file_allocation_table: a proven FAT crate, released on its own
(From calef's rulings on pull requests #1803 and #1806; the title and slug are drafts. On the customer path: milestone 140 (mount a drive this system did not create) needs it for its FAT32 stratum.)
calef's rulings, quoted from the maintainer comments of 2026-10-07 and 2026-10-22 (UTC):
- #1803, fork 2: "take no FAT dependency. nife writes its own FAT12/16/32 crate (about 5,000 lines by the probed crates' sizes), proven with Kani because it parses hostile input from foreign sticks, with rust-fatfs and this probe's round-trip images as its test oracle; and it is built, proven and released on its own, independently of nife." His words: "I'm really questioning taking a dependency on something that isn't updating." and "It seems like something we should build and prove and release on its own independently of nife."
- #1806, scope: "FAT12, FAT16 and FAT32, read and write, with long file names (VFAT), in the first
release; exFAT later, as its own milestone or sibling crate. Proven: hostile images never panic or
read out of bounds, cluster chains cannot loop, written data reads back; oracle rust-fatfs and
fsck_msdoson #1803's images." His word: "Yes". - #1806, name: "
file_allocation_table(crates.io treats it andfile-allocation-tableas one name; free as of today). Permanent once first published." His word: "Yes". - #1806, milestone: "mint a new milestone, "
file_allocation_table: a proven FAT crate, released on its own" (write it, prove it, oracle tests, its own nifeos repository on the shared CI template (milestone 887) at first publication, trusted publishing); milestone 140's FAT32 stratum depends on it and adds the filesystem-contract server. On the customer path." His word: "Yes". - #2580, build or adopt (2026-10-22 19:57 UTC): "build our own full-featured FAT crate, not
adopt
fatfs. It covers FAT12/16/32 read-write, long names, rename, format, FSInfo and the dirty bit, MBR, and a sector interface, with Kani proofs on the parsers, fuzzing and the mutation gate, staged as fat-adopt-or-build.md sets out. Stage 1 is 560's long-name writer in the existing mkfs.fatfsstays the test oracle, outside the base graph." His word: "A".
The stages
Built in this order, by the #2580 ruling. Each lands on its own and leaves the installer working; fat-adopt-or-build.md prices them.
- The long-name writer in the existing
mkfs: milestone 560, built. - The sector interface, boot sector and BPB parse, and FAT type by cluster count, with a per-sector no-panic harness and the reader's first fuzz target. The oracle's dev-dependency pin is ruled here. Built: stage-2-the-reader-begins.md has what landed.
- FAT entry decode, the bounded chain walk, and directory slots read as stored, with the oracle
tests in both directions. Built:
stage-3-the-table-and-the-chain.md
has what landed, the oracle's pin and its
fsckcheck. - Directories: long-name assembly with the checksum checked, and #1803's macOS images read to their recorded hashes. Built: stage-4-directories-and-long-names.md has what landed.
- File read and the MBR. Milestone 140's read-only stratum can start here. Built: stage-5-reading-files-and-the-partition-table.md has what landed.
- Allocation, write, extend, truncate and delete, with FSInfo and the dirty bit, and the round-trip harness. Built in two pull requests: stage-6-allocation-and-write.md has what landed.
- Make and remove directories, rename, and long-name creation with alias numbering. Built: stage-7-directories-and-long-names.md.
- The general format for FAT12, FAT16 and FAT32, folding the
mkfsin, with FAT12 and FAT16 oracle images. Built: stage-8-the-general-format.md. - Timestamps, attributes and the label, then
script/crate-standaloneand the README for release. Attributes, the label and the README landed (stage-9). Timestamps landed (2026-11-01 UTC): a writer supplies aClock,NoClockmeans no time, the crate refuses an unstorable time, and a read takes no clock.
What exists, checked 2026-10-07 (UTC)
crates/file_allocation_tablealready exists: 794 lines, no Kani harnesses, written by milestone 198 (a package manager, and the trivial install that makes a second customer possible) rung 2a. It is amkfsthat lays out one FAT32 EFI system partition holding one 8.3-named file, as pure computation with no I/O.components/src/system_installer.rsis its one caller. It reads nothing. This milestone grows that crate rather than starting a second one, since the ratified name is already its name; the installer's call keeps working throughout. Its module doc says it "cannot open, read, extend, delete or rename anything, and it never will", and points the read half at milestone 140. This milestone retires that sentence. calef has since ruled that the crate is the format and 140 is the server. No scope conflict: themkfsbecomes the crate's format path.- Milestone 560 (a long file name, or riscv64 cannot be installed) is stage 1, built: the
mkfswrites VFAT long-name entries insrc/long_name.rs, with three Kani harnesses insrc/long_name/verification.rson the writer's half of the fourth property below. notes/filesystem-crates-2026-10-07.md(#1803) measured five read-write FAT crates on nife's three targets and built two FAT32 images that macOS formatted and wrote, one bare and one inside an MBR, with every file's hash inexpected.sha256.make-images.shrebuilds them on macOS.crates.ioanswers 404 forfile_allocation_table(checked 2026-10-07).
Reuse: written here, not taken, by calef's ruling on #1803 fork 2. Three reasons, all from that
ruling. It parses hostile input (a stranger's USB stick), and §46 (thin primitives or whole
subsystems) has nife write the crates Kani proves, because a model checker needs code we can
restructure. Proofs are the point. And the main-line candidate, rust-fatfs, has not released since
fatfs 0.3.6 (2023-01-17); that release writes subdirectories fsck_msdos rejects, the fix landed
upstream on 2024-10-23 unreleased, and a release request has been open since 2023 (rafalh/rust-fatfs
#81).
fatfs and embedded-sdmmc were measured against this block on 2026-10-22 (UTC), Kani included,
in 784's FAT appendix. calef's #2580
ruling above settles it: this block builds the full crate, in the stages above.
References and oracles
Read for behavior and test against; copy no code unless its license allows it and the copy is recorded at the copied item with its source, commit and license.
| crate | license | use here |
|---|---|---|
| rust-fatfs (main line), as lamfat 0.4.3 | MIT | the oracle: host tests read what this crate wrote, and this crate reads what it wrote |
| hadris-fat 3.0.0-rc.1 | MIT | a second reader, and the exFAT reference for the later crate |
| embedded-sdmmc 0.10.0 | MIT or Apache-2.0 | a reference for FAT16/32 without allocation. Its project bans AI-generated contributions, so per #1806 fork 8 it gets bug reports only |
| simple-fatfs 0.1.0-alpha.2 | MIT | a no_std reference; alpha, last updated 2025-09-14 |
The specification is Microsoft's "FAT: General Overview of On-Disk Format" (version 1.03), which the existing crate already cites.
The oracle's pin, ruled 2026-10-25 (UTC): lamfat = "=0.4.3" from crates.io is a
[dev-dependencies] line of this crate only, pinned by checksum in Cargo.lock, outside the base
graph. Its fsck condition held; the stage 3 appendix has the run.
Scope
- FAT12, FAT16 and FAT32, read and write: mount, walk directories, read, create, extend, truncate,
delete, rename, make and remove directories, and format (the existing
mkfsfolds in here). - Long file names (VFAT): read and write, with the short-name alias and checksum generated and checked.
- An MBR-partitioned stick and a bare volume, since #1803's images are one of each.
no_std, with no allocation in the parser if that proves feasible. The crate stays sans-I/O, the ruleglobally_unique_identifier_partition_tablekeeps: the caller supplies sectors through a small interface the lane chooses, and the crate never names a device.
Non-goals for the first release:
- exFAT. calef ruled it later, as its own milestone or a sibling crate. hadris-fat is its reference. Milestone 923 (exFAT waits for its patents) holds it until Microsoft's exFAT patents expire.
- A journal or crash-consistency claim. FAT has none. Milestone 140 already says the difference
belongs where a user meets it; this crate's
BUGSsays it too. - The filesystem-contract server. That is milestone 140's FAT32 stratum, which consumes this crate.
What is proven
The table names what is proved; the rest is this milestone's scope, not a step before it. Each row
is a property this crate must prove before it publishes. The harness cell names the Kani harness
that proves it, or says none yet; every named harness carries a falsification patch that makes it
fail at its own assertion. Each patch sits at
crates/file_allocation_table/falsifications/<module.path>.<harness>.patch, as §134 (a harness
carries a machine-replayable falsification record) and script/falsifications require.
| property | harness |
|---|---|
| No panic and no out-of-bounds read on any image: every parse step (boot sector, BPB, FSInfo, FAT entry, directory entry, long-name run, partition table) takes a symbolic sector and returns a value or an error | boot sector and BPB: boot_sector::verification::what_the_parse_accepts_lies_inside_the_volume, the_fat_type_is_the_cluster_counts, the_table_has_an_entry_for_every_cluster, only_a_data_cluster_has_sectors; FAT entry: table::verification::every_entry_lies_inside_the_table, an_entry_decodes_by_its_markers; directory entry: directory::verification::every_slot_parses_as_its_bytes_say, a_directory_reads_only_its_own_sectors; long-name run: long_name_assembly::verification::a_run_is_accepted_only_when_it_is_well_formed; partition table: master_boot_record::verification::every_sector_parses_to_a_sound_table_or_an_error; FSInfo: file_system_information::verification::every_sector_parses_to_hints_inside_the_volume |
| Cluster chains cannot loop: a walk from any start over any FAT contents ends within the volume's cluster count, at an end-of-chain marker or with an error | reader::verification::no_chain_walk_outlasts_the_volume, on volumes of one to eight clusters; file reads: file::verification::a_file_read_stays_inside_its_size_and_its_clusters; partitions: master_boot_record::verification::a_partition_device_reads_only_its_partition |
A table write changes only its entry, allocation takes one free cluster, a release never frees a bad or reserved cluster, a cut keeps exactly the head of the chain, and an FSInfo store changes only its two hints |
table::verification::a_stored_entry_reads_back_and_disturbs_nothing_else, encoding_inverts_decoding; allocation::verification::allocation_takes_one_free_cluster_and_nothing_else, a_release_frees_only_its_own_chain, a_cut_keeps_exactly_the_head_of_the_chain; file_system_information::verification::a_store_changes_only_the_two_hints |
| A format reads back as itself: its boot sector parses to the same type, clusters, table size and data start | format::verification::a_geometry_parses_back_to_itself |
| Write then read round-trips on a small symbolic volume, byte for byte, with the chain as long as the size needs; the directory entry is the oracle tests' | write_cursor::verification::a_partial_sector_write_keeps_the_head_and_zeroes_the_slack, a_write_extends_the_chain_to_the_size_and_stays_inside_it |
| Directory entries and long names are well formed: every short name is legal, every long-name run carries the matching checksum and ordinals, every alias carries its number, and the reader refuses a run that does not | writer: long_name::verification::the_checksum_is_the_specifications_loop, every_long_name_run_is_well_formed, every_alias_is_a_legal_short_name, every_numbered_alias_carries_its_number; directory_writer::verification::the_run_finder_returns_the_first_run_of_free_slots; reader: long_name_assembly::verification::a_run_is_accepted_only_when_it_is_well_formed |
Kani bounds its inputs, so whole-image coverage comes from composing per-sector proofs, with
script/fuzz over whole images as the backstop. The block states that bound rather than claiming
more. Not proven, by design: crash consistency (FAT has none), and the caller's sector interface.
Oracle tests
- Read #1803's two macOS images and check every file against
expected.sha256. - Write a tree (long names, nested directories, a file spanning many clusters, a delete, a rename)
and check it two ways: rust-fatfs reads back the same names and bytes, and
fsck_msdosexits 0. Where CI runs Linux,fsck.fatfrom dosfstools stands in, run as a tool and never linked.tests/the_oracle_agrees.rschecks the other direction. - FAT12 and FAT16 volumes made by
newfs_msdosormkfs.fat, since #1803's images are FAT32 only. No test image is made by this crate.
Parity
The crate is pure logic and its tests run on the host. It builds for
aarch64-unknown-none-softfloat, riscv64imac-unknown-none-elf and x86_64-unknown-none in the
tree's build, so nothing about it can work on one target and not another.
Release, by #1806's rulings
- The name is settled before anything leaves (857's Fork 5 as calef amended it on 2026-10-11 UTC).
script/names file_allocation_tablereports it ratified, crates.io answers 404 for it (or it is already ours), andpartsfoundry/file_allocation_tabledoes not exist yet.script/crate-standalonechecks the first. - In the tree,
script/verifyruns the harnesses, andCargo.tomlsayspublish = false. - The package is version 0.1.0 with its own semver, states its minimum Rust version in
rust-version, and ships its harnesses and falsification patches.cargo package --listshows them. - At first publication, and not before, calef adds it to the lint-checked publish allowlist. The
partsfoundry/file_allocation_tablerepository is created when the crate moves, for the soak (step 5), on the shared CI template (Kani throughkani-github-action, lint, release). Its release workflow refuses to publish unless the proof job is green. - Soak, as its own repository, until the soak's five end conditions in the runbook hold.
- Publish and consume the release by version, by the runbook's publication steps.
Standalone, measured 2026-10-11 (UTC)
script/crate-standalone file_allocation_table found, at base ae6b91e79, a workspace-inherited
manifest, no README or license files, and 14 lines that cite this tree.
script/names reports the name file_allocation_table ratified (checked 2026-10-25).
Measured again on 2026-10-25 (UTC): with --no-kani the manifest, files and all four targets pass,
and only Name: blocks still cite the tree. With Kani, every harness proves and every
falsification patch fails its harness.
Review before release
- The public API speaks the device's vocabulary, not nife's: no nife capability type, spawn handoff or nife error enum in a public signature. A reviewer judges this; no script can.
- The review starts from its package.
Exit
cargo test -p file_allocation_table fails if any piece is missing. It reads both #1803 images to
their recorded hashes, writes the tree above on FAT12, FAT16 and FAT32, and has rust-fatfs and
fsck_msdos (or fsck.fat) accept each. It formats a FAT32 EFI system partition holding
\EFI\BOOT\BOOTRISCV64.EFI, a name that needs long-name entries. script/verify proves the four
properties, script/falsifications reports every harness replayable, and the crate builds for all
three targets. Publication is the last step and not the exit, since it waits on calef. The five soak
criteria of release step 5 hold before it publishes.
The name check of release step 1 passes first, by Fork 5 of milestone 857. Before the move,
script/crate-standalone file_allocation_table exits 0 in nife, and every row of What is proven
names a harness that stock Kani proves in the copy and whose falsification patch makes it fail. No
crate publishes without the proofs milestone 857 (crates released on their own) requires.
Patents
Microsoft's long-name (VFAT) patents have all expired, per Google Patents, checked 2026-10-14 (UTC). Google Patents marks its status an assumption rather than a legal conclusion, and this record is not legal advice.
| patent | title | priority | expired |
|---|---|---|---|
| US 5,579,517 | Common name space for long and short filenames | 1993-04-01 | 2013-11-26 |
| US 5,758,352 | Common name space for long and short filenames | 1993-04-01 | 2013-04-01 |
| US 6,286,013 | A common name space for long and short file names in an operating system | 1993-04-01 | 2013-04-01 |
| US 5,745,902 | Accessing a file using file names having different file name formats | 1992-07-06 | 2015-04-28 |
The first two were the ones asserted against TomTom in 2009 and upheld on reexamination. All four predate 1995, so none can still be in force. FAT12, FAT16 and FAT32 themselves date from 1977 to 1996. The search was for the known Microsoft families, not a freedom-to-operate opinion.
What the crate no longer cites
The crate's source cites nothing of this tree beyond its Name: blocks. This section keeps the
links it carried, by milestone 857's provenance rule.
src/lib.rs, crate doc: why an installer needs a FAT writer wasnotes/installing.md. The read half was milestone 140 (mount a drive this system did not create), and the doc now names the reader and the writer without it. The volume's shape and the reason for each number werenotes/file-allocation-table.md.src/lib.rs,BUGS: the drivers that read the volume back werenotes/file-allocation-table.md, "Who reads it back" (OVMF incargo xtask install-boot, EDK2 on riscv64 incargo xtask stick-boot, and the host test).src/long_name.rs, module doc: the run's padding and how the host's driver checks it werenotes/file-allocation-table.md, "Long names". The padding now sits in the doc itself.src/long_name/verification.rs, module doc:script/verify(nowcargo kani) andnotes/verification.md.src/volume.rs,VolumeLayout::new: the cluster-alignment rounding citednotes/installing.md, section 3 ("FAT32 had to be written, and the alignment is the part that bites"), which tells how ten megabytes landed six sectors early.tests/a_third_party_driver_reads_it.rs, module doc: why the host's driver is the check that counts wasnotes/file-allocation-table.md, "Who reads it back".
Follow-on
- Outstanding. The review package awaits clearance.
BUGS
- Steps 4 and 5 wait on milestone 887 (crate repositories share one CI template),
which owns the shared CI template, the publish allowlist lint and the
nifeoscrates.io team. - The "about 5,000 lines" figure is the probed crates' size, not an estimate of this one.
- One
slot_locationmutant outruns cargo-mutants' 20-second bound.
Index row
nife's own FAT12/16/32 read-write crate with long file names, proven with Kani because a USB stick
is hostile input, checked against rust-fatfs and fsck_msdos, and released on crates.io from its
own nifeos repository. Milestone 140's FAT32 stratum is built on it. exFAT comes later.