~ubuntu-branches/ubuntu/quantal/libarchive/quantal

« back to all changes in this revision

Viewing changes to doc/text/archive_entry_linkify.3.txt

  • Committer: Package Import Robot
  • Author(s): Andres Mejia
  • Date: 2012-02-23 19:29:24 UTC
  • mfrom: (8.1.10 sid)
  • Revision ID: package-import@ubuntu.com-20120223192924-73n4iedok5fwgsyr
Tags: 3.0.3-5
* Detect if locales or locales-all is installed for use with test suite.
* Bump Standards-Version to 3.9.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
ARCHIVE_ENTRY_LINKIFY(3) BSD Library Functions Manual ARCHIVE_ENTRY_LINKIFY(3)
 
3
 
 
4
NAME
 
5
     archive_entry_linkresolver, archive_entry_linkresolver_new,
 
6
     archive_entry_linkresolver_set_strategy, archive_entry_linkresolver_free,
 
7
     archive_entry_linkify — hardlink resolver functions
 
8
 
 
9
LIBRARY
 
10
     library “libarchive”
 
11
 
 
12
SYNOPSIS
 
13
     #include <archive_entry.h>
 
14
 
 
15
     struct archive_entry_linkresolver *
 
16
     archive_entry_linkresolver_new(void);
 
17
 
 
18
     void
 
19
     archive_entry_linkresolver_set_strategy(struct archive_entry_linkresolver *resolver,
 
20
         int format);
 
21
 
 
22
     void
 
23
     archive_entry_linkresolver_free(struct archive_entry_linkresolver *resolver);
 
24
 
 
25
     void
 
26
     archive_entry_linkify(struct archive_entry_linkresolver *resolver,
 
27
         struct archive_entry **entry, struct archive_entry **sparse);
 
28
 
 
29
DESCRIPTION
 
30
     Programs that want to create archives have to deal with hardlinks.
 
31
     Hardlinks are handled in different ways by the archive formats.  The
 
32
     basic strategies are:
 
33
 
 
34
     1.   Ignore hardlinks and store the body for each reference (old cpio,
 
35
          zip).
 
36
 
 
37
     2.   Store the body the first time an inode is seen (ustar, pax).
 
38
 
 
39
     3.   Store the body the last time an inode is seen (new cpio).
 
40
 
 
41
     The archive_entry_linkresolver functions help by providing a unified
 
42
     interface and handling the complexity behind the scene.
 
43
 
 
44
     The archive_entry_linkresolver functions assume that archive_entry
 
45
     instances have valid nlinks, inode and device values.  The inode and
 
46
     device value is used to match entries.  The nlinks value is used to
 
47
     determined if all references have been found and if the internal refer‐
 
48
     ences can be recycled.
 
49
 
 
50
     The archive_entry_linkresolver_new() function allocates a new link
 
51
     resolver.  The instance can be freed using
 
52
     archive_entry_linkresolver_free().  All deferred entries are flushed and
 
53
     the internal storage is freed.
 
54
 
 
55
     The archive_entry_linkresolver_set_strategy() function selects the opti‐
 
56
     mal hardlink strategy for the given format.  The format code can be
 
57
     obtained from archive_format(3).  The function can be called more than
 
58
     once, but it is recommended to flush all deferred entries first.
 
59
 
 
60
     The archive_entry_linkify() function is the core of
 
61
     archive_entry_linkresolver.  The entry() argument points to the
 
62
     archive_entry that should be written.  Depending on the strategy one of
 
63
     the following actions is taken:
 
64
 
 
65
     1.   For the simple archive formats *entry is left unmodified and *sparse
 
66
          is set to NULL.
 
67
 
 
68
     2.   For tar like archive formats, *sparse is set to NULL.  If *entry is
 
69
          NULL, no action is taken.  If the hardlink count of *entry is larger
 
70
          than 1 and the file type is a regular file or symbolic link, the
 
71
          internal list is searched for a matching inode.  If such an inode is
 
72
          found, the link count is decremented and the file size of *entry is
 
73
          set to 0 to notify that no body should be written.  If no such inode
 
74
          is found, a copy of the entry is added to the internal cache with a
 
75
          link count reduced by one.
 
76
 
 
77
     3.   For new cpio like archive formats a value for *entry of NULL is used
 
78
          to flush deferred entries.  In that case *entry is set to an arbi‐
 
79
          trary deferred entry and the entry itself is removed from the inter‐
 
80
          nal list.  If the internal list is empty, *entry is set to NULL.  In
 
81
          either case, *sparse is set to NULL and the function returns.  If
 
82
          the hardlink count of *entry is one or the file type is a directory
 
83
          or device, *sparse is set to NULL and no further action is taken.
 
84
          Otherwise, the internal list is searched for a matching inode.  If
 
85
          such an inode is not found, the entry is added to the internal list,
 
86
          both *entry and *sparse are set to NULL and the function returns.
 
87
          If such an inode is found, the link count is decremented.  If it
 
88
          remains larger than one, the existing entry on the internal list is
 
89
          swapped with *entry after retaining the link count.  The existing
 
90
          entry is returned in *entry.  If the link count reached one, the new
 
91
          entry is also removed from the internal list and returned in
 
92
          *sparse.  Otherwise *sparse is set to NULL.
 
93
 
 
94
     The general usage is therefore:
 
95
 
 
96
     1.   For each new archive entry, call archive_entry_linkify().
 
97
 
 
98
     2.   Keep in mind that the entries returned may have a size of 0 now.
 
99
 
 
100
     3.   If *entry is not NULL, archive it.
 
101
 
 
102
     4.   If *sparse is not NULL, archive it.
 
103
 
 
104
     5.   After all entries have been written to disk, call
 
105
          archive_entry_linkify() with *entry set to NULL and archive the
 
106
          returned entry as long as it is not NULL.
 
107
 
 
108
RETURN VALUES
 
109
     archive_entry_linkresolver_new() returns NULL on malloc(3) failures.
 
110
 
 
111
SEE ALSO
 
112
     archive_entry(3)
 
113
 
 
114
BSD                            February 20, 2010                           BSD