1libarchive-formats(5) BSD File Formats Manual libarchive-formats(5)
2
4 libarchive-formats — archive formats supported by the libarchive library
5
7 The libarchive(3) library reads and writes a variety of streaming archive
8 formats. Generally speaking, all of these archive formats consist of a
9 series of “entries”. Each entry stores a single file system object, such
10 as a file, directory, or symbolic link.
11
12 The following provides a brief description of each format supported by
13 libarchive, with some information about recognized extensions or limita‐
14 tions of the current library support. Note that just because a format is
15 supported by libarchive does not imply that a program that uses
16 libarchive will support that format. Applications that use libarchive
17 specify which formats they wish to support, though many programs do use
18 libarchive convenience functions to enable all supported formats.
19
20 Tar Formats
21 The libarchive(3) library can read most tar archives. However, it only
22 writes POSIX-standard “ustar” and “pax interchange” formats.
23
24 All tar formats store each entry in one or more 512-byte records. The
25 first record is used for file metadata, including filename, timestamp,
26 and mode information, and the file data is stored in subsequent records.
27 Later variants have extended this by either appropriating undefined areas
28 of the header record, extending the header to multiple records, or by
29 storing special entries that modify the interpretation of subsequent
30 entries.
31
32 gnutar The libarchive(3) library can read GNU-format tar archives. It
33 currently supports the most popular GNU extensions, including
34 modern long filename and linkname support, as well as atime and
35 ctime data. The libarchive library does not support multi-volume
36 archives, nor the old GNU long filename format. It can read GNU
37 sparse file entries, including the new POSIX-based formats, but
38 cannot write GNU sparse file entries.
39
40 pax The libarchive(3) library can read and write POSIX-compliant pax
41 interchange format archives. Pax interchange format archives are
42 an extension of the older ustar format that adds a separate entry
43 with additional attributes stored as key/value pairs immediately
44 before each regular entry. The presence of these additional
45 entries is the only difference between pax interchange format and
46 the older ustar format. The extended attributes are of unlimited
47 length and are stored as UTF-8 Unicode strings. Keywords defined
48 in the standard are in all lowercase; vendors are allowed to
49 define custom keys by preceding them with the vendor name in all
50 uppercase. When writing pax archives, libarchive uses many of
51 the SCHILY keys defined by Joerg Schilling's “star” archiver and
52 a few LIBARCHIVE keys. The libarchive library can read most of
53 the SCHILY keys and most of the GNU keys introduced by GNU tar.
54 It silently ignores any keywords that it does not understand.
55
56 restricted pax
57 The libarchive library can also write pax archives in which it
58 attempts to suppress the extended attributes entry whenever pos‐
59 sible. The result will be identical to a ustar archive unless
60 the extended attributes entry is required to store a long file
61 name, long linkname, extended ACL, file flags, or if any of the
62 standard ustar data (user name, group name, UID, GID, etc) cannot
63 be fully represented in the ustar header. In all cases, the
64 result can be dearchived by any program that can read POSIX-com‐
65 pliant pax interchange format archives. Programs that correctly
66 read ustar format (see below) will also be able to read this for‐
67 mat; any extended attributes will be extracted as separate files
68 stored in PaxHeader directories.
69
70 ustar The libarchive library can both read and write this format. This
71 format has the following limitations:
72 · Device major and minor numbers are limited to 21 bits. Nodes
73 with larger numbers will not be added to the archive.
74 · Path names in the archive are limited to 255 bytes. (Shorter
75 if there is no / character in exactly the right place.)
76 · Symbolic links and hard links are stored in the archive with
77 the name of the referenced file. This name is limited to 100
78 bytes.
79 · Extended attributes, file flags, and other extended security
80 information cannot be stored.
81 · Archive entries are limited to 8 gigabytes in size.
82 Note that the pax interchange format has none of these restric‐
83 tions.
84
85 The libarchive library also reads a variety of commonly-used extensions
86 to the basic tar format. These extensions are recognized automatically
87 whenever they appear.
88
89 Numeric extensions.
90 The POSIX standards require fixed-length numeric fields to be
91 written with some character position reserved for terminators.
92 Libarchive allows these fields to be written without terminator
93 characters. This extends the allowable range; in particular,
94 ustar archives with this extension can support entries up to 64
95 gigabytes in size. Libarchive also recognizes base-256 values in
96 most numeric fields. This essentially removes all limitations on
97 file size, modification time, and device numbers.
98
99 Solaris extensions
100 Libarchive recognizes ACL and extended attribute records written
101 by Solaris tar. Currently, libarchive only has support for old-
102 style ACLs; the newer NFSv4 ACLs are recognized but discarded.
103
104 The first tar program appeared in Seventh Edition Unix in 1979. The
105 first official standard for the tar file format was the “ustar” (Unix
106 Standard Tar) format defined by POSIX in 1988. POSIX.1-2001 extended the
107 ustar format to create the “pax interchange” format.
108
109 Cpio Formats
110 The libarchive library can read a number of common cpio variants and can
111 write “odc” and “newc” format archives. A cpio archive stores each entry
112 as a fixed-size header followed by a variable-length filename and vari‐
113 able-length data. Unlike the tar format, the cpio format does only mini‐
114 mal padding of the header or file data. There are several cpio variants,
115 which differ primarily in how they store the initial header: some store
116 the values as octal or hexadecimal numbers in ASCII, others as binary
117 values of varying byte order and length.
118
119 binary The libarchive library transparently reads both big-endian and
120 little-endian variants of the original binary cpio format. This
121 format used 32-bit binary values for file size and mtime, and
122 16-bit binary values for the other fields.
123
124 odc The libarchive library can both read and write this POSIX-stan‐
125 dard format, which is officially known as the “cpio interchange
126 format” or the “octet-oriented cpio archive format” and sometimes
127 unofficially referred to as the “old character format”. This
128 format stores the header contents as octal values in ASCII. It
129 is standard, portable, and immune from byte-order confusion.
130 File sizes and mtime are limited to 33 bits (8GB file size),
131 other fields are limited to 18 bits.
132
133 SVR4 The libarchive library can read both CRC and non-CRC variants of
134 this format. The SVR4 format uses eight-digit hexadecimal values
135 for all header fields. This limits file size to 4GB, and also
136 limits the mtime and other fields to 32 bits. The SVR4 format
137 can optionally include a CRC of the file contents, although
138 libarchive does not currently verify this CRC.
139
140 Cpio first appeared in PWB/UNIX 1.0, which was released within AT&T in
141 1977. PWB/UNIX 1.0 formed the basis of System III Unix, released outside
142 of AT&T in 1981. This makes cpio older than tar, although cpio was not
143 included in Version 7 AT&T Unix. As a result, the tar command became
144 much better known in universities and research groups that used Version
145 7. The combination of the find and cpio utilities provided very precise
146 control over file selection. Unfortunately, the format has many limita‐
147 tions that make it unsuitable for widespread use. Only the POSIX format
148 permits files over 4GB, and its 18-bit limit for most other fields makes
149 it unsuitable for modern systems. In addition, cpio formats only store
150 numeric UID/GID values (not usernames and group names), which can make it
151 very difficult to correctly transfer archives across systems with dissim‐
152 ilar user numbering.
153
154 Shar Formats
155 A “shell archive” is a shell script that, when executed on a POSIX-com‐
156 pliant system, will recreate a collection of file system objects. The
157 libarchive library can write two different kinds of shar archives:
158
159 shar The traditional shar format uses a limited set of POSIX commands,
160 including echo(1), mkdir(1), and sed(1). It is suitable for
161 portably archiving small collections of plain text files. How‐
162 ever, it is not generally well-suited for large archives (many
163 implementations of sh(1) have limits on the size of a script) nor
164 should it be used with non-text files.
165
166 shardump
167 This format is similar to shar but encodes files using
168 uuencode(1) so that the result will be a plain text file regard‐
169 less of the file contents. It also includes additional shell
170 commands that attempt to reproduce as many file attributes as
171 possible, including owner, mode, and flags. The additional com‐
172 mands used to restore file attributes make shardump archives less
173 portable than plain shar archives.
174
175 ISO9660 format
176 Libarchive can read and extract from files containing ISO9660-compliant
177 CDROM images. In many cases, this can remove the need to burn a physical
178 CDROM just in order to read the files contained in an ISO9660 image. It
179 also avoids security and complexity issues that come with virtual mounts
180 and loopback devices. Libarchive supports the most common Rockridge
181 extensions and has partial support for Joliet extensions. If both exten‐
182 sions are present, the Joliet extensions will be used and the Rockridge
183 extensions will be ignored. In particular, this can create problems with
184 hardlinks and symlinks, which are supported by Rockridge but not by
185 Joliet.
186
187 Zip format
188 Libarchive can read and write zip format archives that have uncompressed
189 entries and entries compressed with the “deflate” algorithm. Older zip
190 compression algorithms are not supported. It can extract jar archives,
191 archives that use Zip64 extensions and many self-extracting zip archives.
192 Libarchive reads Zip archives as they are being streamed, which allows it
193 to read archives of arbitrary size. It currently does not use the cen‐
194 tral directory; this limits libarchive's ability to support some self-
195 extracting archives and ones that have been modified in certain ways.
196
197 Archive (library) file format
198 The Unix archive format (commonly created by the ar(1) archiver) is a
199 general-purpose format which is used almost exclusively for object files
200 to be read by the link editor ld(1). The ar format has never been stan‐
201 dardised. There are two common variants: the GNU format derived from
202 SVR4, and the BSD format, which first appeared in 4.4BSD. The two differ
203 primarily in their handling of filenames longer than 15 characters: the
204 GNU/SVR4 variant writes a filename table at the beginning of the archive;
205 the BSD format stores each long filename in an extension area adjacent to
206 the entry. Libarchive can read both extensions, including archives that
207 may include both types of long filenames. Programs using libarchive can
208 write GNU/SVR4 format if they provide a filename table to be written into
209 the archive before any of the entries. Any entries whose names are not
210 in the filename table will be written using BSD-style long filenames.
211 This can cause problems for programs such as GNU ld that do not support
212 the BSD-style long filenames.
213
214 mtree
215 Libarchive can read and write files in mtree(5) format. This format is
216 not a true archive format, but rather a textual description of a file
217 hierarchy in which each line specifies the name of a file and provides
218 specific metadata about that file. Libarchive can read all of the key‐
219 words supported by both the NetBSD and FreeBSD versions of mtree(1),
220 although many of the keywords cannot currently be stored in an
221 archive_entry object. When writing, libarchive supports use of the
222 archive_write_set_options(3) interface to specify which keywords should
223 be included in the output. If libarchive was compiled with access to
224 suitable cryptographic libraries (such as the OpenSSL libraries), it can
225 compute hash entries such as sha512 or md5 from file data being written
226 to the mtree writer.
227
228 When reading an mtree file, libarchive will locate the corresponding
229 files on disk using the contents keyword if present or the regular file‐
230 name. If it can locate and open the file on disk, it will use that to
231 fill in any metadata that is missing from the mtree file and will read
232 the file contents and return those to the program using libarchive. If
233 it cannot locate and open the file on disk, libarchive will return an
234 error for any attempt to read the entry body.
235
237 ar(1), cpio(1), mkisofs(1), shar(1), tar(1), zip(1), zlib(3), cpio(5),
238 mtree(5), tar(5)
239
240BSD December 27, 2009 BSD