~laurynas-biveinis/percona-xtrabackup/xtrabackup-page-filters

« back to all changes in this revision

Viewing changes to src/libarchive/libarchive/libarchive.3

merge parallel compression branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.\" Copyright (c) 2003-2007 Tim Kientzle
 
2
.\" All rights reserved.
 
3
.\"
 
4
.\" Redistribution and use in source and binary forms, with or without
 
5
.\" modification, are permitted provided that the following conditions
 
6
.\" are met:
 
7
.\" 1. Redistributions of source code must retain the above copyright
 
8
.\"    notice, this list of conditions and the following disclaimer.
 
9
.\" 2. Redistributions in binary form must reproduce the above copyright
 
10
.\"    notice, this list of conditions and the following disclaimer in the
 
11
.\"    documentation and/or other materials provided with the distribution.
 
12
.\"
 
13
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 
14
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
15
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
16
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 
17
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
18
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
19
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
20
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
21
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
22
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
23
.\" SUCH DAMAGE.
 
24
.\"
 
25
.\" $FreeBSD: src/lib/libarchive/libarchive.3,v 1.11 2007/01/09 08:05:56 kientzle Exp $
 
26
.\"
 
27
.Dd August 19, 2006
 
28
.Dt LIBARCHIVE 3
 
29
.Os
 
30
.Sh NAME
 
31
.Nm libarchive
 
32
.Nd functions for reading and writing streaming archives
 
33
.Sh LIBRARY
 
34
.Lb libarchive
 
35
.Sh OVERVIEW
 
36
The
 
37
.Nm
 
38
library provides a flexible interface for reading and writing
 
39
streaming archive files such as tar and cpio.
 
40
The library is inherently stream-oriented; readers serially iterate through
 
41
the archive, writers serially add things to the archive.
 
42
In particular, note that there is no built-in support for
 
43
random access nor for in-place modification.
 
44
.Pp
 
45
When reading an archive, the library automatically detects the
 
46
format and the compression.
 
47
The library currently has read support for:
 
48
.Bl -bullet -compact
 
49
.It
 
50
old-style tar archives,
 
51
.It
 
52
most variants of the POSIX
 
53
.Dq ustar
 
54
format,
 
55
.It
 
56
the POSIX
 
57
.Dq pax interchange
 
58
format,
 
59
.It
 
60
GNU-format tar archives,
 
61
.It
 
62
most common cpio archive formats,
 
63
.It
 
64
ISO9660 CD images (with or without RockRidge extensions),
 
65
.It
 
66
Zip archives.
 
67
.El
 
68
The library automatically detects archives compressed with
 
69
.Xr gzip 1 ,
 
70
.Xr bzip2 1 ,
 
71
or
 
72
.Xr compress 1
 
73
and decompresses them transparently.
 
74
.Pp
 
75
When writing an archive, you can specify the compression
 
76
to be used and the format to use.
 
77
The library can write
 
78
.Bl -bullet -compact
 
79
.It
 
80
POSIX-standard
 
81
.Dq ustar
 
82
archives,
 
83
.It
 
84
POSIX
 
85
.Dq pax interchange format
 
86
archives,
 
87
.It
 
88
POSIX octet-oriented cpio archives,
 
89
.It
 
90
two different variants of shar archives.
 
91
.El
 
92
Pax interchange format is an extension of the tar archive format that
 
93
eliminates essentially all of the limitations of historic tar formats
 
94
in a standard fashion that is supported
 
95
by POSIX-compliant
 
96
.Xr pax 1
 
97
implementations on many systems as well as several newer implementations of
 
98
.Xr tar 1 .
 
99
Note that the default write format will suppress the pax extended
 
100
attributes for most entries; explicitly requesting pax format will
 
101
enable those attributes for all entries.
 
102
.Pp
 
103
The read and write APIs are accessed through the
 
104
.Fn archive_read_XXX
 
105
functions and the
 
106
.Fn archive_write_XXX
 
107
functions, respectively, and either can be used independently
 
108
of the other.
 
109
.Pp
 
110
The rest of this manual page provides an overview of the library
 
111
operation.
 
112
More detailed information can be found in the individual manual
 
113
pages for each API or utility function.
 
