Skip to content

erofs: Add erofs_to_filesystem to convert EROFS images back to tree::FileSystem#252

Merged
cgwalters merged 4 commits intocomposefs:mainfrom
cgwalters:erofs-to-fs
Mar 11, 2026
Merged

erofs: Add erofs_to_filesystem to convert EROFS images back to tree::FileSystem#252
cgwalters merged 4 commits intocomposefs:mainfrom
cgwalters:erofs-to-fs

Conversation

@cgwalters
Copy link
Collaborator

Prep for #236

@cgwalters cgwalters marked this pull request as draft March 10, 2026 18:59
Needed for later commits which want to access the hardlink
count conveniently.

Assisted-by: OpenCode (Claude claude-opus-4-6)
Signed-off-by: Colin Walters <walters@verbum.org>
Fix write_escaped to escape a bare '-' as '\x2d'. The dumpfile parser
uses '-' as the sentinel for empty/none fields, so a symlink target or
other field value that is literally '-' would be misinterpreted on
parse. The escape function in dumpfile_parse.rs already handled this.

Split out write_escaped_raw for xattr values, which must not use the
'-' sentinel at all. Previously, an empty xattr value was written as
'-' (the empty sentinel), but the parser doesn't apply optional_str to
xattr values, so it would be read back as the literal byte 0x2d. This
matches the C composefs behavior where xattr values use ESCAPE_EQUAL
without ESCAPE_LONE_DASH.

Fix the Rust dumpfile parser to match the C parser for hardlink entries:
detect the '@' prefix early and skip integer parsing of the remaining
numeric fields (nlink, uid, gid, rdev, mtime). The C parser splits all
fields as strings first, detects '@', and returns early without ever
calling parse_int_field on those values. Our parser was unconditionally
parsing them as integers, which unnecessarily rejected '-' placeholders.

Add comments cross-referencing C composefs escaping behavior throughout.

Assisted-by: OpenCode (Claude claude-opus-4-6)
Signed-off-by: Colin Walters <walters@verbum.org>
Add hash-agnostic proptest strategies that build tree::FileSystem
directly, covering hardlinks, all xattr namespaces (including the
trusted.overlay.* escape path), binary filenames, binary symlink
targets, and all file types.

Also add dumpfile round-trip proptests that exercise
write_dumpfile → dumpfile_to_filesystem → write_dumpfile,
using prop_assume! to skip non-UTF-8 cases that the text-based
dumpfile format cannot represent.

Assisted-by: OpenCode (Claude claude-opus-4-6)
Signed-off-by: Colin Walters <walters@verbum.org>
…FileSystem

The composefs dumpfile was invented to precisely describe exactly
what's in a "composefs EROFS" in a human readable textual fashion.

However our internal FileSystem is an efficient in-memory metadata
tree which we use in various places.

Wire these three things more together by supporting going from
EROFS -> FileSystem.

By adding proptests that cover this we strengthen test coverage
of all of these components together.

Assisted-by: OpenCode (Claude claude-opus-4-6)
Signed-off-by: Colin Walters <walters@verbum.org>
@cgwalters cgwalters marked this pull request as ready for review March 10, 2026 20:07
@cgwalters
Copy link
Collaborator Author

I have to say proptest is so amazing - between that and fuzzing and then onto formal checking there's so many good tools...

@cgwalters cgwalters merged commit 974dfa2 into composefs:main Mar 11, 2026
18 checks passed
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.

2 participants