Blame doc/text/libarchive-formats.5.txt

Packit 08bd4c
LIBARCHIVE-FORMATS(5)	    BSD File Formats Manual	 LIBARCHIVE-FORMATS(5)
Packit 08bd4c
Packit 08bd4c
NAME
Packit 08bd4c
     libarchive-formats — archive formats supported by the libarchive library
Packit 08bd4c
Packit 08bd4c
DESCRIPTION
Packit 08bd4c
     The libarchive(3) library reads and writes a variety of streaming archive
Packit 08bd4c
     formats.  Generally speaking, all of these archive formats consist of a
Packit 08bd4c
     series of “entries”.  Each entry stores a single file system object, such
Packit 08bd4c
     as a file, directory, or symbolic link.
Packit 08bd4c
Packit 08bd4c
     The following provides a brief description of each format supported by
Packit 08bd4c
     libarchive, with some information about recognized extensions or limita‐
Packit 08bd4c
     tions of the current library support.  Note that just because a format is
Packit 08bd4c
     supported by libarchive does not imply that a program that uses
Packit 08bd4c
     libarchive will support that format.  Applications that use libarchive
Packit 08bd4c
     specify which formats they wish to support, though many programs do use
Packit 08bd4c
     libarchive convenience functions to enable all supported formats.
Packit 08bd4c
Packit 08bd4c
   Tar Formats
Packit 08bd4c
     The libarchive(3) library can read most tar archives.  It can write
Packit 08bd4c
     POSIX-standard “ustar” and “pax interchange” formats as well as v7 tar
Packit 08bd4c
     format and a subset of the legacy GNU tar format.
Packit 08bd4c
Packit 08bd4c
     All tar formats store each entry in one or more 512-byte records.	The
Packit 08bd4c
     first record is used for file metadata, including filename, timestamp,
Packit 08bd4c
     and mode information, and the file data is stored in subsequent records.
Packit 08bd4c
     Later variants have extended this by either appropriating undefined areas
Packit 08bd4c
     of the header record, extending the header to multiple records, or by
Packit 08bd4c
     storing special entries that modify the interpretation of subsequent
Packit 08bd4c
     entries.
Packit 08bd4c
Packit 08bd4c
     gnutar  The libarchive(3) library can read most GNU-format tar archives.
Packit 08bd4c
	     It currently supports the most popular GNU extensions, including
Packit 08bd4c
	     modern long filename and linkname support, as well as atime and
Packit 08bd4c
	     ctime data.  The libarchive library does not support multi-volume
Packit 08bd4c
	     archives, nor the old GNU long filename format.  It can read GNU
Packit 08bd4c
	     sparse file entries, including the new POSIX-based formats.
Packit 08bd4c
Packit 08bd4c
	     The libarchive(3) library can write GNU tar format, including
Packit 08bd4c
	     long filename and linkname support, as well as atime and ctime
Packit 08bd4c
	     data.
Packit 08bd4c
Packit 08bd4c
     pax     The libarchive(3) library can read and write POSIX-compliant pax
Packit 08bd4c
	     interchange format archives.  Pax interchange format archives are
Packit 08bd4c
	     an extension of the older ustar format that adds a separate entry
Packit 08bd4c
	     with additional attributes stored as key/value pairs immediately
Packit 08bd4c
	     before each regular entry.  The presence of these additional
Packit 08bd4c
	     entries is the only difference between pax interchange format and
Packit 08bd4c
	     the older ustar format.  The extended attributes are of unlimited
Packit 08bd4c
	     length and are stored as UTF-8 Unicode strings.  Keywords defined
Packit 08bd4c
	     in the standard are in all lowercase; vendors are allowed to
Packit 08bd4c
	     define custom keys by preceding them with the vendor name in all
Packit 08bd4c
	     uppercase.  When writing pax archives, libarchive uses many of
Packit 08bd4c
	     the SCHILY keys defined by Joerg Schilling's “star” archiver and
