Commit Graph

8 Commits

Author SHA1 Message Date
Fabio Scotto di Santolo
464bb58c8c Fix remaining naming and style inconsistencies
- Add const to RecordObjectCompare parameters
- Add static to crc32_table and table_computed in hash.c
- Rename NewRecordObject to RecordObjectNew
- Replace magic number 8192 with BUFFER_SIZE in utility.c
- Unify comment style to /* */ across all files
- Standardize _POSIX_C_SOURCE to 200809L
- Remove unreachable dead code in diff.c
2026-08-26 00:03:13 +02:00
Fabio Scotto di Santolo
dcd17889ac Implement snapshot diff command
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.
2026-08-25 18:13:29 +02:00
Fabio Scotto di Santolo
691988e505 Add SPEC.md and bring list, create and scan in line with it
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
2026-08-16 11:03:31 +02:00
Fabio Scotto di Santolo
60d2af64e2 New feature list with record validation 2026-08-06 23:34:56 +02:00
Fabio Scotto di Santolo
b542113252 Add list command [WIP] 2026-08-05 22:07:21 +02:00
Fabio Scotto di Santolo
777f14a9e9 Harden create command and directory walk
- create: write the snapshot to a temporary file and copy it into place
  only after the walk succeeds; every failure now propagates through rc
  instead of being reported as success, and the temporary is unlinked on
  all exit paths
- create: skip snapshot files by matching the ".fsnap" suffix against the
  basename, so entries below a directory whose name contains ".fsnap" are
  no longer dropped from the snapshot
- walk: emit a record for directories as well as leaf files, honour the
  return value of the operation callback, and free the path and close the
  directory handle on every exit path
- utility: replace the fixed-size realpath buffer with realpath(NULL) and
  add copy(), which reports read, write and close errors instead of
  silently truncating the destination
- scan, create: set errno to EINVAL on invalid arguments so main can print
  a meaningful message

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mbj1ZPUEhxqMYKsK7Y7jkt
2026-08-01 18:08:26 +02:00
Fabio Scotto di Santolo
3eae528f54 Add create command 2026-08-01 14:27:52 +02:00
Fabio Scotto di Santolo
078b95dc4b Add function scan directory 2026-07-31 23:54:45 +02:00