1 .\" Copyright (c) 2003-2007 Tim Kientzle
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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.
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
32 .Nd functions for reading and writing streaming archives
36 library provides a flexible interface for reading and writing
37 archives in various formats such as tar and cpio.
39 also supports reading and writing archives compressed using
40 various compression filters such as gzip and bzip2.
41 The library is inherently stream-oriented; readers serially iterate through
42 the archive, writers serially add things to the archive.
43 In particular, note that there is currently no built-in support for
44 random access nor for in-place modification.
46 When reading an archive, the library automatically detects the
47 format and the compression.
48 The library currently has read support for:
51 old-style tar archives,
53 most variants of the POSIX
61 GNU-format tar archives,
63 most common cpio archive formats,
65 ISO9660 CD images (including RockRidge and Joliet extensions),
69 ar archives (including GNU/SysV and BSD extensions),
71 Microsoft CAB archives,
75 mtree file tree descriptions,
81 The library automatically detects archives compressed with
88 and decompresses them transparently.
89 It can similarly detect and decode archives processed with
95 When writing an archive, you can specify the compression
96 to be used and the format to use.
105 .Dq pax interchange format
108 POSIX octet-oriented cpio archives,
112 two different variants of shar archives,
120 mtree file tree descriptions,
124 Pax interchange format is an extension of the tar archive format that
125 eliminates essentially all of the limitations of historic tar formats
126 in a standard fashion that is supported
129 implementations on many systems as well as several newer implementations of
131 Note that the default write format will suppress the pax extended
132 attributes for most entries; explicitly requesting pax format will
133 enable those attributes for all entries.
135 The read and write APIs are accessed through the
138 .Fn archive_write_XXX
139 functions, respectively, and either can be used independently
142 The rest of this manual page provides an overview of the library
144 More detailed information can be found in the individual manual
145 pages for each API or utility function.
147 .Sh READING AN ARCHIVE
149 .Xr libarchive_read 3 .
151 .Sh WRITING AN ARCHIVE
153 .Xr libarchive_write 3 .
155 .Sh WRITING ENTRIES TO DISK
157 .Xr archive_write_disk 3
158 API allows you to write
160 objects to disk using the same API used by
161 .Xr archive_write 3 .
163 .Xr archive_write_disk 3
164 API is used internally by
165 .Fn archive_read_extract ;
166 using it directly can provide greater control over how entries
168 This API also makes it possible to share code between
169 archive-to-archive copy and archive-to-disk extraction
171 .Sh READING ENTRIES FROM DISK
173 .Xr archive_read_disk 3
174 supports for populating
176 objects from information in the filesystem.
177 This includes the information accessible from the
179 system call as well as ACLs, extended attributes,
182 .Xr archive_read_disk 3
183 API also supports iterating over directory trees,
184 which allows directories of files to be read using
185 an API compatible with
190 Detailed descriptions of each function are provided by the
191 corresponding manual pages.
193 All of the functions utilize an opaque
195 datatype that provides access to the archive contents.
198 .Tn struct archive_entry
199 structure contains a complete description of a single archive
201 It uses an opaque interface that is fully documented in
202 .Xr archive_entry 3 .
204 Users familiar with historic formats should be aware that the newer
205 variants have eliminated most restrictions on the length of textual fields.
206 Clients should not assume that filenames, link names, user names, or
207 group names are limited in length.
208 In particular, pax interchange format can easily accommodate pathnames
209 in arbitrary character sets that exceed
212 Most functions return
214 (zero) on success, non-zero on error.
215 The return value indicates the general severity of the error, ranging
218 which indicates a minor problem that should probably be reported
221 which indicates a serious problem that will prevent any further
222 operations on this archive.
225 function can be used to retrieve a numeric error code (see
228 .Fn archive_error_string
229 returns a textual error message suitable for display.
233 .Fn archive_write_new
234 return pointers to an allocated and initialized
238 .Fn archive_read_data
240 .Fn archive_write_data
241 return a count of the number of bytes actually read or written.
242 A value of zero indicates the end of the data for this entry.
243 A negative value indicates an error, in which case the
246 .Fn archive_error_string
247 functions can be used to obtain more information.
249 There are character set conversions within the
251 functions that are impacted by the currently-selected locale.
254 .Xr archive_entry 3 ,
257 .Xr archive_write 3 ,
262 library first appeared in
268 library was originally written by
269 .An Tim Kientzle Aq kientzle@acm.org .
271 Some archive formats support information that is not supported by
272 .Tn struct archive_entry .
273 Such information cannot be fully archived or restored using this library.
274 This includes, for example, comments, character sets,
275 or the arbitrary key/value pairs that can appear in
276 pax interchange format archives.
278 Conversely, of course, not all of the information that can be
280 .Tn struct archive_entry
281 is supported by all formats.
282 For example, cpio formats do not support nanosecond timestamps;
283 old tar formats do not support large device numbers.
285 The ISO9660 reader cannot yet read all ISO9660 images;
286 it should learn how to seek.
288 The AR writer requires the client program to use
289 two passes, unlike all other libarchive writers.