Blame doc/html/libarchive.3.html

Packit Service 1d0348
Packit Service 1d0348
Packit Service 1d0348
Packit Service 1d0348
"http://www.w3.org/TR/html4/loose.dtd">
Packit Service 1d0348
<html>
Packit Service 1d0348
<head>
Packit Service 1d0348
<meta name="generator" content="groff -Thtml, see www.gnu.org">
Packit Service 1d0348
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
Packit Service 1d0348
<meta name="Content-Style" content="text/css">
Packit Service 1d0348
<style type="text/css">
Packit Service 1d0348
       p       { margin-top: 0; margin-bottom: 0; vertical-align: top }
Packit Service 1d0348
       pre     { margin-top: 0; margin-bottom: 0; vertical-align: top }
Packit Service 1d0348
       table   { margin-top: 0; margin-bottom: 0; vertical-align: top }
Packit Service 1d0348
       h1      { text-align: center }
Packit Service 1d0348
</style>
Packit Service 1d0348
<title></title>
Packit Service 1d0348
</head>
Packit Service 1d0348
<body>
Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348
Packit Service 1d0348

LIBARCHIVE(3) BSD Library Functions Manual

Packit Service 1d0348
LIBARCHIVE(3)

Packit Service 1d0348
Packit Service 1d0348

NAME

Packit Service 1d0348
Packit Service 1d0348

libarchive

Packit Service 1d0348
functions for reading and writing streaming archives

Packit Service 1d0348
Packit Service 1d0348

OVERVIEW

Packit Service 1d0348
Packit Service 1d0348

The libarchive library

Packit Service 1d0348
provides a flexible interface for reading and writing
Packit Service 1d0348
archives in various formats such as tar and cpio.
Packit Service 1d0348
libarchive also supports reading and writing archives
Packit Service 1d0348
compressed using various compression filters such as gzip
Packit Service 1d0348
and bzip2. The library is inherently stream-oriented;
Packit Service 1d0348
readers serially iterate through the archive, writers
Packit Service 1d0348
serially add things to the archive. In particular, note that
Packit Service 1d0348
there is currently no built-in support for random access nor
Packit Service 1d0348
for in-place modification.

Packit Service 1d0348
Packit Service 1d0348

When reading an

Packit Service 1d0348
archive, the library automatically detects the format and
Packit Service 1d0348
the compression. The library currently has read support
Packit Service 1d0348
for:

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

old-style tar archives,

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

most variants of the POSIX

Packit Service 1d0348
’’ustar’’ format,

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

the POSIX ’’pax

Packit Service 1d0348
interchange’’ format,

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

GNU-format tar archives,

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

most common cpio archive

Packit Service 1d0348
formats,

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

ISO9660 CD images (including

Packit Service 1d0348
RockRidge and Joliet extensions),

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

Zip archives,

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

ar archives (including GNU/SysV

Packit Service 1d0348
and BSD extensions),

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

Microsoft CAB archives,

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

LHA archives,

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

mtree file tree

Packit Service 1d0348
descriptions,

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

RAR archives,

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

XAR archives.

Packit Service 1d0348
Packit Service 1d0348

The library automatically

Packit Service 1d0348
detects archives compressed with gzip(1), bzip2(1), xz(1),
Packit Service 1d0348
lzip(1), or compress(1) and decompresses them transparently.
Packit Service 1d0348
It can similarly detect and decode archives processed with
Packit Service 1d0348
uuencode(1) or which have an rpm(1) header.

Packit Service 1d0348
Packit Service 1d0348

When writing an

Packit Service 1d0348
archive, you can specify the compression to be used and the
Packit Service 1d0348
format to use. The library can write

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

POSIX-standard

Packit Service 1d0348
’’ustar’’ archives,

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

POSIX ’’pax

Packit Service 1d0348
interchange format’’ archives,

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

POSIX octet-oriented cpio

Packit Service 1d0348
archives,

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

Zip archive,

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

two different variants of shar

Packit Service 1d0348
archives,

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

ISO9660 CD images,

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

7-Zip archives,

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

ar archives,

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

mtree file tree

Packit Service 1d0348
descriptions,

Packit Service 1d0348
Packit Service 1d0348

