1LIBARCHIVE-FORMATS(5)       BSD File Formats Manual      LIBARCHIVE-FORMATS(5)
2

NAME

4     libarchive-formats — archive formats supported by the libarchive library
5

DESCRIPTION

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.  It can write
22     POSIX-standard “ustar” and “pax interchange” formats and a subset of the
23     legacy GNU tar format.
24
25     All tar formats store each entry in one or more 512-byte records.  The
26     first record is used for file metadata, including filename, timestamp,
27     and mode information, and the file data is stored in subsequent records.
28     Later variants have extended this by either appropriating undefined areas
29     of the header record, extending the header to multiple records, or by
30     storing special entries that modify the interpretation of subsequent
31     entries.
32
33     gnutar  The libarchive(3) library can read most GNU-format tar archives.
34             It currently supports the most popular GNU extensions, including
35             modern long filename and linkname support, as well as atime and
36             ctime data.  The libarchive library does not support multi-volume
37             archives, nor the old GNU long filename format.  It can read GNU
38             sparse file entries, including the new POSIX-based formats.
39
40             The libarchive(3) library can write GNU tar format, including
41             long filename and linkname support, as well as atime and ctime
42             data.
43
44     pax     The libarchive(3) library can read and write POSIX-compliant pax
45             interchange format archives.  Pax interchange format archives are
46             an extension of the older ustar format that adds a separate entry
47             with additional attributes stored as key/value pairs immediately
48             before each regular entry.  The presence of these additional
49             entries is the only difference between pax interchange format and
50             the older ustar format.  The extended attributes are of unlimited
51             length and are stored as UTF-8 Unicode strings.  Keywords defined
52             in the standard are in all lowercase; vendors are allowed to
53             define custom keys by preceding them with the vendor name in all
54             uppercase.  When writing pax archives, libarchive uses many of
55             the SCHILY keys defined by Joerg Schilling's “star” archiver and
56             a few LIBARCHIVE keys.  The libarchive library can read most of
57             the SCHILY keys and most of the GNU keys introduced by GNU tar.
58             It silently ignores any keywords that it does not understand.
59
60             The pax interchange format converts filenames to Unicode and
61             stores them using the UTF-8 encoding.  Prior to libarchive 3.0,
62             libarchive erroneously assumed that the system wide-character
63             routines natively supported Unicode.  This caused it to mis-han‐
64             dle non-ASCII filenames on systems that did not satisfy this
65             assumption.
66
67     restricted pax
68             The libarchive library can also write pax archives in which it
69             attempts to suppress the extended attributes entry whenever pos‐
70             sible.  The result will be identical to a ustar archive unless
71             the extended attributes entry is required to store a long file
72             name, long linkname, extended ACL, file flags, or if any of the
73             standard ustar data (user name, group name, UID, GID, etc) cannot
74             be fully represented in the ustar header.  In all cases, the
75             result can be dearchived by any program that can read POSIX-com‐
76             pliant pax interchange format archives.  Programs that correctly
77             read ustar format (see below) will also be able to read this for‐
78             mat; any extended attributes will be extracted as separate files
79             stored in PaxHeader directories.
80
81     ustar   The libarchive library can both read and write this format.  This
82             format has the following limitations:
83             ·   Device major and minor numbers are limited to 21 bits.  Nodes
84                 with larger numbers will not be added to the archive.
85             ·   Path names in the archive are limited to 255 bytes.  (Shorter
86                 if there is no / character in exactly the right place.)
87             ·   Symbolic links and hard links are stored in the archive with
88                 the name of the referenced file.  This name is limited to 100
89                 bytes.
90             ·   Extended attributes, file flags, and other extended security
91                 information cannot be stored.
92             ·   Archive entries are limited to 8 gigabytes in size.
93             Note that the pax interchange format has none of these restric‐
94             tions.  The ustar format is old and widely supported.  It is rec‐
95             ommended when compatibility is the primary concern.
96
97     The libarchive library also reads a variety of commonly-used extensions
98     to the basic tar format.  These extensions are recognized automatically
99     whenever they appear.
100
101     Numeric extensions.
102             The POSIX standards require fixed-length numeric fields to be
103             written with some character position reserved for terminators.
104             Libarchive allows these fields to be written without terminator
105             characters.  This extends the allowable range; in particular,
106             ustar archives with this extension can support entries up to 64
107             gigabytes in size.  Libarchive also recognizes base-256 values in
108             most numeric fields.  This essentially removes all limitations on
109             file size, modification time, and device numbers.
110
111     Solaris extensions
112             Libarchive recognizes ACL and extended attribute records written
113             by Solaris tar.  Currently, libarchive only has support for old-
114             style ACLs; the newer NFSv4 ACLs are recognized but discarded.
115
116     The first tar program appeared in Seventh Edition Unix in 1979.  The
117     first official standard for the tar file format was the “ustar” (Unix
118     Standard Tar) format defined by POSIX in 1988.  POSIX.1-2001 extended the
119     ustar format to create the “pax interchange” format.
120
121   Cpio Formats
122     The libarchive library can read a number of common cpio variants and can
123     write “odc” and “newc” format archives.  A cpio archive stores each entry
124     as a fixed-size header followed by a variable-length filename and vari‐
125     able-length data.  Unlike the tar format, the cpio format does only mini‐
126     mal padding of the header or file data.  There are several cpio variants,
127     which differ primarily in how they store the initial header: some store
128     the values as octal or hexadecimal numbers in ASCII, others as binary
129     values of varying byte order and length.
130
131     binary  The libarchive library transparently reads both big-endian and
132             little-endian variants of the original binary cpio format.  This
133             format used 32-bit binary values for file size and mtime, and
134             16-bit binary values for the other fields.
135
136     odc     The libarchive library can both read and write this POSIX-stan‐
137             dard format, which is officially known as the “cpio interchange
138             format” or the “octet-oriented cpio archive format” and sometimes
139             unofficially referred to as the “old character format”.  This
140             format stores the header contents as octal values in ASCII.  It
141             is standard, portable, and immune from byte-order confusion.
142             File sizes and mtime are limited to 33 bits (8GB file size),
143             other fields are limited to 18 bits.
144
145     SVR4    The libarchive library can read both CRC and non-CRC variants of
146             this format.  The SVR4 format uses eight-digit hexadecimal values
147             for all header fields.  This limits file size to 4GB, and also
148             limits the mtime and other fields to 32 bits.  The SVR4 format
149             can optionally include a CRC of the file contents, although
150             libarchive does not currently verify this CRC.
151
152     Cpio first appeared in PWB/UNIX 1.0, which was released within AT&T in
153     1977.  PWB/UNIX 1.0 formed the basis of System III Unix, released outside
154     of AT&T in 1981.  This makes cpio older than tar, although cpio was not
155     included in Version 7 AT&T Unix.  As a result, the tar command became
156     much better known in universities and research groups that used Version
157     7.  The combination of the find and cpio utilities provided very precise
158     control over file selection.  Unfortunately, the format has many limita‐
159     tions that make it unsuitable for widespread use.  Only the POSIX format
160     permits files over 4GB, and its 18-bit limit for most other fields makes
161     it unsuitable for modern systems.  In addition, cpio formats only store
162     numeric UID/GID values (not usernames and group names), which can make it
163     very difficult to correctly transfer archives across systems with dissim‐
164     ilar user numbering.
165
166   Shar Formats
167     A “shell archive” is a shell script that, when executed on a POSIX-com‐
168     pliant system, will recreate a collection of file system objects.  The
169     libarchive library can write two different kinds of shar archives:
170
171     shar    The traditional shar format uses a limited set of POSIX commands,
172             including echo(1), mkdir(1), and sed(1).  It is suitable for
173             portably archiving small collections of plain text files.  How‐
174             ever, it is not generally well-suited for large archives (many
175             implementations of sh(1) have limits on the size of a script) nor
176             should it be used with non-text files.
177
178     shardump
179             This format is similar to shar but encodes files using
180             uuencode(1) so that the result will be a plain text file regard‐
181             less of the file contents.  It also includes additional shell
182             commands that attempt to reproduce as many file attributes as
183             possible, including owner, mode, and flags.  The additional com‐
184             mands used to restore file attributes make shardump archives less
185             portable than plain shar archives.
186
187   ISO9660 format
188     Libarchive can read and extract from files containing ISO9660-compliant
189     CDROM images.  In many cases, this can remove the need to burn a physical
190     CDROM just in order to read the files contained in an ISO9660 image.  It
191     also avoids security and complexity issues that come with virtual mounts
192     and loopback devices.  Libarchive supports the most common Rockridge
193     extensions and has partial support for Joliet extensions.  If both exten‐
194     sions are present, the Joliet extensions will be used and the Rockridge
195     extensions will be ignored.  In particular, this can create problems with
196     hardlinks and symlinks, which are supported by Rockridge but not by
197     Joliet.
198
199     Libarchive reads ISO9660 images using a streaming strategy.  This allows
200     it to read compressed images directly (decompressing on the fly) and
201     allows it to read images directly from network sockets, pipes, and other
202     non-seekable data sources.  This strategy works well for optimized
203     ISO9660 images created by many popular programs.  Such programs collect
204     all directory information at the beginning of the ISO9660 image so it can
205     be read from a physical disk with a minimum of seeking.  However, not all
206     ISO9660 images can be read in this fashion.
207
208     Libarchive can also write ISO9660 images.  Such images are fully opti‐
209     mized with the directory information preceding all file data.  This is
210     done by storing all file data to a temporary file while collecting direc‐
211     tory information in memory.  When the image is finished, libarchive
212     writes out the directory structure followed by the file data.  The loca‐
213     tion used for the temporary file can be changed by the usual environment
214     variables.
215
216   Zip format
217     Libarchive can read and write zip format archives that have uncompressed
218     entries and entries compressed with the “deflate” algorithm.  Other zip
219     compression algorithms are not supported.  It can extract jar archives,
220     archives that use Zip64 extensions and self-extracting zip archives.
221     Libarchive can use either of two different strategies for reading Zip ar‐
222     chives: a streaming strategy which is fast and can handle extremely large
223     archives, and a seeking strategy which can correctly process self-
224     extracting Zip archives and archives with deleted members or other in-
225     place modifications.
226
227     The streaming reader processes Zip archives as they are read.  It can
228     read archives of arbitrary size from tape or network sockets, and can
229     decode Zip archives that have been separately compressed or encoded.
230     However, self-extracting Zip archives and archives with certain types of
231     modifications cannot be correctly handled.  Such archives require that
232     the reader first process the Central Directory, which is ordinarily
233     located at the end of a Zip archive and is thus inaccessible to the
234     streaming reader.  If the program using libarchive has enabled seek sup‐
235     port, then libarchive will use this to processes the central directory
236     first.
237
238     In particular, the seeking reader must be used to correctly handle self-
239     extracting archives.  Such archives consist of a program followed by a
240     regular Zip archive.  The streaming reader cannot parse the initial pro‐
241     gram portion, but the seeking reader starts by reading the Central Direc‐
242     tory from the end of the archive.  Similarly, Zip archives that have been
243     modified in-place can have deleted entries or other garbage data that can
244     only be accurately detected by first reading the Central Directory.
245
246   Archive (library) file format
247     The Unix archive format (commonly created by the ar(1) archiver) is a
248     general-purpose format which is used almost exclusively for object files
249     to be read by the link editor ld(1).  The ar format has never been stan‐
250     dardised.  There are two common variants: the GNU format derived from
251     SVR4, and the BSD format, which first appeared in 4.4BSD.  The two differ
252     primarily in their handling of filenames longer than 15 characters: the
253     GNU/SVR4 variant writes a filename table at the beginning of the archive;
254     the BSD format stores each long filename in an extension area adjacent to
255     the entry.  Libarchive can read both extensions, including archives that
256     may include both types of long filenames.  Programs using libarchive can
257     write GNU/SVR4 format if they provide a filename table to be written into
258     the archive before any of the entries.  Any entries whose names are not
259     in the filename table will be written using BSD-style long filenames.
260     This can cause problems for programs such as GNU ld that do not support
261     the BSD-style long filenames.
262
263   mtree
264     Libarchive can read and write files in mtree(5) format.  This format is
265     not a true archive format, but rather a textual description of a file
266     hierarchy in which each line specifies the name of a file and provides
267     specific metadata about that file.  Libarchive can read all of the key‐
268     words supported by both the NetBSD and FreeBSD versions of mtree(8),
269     although many of the keywords cannot currently be stored in an
270     archive_entry object.  When writing, libarchive supports use of the
271     archive_write_set_options(3) interface to specify which keywords should
272     be included in the output.  If libarchive was compiled with access to
273     suitable cryptographic libraries (such as the OpenSSL libraries), it can
274     compute hash entries such as sha512 or md5 from file data being written
275     to the mtree writer.
276
277     When reading an mtree file, libarchive will locate the corresponding
278     files on disk using the contents keyword if present or the regular file‐
279     name.  If it can locate and open the file on disk, it will use that to
280     fill in any metadata that is missing from the mtree file and will read
281     the file contents and return those to the program using libarchive.  If
282     it cannot locate and open the file on disk, libarchive will return an
283     error for any attempt to read the entry body.
284
285   LHA
286     XXX Information about libarchive's LHA support XXX
287
288   CAB
289     XXX Information about libarchive's CAB support XXX
290
291   XAR
292     XXX Information about libarchive's XAR support XXX
293
294   RAR
295     Libarchive has limited support for reading RAR format archives.  Cur‐
296     rently, libarchive can read RARv3 format archives which have been either
297     created uncompressed, or compressed using any of the compression methods
298     supported by the RARv3 format.  Libarchive can also read self-extracting
299     RAR archives.
300

SEE ALSO

302     ar(1), cpio(1), mkisofs(1), shar(1), tar(1), zip(1), zlib(3), cpio(5),
303     mtree(5), tar(5)
304
305BSD                             March 18, 2012                             BSD
Impressum