Files
cubelinux-kernel/drivers/cube
surface-camera-build d569df710d cubelinux: the store's format is one file, and the kernel and userspace both include it
Two build systems cannot share a crate: the kernel's Rust build compiles what is in its own module
tree, and a cargo crate is not that. So they share a *file* — `drivers/cube/cube_format.rs`, which
the driver declares with `mod` and `crates/cube-format` includes by path. There is no copy to drift
from, which is the only arrangement that cannot go stale. What happened when v3 landed and userspace
did not is the argument: an hour of `unsupported-version`, one gate red, and two implementations of
one format each believing itself.

The file holds what both sides must agree about, and nothing else — pure functions over slices, no
allocation, no I/O, no logging:

  * the constants every reader and writer derives its arithmetic from,
  * the header, in all three versions, with refusal rather than guessing: a reader that invents an
    extent can read somebody else's bytes,
  * the v3 space table and index, and the three equalities a reader computes its addresses from,
  * the packed record and the log entry, the two framings a fold and a walk have to parse alike,
  * CRC-32, FNV-1a, and the digest line both sides print.

The driver's copies of the constants are now aliases of the shared ones, and the two functions that
*validate* a header — `parse_header` and the v3 geometry — delegate to it, because validation is
where a second description gets believed. The readers stay where they are: this driver streams from
a file with its own buffers while userspace already holds the whole image, and that difference is
real rather than duplicated.

Nothing changed in behaviour, which is the point: verify-enum.sh, verify-enum-cost.sh,
verify-frontend.sh, verify-kernel-checkpoint.sh and verify-kernel-append.sh all pass, and the shared
crate's own tests include a kernel-written image — ten records, three spaces, 110 value bytes — read
through its arithmetic.
2026-09-21 03:18:52 -04:00
..