Skip to content

Factor out a composefs-erofs crate#247

Closed
cgwalters wants to merge 7 commits intocomposefs:mainfrom
cgwalters:erofs-crate
Closed

Factor out a composefs-erofs crate#247
cgwalters wants to merge 7 commits intocomposefs:mainfrom
cgwalters:erofs-crate

Conversation

@cgwalters
Copy link
Collaborator

Main motivation here is prep for #225

Extract the FsVerityHashValue trait, Sha256HashValue, and Sha512HashValue
types from composefs into a new composefs-types internal crate. This is
prep work for extracting erofs code into a separate crate that needs
these types without depending on all of composefs.

The composefs crate re-exports these types from its existing
fsverity::hashvalue module so all downstream code continues to work
unchanged. The INLINE_CONTENT_MAX constant is also moved to
composefs-types and re-exported.

Assisted-by: OpenCode (Claude claude-opus-4-6)
Signed-off-by: Colin Walters <walters@verbum.org>
Move the EROFS on-disk format definitions (format.rs) into a new
composefs-erofs crate. The file is moved with git mv to preserve
history and is byte-for-byte identical in the new location.

The composefs crate re-exports everything via `pub use
composefs_erofs::format::*` so all downstream code continues to
compile without changes.

The four Debug impls for format types (CompactInodeHeader,
ExtendedInodeHeader, ComposefsHeader, Superblock) that lived in
composefs's debug.rs are moved to composefs-erofs's debug module
to satisfy orphan rules. The XAttrHeader::calculate_n_elems inherent
method is converted to a local free function in reader.rs for the
same reason.

Assisted-by: OpenCode (Claude claude-opus-4-6)
Signed-off-by: Colin Walters <walters@verbum.org>
Move the OverlayMetacopy structure from composefs's erofs module into
the composefs-erofs crate. This type represents the overlay.metacopy
xattr format used for fs-verity digest storage in composefs images.

The visibility changes from pub(super) to pub since the type is now
in a separate crate and needs to be accessible by both the reader
(which will move to composefs-erofs) and the writer (which remains
in composefs). The composefs crate re-exports the module for backward
compatibility.

Assisted-by: OpenCode (Claude claude-opus-4-6)
Signed-off-by: Colin Walters <walters@verbum.org>
Move the EROFS image reader and parser code into the composefs-erofs
crate. The reader provides safe parsing of EROFS filesystem images,
including inode traversal, directory reading, and object reference
collection.

The XAttrHeader::calculate_n_elems method is restored as an inherent
impl now that XAttrHeader and the reader are in the same crate. Debug
impls for reader types (XAttr, Inode, DirectoryBlock, DataBlock) move
to composefs-erofs since those types now live there.
DirectoryEntry::nid() is made public since the type is now part of the
crate's public API.

Reader tests that depend on composefs-specific utilities (dumpfile
parser, mkfs writer) are extracted to crates/composefs/tests/erofs_reader.rs
since they cannot live in composefs-erofs without creating a circular
dependency. The composefs crate re-exports composefs_erofs::reader::*
for backward compatibility.

Assisted-by: OpenCode (Claude claude-opus-4-6)
Signed-off-by: Colin Walters <walters@verbum.org>
Move the EROFS image debug and analysis code into the composefs-erofs
crate. This includes debug_img(), dump_unassigned(), the ImageVisitor
tree walker, and SegmentType enum, as well as all Debug trait
implementations for erofs types.

Consolidate the previously-duplicated utility functions (hexdump,
utf8_or_hex, addr! macro) into a single copy in composefs-erofs.
The composefs crate re-exports composefs_erofs::debug::* for backward
compatibility.

Assisted-by: OpenCode (Claude claude-opus-4-6)
Signed-off-by: Colin Walters <walters@verbum.org>
The writer remains in the composefs crate (it depends on tree types
that can't be extracted without significant restructuring), but now
imports format, reader, and composefs modules directly from the
composefs-erofs crate rather than through the re-export layer.

Assisted-by: OpenCode (Claude claude-opus-4-6)
Signed-off-by: Colin Walters <walters@verbum.org>
The erofs-debug binary now depends directly on composefs-erofs rather
than going through the composefs crate, since all the erofs debug
functionality lives in composefs-erofs. This removes erofs-debug's
dependency on the full composefs crate.

Assisted-by: OpenCode (Claude claude-opus-4-6)
Signed-off-by: Colin Walters <walters@verbum.org>
@cgwalters
Copy link
Collaborator Author

On reflection...nevermind, having even more crates here probably isn't worth it.

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.

1 participant