Merge from vendor branch GDB:
[dragonfly.git] / contrib / libarchive / libarchive-formats.5
1 .\" Copyright (c) 2003-2004 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: src/lib/libarchive/libarchive-formats.5,v 1.6 2005/02/23 06:58:09 kientzle Exp $
26 .\"
27 .Dd April 27, 2004
28 .Dt libarchive-formats 3
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.
49 .Ss Tar Formats
50 The
51 .Xr libarchive 3
52 library can read most tar archives.
53 However, it only writes POSIX-standard
54 .Dq ustar
55 and
56 .Dq pax interchange
57 formats.
58 .Pp
59 All tar formats store each entry in one or more 512-byte records.
60 The first record is used for file metadata, including filename,
61 timestamp, and mode information, and the file data is stored in
62 subsequent records.
63 Later variants have extended this by either appropriating undefined
64 areas of the header record, extending the header to multiple records,
65 or by storing special entries that modify the interpretation of
66 subsequent entries.
67 .Pp
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 sparse files, multi-volume
76 archives, nor the old GNU long filename format.
77 .It Cm pax
78 The
79 .Xr libarchive 3
80 library can read and write POSIX-compliant pax interchange format
81 archives.
82 Pax interchange format archives are an extension of the older ustar
83 format that adds a separate entry with additional attributes stored
84 as key/value pairs.
85 The presence of this additional entry is the only difference between
86 pax interchange format and the older ustar format.
87 The extended attributes are of unlimited length and are stored
88 as UTF-8 Unicode strings.
89 Keywords defined in the standard are in all lowercase; vendors are allowed
90 to define custom keys by preceding them with the vendor name in all uppercase.
91 When writing pax archives, libarchive uses many of the SCHILY keys
92 defined by Joerg Schilling's
93 .Dq star
94 archiver.
95 The libarchive library can read most of the SCHILY keys.
96 It ignores any keywords that it does not understand.
97 .It Cm restricted pax
98 The libarchive library can also write pax archives in which it
99 attempts to suppress the extended attributes entry whenever
100 possible.
101 The result will be identical to a ustar archive unless the
102 extended attributes entry is required to store a long file
103 name, long linkname, extended ACL, file flags, or if any of the standard
104 ustar data (user name, group name, UID, GID, etc) cannot be fully
105 represented in the ustar header.
106 In all cases, the result can be dearchived by any program that
107 can read POSIX-compliant pax interchange format archives.
108 .It Cm ustar
109 The libarchive library can both read and write this format.
110 This format has the following limitations:
111 .Bl -bullet -compact
112 .It
113 Device major and minor numbers are limited to 21 bits.
114 Nodes with larger numbers will not be added to the archive.
115 .It
116 Path names in the archive are limited to 255 bytes.
117 (Shorter if there is no / character in exactly the right place.)
118 .It
119 Symbolic links and hard links are stored in the archive with
120 the name of the referenced file.
121 This name is limited to 100 bytes.
122 .It
123 Extended attributes, file flags, and other extended
124 security information cannot be stored.
125 .It
126 Archive entries are limited to 2 gigabytes in size.
127 .El
128 Note that the pax interchange format has none of these restrictions.
129 .El
130 .Pp
131 The libarchive library can also read a variety of commonly-used extensions to
132 the basic tar format.
133 In particular, it supports base-256 values in certain numeric fields.
134 This essentially removes the limitations on file size, modification time,
135 and device numbers.
136 .Pp
137 The first tar program appeared in Sixth Edition Unix (circa 1976).
138 This makes the tar format one of the oldest and most widely-supported
139 archive formats.
140 The first official standard for the tar file format was the
141 .Dq ustar
142 (Unix Standard Tar) format defined by POSIX in 1988.
143 POSIX.1-2001 extended the ustar format to create the
144 .Dq pax interchange
145 format.
146 There have also been many custom variations.
147 .Ss Cpio Formats
148 The libarchive library can read a number of common cpio variants and can write
149 .Dq odc
150 format archives.
151 A cpio archive stores each entry as a fixed-size header followed
152 by a variable-length filename and variable-length data.
153 Unlike tar, cpio does only minimal padding of the header or file data.
154 There are a variety of cpio formats, which differ primarily in
155 how they store the initial header: some store the values as
156 octal or hexadecimal numbers in ASCII, others as binary values of
157 varying byte order and length.
158 .Bl -tag -width indent
159 .It Cm binary
160 The libarchive library can read both big-endian and little-endian
161 variants of the original binary cpio format.
162 This format used 32-bit binary values for file size and mtime,
163 and 16-bit binary values for the other fields.
164 .It Cm odc
165 The libarchive library can both read and write this
166 POSIX-standard format.
167 This format stores the header contents as octal values in ASCII.
168 It is standard, portable, and immune from byte-order confusion.
169 File sizes and mtime are limited to 33 bits (8GB file size),
170 other fields are limited to 18 bits.
171 .It Cm SVR4
172 The libarchive library can read both CRC and non-CRC variants of
173 this format.
174 The SVR4 format uses eight-digit hexadecimal values for
175 all header fields.
176 This limits file size to 4GB, and also limits the mtime and
177 other fields to 32 bits.
178 The SVR4 format can optionally include a CRC of the file
179 contents, although libarchive does not currently verify this CRC.
180 .El
181 .Pp
182 Cpio is an old format that was widely used because of its simplicity
183 and its support for very long filenames.
184 Unfortunately, it has many limitations that make it unsuitable
185 for widespread use.
186 Only the POSIX format permits files over 4GB, and its 18-bit
187 limit for most other fields makes it unsuitable for modern systems.
188 In addition, cpio formats only store numeric UID/GID values (not
189 usernames and group names), which can make it very difficult to correctly
190 transfer archives across systems.
191 Finally, there is no good way to extend the format, which means that
192 ACLs, file flags, character encoding information, and non-standard file
193 types can not be added except by breaking compatibility with existing
194 implementations.
195 .Ss Shar Formats
196 A
197 .Dq shell archive
198 is a shell script that, when executed on a POSIX-compliant
199 system, will recreate a collection of file system objects.
200 The libarchive library can write two different kinds of shar archives:
201 .Bl -tag -width indent
202 .It Cm shar
203 The traditional shar format uses a limited set of POSIX
204 commands, including
205 .Xr echo 1 ,
206 .Xr mkdir 1 ,
207 and
208 .Xr sed 1 .
209 It is suitable for portably archiving small collections of plain text files.
210 However, it is not generally well-suited for large archives
211 (many implementations of
212 .Xr sh 1
213 have limits on the size of a script) nor should it be used with non-text files.
214 .It Cm shardump
215 This format is similar to shar but encodes files using
216 .Xr uuencode 1
217 so that the result will be a plain text file regardless of the file contents.
218 It also includes additional shell commands that attempt to reproduce as
219 many file attributes as possible, including owner, mode, and flags.
220 The additional commands used to restore file attributes make
221 shardump archives less portable than plain shar archives.
222 .El
223 .Ss ISO9660 format
224 Libarchive can read and extract from files containing ISO9660-compliant
225 CDROM images.  It also has partial support for Rockridge extensions.
226 In many cases, this can remove the need to burn a physical CDROM.
227 It also avoids security and complexity issues that come with
228 virtual mounts and loopback devices.
229 .Ss Zip format
230 Libarchive can extract from most zip format archives.
231 It currently only supports uncompressed entries and entries
232 compressed with the
233 .Dq deflate
234 algorithm.
235 Older zip compression algorithms are not supported.
236 .Sh SEE ALSO
237 .Xr cpio 1 ,
238 .Xr mkisofs 1 ,
239 .Xr shar 1 ,
240 .Xr tar 1 ,
241 .Xr zip 1 ,
242 .Xr zlib 3 ,
243 .Xr tar 5