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

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