Imported Upstream version 3.3.1
[platform/upstream/libarchive.git] / doc / text / libarchive.3.txt
1 LIBARCHIVE(3)            BSD Library Functions Manual            LIBARCHIVE(3)
2
3 1mNAME0m
4      1mlibarchive 22m— functions for reading and writing streaming archives
5
6 1mOVERVIEW0m
7      The 1mlibarchive 22mlibrary provides a flexible interface for reading and
8      writing archives in various formats such as tar and cpio.  1mlibarchive0m
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      1m·   22mold-style tar archives,
19      1m·   22mmost variants of the POSIX “ustar” format,
20      1m·   22mthe POSIX “pax interchange” format,
21      1m·   22mGNU-format tar archives,
22      1m·   22mmost common cpio archive formats,
23      1m·   22mISO9660 CD images (including RockRidge and Joliet extensions),
24      1m·   22mZip archives,
25      1m·   22mar archives (including GNU/SysV and BSD extensions),
26      1m·   22mMicrosoft CAB archives,
27      1m·   22mLHA archives,
28      1m·   22mmtree file tree descriptions,
29      1m·   22mRAR archives,
30      1m·   22mXAR 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      1m·   22mPOSIX-standard “ustar” archives,
39      1m·   22mPOSIX “pax interchange format” archives,
40      1m·   22mPOSIX octet-oriented cpio archives,
41      1m·   22mZip archive,
42      1m·   22mtwo different variants of shar archives,
43      1m·   22mISO9660 CD images,
44      1m·   22m7-Zip archives,
45      1m·   22mar archives,
46      1m·   22mmtree file tree descriptions,
47      1m·   22mXAR 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 1marchive_read_XXX22m() func‐
57      tions and the 1marchive_write_XXX22m() 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 1mREADING AN ARCHIVE0m
65      See archive_read(3).
66
67 1mWRITING AN ARCHIVE0m
68      See archive_write(3).
69
70 1mWRITING ENTRIES TO DISK0m
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 1marchive_read_extract22m();
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 1mREADING ENTRIES FROM DISK0m
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 1mDESCRIPTION0m
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      4mPATH_MAX24m.
103
104 1mRETURN VALUES0m
105      Most functions return 1mARCHIVE_OK 22m(zero) on success, non-zero on error.
106      The return value indicates the general severity of the error, ranging
107      from 1mARCHIVE_WARN22m, which indicates a minor problem that should probably
108      be reported to the user, to 1mARCHIVE_FATAL22m, which indicates a serious
109      problem that will prevent any further operations on this archive.  On
110      error, the 1marchive_errno22m() function can be used to retrieve a numeric
111      error code (see errno(2)).  The 1marchive_error_string22m() returns a textual
112      error message suitable for display.
113
114      1marchive_read_new22m() and 1marchive_write_new22m() return pointers to an allo‐
115      cated and initialized struct archive object.
116
117      1marchive_read_data22m() and 1marchive_write_data22m() 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 1marchive_errno22m() and 1marchive_error_string22m() functions can be used
121      to obtain more information.
122
123 1mENVIRONMENT0m
124      There are character set conversions within the archive_entry(3) functions
125      that are impacted by the currently-selected locale.
126
127 1mSEE ALSO0m
128      tar(1), archive_entry(3), archive_read(3), archive_util(3),
129      archive_write(3), tar(5)
130
131 1mHISTORY0m
132      The 1mlibarchive 22mlibrary first appeared in FreeBSD 5.3.
133
134 1mAUTHORS0m
135      The 1mlibarchive 22mlibrary was originally written by Tim Kientzle
136      <kientzle@acm.org>.
137
138 1mBUGS0m
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