Artifact 1d13a69c7a32bc0a0cc4aa1cfcbb20c17bfb77088a537a1f9f49009bf80e8bef:
- File
src/store_fs.h
— part of check-in
[cbd57cce10]
at
2026-11-12 22:50:34
on branch trunk
— A store interrupted mid-update can be repaired, and symlinks are refused
An update now writes a journal before it changes anything and removes it only when the update, or the put-back after a failure, has finished. If the journal is still there, every store command refuses and names the fix. suit store repair restores each file to the version the store was leaving. Tested with a double failure and by killing suit in the middle of a slowed 100-file update: repair restored every byte.
libfossil's checkout writes symlinks as regular files, so suit refuses them outright: store open and update refuse a version that holds one, and commit refuses to check one in. Each names the path.
The fuzz corpus libFuzzer grew is minimized and checked in (300 inputs for the config parser, 83 for the stamp reader), so every push replays it under the sanitizers and Fil-C.
The budget test takes the best of three runs. It measured 0.43 to 0.59 ms quiet and 0.72 to 0.88 ms at a load average of 130 to 170.
243 unit checks, 220 shell cases, 146 store cases. 100% coverage in all ten source files. (user: dmestas, size: 922) [annotate] [blame] [check-ins using]
#ifndef SUIT_STORE_FS_H #define SUIT_STORE_FS_H #include "libfossil.h" #include <stddef.h> // The prefix of the temporary names store_fs writes beside a file. A listing // never shows them to libfossil. #define STORE_TMP_PREFIX ".suit-tmp." // Write N bytes to PATH by way of a temporary file beside it: written, synced, // renamed over PATH. An executable PATH stays executable. Returns 0 or an // errno value; a failure leaves PATH as it was and no temporary file. int store_atomic_write(const char *path, const void *src, size_t n); // Install suit's file storage on F: libfossil's own for everything except // writing a file, which goes to a temporary name in the same folder, is // synced, and is renamed over the file. A reader sees the old bytes or the // new ones, never a mixture, and a failed write leaves no temporary file. // Returns 0 or a libfossil result code. int store_fs_install(fsl_cx *f); #endif