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