Artifact ed2f72ab84ad5feb5a98e42a4bd32f005161ab9cc060926b73891eb6cbfb3228:
- File
src/machine.h
— part of check-in
[f96cbc3342]
at
2026-11-13 03:51:02
on branch trunk
— Phase 4a: outfits limited to a machine, and instruction files joined
suit machine shows or sets this machine's name. An outfit worn with machine=NAME applies on that machine and nowhere else, and where it and an unlimited outfit supply the same destination the machine's wins.
A harness has one instruction file per scope. When the unlimited and the machine-limited outfit both supply instructions, suit writes one file with the unlimited text first and the machine's after it, and links the harness to that. It is rewritten when either source changes and removed when no longer needed. This is the one case where an edit in the store reaches a harness only after suit's next run.
The ledger gains an entry for a file suit wrote, so suit off removes the joined file too.
420 unit checks, 227 shell cases, 146 store cases, 612 placement cases, under clang and under gcc 16. 100% coverage in all 16 source files. The no-change run costs about 0.46 ms over an empty program quiet and 0.66 to 0.79 ms loaded.
The checked-in fuzz corpus now includes inputs grown for the ledger reader (61) and more for the stamp reader (108), beside the config parser's 300. The replay tool's input table grew, because fuzzing had filled the old one on the development machine. (user: dmestas, size: 691) [annotate] [blame] [check-ins using]
#ifndef SUIT_MACHINE_H #define SUIT_MACHINE_H #include <stddef.h> // The machine's name: $SUIT_HOME/machine, one name on one line. A machine // without the file has no name. constexpr size_t MACHINE_MAX = 64; // True if the LEN bytes are a name: 1 to MACHINE_MAX of A-Z a-z 0-9 . _ - bool machine_name_ok(const char *s, size_t len); // Read PATH into NAME (room for MACHINE_MAX + 1). A file that is not there // leaves NAME empty. Returns 0, or 1 after saying on stderr what is wrong. int machine_read(const char *path, char *name); // Write NAME (already checked) to PATH atomically. Returns 0, or 1 after // saying why. int machine_write(const char *path, const char *name); #endif