1
.TH ARCHIVE_ENTRY_LINKIFY 3 "February 20, 2010" ""
4
\fB\%archive_entry_linkresolver\fP,
5
\fB\%archive_entry_linkresolver_new\fP,
6
\fB\%archive_entry_linkresolver_set_strategy\fP,
7
\fB\%archive_entry_linkresolver_free\fP,
8
\fB\%archive_entry_linkify\fP
9
\- hardlink resolver functions
15
\fB#include <archive_entry.h>\fP
17
\fIstruct archive_entry_linkresolver *\fP
19
\fB\%archive_entry_linkresolver_new\fP(\fI\%void\fP);
23
\fB\%archive_entry_linkresolver_set_strategy\fP(\fI\%struct\ archive_entry_linkresolver\ *resolver\fP, \fI\%int\ format\fP);
27
\fB\%archive_entry_linkresolver_free\fP(\fI\%struct\ archive_entry_linkresolver\ *resolver\fP);
31
\fB\%archive_entry_linkify\fP(\fI\%struct\ archive_entry_linkresolver\ *resolver\fP, \fI\%struct\ archive_entry\ **entry\fP, \fI\%struct\ archive_entry\ **sparse\fP);
34
Programs that want to create archives have to deal with hardlinks.
35
Hardlinks are handled in different ways by the archive formats.
36
The basic strategies are:
39
Ignore hardlinks and store the body for each reference (old cpio, zip).
41
Store the body the first time an inode is seen (ustar, pax).
43
Store the body the last time an inode is seen (new cpio).
47
\fB\%archive_entry_linkresolver\fP
48
functions help by providing a unified interface and handling the complexity
52
\fB\%archive_entry_linkresolver\fP
55
instances have valid nlinks, inode and device values.
56
The inode and device value is used to match entries.
57
The nlinks value is used to determined if all references have been found and
58
if the internal references can be recycled.
61
\fB\%archive_entry_linkresolver_new\fP()
62
function allocates a new link resolver.
63
The instance can be freed using
64
\fB\%archive_entry_linkresolver_free\fP().
65
All deferred entries are flushed and the internal storage is freed.
68
\fB\%archive_entry_linkresolver_set_strategy\fP()
69
function selects the optimal hardlink strategy for the given format.
70
The format code can be obtained from
71
\fBarchive_format\fP(3).
72
The function can be called more than once, but it is recommended to
73
flush all deferred entries first.
76
\fB\%archive_entry_linkify\fP()
77
function is the core of
78
\fB\%archive_entry_linkresolver\fP.
81
argument points to the
83
that should be written.
84
Depending on the strategy one of the following actions is taken:
87
For the simple archive formats
89
is left unmodified and
94
For tar like archive formats,
103
If the hardlink count of
105
is larger than 1 and the file type is a regular file or symbolic link,
106
the internal list is searched for a matching inode.
107
If such an inode is found, the link count is decremented and the file size
110
is set to 0 to notify that no body should be written.
111
If no such inode is found, a copy of the entry is added to the internal cache
112
with a link count reduced by one.
114
For new cpio like archive formats a value for
118
is used to flush deferred entries.
121
is set to an arbitrary deferred entry and the entry itself is removed from the
123
If the internal list is empty,
131
and the function returns.
132
If the hardlink count of
134
is one or the file type is a directory or device,
138
and no further action is taken.
139
Otherwise, the internal list is searched for a matching inode.
140
If such an inode is not found, the entry is added to the internal list,
147
and the function returns.
148
If such an inode is found, the link count is decremented.
149
If it remains larger than one, the existing entry on the internal list
152
after retaining the link count.
153
The existing entry is returned in
155
If the link count reached one, the new entry is also removed from the
156
internal list and returned in
164
The general usage is therefore:
167
For each new archive entry, call
168
\fB\%archive_entry_linkify\fP().
170
Keep in mind that the entries returned may have a size of 0 now.
184
After all entries have been written to disk, call
185
\fB\%archive_entry_linkify\fP()
190
and archive the returned entry as long as it is not
195
\fB\%archive_entry_linkresolver_new\fP()
203
\fBarchive_entry\fP(3)