114
.Sh READING AN ARCHIVE
 
115
To read an archive, you must first obtain an initialized
 
116
.Tn struct archive
 
117
object from
 
118
.Fn archive_read_new .
 
119
You can then modify this object for the desired operations with the
 
120
various
 
121
.Fn archive_read_set_XXX
 
122
and
 
123
.Fn archive_read_support_XXX
 
124
functions.
 
125
In particular, you will need to invoke appropriate
 
126
.Fn archive_read_support_XXX
 
127
functions to enable the corresponding compression and format
 
128
support.
 
129
Note that these latter functions perform two distinct operations:
 
130
they cause the corresponding support code to be linked into your
 
131
program, and they enable the corresponding auto-detect code.
 
132
Unless you have specific constraints, you will generally want
 
133
to invoke
 
134
.Fn archive_read_support_compression_all
 
135
and
 
136
.Fn archive_read_support_format_all
 
137
to enable auto-detect for all formats and compression types
 
138
currently supported by the library.
 
139
.Pp
 
140
Once you have prepared the
 
141
.Tn struct archive
 
142
object, you call
 
143
.Fn archive_read_open
 
144
to actually open the archive and prepare it for reading.
 
145
There are several variants of this function;
 
146
the most basic expects you to provide pointers to several
 
147
functions that can provide blocks of bytes from the archive.
 
148
There are convenience forms that allow you to
 
149
specify a filename, file descriptor,
 
150
.Ft "FILE *"
 
151
object, or a block of memory from which to read the archive data.
 
152
Note that the core library makes no assumptions about the
 
153
size of the blocks read;
 
154
callback functions are free to read whatever block size is
 
155
most appropriate for the medium.
 
156
.Pp
 
157
Each archive entry consists of a header followed by a certain
 
158
amount of data.
 
159
You can obtain the next header with
 
160
.Fn archive_read_next_header ,
 
161
which returns a pointer to an
 
162
.Tn struct archive_entry
 
163
structure with information about the current archive element.
 
164
If the entry is a regular file, then the header will be followed
 
165
by the file data.
 
166
You can use
 
167
.Fn archive_read_data
 
168
(which works much like the
 
169
.Xr read 2
 
170
system call)
 
171
to read this data from the archive.
 
172
You may prefer to use the higher-level
 
173
.Fn archive_read_data_skip ,
 
174
which reads and discards the data for this entry,
 
175
.Fn archive_read_data_to_buffer ,
 
176
which reads the data into an in-memory buffer,
 
177
.Fn archive_read_data_to_file ,
 
178
which copies the data to the provided file descriptor, or
 
179
.Fn archive_read_extract ,
 
180
which recreates the specified entry on disk and copies data
 
181
from the archive.
 
182
In particular, note that
 
183
.Fn archive_read_extract
 
184
uses the
 
185
.Tn struct archive_entry
 
186
structure that you provide it, which may differ from the
 
187
entry just read from the archive.
 
188
In particular, many applications will want to override the
 
189
pathname, file permissions, or ownership.
 
190
.Pp
 
191
Once you have finished reading data from the archive, you
 
192
should call
 
193
.Fn archive_read_close
 
194
to close the archive, then call
 
195
.Fn archive_read_finish
 
196
to release all resources, including all memory allocated by the library.
 
197
.Pp
 
198
The
 
199
.Xr archive_read 3
 
200
manual page provides more detailed calling information for this API.
 
201
.Sh WRITING AN ARCHIVE
 
202
You use a similar process to write an archive.
 
203
The
 
204
.Fn archive_write_new
 
205
function creates an archive object useful for writing,
 
206
the various
 
207
.Fn archive_write_set_XXX
 
208
functions are used to set parameters for writing the archive, and
 
209
.Fn archive_write_open
 
210
completes the setup and opens the archive for writing.
 
211
.Pp
 
212
Individual archive entries are written in a three-step
 
213
process:
 
214
You first initialize a
 
215
.Tn struct archive_entry
 
216
structure with information about the new entry.
 
217
At a minimum, you should set the pathname of the
 
218
entry and provide a
 
219
.Va struct stat
 
220
with a valid
 
221
.Va st_mode
 
222
field, which specifies the type of object and
 
