roadmap PARTIAL

190. ext4, read and write: a Rust implementation with libext2fs as the host-side oracle

calef's ext4 drives hold the family's borg repositories. They were formatted by Linux with mke2fs defaults, metadata_csum among them, and they will not be reformatted. So nife reads and writes ext4 as Linux wrote it. The requirement is standing and has no deadline.

The goal is a functional ext4 for nife that meets the bar of §46 (thin primitives or whole subsystems; we write everything in between) and this block's done-when. The implementation is the Rust crate rsext4, and there is no alternative. We offer every contribution upstream to rcore-os/tgoskits. partsfoundry/rsext4 carries whatever upstream does not take and is maintained indefinitely: the fork is the shipping source, not a stopgap (2026-11-25 UTC). We test it against libext2fs and Linux, under §136 (a mature foreign implementation earns its place as an oracle, not as a dependency). This is the ext4 row of milestone 140 (mount a drive this system did not create), and leaves 140's order for FAT32 and ext2.

§34 (RedoxFS is the primary filesystem) says why RedoxFS cannot stay. rsext4 replaces RedoxFS once the fork meets the bar, and we ask for the adoption ruling then (2026-11-25 UTC). Milestone 982 (Retire RedoxFS once a launch store proves itself) holds the inventory of what leaves.

Reuse: rsext4 0.9.2 on crates.io (Apache-2.0, no_std with alloc, depending on bitflags and thiserror), developed in rcore-os/tgoskits under fs/rsext4, not in the Starry-OS/rsext4 its manifest names. nife uses partsfoundry/rsext4, 0.9.2 with our fixes on top, which its CHANGES.md lists. e2fsprogs 1.47 and a Linux kernel are the host-side oracles. The other candidates and the reason each lost are in the survey.

Why rsext4

It is the one Rust implementation that writes ext4 with metadata_csum and writes a jbd2 journal, and it has a maintained upstream. Taking it is §46's 2026-10-04 default: a file format is the exposure case, and code other systems have run carries evidence that code written here cannot.

What is measured

Measured 2026-11-14 (UTC) on a Linux host with e2fsprogs 1.47, against rsext4 0.9.2 through its public API:

Not yet tested, beyond the follow-on's list: concurrent callers, orphan_file and performance.

The bar, and where rsext4 stands

§46's four conditions, as amended:

condition rsext4 as nife takes it, from partsfoundry/rsext4 what closes it
a safety argument on every use of unsafe the casts are gone, and each of the 12 uses states one the review below, at the commit nife pins
proofs that match ours eight Kani harnesses in the fork, passing in its proofs workflow; none upstream met in the fork
aarch64, riscv64 and x86_64 builds for all three; hardware CRC32C on two, a software path on riscv64 the oracle suite passing on each
maintained upstream is active in tgoskits, at least 24 commits by six people from 2026-08-04 to 2026-11-08 met by partsfoundry/rsext4, maintained indefinitely

What we contribute upstream

