How to identify hardlinks in oldgnu archives?

31 views
Skip to first unread message

Anna Blendermann

unread,
May 17, 2019, 9:54:32 AM5/17/19
to libarchive-discuss
Hey guys,

I've had no luck using libarchive archive_entry_nlink to get the number of hardlinks associated with a file. I've got code that uniquely identifies a hardlink using filetype + size of a tar archive entry, but it doesn't work for oldgnu format. 

Anyone know of a way to detect hardlinks in oldgnu format?

Joerg Sonnenberger

unread,
May 17, 2019, 9:58:42 AM5/17/19
to Anna Blendermann, libarchive-discuss
The short answer is: the tar format doesn't store a link count. You have to iterate the archive and look for entries with hardlink going back to earlier archive entries.

Joerg

Anna Blendermann

unread,
May 17, 2019, 10:13:54 AM5/17/19
to libarchive-discuss
Joerg,

Sorry, let me clarify! I'm iterating the archive but when reaching hardlinks inside a tar archive of the oldgnu format, libarchive's function archive_entry_filetype flags them as regular files and not hardlinks. Is there another way to do this?
Reply all
Reply to author
Forward
0 new messages