Packit Service 1d0348
Packit Service 1d0348

XAR archives.

Packit Service 1d0348
Packit Service 1d0348

Pax interchange format is an

Packit Service 1d0348
extension of the tar archive format that eliminates
Packit Service 1d0348
essentially all of the limitations of historic tar formats
Packit Service 1d0348
in a standard fashion that is supported by POSIX-compliant
Packit Service 1d0348
pax(1) implementations on many systems as well as several
Packit Service 1d0348
newer implementations of tar(1). Note that the default write
Packit Service 1d0348
format will suppress the pax extended attributes for most
Packit Service 1d0348
entries; explicitly requesting pax format will enable those
Packit Service 1d0348
attributes for all entries.

Packit Service 1d0348
Packit Service 1d0348

The read and

Packit Service 1d0348
write APIs are accessed through the
Packit Service 1d0348
archive_read_XXX() functions and the
Packit Service 1d0348
archive_write_XXX() functions, respectively, and
Packit Service 1d0348
either can be used independently of the other.

Packit Service 1d0348
Packit Service 1d0348

The rest of this

Packit Service 1d0348
manual page provides an overview of the library operation.
Packit Service 1d0348
More detailed information can be found in the individual
Packit Service 1d0348
manual pages for each API or utility function.

Packit Service 1d0348
Packit Service 1d0348

READING AN ARCHIVE

Packit Service 1d0348
Packit Service 1d0348

See archive_read(3).

Packit Service 1d0348
Packit Service 1d0348

WRITING AN ARCHIVE

Packit Service 1d0348
Packit Service 1d0348

See archive_write(3).

Packit Service 1d0348
Packit Service 1d0348

WRITING ENTRIES TO

Packit Service 1d0348
DISK

Packit Service 1d0348
Packit Service 1d0348

The archive_write_disk(3) API

Packit Service 1d0348
allows you to write archive_entry(3) objects to disk using
Packit Service 1d0348
the same API used by archive_write(3). The
Packit Service 1d0348
archive_write_disk(3) API is used internally by
Packit Service 1d0348
archive_read_extract(); using it directly can provide
Packit Service 1d0348
greater control over how entries get written to disk. This
Packit Service 1d0348
API also makes it possible to share code between
Packit Service 1d0348
archive-to-archive copy and archive-to-disk extraction
Packit Service 1d0348
operations.

Packit Service 1d0348
Packit Service 1d0348

READING ENTRIES FROM

Packit Service 1d0348
DISK

Packit Service 1d0348
Packit Service 1d0348

The archive_read_disk(3)

Packit Service 1d0348
supports for populating archive_entry(3) objects from
Packit Service 1d0348
information in the filesystem. This includes the information
Packit Service 1d0348
accessible from the stat(2) system call as well as ACLs,
Packit Service 1d0348
extended attributes, and other metadata. The
Packit Service 1d0348
archive_read_disk(3) API also supports iterating over
Packit Service 1d0348
directory trees, which allows directories of files to be
Packit Service 1d0348
read using an API compatible with the archive_read(3)
Packit Service 1d0348
API.

Packit Service 1d0348
Packit Service 1d0348

DESCRIPTION

Packit Service 1d0348
Packit Service 1d0348

Detailed descriptions of each

Packit Service 1d0348
function are provided by the corresponding manual pages.

Packit Service 1d0348
Packit Service 1d0348

All of the

Packit Service 1d0348
functions utilize an opaque struct archive datatype that
Packit Service 1d0348
provides access to the archive contents.

Packit Service 1d0348
Packit Service 1d0348

The struct

Packit Service 1d0348
archive_entry structure contains a complete description of a
Packit Service 1d0348
single archive entry. It uses an opaque interface that is
Packit Service 1d0348
fully documented in archive_entry(3).

Packit Service 1d0348
Packit Service 1d0348

Users familiar

Packit Service 1d0348
with historic formats should be aware that the newer
Packit Service 1d0348
variants have eliminated most restrictions on the length of
Packit Service 1d0348
textual fields. Clients should not assume that filenames,
Packit Service 1d0348
link names, user names, or group names are limited in
Packit Service 1d0348
length. In particular, pax interchange format can easily
Packit Service 1d0348
accommodate pathnames in arbitrary character sets that
Packit Service 1d0348
exceed PATH_MAX.

