Imported Upstream version 3.3.0
[platform/upstream/libarchive.git] / doc / text / libarchive.3.txt
1 LIBARCHIVE(3)            BSD Library Functions Manual            LIBARCHIVE(3)
2
3 NAME
4      libarchive — functions for reading and writing streaming archives
5
6 OVERVIEW
7      The libarchive library provides a flexible interface for reading and
8      writing archives in various formats such as tar and cpio.  libarchive
9      also supports reading and writing archives compressed using various com‐
10      pression filters such as gzip and bzip2.  The library is inherently
11      stream-oriented; readers serially iterate through the archive, writers
12      serially add things to the archive.  In particular, note that there is
13      currently no built-in support for random access nor for in-place modifi‐
14      cation.
15
16      When reading an archive, the library automatically detects the format and
17      the compression.  The library currently has read support for:
18      ·  old-style tar archives,
19      ·  most variants of the POSIX “ustar” format,
20      ·  the POSIX “pax interchange” format,
21      ·  GNU-format tar archives,
22      ·  most common cpio archive formats,
23      ·  ISO9660 CD images (including RockRidge and Joliet extensions),
24      ·  Zip archives,
25      ·  ar archives (including GNU/SysV and BSD extensions),
26      ·  Microsoft CAB archives,
27      ·  LHA archives,
28      ·  mtree file tree descriptions,
29      ·  RAR archives,
30      ·  XAR archives.
31      The library automatically detects archives compressed with gzip(1),
32      bzip2(1), xz(1), lzip(1), or compress(1) and decompresses them transpar‐
33      ently.  It can similarly detect and decode archives processed with
34      uuencode(1) or which have an rpm(1) header.
35
36      When writing an archive, you can specify the compression to be used and
37      the format to use.  The library can write
38      ·  POSIX-standard “ustar” archives,
39      ·  POSIX “pax interchange format” archives,
40      ·  POSIX octet-oriented cpio archives,
41      ·  Zip archive,
42      ·  two different variants of shar archives,
43      ·  ISO9660 CD images,
44      ·  7-Zip archives,
45      ·  ar archives,
46      ·  mtree file tree descriptions,
47      ·  XAR archives.
48      Pax interchange format is an extension of the tar archive format that
49      eliminates essentially all of the limitations of historic tar formats in
50      a standard fashion that is supported by POSIX-compliant pax(1) implemen‐
51      tations on many systems as well as several newer implementations of
52      tar(1).  Note that the default write format will suppress the pax
53      extended attributes for most entries; explicitly requesting pax format
54      will enable those attributes for all entries.
55
56      The read and write APIs are accessed through the archive_read_XXX() func‐
57      tions and the archive_write_XXX() functions, respectively, and either can
58      be used independently of the other.
59
60      The rest of this manual page provides an overview of the library opera‐
61      tion.  More detailed information can be found in the individual manual
62      pages for each API or utility function.
63
64 READING AN ARCHIVE
65      See archive_read(3).
66
67 WRITING AN ARCHIVE
68      See archive_write(3).
69
70 WRITING ENTRIES TO DISK
71      The archive_write_disk(3) API allows you to write archive_entry(3)
72      objects to disk using the same API used by archive_write(3).  The
73      archive_write_disk(3) API is used internally by archive_read_extract();
74      using it directly can provide greater control over how entries get writ‐
75      ten to disk.  This API also makes it possible to share code between ar‐
76      chive-to-archive copy and archive-to-disk extraction operations.
77
78 READING ENTRIES FROM DISK
79      The archive_read_disk(3) supports for populating archive_entry(3) objects
80      from information in the filesystem.  This includes the information acces‐
81      sible from the stat(2) system call as well as ACLs, extended attributes,
82      and other metadata.  The archive_read_disk(3) API also supports iterating
83      over directory trees, which allows directories of files to be read using
84      an API compatible with the archive_read(3) API.
85
86 DESCRIPTION
87      Detailed descriptions of each function are provided by the corresponding
88      manual pages.
89
90      All of the functions utilize an opaque struct archive datatype that pro‐
91      vides access to the archive contents.
92
93      The struct archive_entry structure contains a complete description of a
94      single archive entry.  It uses an opaque interface that is fully docu‐
95      mented in archive_entry(3).
96
97      Users familiar with historic formats should be aware that the newer vari‐
98      ants have eliminated most restrictions on the length of textual fields.
99      Clients should not assume that filenames, link names, user names, or
100      group names are limited in length.  In particular, pax interchange format
101      can easily accommodate pathnames in arbitrary character sets that exceed
102      PATH_MAX.
103
104 RETURN VALUES
105      Most functions return ARCHIVE_OK (zero) on success, non-zero on error.
106      The return value indicates the general severity of the error, ranging
107      from ARCHIVE_WARN, which indicates a minor problem that should probably
108      be reported to the user, to ARCHIVE_FATAL, which indicates a serious
109      problem that will prevent any further operations on this archive.  On
110      error, the archive_errno() function can be used to retrieve a numeric
111      error code (see errno(2)).  The archive_error_string() returns a textual
112      error message suitable for display.
113
114      archive_read_new() and archive_write_new() return pointers to an allo‐
115      cated and initialized struct archive object.
116
117      archive_read_data() and archive_write_data() return a count of the number
118      of bytes actually read or written.  A value of zero indicates the end of
119      the data for this entry.  A negative value indicates an error, in which
120      case the archive_errno() and archive_error_string() functions can be used
121      to obtain more information.
122
123 ENVIRONMENT
124      There are character set conversions within the archive_entry(3) functions
125      that are impacted by the currently-selected locale.
126
127 SEE ALSO
128      tar(1), archive_entry(3), archive_read(3), archive_util(3),
129      archive_write(3), tar(5)
130
131 HISTORY
132      The libarchive library first appeared in FreeBSD 5.3.
133
134 AUTHORS
135      The libarchive library was originally written by Tim Kientzle
136      <kientzle@acm.org>.
137
138 BUGS
139      Some archive formats support information that is not supported by struct
140      archive_entry.  Such information cannot be fully archived or restored
141      using this library.  This includes, for example, comments, character
142      sets, or the arbitrary key/value pairs that can appear in pax interchange
143      format archives.
144
145      Conversely, of course, not all of the information that can be stored in
146      an struct archive_entry is supported by all formats.  For example, cpio
147      formats do not support nanosecond timestamps; old tar formats do not sup‐
148      port large device numbers.
149
150      The ISO9660 reader cannot yet read all ISO9660 images; it should learn
151      how to seek.
152
153      The AR writer requires the client program to use two passes, unlike all
154      other libarchive writers.
155
156 BSD                             March 18, 2012                             BSD