Skip to content

Add support for normalizing / hiding hardlinks in the output image #349

Description

@cipriancraciun

At the moment, mkdwarfs faithfully reflects the hardlink relation between files from the source file-system (i.e. if file /a and /b are hardlinks to one-another, so they appear in the image.dwarfs when mounted with FUSE). (And this is great.)

However, there are use-cases when one wants to break (or tweak) this relationship in the resulting image, namely:

  • (A) either having all files appear with exactly 1 hardlink, although underneath in the resulting image they share exactly the same content;
  • (B) either having all duplicate files (based on the hash) in the source file-system appear as hard-links in the resulting image;

Why would case (A) (i.e. hardlinks are dissolved) be useful? The hardlinks in the source file-system might be an implementation detail / optimization, and the user wouldn't want that fact shown in the resulting image.

For example there are techniques of using rsync to create snapshots back-ups that use hardlinks. However, the user might want to create a final image, and would like to hide this fact away.

Why would case (B) (i.e. all duplicate files to become hard-links to each-other), some other times, it's beneficial to have deduplicated files share the same hard-links, as this would allow more advanced tools to take benefit of this information in how they operate. (Again, rsync might be one such tool.)


As a side-note to point (B), how does DwarFS handle files that have more than 65536 hard-links?

(Where would one encounter such a case: MAME supporting files, namely cheats which are XML files, and for some reason, the developers of MAME decided to copy the same hash-duplicate file ~120K times in the same folder...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestwishlistNot high priority, unlikely to happen unless there are real use cases.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions