Blame doc/wiki/ManPageArchiveEntryLinkify3.wiki

Packit 08bd4c
ARCHIVE_ENTRY_LINKIFY(3) manual page 
Packit 08bd4c
== NAME == 
Packit 08bd4c
'''archive_entry_linkresolver''', 
Packit 08bd4c
'''archive_entry_linkresolver_new''', 
Packit 08bd4c
'''archive_entry_linkresolver_set_strategy''', 
Packit 08bd4c
'''archive_entry_linkresolver_free''', 
Packit 08bd4c
'''archive_entry_linkify''' 
Packit 08bd4c
- hardlink resolver functions 
Packit 08bd4c
== LIBRARY == 
Packit 08bd4c
Streaming Archive Library (libarchive, -larchive) 
Packit 08bd4c
== SYNOPSIS == 
Packit 08bd4c
'''<nowiki>#include <archive_entry.h></nowiki>''' 
Packit 08bd4c

Packit 08bd4c
''struct archive_entry_linkresolver *'' 
Packit 08bd4c

Packit 08bd4c
'''archive_entry_linkresolver_new'''(''void''); 
Packit 08bd4c

Packit 08bd4c
''void'' 
Packit 08bd4c

Packit 08bd4c
'''archive_entry_linkresolver_set_strategy'''(''struct archive_entry_linkresolver *resolver'', ''int format''); 
Packit 08bd4c

Packit 08bd4c
''void'' 
Packit 08bd4c

Packit 08bd4c
'''archive_entry_linkresolver_free'''(''struct archive_entry_linkresolver *resolver''); 
Packit 08bd4c

Packit 08bd4c
''void'' 
Packit 08bd4c

Packit 08bd4c
'''archive_entry_linkify'''(''struct archive_entry_linkresolver *resolver'', ''struct archive_entry **entry'', ''struct archive_entry **sparse''); 
Packit 08bd4c
== DESCRIPTION == 
Packit 08bd4c
Programs that want to create archives have to deal with hardlinks. 
Packit 08bd4c
Hardlinks are handled in different ways by the archive formats. 
Packit 08bd4c
The basic strategies are: 
Packit 08bd4c
Packit 08bd4c
  • Packit 08bd4c
    Ignore hardlinks and store the body for each reference (old cpio, zip). 
    Packit 08bd4c
  • Packit 08bd4c
    Store the body the first time an inode is seen (ustar, pax). 
    Packit 08bd4c
  • Packit 08bd4c
    Store the body the last time an inode is seen (new cpio). 
    Packit 08bd4c
     
    Packit 08bd4c
    Packit 08bd4c
    The 
    Packit 08bd4c
    '''archive_entry_linkresolver''' 
    Packit 08bd4c
    functions help by providing a unified interface and handling the complexity 
    Packit 08bd4c
    behind the scene. 
    Packit 08bd4c
    Packit 08bd4c
    The 
    Packit 08bd4c
    '''archive_entry_linkresolver''' 
    Packit 08bd4c
    functions assume that 
    Packit 08bd4c
    ''archive_entry'' 
    Packit 08bd4c
    instances have valid nlinks, inode and device values. 
    Packit 08bd4c
    The inode and device value is used to match entries. 
    Packit 08bd4c
    The nlinks value is used to determined if all references have been found and 
    Packit 08bd4c
    if the internal references can be recycled. 
    Packit 08bd4c
    Packit 08bd4c
    The 
    Packit 08bd4c
    '''archive_entry_linkresolver_new'''() 
    Packit 08bd4c
    function allocates a new link resolver. 
    Packit 08bd4c
    The instance can be freed using 
    Packit 08bd4c
    '''archive_entry_linkresolver_free'''(). 
    Packit 08bd4c
    All deferred entries are flushed and the internal storage is freed. 
    Packit 08bd4c
    Packit 08bd4c
    The 
    Packit 08bd4c
    '''archive_entry_linkresolver_set_strategy'''() 
    Packit 08bd4c
    function selects the optimal hardlink strategy for the given format. 
    Packit 08bd4c
    The format code can be obtained from 
    Packit 08bd4c
    [[ManPagerchiveormat3]]. 
    Packit 08bd4c
    The function can be called more than once, but it is recommended to 
    Packit 08bd4c
    flush all deferred entries first. 
    Packit 08bd4c
    Packit 08bd4c
    The 
    Packit 08bd4c
    '''archive_entry_linkify'''() 
    Packit 08bd4c
    function is the core of 
    Packit 08bd4c
    '''archive_entry_linkresolver'''. 
    Packit 08bd4c
    The 
    Packit 08bd4c
    '''entry'''() 
    Packit 08bd4c
    argument points to the 
    Packit 08bd4c
    ''archive_entry'' 
    Packit 08bd4c
    that should be written. 
    Packit 08bd4c
    Depending on the strategy one of the following actions is taken: 
    Packit 08bd4c
    Packit 08bd4c
  • Packit 08bd4c
    For the simple archive formats 
    Packit 08bd4c
    ''*entry'' 
    Packit 08bd4c
    is left unmodified and 
    Packit 08bd4c
    ''*sparse'' 
    Packit 08bd4c
    is set to 
    Packit 08bd4c
    NULL. 
    Packit 08bd4c
  • Packit 08bd4c
    For tar like archive formats, 
    Packit 08bd4c
    ''*sparse'' 
    Packit 08bd4c
    is set to 
    Packit 08bd4c
    NULL. 
    Packit 08bd4c
    If 
    Packit 08bd4c
    ''*entry'' 
    Packit 08bd4c
    is 
    Packit 08bd4c
    NULL, 
    Packit 08bd4c
    no action is taken. 
    Packit 08bd4c
    If the hardlink count of 
    Packit 08bd4c
    ''*entry'' 
    Packit 08bd4c
    is larger than 1 and the file type is a regular file or symbolic link, 
    Packit 08bd4c
    the internal list is searched for a matching inode. 
    Packit 08bd4c
    If such an inode is found, the link count is decremented and the file size 
    Packit 08bd4c
    of 
    Packit 08bd4c
    ''*entry'' 
    Packit 08bd4c
    is set to 0 to notify that no body should be written. 
    Packit 08bd4c
    If no such inode is found, a copy of the entry is added to the internal cache 
    Packit 08bd4c
    with a link count reduced by one. 
    Packit 08bd4c
  • Packit 08bd4c
    For new cpio like archive formats a value for 
    Packit 08bd4c
    ''*entry'' 
    Packit 08bd4c
    of 
    Packit 08bd4c
    NULL 
    Packit 08bd4c
    is used to flush deferred entries. 
    Packit 08bd4c
    In that case 
    Packit 08bd4c
    ''*entry'' 
    Packit 08bd4c
    is set to an arbitrary deferred entry and the entry itself is removed from the 
    Packit 08bd4c
    internal list. 
    Packit 08bd4c
    If the internal list is empty, 
    Packit 08bd4c
    ''*entry'' 
    Packit 08bd4c
    is set to 
    Packit 08bd4c
    NULL. 
    Packit 08bd4c
    In either case, 
    Packit 08bd4c
    ''*sparse'' 
    Packit 08bd4c
    is set to 
    Packit 08bd4c
    NULL 
    Packit 08bd4c
    and the function returns. 
    Packit 08bd4c
    If the hardlink count of 
    Packit 08bd4c
    ''*entry'' 
    Packit 08bd4c
    is one or the file type is a directory or device, 
    Packit 08bd4c
    ''*sparse'' 
    Packit 08bd4c
    is set to 
    Packit 08bd4c
    NULL 
    Packit 08bd4c
    and no further action is taken. 
    Packit 08bd4c
    Otherwise, the internal list is searched for a matching inode. 
    Packit 08bd4c
    If such an inode is not found, the entry is added to the internal list, 
    Packit 08bd4c
    both 
    Packit 08bd4c
    ''*entry'' 
    Packit 08bd4c
    and 
    Packit 08bd4c
    ''*sparse'' 
    Packit 08bd4c
    are set to 
    Packit 08bd4c
    NULL 
    Packit 08bd4c
    and the function returns. 
    Packit 08bd4c
    If such an inode is found, the link count is decremented. 
    Packit 08bd4c
    If it remains larger than one, the existing entry on the internal list 
    Packit 08bd4c
    is swapped with 
    Packit 08bd4c
    ''*entry'' 
    Packit 08bd4c
    after retaining the link count. 
    Packit 08bd4c
    The existing entry is returned in 
    Packit 08bd4c
    ''*entry''. 
    Packit 08bd4c
    If the link count reached one, the new entry is also removed from the 
    Packit 08bd4c
    internal list and returned in 
    Packit 08bd4c
    ''*sparse''. 
    Packit 08bd4c
    Otherwise 
    Packit 08bd4c
    ''*sparse'' 
    Packit 08bd4c
    is set to 
    Packit 08bd4c
    NULL. 
    Packit 08bd4c
     
    Packit 08bd4c
    Packit 08bd4c
    The general usage is therefore: 
    Packit 08bd4c
    Packit 08bd4c
  • Packit 08bd4c
    For each new archive entry, call 
    Packit 08bd4c
    '''archive_entry_linkify'''(). 
    Packit 08bd4c
  • Packit 08bd4c
    Keep in mind that the entries returned may have a size of 0 now. 
    Packit 08bd4c
  • Packit 08bd4c
    If 
    Packit 08bd4c
    ''*entry'' 
    Packit 08bd4c
    is not 
    Packit 08bd4c
    NULL, 
    Packit 08bd4c
    archive it. 
    Packit 08bd4c
  • Packit 08bd4c
    If 
    Packit 08bd4c
    ''*sparse'' 
    Packit 08bd4c
    is not 
    Packit 08bd4c
    NULL, 
    Packit 08bd4c
    archive it. 
    Packit 08bd4c
  • Packit 08bd4c
    After all entries have been written to disk, call 
    Packit 08bd4c
    '''archive_entry_linkify'''() 
    Packit 08bd4c
    with 
    Packit 08bd4c
    ''*entry'' 
    Packit 08bd4c
    set to 
    Packit 08bd4c
    NULL 
    Packit 08bd4c
    and archive the returned entry as long as it is not 
    Packit 08bd4c
    NULL. 
    Packit 08bd4c
     
    Packit 08bd4c
    == RETURN VALUES == 
    Packit 08bd4c
    '''archive_entry_linkresolver_new'''() 
    Packit 08bd4c
    returns 
    Packit 08bd4c
    NULL 
    Packit 08bd4c
    on 
    Packit 08bd4c
    [[malloc(3)|http://www.freebsd.org/cgi/man.cgi?query=malloc&sektion=3]] 
    Packit 08bd4c
    failures. 
    Packit 08bd4c
    == SEE ALSO == 
    Packit 08bd4c
    [[ManPagerchiventry3]]