Skip to content

dumpfile: Various canonicalization fixes, limit symlink length#270

Open
cgwalters wants to merge 2 commits intocomposefs:mainfrom
cgwalters:prep-dir-size-zero
Open

dumpfile: Various canonicalization fixes, limit symlink length#270
cgwalters wants to merge 2 commits intocomposefs:mainfrom
cgwalters:prep-dir-size-zero

Conversation

@cgwalters
Copy link
Collaborator

Per composefs-dump(5): "SIZE: The size of the file. This is ignored for directories."

Directory sizes are filesystem-specific implementation details (ext4 reports block-aligned sizes, EROFS reports serialized dirent byte counts, btrfs may report 0) and have no portable meaning. No consumer of the dumpfile format uses the directory size field.

Drop the size field from Item::Directory and always emit 0 in both the parser's Display impl and write_directory(). The parser still accepts any numeric value in the size field for backward compat with existing dumpfiles.

Assisted-by: OpenCode (Claude Opus 4)

@cgwalters cgwalters enabled auto-merge March 17, 2026 18:31
@cgwalters
Copy link
Collaborator Author

Prep for #225 also xref composefs/composefs#434

@cgwalters cgwalters requested a review from jeckersb March 17, 2026 20:38
The composefs-dump(5) spec leaves several fields unspecified or
explicitly ignored. Canonicalize them at parse time so that parsed
entries have a single canonical representation regardless of which
implementation produced them:

- **Directory sizes**: "This is ignored for directories." Drop the
  size field from Item::Directory, always emit 0.

- **Hardlink metadata**: "We ignore all the fields except the
  payload." Zero uid/gid/mode/mtime and skip xattrs, matching the
  C parser which bails out early (mkcomposefs.c:477-491).

- **Xattr ordering**: The spec doesn't define an order. Sort
  lexicographically so output is deterministic regardless of
  on-disk ordering.

The parser still accepts any input values for backward compatibility.

Assisted-by: OpenCode (Claude Opus 4)
Signed-off-by: Colin Walters <walters@verbum.org>
XFS limits symlink targets to 1024 bytes, and since generic Linux
containers are commonly backed by XFS, enforce that limit in both
the dumpfile parser and the EROFS reader rather than allowing up to
PATH_MAX (4096).

This also avoids exercising a known limitation in our EROFS reader
where symlink data that spills into a non-inline data block (which
can happen with long symlinks + xattrs) is not read back correctly.
See composefs/composefs#342 for the
corresponding C fix for that edge case.

Assisted-by: OpenCode (Claude Opus 4)
Signed-off-by: Colin Walters <walters@verbum.org>
@cgwalters cgwalters force-pushed the prep-dir-size-zero branch from df709e5 to 6dfb4c4 Compare March 17, 2026 22:38
@cgwalters cgwalters changed the title dumpfile: Canonicalize directory size to 0 dumpfile: Various canonicalization fixes, limit symlink length Mar 17, 2026
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