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