#30 Hardlink support

open
nobody
None
5
2010-09-29
2010-09-29
No

Could you give p7zip hardlink support? A hardlink entry in a .7z
file would mean something like "create a hardlink if supported and
not disabled by a user option, otherwise make a file copy".

The preferred format should be to store a file's names before its
contents. Otherwise attempting to extract a single file can fail:
If B is archived after A as a hardlink to A, '7z x foo.7z B' has
bypassed A by the time sees B and realizes it needed A's contents.

If each hardlink entry would contain the name of the file where
the actual contents is stored: I think p7zip should *not* blindly
link B to A when it sees an entry "B is a hardlink to A". It
should report an error if it does not know A on the disk matches
the A in the archive or was just extracted from the archive.
Otherwise '7z x foo.7z B' could get an old copy of B (linked to
old A on the disk) instead of the one in the archive.

Discussion

  • Other thoughts:

    Set a limit "max #bytes of link names for upcoming file contents".
    Otherwise a naughty archive can tell '7z x' to remember gigabytes
    of names while looking for their contents.

    If an archive would exceed the limit, it could instead list the
    remaining links both before and after the contents. Thus '7z x'
    can extract the file if it sees at least one desired name before
    the contents, and need not remember the rest of the note.

    Format of links: It's random which name would become the main
    file, yet links stored as "B is a hard link to A" are unequal.
    In particular with archivers that do not understand links.
    Replace A in the archive: Both get replaced. Replace B: You
    merely undo the link. Delete A: B becomes invalid.

    Fixes would be to either put all of a file's names in a single
    archive entry, or for no link entry to include the file contents -
    instead they'd all refer to a nameless entry with the contents.

    However an archive which doesn't understand link entries would
    still mess up the archive, in particular with my suggestion above
    for listing links twice.