]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - lib/libarchive/libarchive-formats.5
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.0.git] / lib / 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 December 27, 2009
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 However, it only writes POSIX-standard
55 .Dq ustar
56 and
57 .Dq pax interchange
58 formats.
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 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, but cannot write GNU sparse file entries.
79 .It Cm pax
80 The
81 .Xr libarchive 3
82 library can read and write POSIX-compliant pax interchange format
83 archives.
84 Pax interchange format archives are an extension of the older ustar
85 format that adds a separate entry with additional attributes stored
86 as key/value pairs immediately before each regular entry.
87 The presence of these additional entries is the only difference between
88 pax interchange format and the older ustar format.
89 The extended attributes are of unlimited length and are stored
90 as UTF-8 Unicode strings.
91 Keywords defined in the standard are in all lowercase; vendors are allowed
92 to define custom keys by preceding them with the vendor name in all uppercase.
93 When writing pax archives, libarchive uses many of the SCHILY keys
94 defined by Joerg Schilling's
95 .Dq star
96 archiver and a few LIBARCHIVE keys.
97 The libarchive library can read most of the SCHILY keys
98 and most of the GNU keys introduced by GNU tar.
99 It silently ignores any keywords that it does not understand.
100 .It Cm restricted pax
101 The libarchive library can also write pax archives in which it
102 attempts to suppress the extended attributes entry whenever
103 possible.
104 The result will be identical to a ustar archive unless the
105 extended attributes entry is required to store a long file
106 name, long linkname, extended ACL, file flags, or if any of the standard
107 ustar data (user name, group name, UID, GID, etc) cannot be fully
108 represented in the ustar header.
109 In all cases, the result can be dearchived by any program that
110 can read POSIX-compliant pax interchange format archives.
111 Programs that correctly read ustar format (see below) will also be
112 able to read this format; any extended attributes will be extracted as
113 separate files stored in
114 .Pa PaxHeader
115 directories.
116 .It Cm ustar
117 The libarchive library can both read and write this format.
118 This format has the following limitations:
119 .Bl -bullet -compact
120 .It
121 Device major and minor numbers are limited to 21 bits.
122 Nodes with larger numbers will not be added to the archive.
123 .It
124 Path names in the archive are limited to 255 bytes.
125 (Shorter if there is no / character in exactly the right place.)
126 .It
127 Symbolic links and hard links are stored in the archive with
128 the name of the referenced file.
129 This name is limited to 100 bytes.
130 .It
131 Extended attributes, file flags, and other extended
132 security information cannot be stored.
133 .It
134 Archive entries are limited to 8 gigabytes in size.
135 .El
136 Note that the pax interchange format has none of these restrictions.
137 .El
138 .Pp
139 The libarchive library also reads a variety of commonly-used extensions to
140 the basic tar format.
141 These extensions are recognized automatically whenever they appear.
142 .Bl -tag -width indent
143 .It Numeric extensions.
144 The POSIX standards require fixed-length numeric fields to be written with
145 some character position reserved for terminators.
146 Libarchive allows these fields to be written without terminator characters.
147 This extends the allowable range; in particular, ustar archives with this
148 extension can support entries up to 64 gigabytes in size.
149 Libarchive also recognizes base-256 values in most numeric fields.
150 This essentially removes all limitations on file size, modification time,
151 and device numbers.
152 .It Solaris extensions
153 Libarchive recognizes ACL and extended attribute records written
154 by Solaris tar.
155 Currently, libarchive only has support for old-style ACLs; the
156 newer NFSv4 ACLs are recognized but discarded.
157 .El
158 .Pp
159 The first tar program appeared in Seventh Edition Unix in 1979.
160 The first official standard for the tar file format was the
161 .Dq ustar
162 (Unix Standard Tar) format defined by POSIX in 1988.
163 POSIX.1-2001 extended the ustar format to create the
164 .Dq pax interchange
165 format.
166 .Ss Cpio Formats
167 The libarchive library can read a number of common cpio variants and can write
168 .Dq odc
169 and
170 .Dq newc
171 format archives.
172 A cpio archive stores each entry as a fixed-size header followed
173 by a variable-length filename and variable-length data.
174 Unlike the tar format, the cpio format does only minimal padding
175 of the header or file data.
176 There are several cpio variants, which differ primarily in
177 how they store the initial header: some store the values as
178 octal or hexadecimal numbers in ASCII, others as binary values of
179 varying byte order and length.
180 .Bl -tag -width indent
181 .It Cm binary
182 The libarchive library transparently reads both big-endian and little-endian
183 variants of the original binary cpio format.
184 This format used 32-bit binary values for file size and mtime,
185 and 16-bit binary values for the other fields.
186 .It Cm odc
187 The libarchive library can both read and write this
188 POSIX-standard format, which is officially known as the
189 .Dq cpio interchange format
190 or the
191 .Dq octet-oriented cpio archive format
192 and sometimes unofficially referred to as the
193 .Dq old character format .
194 This format stores the header contents as octal values in ASCII.
195 It is standard, portable, and immune from byte-order confusion.
196 File sizes and mtime are limited to 33 bits (8GB file size),
197 other fields are limited to 18 bits.
198 .It Cm SVR4
199 The libarchive library can read both CRC and non-CRC variants of
200 this format.
201 The SVR4 format uses eight-digit hexadecimal values for
202 all header fields.
203 This limits file size to 4GB, and also limits the mtime and
204 other fields to 32 bits.
205 The SVR4 format can optionally include a CRC of the file
206 contents, although libarchive does not currently verify this CRC.
207 .El
208 .Pp
209 Cpio first appeared in PWB/UNIX 1.0, which was released within
210 AT&T in 1977.
211 PWB/UNIX 1.0 formed the basis of System III Unix, released outside
212 of AT&T in 1981.
213 This makes cpio older than tar, although cpio was not included
214 in Version 7 AT&T Unix.
215 As a result, the tar command became much better known in universities
216 and research groups that used Version 7.
217 The combination of the
218 .Nm find
219 and
220 .Nm cpio
221 utilities provided very precise control over file selection.
222 Unfortunately, the format has many limitations that make it unsuitable
223 for widespread use.
224 Only the POSIX format permits files over 4GB, and its 18-bit
225 limit for most other fields makes it unsuitable for modern systems.
226 In addition, cpio formats only store numeric UID/GID values (not
227 usernames and group names), which can make it very difficult to correctly
228 transfer archives across systems with dissimilar user numbering.
229 .Ss Shar Formats
230 A
231 .Dq shell archive
232 is a shell script that, when executed on a POSIX-compliant
233 system, will recreate a collection of file system objects.
234 The libarchive library can write two different kinds of shar archives:
235 .Bl -tag -width indent
236 .It Cm shar
237 The traditional shar format uses a limited set of POSIX
238 commands, including
239 .Xr echo 1 ,
240 .Xr mkdir 1 ,
241 and
242 .Xr sed 1 .
243 It is suitable for portably archiving small collections of plain text files.
244 However, it is not generally well-suited for large archives
245 (many implementations of
246 .Xr sh 1
247 have limits on the size of a script) nor should it be used with non-text files.
248 .It Cm shardump
249 This format is similar to shar but encodes files using
250 .Xr uuencode 1
251 so that the result will be a plain text file regardless of the file contents.
252 It also includes additional shell commands that attempt to reproduce as
253 many file attributes as possible, including owner, mode, and flags.
254 The additional commands used to restore file attributes make
255 shardump archives less portable than plain shar archives.
256 .El
257 .Ss ISO9660 format
258 Libarchive can read and extract from files containing ISO9660-compliant
259 CDROM images.
260 In many cases, this can remove the need to burn a physical CDROM
261 just in order to read the files contained in an ISO9660 image.
262 It also avoids security and complexity issues that come with
263 virtual mounts and loopback devices.
264 Libarchive supports the most common Rockridge extensions and has partial
265 support for Joliet extensions.
266 If both extensions are present, the Joliet extensions will be
267 used and the Rockridge extensions will be ignored.
268 In particular, this can create problems with hardlinks and symlinks,
269 which are supported by Rockridge but not by Joliet.
270 .Ss Zip format
271 Libarchive can read and write zip format archives that have
272 uncompressed entries and entries compressed with the
273 .Dq deflate
274 algorithm.
275 Older zip compression algorithms are not supported.
276 It can extract jar archives, archives that use Zip64 extensions and many
277 self-extracting zip archives.
278 Libarchive reads Zip archives as they are being streamed,
279 which allows it to read archives of arbitrary size.
280 It currently does not use the central directory; this
281 limits libarchive's ability to support some self-extracting
282 archives and ones that have been modified in certain ways.
283 .Ss Archive (library) file format
284 The Unix archive format (commonly created by the
285 .Xr ar 1
286 archiver) is a general-purpose format which is
287 used almost exclusively for object files to be
288 read by the link editor
289 .Xr ld 1 .
290 The ar format has never been standardised.
291 There are two common variants:
292 the GNU format derived from SVR4,
293 and the BSD format, which first appeared in 4.4BSD.
294 The two differ primarily in their handling of filenames
295 longer than 15 characters:
296 the GNU/SVR4 variant writes a filename table at the beginning of the archive;
297 the BSD format stores each long filename in an extension
298 area adjacent to the entry.
299 Libarchive can read both extensions,
300 including archives that may include both types of long filenames.
301 Programs using libarchive can write GNU/SVR4 format
302 if they provide a filename table to be written into
303 the archive before any of the entries.
304 Any entries whose names are not in the filename table
305 will be written using BSD-style long filenames.
306 This can cause problems for programs such as
307 GNU ld that do not support the BSD-style long filenames.
308 .Ss mtree
309 Libarchive can read and write files in
310 .Xr mtree 5
311 format.
312 This format is not a true archive format, but rather a textual description
313 of a file hierarchy in which each line specifies the name of a file and
314 provides specific metadata about that file.
315 Libarchive can read all of the keywords supported by both
316 the NetBSD and FreeBSD versions of
317 .Xr mtree 1 ,
318 although many of the keywords cannot currently be stored in an
319 .Tn archive_entry
320 object.
321 When writing, libarchive supports use of the
322 .Xr archive_write_set_options 3
323 interface to specify which keywords should be included in the
324 output.
325 If libarchive was compiled with access to suitable
326 cryptographic libraries (such as the OpenSSL libraries),
327 it can compute hash entries such as
328 .Cm sha512
329 or
330 .Cm md5
331 from file data being written to the mtree writer.
332 .Pp
333 When reading an mtree file, libarchive will locate the corresponding
334 files on disk using the
335 .Cm contents
336 keyword if present or the regular filename.
337 If it can locate and open the file on disk, it will use that
338 to fill in any metadata that is missing from the mtree file
339 and will read the file contents and return those to the program
340 using libarchive.
341 If it cannot locate and open the file on disk, libarchive
342 will return an error for any attempt to read the entry
343 body.
344 .Sh SEE ALSO
345 .Xr ar 1 ,
346 .Xr cpio 1 ,
347 .Xr mkisofs 1 ,
348 .Xr shar 1 ,
349 .Xr tar 1 ,
350 .Xr zip 1 ,
351 .Xr zlib 3 ,
352 .Xr cpio 5 ,
353 .Xr mtree 5 ,
354 .Xr tar 5