Imported Upstream version 3.3.1
[platform/upstream/libarchive.git] / doc / wiki / ManPageLibarchiveFormats5.wiki
1 LIBARCHIVE-FORMATS(5) manual page 
2 == NAME == 
3 '''libarchive-formats''' 
4 - archive formats supported by the libarchive library 
5 == DESCRIPTION == 
6 The 
7 [[ManPageLibarchive3]] 
8 library reads and writes a variety of streaming archive formats. 
9 Generally speaking, all of these archive formats consist of a series of 
10 "entries". 
11 Each entry stores a single file system object, such as a file, directory, 
12 or symbolic link. 
13
14 The following provides a brief description of each format supported 
15 by libarchive, with some information about recognized extensions or 
16 limitations of the current library support. 
17 Note that just because a format is supported by libarchive does not 
18 imply that a program that uses libarchive will support that format. 
19 Applications that use libarchive specify which formats they wish 
20 to support, though many programs do use libarchive convenience 
21 functions to enable all supported formats. 
22 === Tar Formats=== 
23 The 
24 [[ManPageLibarchive3]] 
25 library can read most tar archives. 
26 It can write POSIX-standard 
27 "ustar" 
28 and 
29 "pax interchange" 
30 formats as well as v7 tar format and a subset of the legacy GNU tar format. 
31
32 All tar formats store each entry in one or more 512-byte records. 
33 The first record is used for file metadata, including filename, 
34 timestamp, and mode information, and the file data is stored in 
35 subsequent records. 
36 Later variants have extended this by either appropriating undefined 
37 areas of the header record, extending the header to multiple records, 
38 or by storing special entries that modify the interpretation of 
39 subsequent entries. 
40 <dl> 
41 <dt>'''gnutar'''</dt><dd> 
42 The 
43 [[ManPageLibarchive3]] 
44 library can read most GNU-format tar archives. 
45 It currently supports the most popular GNU extensions, including 
46 modern long filename and linkname support, as well as atime and ctime data. 
47 The libarchive library does not support multi-volume 
48 archives, nor the old GNU long filename format. 
49 It can read GNU sparse file entries, including the new POSIX-based 
50 formats. 
51
52 The 
53 [[ManPageLibarchive3]] 
54 library can write GNU tar format, including long filename 
55 and linkname support, as well as atime and ctime data. 
56 </dd><dt>'''pax'''</dt><dd> 
57 The 
58 [[ManPageLibarchive3]] 
59 library can read and write POSIX-compliant pax interchange format 
60 archives. 
61 Pax interchange format archives are an extension of the older ustar 
62 format that adds a separate entry with additional attributes stored 
63 as key/value pairs immediately before each regular entry. 
64 The presence of these additional entries is the only difference between 
65 pax interchange format and the older ustar format. 
66 The extended attributes are of unlimited length and are stored 
67 as UTF-8 Unicode strings. 
68 Keywords defined in the standard are in all lowercase; vendors are allowed 
69 to define custom keys by preceding them with the vendor name in all uppercase. 
70 When writing pax archives, libarchive uses many of the SCHILY keys 
71 defined by Joerg Schilling's 
72 "star" 
73 archiver and a few LIBARCHIVE keys. 
74 The libarchive library can read most of the SCHILY keys 
75 and most of the GNU keys introduced by GNU tar. 
76 It silently ignores any keywords that it does not understand. 
77
78 The pax interchange format converts filenames to Unicode 
79 and stores them using the UTF-8 encoding. 
80 Prior to libarchive 3.0, libarchive erroneously assumed 
81 that the system wide-character routines natively supported 
82 Unicode. 
83 This caused it to mis-handle non-ASCII filenames on systems 
84 that did not satisfy this assumption. 
85 </dd><dt>'''restricted''' pax</dt><dd> 
86 The libarchive library can also write pax archives in which it 
87 attempts to suppress the extended attributes entry whenever 
88 possible. 
89 The result will be identical to a ustar archive unless the 
90 extended attributes entry is required to store a long file 
91 name, long linkname, extended ACL, file flags, or if any of the standard 
92 ustar data (user name, group name, UID, GID, etc) cannot be fully 
93 represented in the ustar header. 
94 In all cases, the result can be dearchived by any program that 
95 can read POSIX-compliant pax interchange format archives. 
96 Programs that correctly read ustar format (see below) will also be 
97 able to read this format; any extended attributes will be extracted as 
98 separate files stored in 
99 ''PaxHeader'' 
100 directories. 
101 </dd><dt>'''ustar'''</dt><dd> 
102 The libarchive library can both read and write this format. 
103 This format has the following limitations: 
104 <ul> 
105 <li> 
106 Device major and minor numbers are limited to 21 bits. 
107 Nodes with larger numbers will not be added to the archive. 
108 </li><li> 
109 Path names in the archive are limited to 255 bytes. 
110 (Shorter if there is no / character in exactly the right place.) 
111 </li><li> 
112 Symbolic links and hard links are stored in the archive with 
113 the name of the referenced file. 
114 This name is limited to 100 bytes. 
115 </li><li> 
116 Extended attributes, file flags, and other extended 
117 security information cannot be stored. 
118 </li><li> 
119 Archive entries are limited to 8 gigabytes in size. 
120 </li></ul> 
121 Note that the pax interchange format has none of these restrictions. 
122 The ustar format is old and widely supported. 
123 It is recommended when compatibility is the primary concern. 
124 </dd><dt>'''v7'''</dt><dd> 
125 The libarchive library can read and write the legacy v7 tar format. 
126 This format has the following limitations: 
127 <ul> 
128 <li> 
129 Only regular files, directories, and symbolic links can be archived. 
130 Block and character device nodes, FIFOs, and sockets cannot be archived. 
131 </li><li> 
132 Path names in the archive are limited to 100 bytes. 
133 </li><li> 
134 Symbolic links and hard links are stored in the archive with 
135 the name of the referenced file. 
136 This name is limited to 100 bytes. 
137 </li><li> 
138 User and group information are stored as numeric IDs; there 
139 is no provision for storing user or group names. 
140 </li><li> 
141 Extended attributes, file flags, and other extended 
142 security information cannot be stored. 
143 </li><li> 
144 Archive entries are limited to 8 gigabytes in size. 
145 </li></ul> 
146 Generally, users should prefer the ustar format for portability 
147 as the v7 tar format is both less useful and less portable. 
148 </dd></dl> 
149
150 The libarchive library also reads a variety of commonly-used extensions to 
151 the basic tar format. 
152 These extensions are recognized automatically whenever they appear. 
153 <dl> 
154 <dt>Numeric extensions.</dt><dd> 
155 The POSIX standards require fixed-length numeric fields to be written with 
156 some character position reserved for terminators. 
157 Libarchive allows these fields to be written without terminator characters. 
158 This extends the allowable range; in particular, ustar archives with this 
159 extension can support entries up to 64 gigabytes in size. 
160 Libarchive also recognizes base-256 values in most numeric fields. 
161 This essentially removes all limitations on file size, modification time, 
162 and device numbers. 
163 </dd><dt>Solaris extensions</dt><dd> 
164 Libarchive recognizes ACL and extended attribute records written 
165 by Solaris tar. 
166 </dd></dl> 
167
168 The first tar program appeared in Seventh Edition Unix in 1979. 
169 The first official standard for the tar file format was the 
170 "ustar" 
171 (Unix Standard Tar) format defined by POSIX in 1988. 
172 POSIX.1-2001 extended the ustar format to create the 
173 "pax interchange" 
174 format. 
175 === Cpio Formats=== 
176 The libarchive library can read a number of common cpio variants and can write 
177 "odc" 
178 and 
179 "newc" 
180 format archives. 
181 A cpio archive stores each entry as a fixed-size header followed 
182 by a variable-length filename and variable-length data. 
183 Unlike the tar format, the cpio format does only minimal padding 
184 of the header or file data. 
185 There are several cpio variants, which differ primarily in 
186 how they store the initial header: some store the values as 
187 octal or hexadecimal numbers in ASCII, others as binary values of 
188 varying byte order and length. 
189 <dl> 
190 <dt>'''binary'''</dt><dd> 
191 The libarchive library transparently reads both big-endian and little-endian 
192 variants of the original binary cpio format. 
193 This format used 32-bit binary values for file size and mtime, 
194 and 16-bit binary values for the other fields. 
195 </dd><dt>'''odc'''</dt><dd> 
196 The libarchive library can both read and write this 
197 POSIX-standard format, which is officially known as the 
198 "cpio interchange format" 
199 or the 
200 "octet-oriented cpio archive format" 
201 and sometimes unofficially referred to as the 
202 "old character format". 
203 This format stores the header contents as octal values in ASCII. 
204 It is standard, portable, and immune from byte-order confusion. 
205 File sizes and mtime are limited to 33 bits (8GB file size), 
206 other fields are limited to 18 bits. 
207 </dd><dt>'''SVR4/newc'''</dt><dd> 
208 The libarchive library can read both CRC and non-CRC variants of 
209 this format. 
210 The SVR4 format uses eight-digit hexadecimal values for 
211 all header fields. 
212 This limits file size to 4GB, and also limits the mtime and 
213 other fields to 32 bits. 
214 The SVR4 format can optionally include a CRC of the file 
215 contents, although libarchive does not currently verify this CRC. 
216 </dd></dl> 
217
218 Cpio first appeared in PWB/UNIX 1.0, which was released within 
219 AT&T in 1977. 
220 PWB/UNIX 1.0 formed the basis of System III Unix, released outside 
221 of AT&T in 1981. 
222 This makes cpio older than tar, although cpio was not included 
223 in Version 7 AT&T Unix. 
224 As a result, the tar command became much better known in universities 
225 and research groups that used Version 7. 
226 The combination of the 
227 '''find''' 
228 and 
229 '''cpio''' 
230 utilities provided very precise control over file selection. 
231 Unfortunately, the format has many limitations that make it unsuitable 
232 for widespread use. 
233 Only the POSIX format permits files over 4GB, and its 18-bit 
234 limit for most other fields makes it unsuitable for modern systems. 
235 In addition, cpio formats only store numeric UID/GID values (not 
236 usernames and group names), which can make it very difficult to correctly 
237 transfer archives across systems with dissimilar user numbering. 
238 === Shar Formats=== 
239
240 "shell archive" 
241 is a shell script that, when executed on a POSIX-compliant 
242 system, will recreate a collection of file system objects. 
243 The libarchive library can write two different kinds of shar archives: 
244 <dl> 
245 <dt>'''shar'''</dt><dd> 
246 The traditional shar format uses a limited set of POSIX 
247 commands, including 
248 [[echo(1)|http://www.freebsd.org/cgi/man.cgi?query=echo&sektion=1]], 
249 [[mkdir(1)|http://www.freebsd.org/cgi/man.cgi?query=mkdir&sektion=1]], 
250 and 
251 [[sed(1)|http://www.freebsd.org/cgi/man.cgi?query=sed&sektion=1]]. 
252 It is suitable for portably archiving small collections of plain text files. 
253 However, it is not generally well-suited for large archives 
254 (many implementations of 
255 [[sh(1)|http://www.freebsd.org/cgi/man.cgi?query=sh&sektion=1]] 
256 have limits on the size of a script) nor should it be used with non-text files. 
257 </dd><dt>'''shardump'''</dt><dd> 
258 This format is similar to shar but encodes files using 
259 [[uuencode(1)|http://www.freebsd.org/cgi/man.cgi?query=uuencode&sektion=1]] 
260 so that the result will be a plain text file regardless of the file contents. 
261 It also includes additional shell commands that attempt to reproduce as 
262 many file attributes as possible, including owner, mode, and flags. 
263 The additional commands used to restore file attributes make 
264 shardump archives less portable than plain shar archives. 
265 </dd></dl> 
266 === ISO9660 format=== 
267 Libarchive can read and extract from files containing ISO9660-compliant 
268 CDROM images. 
269 In many cases, this can remove the need to burn a physical CDROM 
270 just in order to read the files contained in an ISO9660 image. 
271 It also avoids security and complexity issues that come with 
272 virtual mounts and loopback devices. 
273 Libarchive supports the most common Rockridge extensions and has partial 
274 support for Joliet extensions. 
275 If both extensions are present, the Joliet extensions will be 
276 used and the Rockridge extensions will be ignored. 
277 In particular, this can create problems with hardlinks and symlinks, 
278 which are supported by Rockridge but not by Joliet. 
279
280 Libarchive reads ISO9660 images using a streaming strategy. 
281 This allows it to read compressed images directly 
282 (decompressing on the fly) and allows it to read images 
283 directly from network sockets, pipes, and other non-seekable 
284 data sources. 
285 This strategy works well for optimized ISO9660 images created 
286 by many popular programs. 
287 Such programs collect all directory information at the beginning 
288 of the ISO9660 image so it can be read from a physical disk 
289 with a minimum of seeking. 
290 However, not all ISO9660 images can be read in this fashion. 
291
292 Libarchive can also write ISO9660 images. 
293 Such images are fully optimized with the directory information 
294 preceding all file data. 
295 This is done by storing all file data to a temporary file 
296 while collecting directory information in memory. 
297 When the image is finished, libarchive writes out the 
298 directory structure followed by the file data. 
299 The location used for the temporary file can be changed 
300 by the usual environment variables. 
301 === Zip format=== 
302 Libarchive can read and write zip format archives that have 
303 uncompressed entries and entries compressed with the 
304 "deflate" 
305 algorithm. 
306 Other zip compression algorithms are not supported. 
307 It can extract jar archives, archives that use Zip64 extensions and 
308 self-extracting zip archives. 
309 Libarchive can use either of two different strategies for 
310 reading Zip archives: 
311 a streaming strategy which is fast and can handle extremely 
312 large archives, and a seeking strategy which can correctly 
313 process self-extracting Zip archives and archives with 
314 deleted members or other in-place modifications. 
315
316 The streaming reader processes Zip archives as they are read. 
317 It can read archives of arbitrary size from tape or 
318 network sockets, and can decode Zip archives that have 
319 been separately compressed or encoded. 
320 However, self-extracting Zip archives and archives with 
321 certain types of modifications cannot be correctly 
322 handled. 
323 Such archives require that the reader first process the 
324 Central Directory, which is ordinarily located 
325 at the end of a Zip archive and is thus inaccessible 
326 to the streaming reader. 
327 If the program using libarchive has enabled seek support, then 
328 libarchive will use this to processes the central directory first. 
329
330 In particular, the seeking reader must be used to 
331 correctly handle self-extracting archives. 
332 Such archives consist of a program followed by a regular 
333 Zip archive. 
334 The streaming reader cannot parse the initial program 
335 portion, but the seeking reader starts by reading the 
336 Central Directory from the end of the archive. 
337 Similarly, Zip archives that have been modified in-place 
338 can have deleted entries or other garbage data that 
339 can only be accurately detected by first reading the 
340 Central Directory. 
341 === Archive (library) file format=== 
342 The Unix archive format (commonly created by the 
343 [[ar(1)|http://www.freebsd.org/cgi/man.cgi?query=ar&sektion=1]] 
344 archiver) is a general-purpose format which is 
345 used almost exclusively for object files to be 
346 read by the link editor 
347 [[ld(1)|http://www.freebsd.org/cgi/man.cgi?query=ld&sektion=1]]. 
348 The ar format has never been standardised. 
349 There are two common variants: 
350 the GNU format derived from SVR4, 
351 and the BSD format, which first appeared in 4.4BSD. 
352 The two differ primarily in their handling of filenames 
353 longer than 15 characters: 
354 the GNU/SVR4 variant writes a filename table at the beginning of the archive; 
355 the BSD format stores each long filename in an extension 
356 area adjacent to the entry. 
357 Libarchive can read both extensions, 
358 including archives that may include both types of long filenames. 
359 Programs using libarchive can write GNU/SVR4 format 
360 if they provide an entry called 
361 ''//'' 
362 containing a filename table to be written into the archive 
363 before any of the entries. 
364 Any entries whose names are not in the filename table 
365 will be written using BSD-style long filenames. 
366 This can cause problems for programs such as 
367 GNU ld that do not support the BSD-style long filenames. 
368 === mtree=== 
369 Libarchive can read and write files in 
370 [[ManPageMtree5]] 
371 format. 
372 This format is not a true archive format, but rather a textual description 
373 of a file hierarchy in which each line specifies the name of a file and 
374 provides specific metadata about that file. 
375 Libarchive can read all of the keywords supported by both 
376 the NetBSD and FreeBSD versions of 
377 [[mtree(8)|http://www.freebsd.org/cgi/man.cgi?query=mtree&sektion=8]], 
378 although many of the keywords cannot currently be stored in an 
379 '''archive_entry''' 
380 object. 
381 When writing, libarchive supports use of the 
382 [[ManPageArchiveWriteSetOptions3]] 
383 interface to specify which keywords should be included in the 
384 output. 
385 If libarchive was compiled with access to suitable 
386 cryptographic libraries (such as the OpenSSL libraries), 
387 it can compute hash entries such as 
388 '''sha512''' 
389 or 
390 '''md5''' 
391 from file data being written to the mtree writer. 
392
393 When reading an mtree file, libarchive will locate the corresponding 
394 files on disk using the 
395 '''contents''' 
396 keyword if present or the regular filename. 
397 If it can locate and open the file on disk, it will use that 
398 to fill in any metadata that is missing from the mtree file 
399 and will read the file contents and return those to the program 
400 using libarchive. 
401 If it cannot locate and open the file on disk, libarchive 
402 will return an error for any attempt to read the entry 
403 body. 
404 === 7-Zip=== 
405 Libarchive can read and write 7-Zip format archives. 
406 TODO: Need more information 
407 === CAB=== 
408 Libarchive can read Microsoft Cabinet ( 
409 "CAB )" 
410 format archives. 
411 TODO: Need more information. 
412 === LHA=== 
413 TODO: Information about libarchive's LHA support 
414 === RAR=== 
415 Libarchive has limited support for reading RAR format archives. 
416 Currently, libarchive can read RARv3 format archives 
417 which have been either created uncompressed, or compressed using 
418 any of the compression methods supported by the RARv3 format. 
419 Libarchive can also read self-extracting RAR archives. 
420 === Warc=== 
421 Libarchive can read and write 
422 "web archives". 
423 TODO: Need more information 
424 === XAR=== 
425 Libarchive can read and write the XAR format used by many Apple tools. 
426 TODO: Need more information 
427 == SEE ALSO == 
428 [[ar(1)|http://www.freebsd.org/cgi/man.cgi?query=ar&sektion=1]], 
429 [[ManPageBsdcpio1]], 
430 [[mkisofs(1)|http://www.freebsd.org/cgi/man.cgi?query=mkisofs&sektion=1]], 
431 [[shar(1)|http://www.freebsd.org/cgi/man.cgi?query=shar&sektion=1]], 
432 [[ManPageBsdtar1]], 
433 [[zip(1)|http://www.freebsd.org/cgi/man.cgi?query=zip&sektion=1]], 
434 [[zlib(3)|http://www.freebsd.org/cgi/man.cgi?query=zlib&sektion=3]], 
435 [[ManPageCpio5]], 
436 [[ManPageMtree5]], 
437 [[ManPageTar5]]