Packit 08bd4c
	     a few LIBARCHIVE keys.  The libarchive library can read most of
Packit 08bd4c
	     the SCHILY keys and most of the GNU keys introduced by GNU tar.
Packit 08bd4c
	     It silently ignores any keywords that it does not understand.
Packit 08bd4c
Packit 08bd4c
	     The pax interchange format converts filenames to Unicode and
Packit 08bd4c
	     stores them using the UTF-8 encoding.  Prior to libarchive 3.0,
Packit 08bd4c
	     libarchive erroneously assumed that the system wide-character
Packit 08bd4c
	     routines natively supported Unicode.  This caused it to mis-han‐
Packit 08bd4c
	     dle non-ASCII filenames on systems that did not satisfy this
Packit 08bd4c
	     assumption.
Packit 08bd4c
Packit 08bd4c
     restricted pax
Packit 08bd4c
	     The libarchive library can also write pax archives in which it
Packit 08bd4c
	     attempts to suppress the extended attributes entry whenever pos‐
Packit 08bd4c
	     sible.  The result will be identical to a ustar archive unless
Packit 08bd4c
	     the extended attributes entry is required to store a long file
Packit 08bd4c
	     name, long linkname, extended ACL, file flags, or if any of the
Packit 08bd4c
	     standard ustar data (user name, group name, UID, GID, etc) cannot
Packit 08bd4c
	     be fully represented in the ustar header.	In all cases, the
Packit 08bd4c
	     result can be dearchived by any program that can read POSIX-com‐
Packit 08bd4c
	     pliant pax interchange format archives.  Programs that correctly
Packit 08bd4c
	     read ustar format (see below) will also be able to read this for‐
Packit 08bd4c
	     mat; any extended attributes will be extracted as separate files
Packit 08bd4c
	     stored in PaxHeader directories.
Packit 08bd4c
Packit 08bd4c
     ustar   The libarchive library can both read and write this format.  This
Packit 08bd4c
	     format has the following limitations:
Packit 08bd4c
	     ·	 Device major and minor numbers are limited to 21 bits.  Nodes
Packit 08bd4c
		 with larger numbers will not be added to the archive.
Packit 08bd4c
	     ·	 Path names in the archive are limited to 255 bytes.  (Shorter
Packit 08bd4c
		 if there is no / character in exactly the right place.)
Packit 08bd4c
	     ·	 Symbolic links and hard links are stored in the archive with
Packit 08bd4c
		 the name of the referenced file.  This name is limited to 100
Packit 08bd4c
		 bytes.
Packit 08bd4c
	     ·	 Extended attributes, file flags, and other extended security
Packit 08bd4c
		 information cannot be stored.
Packit 08bd4c
	     ·	 Archive entries are limited to 8 gigabytes in size.
Packit 08bd4c
	     Note that the pax interchange format has none of these restric‐
Packit 08bd4c
	     tions.  The ustar format is old and widely supported.  It is rec‐
Packit 08bd4c
	     ommended when compatibility is the primary concern.
Packit 08bd4c
Packit 08bd4c
     v7      The libarchive library can read and write the legacy v7 tar for‐
Packit 08bd4c
	     mat.  This format has the following limitations:
Packit 08bd4c
	     ·	 Only regular files, directories, and symbolic links can be
Packit 08bd4c
		 archived.  Block and character device nodes, FIFOs, and sock‐
Packit 08bd4c
		 ets cannot be archived.
Packit 08bd4c
	     ·	 Path names in the archive are limited to 100 bytes.
Packit 08bd4c
	     ·	 Symbolic links and hard links are stored in the archive with
Packit 08bd4c
		 the name of the referenced file.  This name is limited to 100
Packit 08bd4c
		 bytes.
Packit 08bd4c
	     ·	 User and group information are stored as numeric IDs; there
Packit 08bd4c
		 is no provision for storing user or group names.
Packit 08bd4c
	     ·	 Extended attributes, file flags, and other extended security
Packit 08bd4c
		 information cannot be stored.
Packit 08bd4c
	     ·	 Archive entries are limited to 8 gigabytes in size.
Packit 08bd4c
	     Generally, users should prefer the ustar format for portability
Packit 08bd4c
	     as the v7 tar format is both less useful and less portable.
Packit 08bd4c
Packit 08bd4c
     The libarchive library also reads a variety of commonly-used extensions
Packit 08bd4c
     to the basic tar format.  These extensions are recognized automatically
Packit 08bd4c
     whenever they appear.
Packit 08bd4c
Packit 08bd4c
     Numeric extensions.
Packit 08bd4c
	     The POSIX standards require fixed-length numeric fields to be
Packit 08bd4c
	     written with some character position reserved for terminators.
Packit 08bd4c
	     Libarchive allows these fields to be written without terminator
Packit 08bd4c
	     characters.  This extends the allowable range; in particular,
Packit 08bd4c
	     ustar archives with this extension can support entries up to 64
Packit 08bd4c
	     gigabytes in size.  Libarchive also recognizes base-256 values in
Packit 08bd4c
	     most numeric fields.  This essentially removes all limitations on
Packit 08bd4c
	     file size, modification time, and device numbers.
Packit 08bd4c
Packit 08bd4c
     Solaris extensions
Packit 08bd4c
	     Libarchive recognizes ACL and extended attribute records written
Packit 08bd4c
	     by Solaris tar.
Packit 08bd4c
Packit 08bd4c
     The first tar program appeared in Seventh Edition Unix in 1979.  The
Packit 08bd4c
     first official standard for the tar file format was the “ustar” (Unix
Packit 08bd4c
     Standard Tar) format defined by POSIX in 1988.  POSIX.1-2001 extended the
Packit 08bd4c
     ustar format to create the “pax interchange” format.
Packit 08bd4c
Packit 08bd4c
   Cpio Formats
Packit 08bd4c
     The libarchive library can read a number of common cpio variants and can
Packit 08bd4c
     write “odc” and “newc” format archives.  A cpio archive stores each entry
Packit 08bd4c
     as a fixed-size header followed by a variable-length filename and vari‐
Packit 08bd4c
     able-length data.	Unlike the tar format, the cpio format does only mini‐
Packit 08bd4c
     mal padding of the header or file data.  There are several cpio variants,
Packit 08bd4c
     which differ primarily in how they store the initial header: some store
Packit 08bd4c
     the values as octal or hexadecimal numbers in ASCII, others as binary
Packit 08bd4c
     values of varying byte order and length.
Packit 08bd4c
Packit 08bd4c
     binary  The libarchive library transparently reads both big-endian and
Packit 08bd4c
	     little-endian variants of the original binary cpio format.  This
Packit 08bd4c
	     format used 32-bit binary values for file size and mtime, and
Packit 08bd4c
	     16-bit binary values for the other fields.
Packit 08bd4c
Packit 08bd4c
     odc     The libarchive library can both read and write this POSIX-stan‐
Packit 08bd4c
	     dard format, which is officially known as the “cpio interchange
Packit 08bd4c
	     format” or the “octet-oriented cpio archive format” and sometimes
Packit 08bd4c
	     unofficially referred to as the “old character format”.  This
Packit 08bd4c
	     format stores the header contents as octal values in ASCII.  It
Packit 08bd4c
	     is standard, portable, and immune from byte-order confusion.
Packit 08bd4c
	     File sizes and mtime are limited to 33 bits (8GB file size),
Packit 08bd4c
	     other fields are limited to 18 bits.
Packit 08bd4c
Packit 08bd4c
     SVR4/newc
Packit 08bd4c
	     The libarchive library can read both CRC and non-CRC variants of
Packit 08bd4c
	     this format.  The SVR4 format uses eight-digit hexadecimal values
Packit 08bd4c
	     for all header fields.  This limits file size to 4GB, and also
Packit 08bd4c
	     limits the mtime and other fields to 32 bits.  The SVR4 format
Packit 08bd4c
	     can optionally include a CRC of the file contents, although
Packit 08bd4c
	     libarchive does not currently verify this CRC.
Packit 08bd4c
Packit 08bd4c
     Cpio first appeared in PWB/UNIX 1.0, which was released within AT&T in
Packit 08bd4c
     1977.  PWB/UNIX 1.0 formed the basis of System III Unix, released outside
Packit 08bd4c
     of AT&T in 1981.  This makes cpio older than tar, although cpio was not
Packit 08bd4c
     included in Version 7 AT&T Unix.  As a result, the tar command became
Packit 08bd4c
     much better known in universities and research groups that used Version
Packit 08bd4c
     7.  The combination of the find and cpio utilities provided very precise
Packit 08bd4c
     control over file selection.  Unfortunately, the format has many limita‐
Packit 08bd4c
     tions that make it unsuitable for widespread use.	Only the POSIX format
Packit 08bd4c
     permits files over 4GB, and its 18-bit limit for most other fields makes
Packit 08bd4c
     it unsuitable for modern systems.	In addition, cpio formats only store
Packit 08bd4c
     numeric UID/GID values (not usernames and group names), which can make it
Packit 08bd4c
     very difficult to correctly transfer archives across systems with dissim‐
Packit 08bd4c
     ilar user numbering.
Packit 08bd4c
Packit 08bd4c
   Shar Formats
Packit 08bd4c
     A “shell archive” is a shell script that, when executed on a POSIX-com‐
Packit 08bd4c
     pliant system, will recreate a collection of file system objects.	The
Packit 08bd4c
     libarchive library can write two different kinds of shar archives:
Packit 08bd4c
Packit 08bd4c
     shar    The traditional shar format uses a limited set of POSIX commands,
Packit 08bd4c
	     including echo(1), mkdir(1), and sed(1).  It is suitable for
Packit 08bd4c
	     portably archiving small collections of plain text files.	How‐
Packit 08bd4c
	     ever, it is not generally well-suited for large archives (many
Packit 08bd4c
	     implementations of sh(1) have limits on the size of a script) nor
Packit 08bd4c
	     should it be used with non-text files.
Packit 08bd4c
Packit 08bd4c
     shardump
Packit 08bd4c
	     This format is similar to shar but encodes files using
Packit 08bd4c
	     uuencode(1) so that the result will be a plain text file regard‐
Packit 08bd4c
	     less of the file contents.  It also includes additional shell
Packit 08bd4c
	     commands that attempt to reproduce as many file attributes as
Packit 08bd4c
	     possible, including owner, mode, and flags.  The additional com‐
Packit 08bd4c
	     mands used to restore file attributes make shardump archives less
Packit 08bd4c
	     portable than plain shar archives.
Packit 08bd4c
Packit 08bd4c
   ISO9660 format
Packit 08bd4c
     Libarchive can read and extract from files containing ISO9660-compliant
Packit 08bd4c
     CDROM images.  In many cases, this can remove the need to burn a physical
Packit 08bd4c
     CDROM just in order to read the files contained in an ISO9660 image.  It
Packit 08bd4c
     also avoids security and complexity issues that come with virtual mounts
Packit 08bd4c
     and loopback devices.  Libarchive supports the most common Rockridge
Packit 08bd4c
     extensions and has partial support for Joliet extensions.	If both exten‐
Packit 08bd4c
     sions are present, the Joliet extensions will be used and the Rockridge
Packit 08bd4c
     extensions will be ignored.  In particular, this can create problems with
Packit 08bd4c
     hardlinks and symlinks, which are supported by Rockridge but not by
Packit 08bd4c
     Joliet.
Packit 08bd4c
Packit 08bd4c
     Libarchive reads ISO9660 images using a streaming strategy.  This allows
Packit 08bd4c
     it to read compressed images directly (decompressing on the fly) and
Packit 08bd4c
     allows it to read images directly from network sockets, pipes, and other
Packit 08bd4c
     non-seekable data sources.  This strategy works well for optimized
Packit 08bd4c
     ISO9660 images created by many popular programs.  Such programs collect
Packit 08bd4c
     all directory information at the beginning of the ISO9660 image so it can
Packit 08bd4c
     be read from a physical disk with a minimum of seeking.  However, not all
Packit 08bd4c
     ISO9660 images can be read in this fashion.
Packit 08bd4c
Packit 08bd4c
     Libarchive can also write ISO9660 images.	Such images are fully opti‐
Packit 08bd4c
     mized with the directory information preceding all file data.  This is
Packit 08bd4c
     done by storing all file data to a temporary file while collecting direc‐
Packit 08bd4c
     tory information in memory.  When the image is finished, libarchive
Packit 08bd4c
     writes out the directory structure followed by the file data.  The loca‐
Packit 08bd4c
     tion used for the temporary file can be changed by the usual environment
Packit 08bd4c
     variables.
Packit 08bd4c
Packit 08bd4c
   Zip format
Packit 08bd4c
     Libarchive can read and write zip format archives that have uncompressed
Packit 08bd4c
     entries and entries compressed with the “deflate” algorithm.  Other zip
Packit 08bd4c
     compression algorithms are not supported.	It can extract jar archives,
Packit 08bd4c
     archives that use Zip64 extensions and self-extracting zip archives.
Packit 08bd4c
     Libarchive can use either of two different strategies for reading Zip ar‐
Packit 08bd4c
     chives: a streaming strategy which is fast and can handle extremely large
Packit 08bd4c
     archives, and a seeking strategy which can correctly process self-
Packit 08bd4c
     extracting Zip archives and archives with deleted members or other in-
Packit 08bd4c
     place modifications.
Packit 08bd4c
Packit 08bd4c
     The streaming reader processes Zip archives as they are read.  It can
Packit 08bd4c
     read archives of arbitrary size from tape or network sockets, and can
Packit 08bd4c
     decode Zip archives that have been separately compressed or encoded.
Packit 08bd4c
     However, self-extracting Zip archives and archives with certain types of
Packit 08bd4c
     modifications cannot be correctly handled.  Such archives require that
Packit 08bd4c
     the reader first process the Central Directory, which is ordinarily
Packit 08bd4c
     located at the end of a Zip archive and is thus inaccessible to the
Packit 08bd4c
     streaming reader.	If the program using libarchive has enabled seek sup‐
Packit 08bd4c
     port, then libarchive will use this to processes the central directory
Packit 08bd4c
     first.
Packit 08bd4c
Packit 08bd4c
     In particular, the seeking reader must be used to correctly handle self-
Packit 08bd4c
     extracting archives.  Such archives consist of a program followed by a
Packit 08bd4c
     regular Zip archive.  The streaming reader cannot parse the initial pro‐
Packit 08bd4c
     gram portion, but the seeking reader starts by reading the Central Direc‐
Packit 08bd4c
     tory from the end of the archive.	Similarly, Zip archives that have been
Packit 08bd4c
     modified in-place can have deleted entries or other garbage data that can
Packit 08bd4c
     only be accurately detected by first reading the Central Directory.
Packit 08bd4c
Packit 08bd4c
   Archive (library) file format
Packit 08bd4c
     The Unix archive format (commonly created by the ar(1) archiver) is a
Packit 08bd4c
     general-purpose format which is used almost exclusively for object files
Packit 08bd4c
     to be read by the link editor ld(1).  The ar format has never been stan‐
Packit 08bd4c
     dardised.	There are two common variants: the GNU format derived from
Packit 08bd4c
     SVR4, and the BSD format, which first appeared in 4.4BSD.	The two differ
Packit 08bd4c
     primarily in their handling of filenames longer than 15 characters: the
Packit 08bd4c
     GNU/SVR4 variant writes a filename table at the beginning of the archive;
Packit 08bd4c
     the BSD format stores each long filename in an extension area adjacent to
Packit 08bd4c
     the entry.  Libarchive can read both extensions, including archives that
Packit 08bd4c
     may include both types of long filenames.	Programs using libarchive can
Packit 08bd4c
     write GNU/SVR4 format if they provide an entry called // containing a
Packit 08bd4c
     filename table to be written into the archive before any of the entries.
Packit 08bd4c
     Any entries whose names are not in the filename table will be written
Packit 08bd4c
     using BSD-style long filenames.  This can cause problems for programs
Packit 08bd4c
     such as GNU ld that do not support the BSD-style long filenames.
Packit 08bd4c
Packit 08bd4c
   mtree
Packit 08bd4c
     Libarchive can read and write files in mtree(5) format.  This format is
Packit 08bd4c
     not a true archive format, but rather a textual description of a file
Packit 08bd4c
     hierarchy in which each line specifies the name of a file and provides
Packit 08bd4c
     specific metadata about that file.  Libarchive can read all of the key‐
Packit 08bd4c
     words supported by both the NetBSD and FreeBSD versions of mtree(8),
Packit 08bd4c
     although many of the keywords cannot currently be stored in an
Packit 08bd4c
     archive_entry object.  When writing, libarchive supports use of the
Packit 08bd4c
     archive_write_set_options(3) interface to specify which keywords should
Packit 08bd4c
     be included in the output.  If libarchive was compiled with access to
Packit 08bd4c
     suitable cryptographic libraries (such as the OpenSSL libraries), it can
Packit 08bd4c
     compute hash entries such as sha512 or md5 from file data being written
Packit 08bd4c
     to the mtree writer.
Packit 08bd4c
Packit 08bd4c
     When reading an mtree file, libarchive will locate the corresponding
Packit 08bd4c
     files on disk using the contents keyword if present or the regular file‐
Packit 08bd4c
     name.  If it can locate and open the file on disk, it will use that to
Packit 08bd4c
     fill in any metadata that is missing from the mtree file and will read
Packit 08bd4c
     the file contents and return those to the program using libarchive.  If
Packit 08bd4c
     it cannot locate and open the file on disk, libarchive will return an
Packit 08bd4c
     error for any attempt to read the entry body.
Packit 08bd4c
Packit 08bd4c
   7-Zip
Packit 08bd4c
     Libarchive can read and write 7-Zip format archives.  TODO: Need more
Packit 08bd4c
     information
Packit 08bd4c
Packit 08bd4c
   CAB
Packit 08bd4c
     Libarchive can read Microsoft Cabinet ( “CAB”) format archives.  TODO:
Packit 08bd4c
     Need more information.
Packit 08bd4c
Packit 08bd4c
   LHA
Packit 08bd4c
     TODO: Information about libarchive's LHA support
Packit 08bd4c
Packit 08bd4c
   RAR
Packit 08bd4c
     Libarchive has limited support for reading RAR format archives.  Cur‐
Packit 08bd4c
     rently, libarchive can read RARv3 format archives which have been either
Packit 08bd4c
     created uncompressed, or compressed using any of the compression methods
Packit 08bd4c
     supported by the RARv3 format.  Libarchive can also read self-extracting
Packit 08bd4c
     RAR archives.
Packit 08bd4c
Packit 08bd4c
   Warc
Packit 08bd4c
     Libarchive can read and write “web archives”.  TODO: Need more informa‐
Packit 08bd4c
     tion
Packit 08bd4c
Packit 08bd4c
   XAR
Packit 08bd4c
     Libarchive can read and write the XAR format used by many Apple tools.
Packit 08bd4c
     TODO: Need more information
Packit 08bd4c
Packit 08bd4c
SEE ALSO
Packit 08bd4c
     ar(1), cpio(1), mkisofs(1), shar(1), tar(1), zip(1), zlib(3), cpio(5),
Packit 08bd4c
     mtree(5), tar(5)
Packit 08bd4c
Packit 08bd4c
BSD			       December 27, 2016			   BSD