Packit Service 1d0348
Packit Service 1d0348

RETURN VALUES

Packit Service 1d0348
Packit Service 1d0348

Most functions return

Packit Service 1d0348
ARCHIVE_OK (zero) on success, non-zero on error. The
Packit Service 1d0348
return value indicates the general severity of the error,
Packit Service 1d0348
ranging from ARCHIVE_WARN, which indicates a minor
Packit Service 1d0348
problem that should probably be reported to the user, to
Packit Service 1d0348
ARCHIVE_FATAL, which indicates a serious problem that
Packit Service 1d0348
will prevent any further operations on this archive. On
Packit Service 1d0348
error, the archive_errno() function can be used to
Packit Service 1d0348
retrieve a numeric error code (see errno(2)). The
Packit Service 1d0348
archive_error_string() returns a textual error
Packit Service 1d0348
message suitable for display.

Packit Service 1d0348
Packit Service 1d0348
Packit Service 1d0348

archive_read_new()

Packit Service 1d0348
and archive_write_new() return pointers to an
Packit Service 1d0348
allocated and initialized struct archive object.

Packit Service 1d0348
Packit Service 1d0348
Packit Service 1d0348

archive_read_data()

Packit Service 1d0348
and archive_write_data() return a count of the number
Packit Service 1d0348
of bytes actually read or written. A value of zero indicates
Packit Service 1d0348
the end of the data for this entry. A negative value
Packit Service 1d0348
indicates an error, in which case the archive_errno()
Packit Service 1d0348
and archive_error_string() functions can be used to
Packit Service 1d0348
obtain more information.

Packit Service 1d0348
Packit Service 1d0348

ENVIRONMENT

Packit Service 1d0348
Packit Service 1d0348

There are character set

Packit Service 1d0348
conversions within the archive_entry(3) functions that are
Packit Service 1d0348
impacted by the currently-selected locale.

Packit Service 1d0348
Packit Service 1d0348

SEE ALSO

Packit Service 1d0348
Packit Service 1d0348

tar(1), archive_entry(3),

Packit Service 1d0348
archive_read(3), archive_util(3), archive_write(3),
Packit Service 1d0348
tar(5)

Packit Service 1d0348
Packit Service 1d0348

HISTORY

Packit Service 1d0348
Packit Service 1d0348

The libarchive library

Packit Service 1d0348
first appeared in FreeBSD 5.3.

Packit Service 1d0348
Packit Service 1d0348

AUTHORS

Packit Service 1d0348
Packit Service 1d0348

The libarchive library

Packit Service 1d0348
was originally written by Tim Kientzle
Packit Service 1d0348
<kientzle@acm.org>.

Packit Service 1d0348
Packit Service 1d0348

BUGS

Packit Service 1d0348
Packit Service 1d0348

Some archive formats support

Packit Service 1d0348
information that is not supported by struct archive_entry.
Packit Service 1d0348
Such information cannot be fully archived or restored using
Packit Service 1d0348
this library. This includes, for example, comments,
Packit Service 1d0348
character sets, or the arbitrary key/value pairs that can
Packit Service 1d0348
appear in pax interchange format archives.

Packit Service 1d0348
Packit Service 1d0348

Conversely, of

Packit Service 1d0348
course, not all of the information that can be stored in an
Packit Service 1d0348
struct archive_entry is supported by all formats. For
Packit Service 1d0348
example, cpio formats do not support nanosecond timestamps;
Packit Service 1d0348
old tar formats do not support large device numbers.

Packit Service 1d0348
Packit Service 1d0348

The ISO9660

Packit Service 1d0348
reader cannot yet read all ISO9660 images; it should learn
Packit Service 1d0348
how to seek.

Packit Service 1d0348
Packit Service 1d0348

The AR writer

Packit Service 1d0348
requires the client program to use two passes, unlike all
Packit Service 1d0348
other libarchive writers.

Packit Service 1d0348
Packit Service 1d0348

BSD

Packit Service 1d0348
March 18, 2012 BSD

Packit Service 1d0348

Packit Service 1d0348
</body>
Packit Service 1d0348
</html>