Every contribution goes to rcore-os/tgoskits, against fs/rsext4; the numbers and the commit below are that repository's. We follow its policy on agent-written submissions.

  1. The i_blocks fix, with its reproducer as a test in the crate: grow a directory to 300 entries, unmount, and require e2fsck -fn to exit 0. Fixed upstream in dde4020be; the fork carries the part that fixes it (4dc13db).
  2. The truncate fix, with its reproducer: the failing seeds as fixed inputs, a check that truncation of a depth-2 tree succeeds, and a check that a failed truncation leaves the file's bytes as they were. 2a merged (#2827). 2b open (#2829), with #2845 stacked on it, which commits a shrink's new size before zeroing its tail.
  3. The recovery-flag order. The journal's start is reset before needs_recovery is cleared, with the power-cut point that showed it as a test. Fixed upstream in dde4020be; not in the fork.
  4. Fuzz targets: mount and walk an arbitrary image; parse a superblock, a group descriptor table, an extent tree, a directory block and an htree index; and replay an arbitrary journal. Each target runs under cargo fuzz with a seed corpus of small images mke2fs made. Merged (#2835).
  5. The unsafe review: a SAFETY comment on each CRC32C use, naming the CPU feature it needs and where it is detected, and the group-descriptor casts replaced by decoding each field from its bytes, at both descriptor sizes. Merged: 5a (#2831), which takes hardware CRC32C availability from the environment, and 5b (#2833).
  6. Kani harnesses that match ours. Decoding a superblock, a group descriptor, an extent header or entry, or a directory entry reads only inside its slice, for every input up to a stated bound. A directory block walk ends inside its block. The software CRC32C equals the bitwise definition. Merged (#2846), after issue #2836. They run in the fork.
  7. Mount reports why it refused, rather than mapping every error from read_superblock to a bare Io. Merged (#2839).
  8. InodeInfo reports whole times: nanoseconds, times before 1970 and times past 2106. Open (#2840).
  9. The inode bitmap's padding (bug 3), set as e2fsck requires when a group mke2fs left INODE_UNINIT gets its first inode, with the crate's own allocation test strengthened. Merged (#2825).

Every issue and pull request text is shown to the architect before it is filed. An upstream submission is an outward step, and the review is of the exact text, not of the idea. A fuzz finding in rsext4 is reported the same way. Upstream merge is the goal of every contribution, not a gate: partsfoundry/rsext4 carries every fix, and keeps carrying whatever upstream does not take.

No contribution is consumed from a branch. §305 (git dependencies are allowed on nifeos/* and partsfoundry/* only, pinned to a landed commit) rules out a git dependency on tgoskits. A fix counts once it is on partsfoundry/rsext4's main at the commit nife pins by rev under §305.

What we test on our side

Each of the four phases is useful alone, and the oracle judges each.

phase what judged by
1 Read-only: one confined ext4_server holding one block-device capability, with rsext4 mounted read-only. nifeos/nife#4110 (provisional) builds the core: "Milestone 190 phase 1: a read-only ext4_server core, judged by the read oracle" the oracle, read half, over the corpus
2 The differential oracle: rsext4 against libext2fs and against Linux, in tools/, on the host itself, in CI, before any write is trusted
3 Write, metadata_csum on every write e2fsck -fn exits 0 after each operation; Linux reads back what nife wrote
4 jbd2: rsext4's journal, which Linux replays power cut, then Linux replay, then e2fsck -fn

The oracle is a std host workspace in tools/ext4_oracle/, never in the shipping graph. It requires every listing and file rsext4 reads to equal debugfs's, and judges each write with e2fsck -fn and a debugfs readback.

The corpus is images mke2fs makes with its defaults and with 1 KiB, 2 KiB and 4 KiB blocks, on devices with 512-byte and 4,096-byte sectors. It adds extent depths 0 to 2, htree directories, orphan_file, and a volume over 1 GiB. calef's own drives join it read-only, after a dumpe2fs -h on each shows the feature set phase 1 must support. Their borg repositories verify themselves, so borg check after a round trip is an end-to-end result no synthetic image gives.

Write reordering. A block device between rsext4 and the image records every write and every flush. For each interval between two flushes, the sweep persists the interval's writes in other orders and cuts power after each prefix of each order, then lets Linux replay and runs e2fsck -fn. A device may reorder writes between barriers, so a volume that recovers only from the order it was written in is wrong.

Power cuts and lying devices. Milestone 997 puts rsext4 behind the injector of milestone 37 (Prove RedoxFS's crash consistency). Phase 4 reuses that glue, judges with Linux replay, and adds a mount on a real Linux kernel in a virtual machine.

Hostile images. nife's fuzz rotation runs the upstream targets over this corpus, under the runner of milestone 42 (supply chain and fuzzing in CI), and also drives ext4_server over the block-device seam with mutated images. A drive nife did not write is untrusted input, and the server holding it is confined so that a parser bug costs one server.

The adoption ruling it still needs

Each dependency is an architect's ruling, and rsext4 is not yet ruled. We ask for it once every other condition of the done-when holds (2026-11-25 UTC). The proposal is its own pull request, which carries needs-architect and shows, for the version it pins:

Phase 1 may start against the oracle on the host before the ruling. Nothing links rsext4 into a nife image until it is given.

The rule in force for the oracle, ruled 2026-11-16 (UTC) on pull request #3639: rsext4 is a host-only dependency of tools/ext4_oracle, in a workspace and lockfile of its own. It is pinned to partsfoundry/rsext4 at one commit by rev, under the 2026-11-23 (UTC) ruling to fork. It never enters a nife image, kernel, program or the lockfile of a shipping package. deny.toml refuses the crate anywhere else, and the oracle is a test package, so no shipping package may link it. That ruling is not the adoption ruling above, which stays open.

Done when

What this milestone does not decide

BUGS

Follow-on

Index row

calef's ext4 drives hold the family's borg repositories, so nife reads and writes the format Linux wrote. The implementation is rsext4, with no alternative, from partsfoundry/rsext4: a fork that offers every fix upstream, carries what upstream does not take, and is the shipping source. Upstream work and the fork bring it to the bar of §46: write-path fixes, fuzz targets, safety arguments, decoded group descriptors and Kani harnesses. A differential oracle against libext2fs and Linux judges read, write and jbd2 replay, plus write reordering and hostile-image fuzzing. Once the fork meets the bar, we ask for the adoption ruling, and rsext4 replaces RedoxFS.