Skip to content

fix(snapshot): set ext4 lost+found to 0755 (#177) - #178

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/177-snapshot-lostfound-mode
Jun 15, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/177-snapshot-lostfound-mode

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Cosmetic fix surfaced validating nf-spawn#55 (zero-copy DBs on read-only EBS volumes).

Problem: tar2ext4 (hcsshim compactext4) creates the ext4 lost+found directory root-owned, mode 0700. A tool that walks a volume-mounted snapshot as a non-root user emits a spurious stderr line — e.g. MetaPhlAn's find -L metaphlan → find: 'metaphlan/lost+found': Permission denied. Harmless (find still resolves the content) but confusing in logs.

Fix: prependLostFound injects a single lost+found/ directory tar entry at mode 0755 ahead of the source tar stream before tar2ext4.Convert. The writer re-applies the mode when a lost+found directory entry repeats (confirmed by hcsshim's own compact_test.go), so this overrides the default without re-muxing the (possibly very large) source archive. Only a tar header is written (Flush, not Close, so no archive trailer precedes the real stream).

Tests: TestPrependLostFound asserts the combined stream is lost+found/ (dir, 0755) followed by the original entry intact, ending cleanly at EOF. The existing TestPrepareSnapshotImage_* ext4-build tests still pass (the prepend doesn't break Convert).

Fixes #177. Pairs with nf-spawn#61 (doc note: volumes remove the copy, not the RAM footprint).

tar2ext4 (hcsshim compactext4) creates lost+found as root-owned 0700, so a tool
walking a volume-mounted snapshot as non-root (e.g. MetaPhlAn's `find -L <db>`)
emits a spurious `Permission denied` on lost+found. Prepend a lost+found/ dir
tar entry at 0755 before Convert — the writer re-applies the mode when the
directory entry repeats — overriding the default without re-muxing the source.

Surfaced validating nf-spawn#55.

Fixes #177
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 682f106 into main Jun 15, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/177-snapshot-lostfound-mode branch June 15, 2026 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

snapshot create: ext4 lost+found is root-only 0700 → noisy find Permission denied on volume walks

1 participant