Add fsnap diff <old> <new> that compares two snapshots and reports
added (A), deleted (D), metadata changed (M), permissions changed (P),
and symlink target changed (L) records.
Both snapshots are loaded into memory, sorted by path using qsort,
and merged with a two-pointer algorithm. Residual records after the
merge are emitted as A or D. Escape sequences in paths are decoded
on output.
Also add GetTime accessor, set errno on load_in_memory failures
for meaningful error messages, and fix unused-variable warnings.
SPEC.md records the design the project has been following: goals, staged
plan, and the rules for parsing, error handling and resource ownership.
Conformance fixes it made visible:
- list: accept the `?` file type that create legitimately writes; read
records with getline so long paths are no longer truncated at a fixed
buffer size (SPEC 13); reject numeric fields that are not bare digits
and check ERANGE, so out-of-range values and negative uid/gid no
longer wrap silently (SPEC 14); release the record when the path
allocation fails (SPEC 11).
- list, create: keep the errno of the failure that actually occurred.
An error raised before the cleanup owns errno and is restored; one
raised by fclose owns it only when nothing had failed yet, which is
the case a buffered write can hit for the first time at close
(SPEC 8, SPEC 10).
- scan: propagate printf failures and check fflush(stdout), so a write
error to a redirected stdout is no longer silently ignored (SPEC 8).
- An empty snapshot is a valid snapshot with zero records, not an
error: create produces one for an empty directory.
README.md now documents list, points at SPEC.md where the two differ,
and drops the roadmap entry that proposed renaming list to verify --
SPEC 12 defines list as the parser and SPEC 18 reserves verify for
comparing a snapshot against the live filesystem.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F3NNME8GifswDYLr9VpBzs
The previous text advertised inode data, hard-link tracking, snapshot
comparison and verification, none of which exist. Replace it with what the
code does today: the scan and create commands, the seven-field record
format, and the behaviour around symlinks, absolute paths, unreadable
directories and the .fsnap filter.
State plainly that this is a hobby project and not production ready, list
the limitations that are known and reproducible — non-atomic output, one
directory handle per recursion level, no exit code for a partial snapshot,
no quoting for paths containing a pipe or a newline, no hard-link data, no
tests — and record the intended work as a roadmap.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mbj1ZPUEhxqMYKsK7Y7jkt