223
.Va st_size
 
224
field, which specifies the size of the data portion of the object.
 
225
The
 
226
.Fn archive_write_header
 
227
function actually writes the header data to the archive.
 
228
You can then use
 
229
.Fn archive_write_data
 
230
to write the actual data.
 
231
.Pp
 
232
After all entries have been written, use the
 
233
.Fn archive_write_finish
 
234
function to release all resources.
 
235
.Pp
 
236
The
 
237
.Xr archive_write 3
 
238
manual page provides more detailed calling information for this API.
 
239
.Sh DESCRIPTION
 
240
Detailed descriptions of each function are provided by the
 
241
corresponding manual pages.
 
242
.Pp
 
243
All of the functions utilize an opaque
 
244
.Tn struct archive
 
245
datatype that provides access to the archive contents.
 
246
.Pp
 
247
The
 
248
.Tn struct archive_entry
 
249
structure contains a complete description of a single archive
 
250
entry.
 
251
It uses an opaque interface that is fully documented in
 
252
.Xr archive_entry 3 .
 
253
.Pp
 
254
Users familiar with historic formats should be aware that the newer
 
255
variants have eliminated most restrictions on the length of textual fields.
 
256
Clients should not assume that filenames, link names, user names, or
 
257
group names are limited in length.
 
258
In particular, pax interchange format can easily accommodate pathnames
 
259
in arbitrary character sets that exceed
 
260
.Va PATH_MAX .
 
261
.Sh RETURN VALUES
 
262
Most functions return zero on success, non-zero on error.
 
263
The return value indicates the general severity of the error, ranging
 
264
from
 
265
.Cm ARCHIVE_WARN ,
 
266
which indicates a minor problem that should probably be reported
 
267
to the user, to
 
268
.Cm ARCHIVE_FATAL ,
 
269
which indicates a serious problem that will prevent any further
 
270
operations on this archive.
 
271
On error, the
 
272
.Fn archive_errno
 
273
function can be used to retrieve a numeric error code (see
 
274
.Xr errno 2 ) .
 
275
The
 
276
.Fn archive_error_string
 
277
returns a textual error message suitable for display.
 
278
.Pp
 
279
.Fn archive_read_new
 
280
and
 
281
.Fn archive_write_new
 
282
return pointers to an allocated and initialized
 
283
.Tn struct archive
 
284
object.
 
285
.Pp
 
286
.Fn archive_read_data
 
287
and
 
288
.Fn archive_write_data
 
289
return a count of the number of bytes actually read or written.
 
290
A value of zero indicates the end of the data for this entry.
 
291
A negative value indicates an error, in which case the
 
292
.Fn archive_errno
 
293
and
 
294
.Fn archive_error_string
 
295
functions can be used to obtain more information.
 
296
.Sh ENVIRONMENT
 
297
There are character set conversions within the
 
298
.Xr archive_entry 3
 
299
functions that are impacted by the currently-selected locale.
 
300
.Sh SEE ALSO
 
301
.Xr tar 1 ,
 
302
.Xr archive_entry 3 ,
 
303
.Xr archive_read 3 ,
 
304
.Xr archive_util 3 ,
 
305
.Xr archive_write 3 ,
 
306
.Xr tar 5
 
307
.Sh HISTORY
 
308
The
 
309
.Nm libarchive
 
310
library first appeared in
 
311
.Fx 5.3 .
 
312
.Sh AUTHORS
 
313
.An -nosplit
 
314
The
 
315
.Nm libarchive
 
316
library was written by
 
317
.An Tim Kientzle Aq kientzle@acm.org .
 
318
.Sh BUGS
 
319
Some archive formats support information that is not supported by
 
320
.Tn struct archive_entry .
 
321
Such information cannot be fully archived or restored using this library.
 
322
This includes, for example, comments, character sets,
 
323
or the arbitrary key/value pairs that can appear in
 
324
pax interchange format archives.
 
325
.Pp
 
326
Conversely, of course, not all of the information that can be
 
327
stored in an
 
328
.Tn struct archive_entry
 
329
is supported by all formats.
 
330
For example, cpio formats do not support nanosecond timestamps;
 
331
old tar formats do not support large device numbers.