Skip to content

fix: support ino in --output-attrs to preserve hardlinks - #686

Merged
dundee merged 1 commit into
dundee:masterfrom
AdamMagued:fix-issue-667
Oct 5, 2026
Merged

dundee merged 1 commit into
dundee:masterfrom
AdamMagued:fix-issue-667

Conversation

@AdamMagued

Copy link
Copy Markdown
Contributor

Fixes #667

Problem

When users export directory scans with explicit --output-attrs, hardlink identity fields (ino and hlnkc) are dropped because both the in-memory (pkg/analyze/encode.go) and SQLite (pkg/analyze/sqlite.go) encoders check attributes == nil && Flag == 'H'. Additionally, parseJSONAttributes in cmd/gdu/app/output_attrs.go rejected ino with an unknown attribute error, preventing users from selecting hardlink attributes. Re-importing such filtered exports causes formerly hardlinked files to be treated as distinct files, inflating calculated directory sizes.

Solution

  1. Add ino to the accepted attribute list in cmd/gdu/app/output_attrs.go.
  2. Gate emission of ino and hlnkc on attributes.Includes("ino") && Flag == 'H' in pkg/analyze/encode.go and pkg/analyze/sqlite.go.
  3. Update the --output-attrs flag description in cmd/gdu/main.go and README.md.
  4. Add unit tests verifying ino parsing, JSON encoding with and without ino, and export/import round-trip integrity for hardlinked trees.

Exporting with explicit --output-attrs previously dropped ino and hlnkc for hardlinked files because emission checked attributes == nil, and parseJSONAttributes rejected "ino". This caused reimported exports to treat hardlinked files as independent entries, inflating apparent size.

Accept "ino" in parseJSONAttributes, gate emission on attributes.Includes("ino") for hardlinks in memory and SQLite encoders, and update flag documentation in main and README.
@dundee
dundee merged commit 726ec72 into dundee:master Oct 5, 2026
7 of 8 checks passed
@dundee

dundee commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Thank you!

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.

Explicit --output-attrs exports silently drop hardlink identity (ino/hlnkc) with no way to opt back in

2 participants