Add EWAD header hash (format v2) and atomic file writes #3
Loading…
Reference in a new issue
No description provided.
Delete branch "ewad-v2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Two changes ahead of Wayfinder adopting EWAD for game data and save games.
wad_view_openbounds-checks both ranges, checks the hash, then runs the per-entry validation. It reads no lump data. The value is exposed asWAD_View.archive_hash. Version 1 is rejected, and all structural checks stay.wad_write_fileandwad_write_file_exwrite a uniquely named temporary file beside the target, fsync it, rename it over the target, and fsync the directory. On failure the target keeps its bytes and the temporary file is removed. POSIX-only.Also updates
README.md,docs/spitwad.md,docs/WAD Format.mdand thespitwad.hcomments, and removesdocs/research/, which described the earlier design.Behaviour changes
struct WAD_Viewgainsarchive_hashas its last field.spitwad.cno longer compiles on Windows.SPITWAD_ERR_IOand creates nothing.SPITWAD_ERR_IO. Renaming over/dev/fullas root would otherwise destroy the node and report success.SPITWAD_ERR_IO. This is the one exception to the target being untouched on failure, and it is documented.Testing
SPITWAD_SANITIZE=ONbuild on Apple clang 21, and on GCC 15.2 inalpine:3.24as root and as non-root with leak detection on.spitwad.ccompiles without warnings under Wayfinder's flags on both compilers.PROT_NONE; atomic-write failure, permission and symlink cases.Not verified
RLIMIT_FSIZE, and the fsync order was confirmed from an instrumented build.fsyncdoes not flush the drive's own cache.🤖 Generated with Claude Code