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

« back to all changes in this revision

Viewing changes to doc/man/archive_entry_linkify.3

  • 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
.TH ARCHIVE_ENTRY_LINKIFY 3 "February 20, 2010" ""
 
2
.SH NAME
 
3
.ad l
 
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
 
10
.SH LIBRARY
 
11
.ad l
 
12
Lb libarchive
 
13
.SH SYNOPSIS
 
14
.ad l
 
15
\fB#include <archive_entry.h>\fP
 
16
.br
 
17
\fIstruct archive_entry_linkresolver *\fP
 
18
.br
 
19
\fB\%archive_entry_linkresolver_new\fP(\fI\%void\fP);
 
20
.br
 
21
\fIvoid\fP
 
22
.br
 
23
\fB\%archive_entry_linkresolver_set_strategy\fP(\fI\%struct\ archive_entry_linkresolver\ *resolver\fP, \fI\%int\ format\fP);
 
24
.br
 
25
\fIvoid\fP
 
26
.br
 
27
\fB\%archive_entry_linkresolver_free\fP(\fI\%struct\ archive_entry_linkresolver\ *resolver\fP);
 
28
.br
 
29
\fIvoid\fP
 
30
.br
 
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);
 
32
.SH DESCRIPTION
 
33
.ad l
 
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:
 
37
.RS 5
 
38
.IP 1.
 
39
Ignore hardlinks and store the body for each reference (old cpio, zip).
 
40
.IP 2.
 
41
Store the body the first time an inode is seen (ustar, pax).
 
42
.IP 3.
 
43
Store the body the last time an inode is seen (new cpio).
 
44
.RE
 
45
.PP
 
46
The
 
47
\fB\%archive_entry_linkresolver\fP
 
48
functions help by providing a unified interface and handling the complexity
 
49
behind the scene.
 
50
.PP
 
51
The
 
52
\fB\%archive_entry_linkresolver\fP
 
53
functions assume that
 
54
Vt archive_entry
 
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.
 
59
.PP
 
60
The
 
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.
 
66
.PP
 
67
The
 
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.
 
74
.PP
 
75
The
 
76
\fB\%archive_entry_linkify\fP()
 
77
function is the core of
 
78
\fB\%archive_entry_linkresolver\fP.
 
79
The
 
80
\fB\%entry\fP()
 
81
argument points to the
 
82
Vt archive_entry
 
83
that should be written.
 
84
Depending on the strategy one of the following actions is taken:
 
85
.RS 5
 
86
.IP 1.
 
87
For the simple archive formats
 
88
\fI*entry\fP
 
89
is left unmodified and
 
90
\fI*sparse\fP
 
91
is set to
 
92
.BR NULL.
 
93
.IP 2.
 
94
For tar like archive formats,
 
95
\fI*sparse\fP
 
96
is set to
 
97
.BR NULL.
 
98
If
 
99
\fI*entry\fP
 
100
is
 
101
.BR NULL,
 
102
no action is taken.
 
103
If the hardlink count of
 
104
\fI*entry\fP
 
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
 
108
of
 
109
\fI*entry\fP
 
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.
 
113
.IP 3.
 
114
For new cpio like archive formats a value for
 
115
\fI*entry\fP
 
116
of
 
117
.BR NULL
 
118
is used to flush deferred entries.
 
119
In that case
 
120
\fI*entry\fP
 
121
is set to an arbitrary deferred entry and the entry itself is removed from the
 
122
internal list.
 
123
If the internal list is empty,
 
124
\fI*entry\fP
 
125
is set to
 
126
.BR NULL.
 
127
In either case,
 
128
\fI*sparse\fP
 
129
is set to
 
130
.BR NULL
 
131
and the function returns.
 
132
If the hardlink count of
 
133
\fI*entry\fP
 
134
is one or the file type is a directory or device,
 
135
\fI*sparse\fP
 
136
is set to
 
137
.BR NULL
 
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,
 
141
both
 
142
\fI*entry\fP
 
143
and
 
144
\fI*sparse\fP
 
145
are set to
 
146
.BR NULL
 
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
 
150
is swapped with
 
151
\fI*entry\fP
 
152
after retaining the link count.
 
153
The existing entry is returned in
 
154
\fI*entry\fP.
 
155
If the link count reached one, the new entry is also removed from the
 
156
internal list and returned in
 
157
\fI*sparse\fP.
 
158
Otherwise
 
159
\fI*sparse\fP
 
160
is set to
 
161
.BR NULL.
 
162
.RE
 
163
.PP
 
164
The general usage is therefore:
 
165
.RS 5
 
166
.IP 1.
 
167
For each new archive entry, call
 
168
\fB\%archive_entry_linkify\fP().
 
169
.IP 2.
 
170
Keep in mind that the entries returned may have a size of 0 now.
 
171
.IP 3.
 
172
If
 
173
\fI*entry\fP
 
174
is not
 
175
.BR NULL,
 
176
archive it.
 
177
.IP 4.
 
178
If
 
179
\fI*sparse\fP
 
180
is not
 
181
.BR NULL,
 
182
archive it.
 
183
.IP 5.
 
184
After all entries have been written to disk, call
 
185
\fB\%archive_entry_linkify\fP()
 
186
with
 
187
\fI*entry\fP
 
188
set to
 
189
.BR NULL
 
190
and archive the returned entry as long as it is not
 
191
.BR NULL.
 
192
.RE
 
193
.SH RETURN VALUES
 
194
.ad l
 
195
\fB\%archive_entry_linkresolver_new\fP()
 
196
returns
 
197
.BR NULL
 
198
on
 
199
\fBmalloc\fP(3)
 
200
failures.
 
201
.SH SEE ALSO
 
202
.ad l
 
203
\fBarchive_entry\fP(3)