NAME
archive_entry_linkresolver, archive_entry_linkresolver_new, archive_entry_linkresolver_set_strategy, archive_entry_linkresolver_free, archive_entry_linkify — hardlink resolver functionsLIBRARY
Streaming Archive Library (libarchive, -larchive)SYNOPSIS
#include <archive_entry.h> struct archive_entry_linkresolver *archive_entry_linkresolver_new(void); void
archive_entry_linkresolver_set_strategy(struct archive_entry_linkresolver *resolver, int format); void
archive_entry_linkresolver_free(struct archive_entry_linkresolver *resolver); void
archive_entry_linkify(struct archive_entry_linkresolver *resolver, struct archive_entry **entry, struct archive_entry **sparse);
DESCRIPTION
Programs that want to create archives have to deal with hardlinks. Hardlinks are handled in different ways by the archive formats. The basic strategies are:- Ignore hardlinks and store the body for each reference (old cpio, zip).
- Store the body the first time an inode is seen (ustar, pax).
- Store the body the last time an inode is seen (new cpio).
- For the simple archive formats
*entry is left unmodified and
*sparse is set to
NULL
. - For tar like archive formats,
*sparse is set to
NULL
. If *entry isNULL
, no action is taken. If the hardlink count of *entry is larger than 1 and the file type is a regular file or symbolic link, the internal list is searched for a matching inode. If such an inode is found, the link count is decremented and the file size of *entry is set to 0 to notify that no body should be written. If no such inode is found, a copy of the entry is added to the internal cache with a link count reduced by one. - For new cpio like archive formats a value for
*entry of
NULL
is used to flush deferred entries. In that case *entry is set to an arbitrary deferred entry and the entry itself is removed from the internal list. If the internal list is empty, *entry is set toNULL
. In either case, *sparse is set toNULL
and the function returns. If the hardlink count of *entry is one or the file type is a directory or device, *sparse is set toNULL
and no further action is taken. Otherwise, the internal list is searched for a matching inode. If such an inode is not found, the entry is added to the internal list, both *entry and *sparse are set toNULL
and the function returns. If such an inode is found, the link count is decremented. If it remains larger than one, the existing entry on the internal list is swapped with *entry after retaining the link count. The existing entry is returned in *entry. If the link count reached one, the new entry is also removed from the internal list and returned in *sparse. Otherwise *sparse is set toNULL
.
- For each new archive entry, call archive_entry_linkify().
- Keep in mind that the entries returned may have a size of 0 now.
- If *entry is not
NULL
, archive it. - If *sparse is not
NULL
, archive it. - After all entries have been written to disk, call
archive_entry_linkify() with
*entry set to
NULL
and archive the returned entry as long as it is notNULL
.
RETURN VALUES
archive_entry_linkresolver_new() returnsNULL
on
malloc(3) failures.
SEE ALSO
archive_entry(3)February 2, 2012 | Debian |