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 as well as v7 tar
23     format and a subset of the 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 en‐
31     tries.
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 en‐
49             tries 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 de‐
53             fine 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 as‐
65             sumption.
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 re‐
75             sult can be dearchived by any program that can read POSIX-compli‐
76             ant 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     v7      The libarchive library can read and write the legacy v7 tar for‐
98             mat.  This format has the following limitations:
99             Only regular files, directories, and symbolic links can be
100                 archived.  Block and character device nodes, FIFOs, and sock‐
101                 ets cannot be archived.
102             Path names in the archive are limited to 100 bytes.
103             Symbolic links and hard links are stored in the archive with
104                 the name of the referenced file.  This name is limited to 100
105                 bytes.
106             User and group information are stored as numeric IDs; there
107                 is no provision for storing user or group names.
108             Extended attributes, file flags, and other extended security
109                 information cannot be stored.
110             Archive entries are limited to 8 gigabytes in size.
111             Generally, users should prefer the ustar format for portability
112             as the v7 tar format is both less useful and less portable.
113
114     The libarchive library also reads a variety of commonly-used extensions
115     to the basic tar format.  These extensions are recognized automatically
116     whenever they appear.
117
118     Numeric extensions.
119             The POSIX standards require fixed-length numeric fields to be
120             written with some character position reserved for terminators.
121             Libarchive allows these fields to be written without terminator
122             characters.  This extends the allowable range; in particular, us‐
123             tar archives with this extension can support entries up to 64 gi‐
124             gabytes in size.  Libarchive also recognizes base-256 values in
125             most numeric fields.  This essentially removes all limitations on
126             file size, modification time, and device numbers.
127
128     Solaris extensions
129             Libarchive recognizes ACL and extended attribute records written
130             by Solaris tar.
131
132     The first tar program appeared in Seventh Edition Unix in 1979.  The
133     first official standard for the tar file format was the “ustar” (Unix
134     Standard Tar) format defined by POSIX in 1988.  POSIX.1-2001 extended the
135     ustar format to create the “pax interchange” format.
136
137   Cpio Formats
138     The libarchive library can read and write a number of common cpio vari‐
139     ants.  A cpio archive stores each entry as a fixed-size header followed
140     by a variable-length filename and variable-length data.  Unlike the tar
141     format, the cpio format does only minimal padding of the header or file
142     data.  There are several cpio variants, which differ primarily in how
143     they store the initial header: some store the values as octal or hexadec‐
144     imal numbers in ASCII, others as binary values of varying byte order and
145     length.
146
147     binary  The libarchive library transparently reads both big-endian and
148             little-endian variants of the the two binary cpio formats; the
149             original one from PWB/UNIX, and the later, more widely used,
150             variant.  This format used 32-bit binary values for file size and
151             mtime, and 16-bit binary values for the other fields.  The for‐
152             mats support only the file types present in UNIX at the time of
153             their creation.  File sizes are limited to 24 bits in the PWB
154             format, because of the limits of the file system, and to 31 bits
155             in the newer binary format, where signed 32 bit longs were used.
156
157     odc     This is the POSIX standardized format, which is officially known
158             as the “cpio interchange format” or the “octet-oriented cpio
159             archive format” and sometimes unofficially referred to as the
160             “old character format”.  This format stores the header contents
161             as octal values in ASCII.  It is standard, portable, and immune
162             from byte-order confusion.  File sizes and mtime are limited to
163             33 bits (8GB file size), other fields are limited to 18 bits.
164
165     SVR4/newc
166             The libarchive library can read both CRC and non-CRC variants of
167             this format.  The SVR4 format uses eight-digit hexadecimal values
168             for all header fields.  This limits file size to 4GB, and also
169             limits the mtime and other fields to 32 bits.  The SVR4 format
170             can optionally include a CRC of the file contents, although
171             libarchive does not currently verify this CRC.
172
173     Cpio first appeared in PWB/UNIX 1.0, which was released within AT&T in
174     1977.  PWB/UNIX 1.0 formed the basis of System III Unix, released outside
175     of AT&T in 1981.  This makes cpio older than tar, although cpio was not
176     included in Version 7 AT&T Unix.  As a result, the tar command became
177     much better known in universities and research groups that used Version
178     7.  The combination of the find and cpio utilities provided very precise
179     control over file selection.  Unfortunately, the format has many limita‐
180     tions that make it unsuitable for widespread use.  Only the POSIX format
181     permits files over 4GB, and its 18-bit limit for most other fields makes
182     it unsuitable for modern systems.  In addition, cpio formats only store
183     numeric UID/GID values (not usernames and group names), which can make it
184     very difficult to correctly transfer archives across systems with dissim‐
185     ilar user numbering.
186
187   Shar Formats
188     A “shell archive” is a shell script that, when executed on a POSIX-com‐
189     pliant system, will recreate a collection of file system objects.  The
190     libarchive library can write two different kinds of shar archives:
191
192     shar    The traditional shar format uses a limited set of POSIX commands,
193             including echo(1), mkdir(1), and sed(1).  It is suitable for
194             portably archiving small collections of plain text files.  How‐
195             ever, it is not generally well-suited for large archives (many
196             implementations of sh(1) have limits on the size of a script) nor
197             should it be used with non-text files.
198
199     shardump
200             This format is similar to shar but encodes files using
201             uuencode(1) so that the result will be a plain text file regard‐
202             less of the file contents.  It also includes additional shell
203             commands that attempt to reproduce as many file attributes as
204             possible, including owner, mode, and flags.  The additional com‐
205             mands used to restore file attributes make shardump archives less
206             portable than plain shar archives.
207
208   ISO9660 format
209     Libarchive can read and extract from files containing ISO9660-compliant
210     CDROM images.  In many cases, this can remove the need to burn a physical
211     CDROM just in order to read the files contained in an ISO9660 image.  It
212     also avoids security and complexity issues that come with virtual mounts
213     and loopback devices.  Libarchive supports the most common Rockridge ex‐
214     tensions and has partial support for Joliet extensions.  If both exten‐
215     sions are present, the Joliet extensions will be used and the Rockridge
216     extensions will be ignored.  In particular, this can create problems with
217     hardlinks and symlinks, which are supported by Rockridge but not by
218     Joliet.
219
220     Libarchive reads ISO9660 images using a streaming strategy.  This allows
221     it to read compressed images directly (decompressing on the fly) and al‐
222     lows it to read images directly from network sockets, pipes, and other
223     non-seekable data sources.  This strategy works well for optimized
224     ISO9660 images created by many popular programs.  Such programs collect
225     all directory information at the beginning of the ISO9660 image so it can
226     be read from a physical disk with a minimum of seeking.  However, not all
227     ISO9660 images can be read in this fashion.
228
229     Libarchive can also write ISO9660 images.  Such images are fully opti‐
230     mized with the directory information preceding all file data.  This is
231     done by storing all file data to a temporary file while collecting direc‐
232     tory information in memory.  When the image is finished, libarchive
233     writes out the directory structure followed by the file data.  The loca‐
234     tion used for the temporary file can be changed by the usual environment
235     variables.
236
237   Zip format
238     Libarchive can read and write zip format archives that have uncompressed
239     entries and entries compressed with the “deflate” algorithm.  Other zip
240     compression algorithms are not supported.  It can extract jar archives,
241     archives that use Zip64 extensions and self-extracting zip archives.
242     Libarchive can use either of two different strategies for reading Zip ar‐
243     chives: a streaming strategy which is fast and can handle extremely large
244     archives, and a seeking strategy which can correctly process self-ex‐
245     tracting Zip archives and archives with deleted members or other in-place
246     modifications.
247
248     The streaming reader processes Zip archives as they are read.  It can
249     read archives of arbitrary size from tape or network sockets, and can de‐
250     code Zip archives that have been separately compressed or encoded.  How‐
251     ever, self-extracting Zip archives and archives with certain types of
252     modifications cannot be correctly handled.  Such archives require that
253     the reader first process the Central Directory, which is ordinarily lo‐
254     cated at the end of a Zip archive and is thus inaccessible to the stream‐
255     ing reader.  If the program using libarchive has enabled seek support,
256     then libarchive will use this to processes the central directory first.
257
258     In particular, the seeking reader must be used to correctly handle self-
259     extracting archives.  Such archives consist of a program followed by a
260     regular Zip archive.  The streaming reader cannot parse the initial pro‐
261     gram portion, but the seeking reader starts by reading the Central Direc‐
262     tory from the end of the archive.  Similarly, Zip archives that have been
263     modified in-place can have deleted entries or other garbage data that can
264     only be accurately detected by first reading the Central Directory.
265
266   Archive (library) file format
267     The Unix archive format (commonly created by the ar(1) archiver) is a
268     general-purpose format which is used almost exclusively for object files
269     to be read by the link editor ld(1).  The ar format has never been stan‐
270     dardised.  There are two common variants: the GNU format derived from
271     SVR4, and the BSD format, which first appeared in 4.4BSD.  The two differ
272     primarily in their handling of filenames longer than 15 characters: the
273     GNU/SVR4 variant writes a filename table at the beginning of the archive;
274     the BSD format stores each long filename in an extension area adjacent to
275     the entry.  Libarchive can read both extensions, including archives that
276     may include both types of long filenames.  Programs using libarchive can
277     write GNU/SVR4 format if they provide an entry called // containing a
278     filename table to be written into the archive before any of the entries.
279     Any entries whose names are not in the filename table will be written us‐
280     ing BSD-style long filenames.  This can cause problems for programs such
281     as GNU ld that do not support the BSD-style long filenames.
282
283   mtree
284     Libarchive can read and write files in mtree(5) format.  This format is
285     not a true archive format, but rather a textual description of a file hi‐
286     erarchy in which each line specifies the name of a file and provides spe‐
287     cific metadata about that file.  Libarchive can read all of the keywords
288     supported by both the NetBSD and FreeBSD versions of mtree(8), although
289     many of the keywords cannot currently be stored in an archive_entry ob‐
290     ject.  When writing, libarchive supports use of the
291     archive_write_set_options(3) interface to specify which keywords should
292     be included in the output.  If libarchive was compiled with access to
293     suitable cryptographic libraries (such as the OpenSSL libraries), it can
294     compute hash entries such as sha512 or md5 from file data being written
295     to the mtree writer.
296
297     When reading an mtree file, libarchive will locate the corresponding
298     files on disk using the contents keyword if present or the regular file‐
299     name.  If it can locate and open the file on disk, it will use that to
300     fill in any metadata that is missing from the mtree file and will read
301     the file contents and return those to the program using libarchive.  If
302     it cannot locate and open the file on disk, libarchive will return an er‐
303     ror for any attempt to read the entry body.
304
305   7-Zip
306     Libarchive can read and write 7-Zip format archives.  TODO: Need more in‐
307     formation
308
309   CAB
310     Libarchive can read Microsoft Cabinet ( “CAB”) format archives.  TODO:
311     Need more information.
312
313   LHA
314     TODO: Information about libarchive's LHA support
315
316   RAR
317     Libarchive has limited support for reading RAR format archives.  Cur‐
318     rently, libarchive can read RARv3 format archives which have been either
319     created uncompressed, or compressed using any of the compression methods
320     supported by the RARv3 format.  Libarchive can also read self-extracting
321     RAR archives.
322
323   Warc
324     Libarchive can read and write “web archives”.  TODO: Need more informa‐
325     tion
326
327   XAR
328     Libarchive can read and write the XAR format used by many Apple tools.
329     TODO: Need more information
330

SEE ALSO

332     ar(1), cpio(1), mkisofs(1), shar(1), tar(1), zip(1), zlib(3), cpio(5),
333     mtree(5), tar(5)
334
335BSD                            December 27, 2016                           BSD
Impressum