1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329
|
<!-- Creator : groff version 1.23.0 -->
<!-- CreationDate: Mon Jan 5 10:42:45 2026 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="generator" content="groff -Thtml, see www.gnu.org">
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta name="Content-Style" content="text/css">
<style type="text/css">
p { margin-top: 0; margin-bottom: 0; vertical-align: top }
pre { margin-top: 0; margin-bottom: 0; vertical-align: top }
table { margin-top: 0; margin-bottom: 0; vertical-align: top }
h1 { text-align: center }
</style>
<title></title>
</head>
<body>
<hr>
<p><i>LIBARCHIVE</i>(3) Library Functions Manual
<i>LIBARCHIVE</i>(3)</p>
<p style="margin-top: 1em"><b>NAME</b></p>
<p style="margin-left:9%;">libarchive — functions for
reading and writing streaming archives</p>
<p style="margin-top: 1em"><b>OVERVIEW</b></p>
<p style="margin-left:9%;">The <b>libarchive</b> library
provides a flexible interface for reading and writing
archives in various formats such as tar and cpio.
<b>libarchive</b> also supports reading and writing archives
compressed using various compression filters such as gzip
and bzip2. The library is inherently stream-oriented;
readers serially iterate through the archive, writers
serially add things to the archive. In particular, note that
there is currently no built-in support for random access nor
for in-place modification.</p>
<p style="margin-left:9%; margin-top: 1em">When reading an
archive, the library automatically detects the format and
the compression. The library currently has read support
for:</p>
<p><b>•</b></p>
<p style="margin-left:14%;">old-style tar archives,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">most variants of the POSIX
“ustar” format,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">the POSIX “pax
interchange” format,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">GNU-format tar archives,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">most common cpio archive
formats,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">7-Zip archives,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">ar archives (including GNU/SysV
and BSD extensions),</p>
<p><b>•</b></p>
<p style="margin-left:14%;">Microsoft CAB archives,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">ISO9660 CD images (including
RockRidge and Joliet extensions),</p>
<p><b>•</b></p>
<p style="margin-left:14%;">LHA archives,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">mtree file tree
descriptions,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">RAR and most RAR5 archives,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">WARC archives,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">XAR archives,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">Zip archives.</p>
<p style="margin-left:9%;">The library automatically
detects archives compressed with <i>compress</i>(1),
<i>bzip2</i>(1), <i>grzip</i>(1), <i>gzip</i>(1),
<i>lrzip</i>(1), <i>lz4</i>(1), <i>lzip</i>(1),
<i>lzop</i>(1), <i>xz</i>(1), or <i>zstd</i>(1) and
decompresses them transparently. Decompression of some
formats requires external decompressor utilities. It can
similarly detect and decode archives processed with
<i>uuencode</i>(1) or which have an <i>rpm</i>(1)
header.</p>
<p style="margin-left:9%; margin-top: 1em">When writing an
archive, you can specify the compression to be used and the
format to use. The library can write</p>
<p><b>•</b></p>
<p style="margin-left:14%;">POSIX-standard
“ustar” archives,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">POSIX “pax interchange
format” archives,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">cpio archives,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">7-Zip archives,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">ar archives,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">two different variants of shar
archives,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">ISO9660 CD images,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">mtree file tree
descriptions,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">XAR archives,</p>
<p><b>•</b></p>
<p style="margin-left:14%;">Zip archive.</p>
<p style="margin-left:9%;">Pax interchange format is an
extension of the tar archive format that eliminates
essentially all of the limitations of historic tar formats
in a standard fashion that is supported by POSIX-compliant
<i>pax</i>(1) implementations on many systems as well as
several newer implementations of <i>tar</i>(1). Note that
the default write format will suppress the pax extended
attributes for most entries; explicitly requesting pax
format will enable those attributes for all entries.</p>
<p style="margin-left:9%; margin-top: 1em">The read and
write APIs are accessed through the
<b>archive_read_XXX</b>() functions and the
<b>archive_write_XXX</b>() functions, respectively, and
either can be used independently of the other.</p>
<p style="margin-left:9%; margin-top: 1em">The rest of this
manual page provides an overview of the library operation.
More detailed information can be found in the individual
manual pages for each API or utility function.</p>
<p style="margin-top: 1em"><b>READING AN ARCHIVE</b></p>
<p style="margin-left:9%;">See <i>archive_read</i>(3).</p>
<p style="margin-top: 1em"><b>WRITING AN ARCHIVE</b></p>
<p style="margin-left:9%;">See <i>archive_write</i>(3).</p>
<p style="margin-top: 1em"><b>WRITING ENTRIES TO
DISK</b></p>
<p style="margin-left:9%;">The <i>archive_write_disk</i>(3)
API allows you to write <i>archive_entry</i>(3) objects to
disk using the same API used by <i>archive_write</i>(3). The
<i>archive_write_disk</i>(3) API is used internally by
<b>archive_read_extract</b>(); using it directly can provide
greater control over how entries get written to disk. This
API also makes it possible to share code between
archive-to-archive copy and archive-to-disk extraction
operations.</p>
<p style="margin-top: 1em"><b>READING ENTRIES FROM
DISK</b></p>
<p style="margin-left:9%;">The <i>archive_read_disk</i>(3)
supports for populating <i>archive_entry</i>(3) objects from
information in the filesystem. This includes the information
accessible from the <i>stat</i>(2) system call as well as
ACLs, extended attributes, and other metadata. The
<i>archive_read_disk</i>(3) API also supports iterating over
directory trees, which allows directories of files to be
read using an API compatible with the <i>archive_read</i>(3)
API.</p>
<p style="margin-top: 1em"><b>DESCRIPTION</b></p>
<p style="margin-left:9%;">Detailed descriptions of each
function are provided by the corresponding manual pages.</p>
<p style="margin-left:9%; margin-top: 1em">All of the
functions utilize an opaque struct archive datatype that
provides access to the archive contents.</p>
<p style="margin-left:9%; margin-top: 1em">The struct
archive_entry structure contains a complete description of a
single archive entry. It uses an opaque interface that is
fully documented in <i>archive_entry</i>(3).</p>
<p style="margin-left:9%; margin-top: 1em">Users familiar
with historic formats should be aware that the newer
variants have eliminated most restrictions on the length of
textual fields. Clients should not assume that filenames,
link names, user names, or group names are limited in
length. In particular, pax interchange format can easily
accommodate pathnames in arbitrary character sets that
exceed <i>PATH_MAX</i>.</p>
<p style="margin-top: 1em"><b>RETURN VALUES</b></p>
<p style="margin-left:9%;">Most functions return
<b>ARCHIVE_OK</b> (zero) on success, non-zero on error. The
return value indicates the general severity of the error,
ranging from <b>ARCHIVE_WARN</b>, which indicates a minor
problem that should probably be reported to the user, to
<b>ARCHIVE_FATAL</b>, which indicates a serious problem that
will prevent any further operations on this archive. On
error, the <b>archive_errno</b>() function can be used to
retrieve a numeric error code (see <i>errno</i>(2)). The
<b>archive_error_string</b>() returns a textual error
message suitable for display.</p>
<p style="margin-left:9%; margin-top: 1em"><b>archive_read_new</b>()
and <b>archive_write_new</b>() return pointers to an
allocated and initialized struct archive object.</p>
<p style="margin-left:9%; margin-top: 1em"><b>archive_read_data</b>()
and <b>archive_write_data</b>() return a count of the number
of bytes actually read or written. A value of zero indicates
the end of the data for this entry. A negative value
indicates an error, in which case the <b>archive_errno</b>()
and <b>archive_error_string</b>() functions can be used to
obtain more information.</p>
<p style="margin-top: 1em"><b>ENVIRONMENT</b></p>
<p style="margin-left:9%;">There are character set
conversions within the <i>archive_entry</i>(3) functions
that are impacted by the currently-selected locale.</p>
<p style="margin-top: 1em"><b>SEE ALSO</b></p>
<p style="margin-left:9%;"><i>tar</i>(1),
<i>archive_entry</i>(3), <i>archive_read</i>(3),
<i>archive_util</i>(3), <i>archive_write</i>(3),
<i>tar</i>(5)</p>
<p style="margin-top: 1em"><b>HISTORY</b></p>
<p style="margin-left:9%;">The <b>libarchive</b> library
first appeared in FreeBSD 5.3.</p>
<p style="margin-top: 1em"><b>AUTHORS</b></p>
<p style="margin-left:9%;">The <b>libarchive</b> library
was originally written by Tim Kientzle
<kientzle@acm.org>.</p>
<p style="margin-top: 1em"><b>BUGS</b></p>
<p style="margin-left:9%;">Some archive formats support
information that is not supported by struct archive_entry.
Such information cannot be fully archived or restored using
this library. This includes, for example, comments,
character sets, or the arbitrary key/value pairs that can
appear in pax interchange format archives.</p>
<p style="margin-left:9%; margin-top: 1em">Conversely, of
course, not all of the information that can be stored in an
struct archive_entry is supported by all formats. For
example, cpio formats do not support nanosecond timestamps;
old tar formats do not support large device numbers.</p>
<p style="margin-left:9%; margin-top: 1em">The ISO9660
reader cannot yet read all ISO9660 images; it should learn
how to seek.</p>
<p style="margin-left:9%; margin-top: 1em">The AR writer
requires the client program to use two passes, unlike all
other libarchive writers. Debian March 18, 2012
<i>LIBARCHIVE</i>(3)</p>
<hr>
</body>
</html>
|