Imported Upstream version 3.4.1
[platform/upstream/libarchive.git] / doc / wiki / ManPageLibarchive3.wiki
1 LIBARCHIVE(3) manual page 
2 == NAME == 
3 '''libarchive''' 
4 - functions for reading and writing streaming archives 
5 == OVERVIEW == 
6 The 
7 '''libarchive''' 
8 library provides a flexible interface for reading and writing 
9 archives in various formats such as tar and cpio. 
10 '''libarchive''' 
11 also supports reading and writing archives compressed using 
12 various compression filters such as gzip and bzip2. 
13 The library is inherently stream-oriented; readers serially iterate through 
14 the archive, writers serially add things to the archive. 
15 In particular, note that there is currently no built-in support for 
16 random access nor for in-place modification. 
17
18 When reading an archive, the library automatically detects the 
19 format and the compression. 
20 The library currently has read support for: 
21 <ul> 
22 <li> 
23 old-style tar archives, 
24 </li><li> 
25 most variants of the POSIX 
26 "ustar" 
27 format, 
28 </li><li> 
29 the POSIX 
30 "pax interchange" 
31 format, 
32 </li><li> 
33 GNU-format tar archives, 
34 </li><li> 
35 most common cpio archive formats, 
36 </li><li> 
37 ISO9660 CD images (including RockRidge and Joliet extensions), 
38 </li><li> 
39 Zip archives, 
40 </li><li> 
41 ar archives (including GNU/SysV and BSD extensions), 
42 </li><li> 
43 Microsoft CAB archives, 
44 </li><li> 
45 LHA archives, 
46 </li><li> 
47 mtree file tree descriptions, 
48 </li><li> 
49 RAR archives, 
50 </li><li> 
51 XAR archives. 
52 </li></ul> 
53 The library automatically detects archives compressed with 
54 [[gzip(1)|http://www.freebsd.org/cgi/man.cgi?query=gzip&sektion=1]], 
55 [[bzip2(1)|http://www.freebsd.org/cgi/man.cgi?query=bzip2&sektion=1]], 
56 [[xz(1)|http://www.freebsd.org/cgi/man.cgi?query=xz&sektion=1]], 
57 [[lzip(1)|http://www.freebsd.org/cgi/man.cgi?query=lzip&sektion=1]], 
58 or 
59 [[compress(1)|http://www.freebsd.org/cgi/man.cgi?query=compress&sektion=1]] 
60 and decompresses them transparently. 
61 It can similarly detect and decode archives processed with 
62 [[uuencode(1)|http://www.freebsd.org/cgi/man.cgi?query=uuencode&sektion=1]] 
63 or which have an 
64 [[rpm(1)|http://www.freebsd.org/cgi/man.cgi?query=rpm&sektion=1]] 
65 header. 
66
67 When writing an archive, you can specify the compression 
68 to be used and the format to use. 
69 The library can write 
70 <ul> 
71 <li> 
72 POSIX-standard 
73 "ustar" 
74 archives, 
75 </li><li> 
76 POSIX 
77 "pax interchange format" 
78 archives, 
79 </li><li> 
80 POSIX octet-oriented cpio archives, 
81 </li><li> 
82 Zip archive, 
83 </li><li> 
84 two different variants of shar archives, 
85 </li><li> 
86 ISO9660 CD images, 
87 </li><li> 
88 7-Zip archives, 
89 </li><li> 
90 ar archives, 
91 </li><li> 
92 mtree file tree descriptions, 
93 </li><li> 
94 XAR archives. 
95 </li></ul> 
96 Pax interchange format is an extension of the tar archive format that 
97 eliminates essentially all of the limitations of historic tar formats 
98 in a standard fashion that is supported 
99 by POSIX-compliant 
100 [[pax(1)|http://www.freebsd.org/cgi/man.cgi?query=pax&sektion=1]] 
101 implementations on many systems as well as several newer implementations of 
102 [[ManPageBsdtar1]]. 
103 Note that the default write format will suppress the pax extended 
104 attributes for most entries; explicitly requesting pax format will 
105 enable those attributes for all entries. 
106
107 The read and write APIs are accessed through the 
108 '''archive_read_XXX'''() 
109 functions and the 
110 '''archive_write_XXX'''() 
111 functions, respectively, and either can be used independently 
112 of the other. 
113
114 The rest of this manual page provides an overview of the library 
115 operation. 
116 More detailed information can be found in the individual manual 
117 pages for each API or utility function. 
118 == READING AN ARCHIVE == 
119 See 
120 [[ManPagerchiveead3]]. 
121 == WRITING AN ARCHIVE == 
122 See 
123 [[ManPagerchiverite3]]. 
124 == WRITING ENTRIES TO DISK == 
125 The 
126 [[ManPagerchiveriteisk3]] 
127 API allows you to write 
128 [[ManPagerchiventry3]] 
129 objects to disk using the same API used by 
130 [[ManPagerchiverite3]]. 
131 The 
132 [[ManPagerchiveriteisk3]] 
133 API is used internally by 
134 '''archive_read_extract'''('';'') 
135 using it directly can provide greater control over how entries 
136 get written to disk. 
137 This API also makes it possible to share code between 
138 archive-to-archive copy and archive-to-disk extraction 
139 operations. 
140 == READING ENTRIES FROM DISK == 
141 The 
142 [[ManPagerchiveeadisk3]] 
143 supports for populating 
144 [[ManPagerchiventry3]] 
145 objects from information in the filesystem. 
146 This includes the information accessible from the 
147 [[stat(2)|http://www.freebsd.org/cgi/man.cgi?query=stat&sektion=2]] 
148 system call as well as ACLs, extended attributes, 
149 and other metadata. 
150 The 
151 [[ManPagerchiveeadisk3]] 
152 API also supports iterating over directory trees, 
153 which allows directories of files to be read using 
154 an API compatible with 
155 the 
156 [[ManPagerchiveead3]] 
157 API. 
158 == DESCRIPTION == 
159 Detailed descriptions of each function are provided by the 
160 corresponding manual pages. 
161
162 All of the functions utilize an opaque 
163 '''struct archive''' 
164 datatype that provides access to the archive contents. 
165
166 The 
167 '''struct archive_entry''' 
168 structure contains a complete description of a single archive 
169 entry. 
170 It uses an opaque interface that is fully documented in 
171 [[ManPagerchiventry3]]. 
172
173 Users familiar with historic formats should be aware that the newer 
174 variants have eliminated most restrictions on the length of textual fields. 
175 Clients should not assume that filenames, link names, user names, or 
176 group names are limited in length. 
177 In particular, pax interchange format can easily accommodate pathnames 
178 in arbitrary character sets that exceed 
179 ''PATH_MAX''. 
180 == RETURN VALUES == 
181 Most functions return 
182 '''ARCHIVE_OK''' 
183 (zero) on success, non-zero on error. 
184 The return value indicates the general severity of the error, ranging 
185 from 
186 '''ARCHIVE_WARN''', 
187 which indicates a minor problem that should probably be reported 
188 to the user, to 
189 '''ARCHIVE_FATAL''', 
190 which indicates a serious problem that will prevent any further 
191 operations on this archive. 
192 On error, the 
193 '''archive_errno'''() 
194 function can be used to retrieve a numeric error code (see 
195 [[errno(2)|http://www.freebsd.org/cgi/man.cgi?query=errno&sektion=2]]). 
196 The 
197 '''archive_error_string'''() 
198 returns a textual error message suitable for display. 
199
200 '''archive_read_new'''() 
201 and 
202 '''archive_write_new'''() 
203 return pointers to an allocated and initialized 
204 '''struct archive''' 
205 object. 
206
207 '''archive_read_data'''() 
208 and 
209 '''archive_write_data'''() 
210 return a count of the number of bytes actually read or written. 
211 A value of zero indicates the end of the data for this entry. 
212 A negative value indicates an error, in which case the 
213 '''archive_errno'''() 
214 and 
215 '''archive_error_string'''() 
216 functions can be used to obtain more information. 
217 == ENVIRONMENT == 
218 There are character set conversions within the 
219 [[ManPagerchiventry3]] 
220 functions that are impacted by the currently-selected locale. 
221 == SEE ALSO == 
222 [[ManPageBsdtar1]], 
223 [[ManPagerchiventry3]], 
224 [[ManPagerchiveead3]], 
225 [[ManPagerchivetil3]], 
226 [[ManPagerchiverite3]], 
227 [[ManPageTar5]] 
228 == HISTORY == 
229 The 
230 '''libarchive''' 
231 library first appeared in 
232 FreeBSD 5.3. 
233 == AUTHORS == 
234 The 
235 '''libarchive''' 
236 library was originally written by 
237 Tim Kientzle  &lt;kientzle@acm.org.&gt; 
238 == BUGS == 
239 Some archive formats support information that is not supported by 
240 '''struct archive_entry .''' 
241 Such information cannot be fully archived or restored using this library. 
242 This includes, for example, comments, character sets, 
243 or the arbitrary key/value pairs that can appear in 
244 pax interchange format archives. 
245
246 Conversely, of course, not all of the information that can be 
247 stored in an 
248 '''struct archive_entry''' 
249 is supported by all formats. 
250 For example, cpio formats do not support nanosecond timestamps; 
251 old tar formats do not support large device numbers. 
252
253 The ISO9660 reader cannot yet read all ISO9660 images; 
254 it should learn how to seek. 
255
256 The AR writer requires the client program to use 
257 two passes, unlike all other libarchive writers.