|
Packit |
08bd4c |
.\" Copyright (c) 2003-2007 Tim Kientzle
|
|
Packit |
08bd4c |
.\" All rights reserved.
|
|
Packit |
08bd4c |
.\"
|
|
Packit |
08bd4c |
.\" Redistribution and use in source and binary forms, with or without
|
|
Packit |
08bd4c |
.\" modification, are permitted provided that the following conditions
|
|
Packit |
08bd4c |
.\" are met:
|
|
Packit |
08bd4c |
.\" 1. Redistributions of source code must retain the above copyright
|
|
Packit |
08bd4c |
.\" notice, this list of conditions and the following disclaimer.
|
|
Packit |
08bd4c |
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
Packit |
08bd4c |
.\" notice, this list of conditions and the following disclaimer in the
|
|
Packit |
08bd4c |
.\" documentation and/or other materials provided with the distribution.
|
|
Packit |
08bd4c |
.\"
|
|
Packit |
08bd4c |
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
Packit |
08bd4c |
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit |
08bd4c |
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
Packit |
08bd4c |
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
Packit |
08bd4c |
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
Packit |
08bd4c |
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
Packit |
08bd4c |
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
Packit |
08bd4c |
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
Packit |
08bd4c |
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
Packit |
08bd4c |
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
Packit |
08bd4c |
.\" SUCH DAMAGE.
|
|
Packit |
08bd4c |
.\"
|
|
Packit |
08bd4c |
.\" $FreeBSD$
|
|
Packit |
08bd4c |
.\"
|
|
Packit |
08bd4c |
.Dd March 18, 2012
|
|
Packit |
08bd4c |
.Dt LIBARCHIVE 3
|
|
Packit |
08bd4c |
.Os
|
|
Packit |
08bd4c |
.Sh NAME
|
|
Packit |
08bd4c |
.Nm libarchive
|
|
Packit |
08bd4c |
.Nd functions for reading and writing streaming archives
|
|
Packit |
08bd4c |
.Sh OVERVIEW
|
|
Packit |
08bd4c |
The
|
|
Packit |
08bd4c |
.Nm
|
|
Packit |
08bd4c |
library provides a flexible interface for reading and writing
|
|
Packit |
08bd4c |
archives in various formats such as tar and cpio.
|
|
Packit |
08bd4c |
.Nm
|
|
Packit |
08bd4c |
also supports reading and writing archives compressed using
|
|
Packit |
08bd4c |
various compression filters such as gzip and bzip2.
|
|
Packit |
08bd4c |
The library is inherently stream-oriented; readers serially iterate through
|
|
Packit |
08bd4c |
the archive, writers serially add things to the archive.
|
|
Packit |
08bd4c |
In particular, note that there is currently no built-in support for
|
|
Packit |
08bd4c |
random access nor for in-place modification.
|
|
Packit |
08bd4c |
.Pp
|
|
Packit |
08bd4c |
When reading an archive, the library automatically detects the
|
|
Packit |
08bd4c |
format and the compression.
|
|
Packit |
08bd4c |
The library currently has read support for:
|
|
Packit |
08bd4c |
.Bl -bullet -compact
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
old-style tar archives,
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
most variants of the POSIX
|
|
Packit |
08bd4c |
.Dq ustar
|
|
Packit |
08bd4c |
format,
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
the POSIX
|
|
Packit |
08bd4c |
.Dq pax interchange
|
|
Packit |
08bd4c |
format,
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
GNU-format tar archives,
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
most common cpio archive formats,
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
ISO9660 CD images (including RockRidge and Joliet extensions),
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
Zip archives,
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
ar archives (including GNU/SysV and BSD extensions),
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
Microsoft CAB archives,
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
LHA archives,
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
mtree file tree descriptions,
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
RAR archives,
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
XAR archives.
|
|
Packit |
08bd4c |
.El
|
|
Packit |
08bd4c |
The library automatically detects archives compressed with
|
|
Packit |
08bd4c |
.Xr gzip 1 ,
|
|
Packit |
08bd4c |
.Xr bzip2 1 ,
|
|
Packit |
08bd4c |
.Xr xz 1 ,
|
|
Packit |
08bd4c |
.Xr lzip 1 ,
|
|
Packit |
08bd4c |
or
|
|
Packit |
08bd4c |
.Xr compress 1
|
|
Packit |
08bd4c |
and decompresses them transparently.
|
|
Packit |
08bd4c |
It can similarly detect and decode archives processed with
|
|
Packit |
08bd4c |
.Xr uuencode 1
|
|
Packit |
08bd4c |
or which have an
|
|
Packit |
08bd4c |
.Xr rpm 1
|
|
Packit |
08bd4c |
header.
|
|
Packit |
08bd4c |
.Pp
|
|
Packit |
08bd4c |
When writing an archive, you can specify the compression
|
|
Packit |
08bd4c |
to be used and the format to use.
|
|
Packit |
08bd4c |
The library can write
|
|
Packit |
08bd4c |
.Bl -bullet -compact
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
POSIX-standard
|
|
Packit |
08bd4c |
.Dq ustar
|
|
Packit |
08bd4c |
archives,
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
POSIX
|
|
Packit |
08bd4c |
.Dq pax interchange format
|
|
Packit |
08bd4c |
archives,
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
POSIX octet-oriented cpio archives,
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
Zip archive,
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
two different variants of shar archives,
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
ISO9660 CD images,
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
7-Zip archives,
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
ar archives,
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
mtree file tree descriptions,
|
|
Packit |
08bd4c |
.It
|
|
Packit |
08bd4c |
XAR archives.
|
|
Packit |
08bd4c |
.El
|
|
Packit |
08bd4c |
Pax interchange format is an extension of the tar archive format that
|
|
Packit |
08bd4c |
eliminates essentially all of the limitations of historic tar formats
|
|
Packit |
08bd4c |
in a standard fashion that is supported
|
|
Packit |
08bd4c |
by POSIX-compliant
|
|
Packit |
08bd4c |
.Xr pax 1
|
|
Packit |
08bd4c |
implementations on many systems as well as several newer implementations of
|
|
Packit |
08bd4c |
.Xr tar 1 .
|
|
Packit |
08bd4c |
Note that the default write format will suppress the pax extended
|
|
Packit |
08bd4c |
attributes for most entries; explicitly requesting pax format will
|
|
Packit |
08bd4c |
enable those attributes for all entries.
|
|
Packit |
08bd4c |
.Pp
|
|
Packit |
08bd4c |
The read and write APIs are accessed through the
|
|
Packit |
08bd4c |
.Fn archive_read_XXX
|
|
Packit |
08bd4c |
functions and the
|
|
Packit |
08bd4c |
.Fn archive_write_XXX
|
|
Packit |
08bd4c |
functions, respectively, and either can be used independently
|
|
Packit |
08bd4c |
of the other.
|
|
Packit |
08bd4c |
.Pp
|
|
Packit |
08bd4c |
The rest of this manual page provides an overview of the library
|
|
Packit |
08bd4c |
operation.
|
|
Packit |
08bd4c |
More detailed information can be found in the individual manual
|
|
Packit |
08bd4c |
pages for each API or utility function.
|
|
Packit |
08bd4c |
.\"
|
|
Packit |
08bd4c |
.Sh READING AN ARCHIVE
|
|
Packit |
08bd4c |
See
|
|
Packit |
08bd4c |
.Xr archive_read 3 .
|
|
Packit |
08bd4c |
.\"
|
|
Packit |
08bd4c |
.Sh WRITING AN ARCHIVE
|
|
Packit |
08bd4c |
See
|
|
Packit |
08bd4c |
.Xr archive_write 3 .
|
|
Packit |
08bd4c |
.\"
|
|
Packit |
08bd4c |
.Sh WRITING ENTRIES TO DISK
|
|
Packit |
08bd4c |
The
|
|
Packit |
08bd4c |
.Xr archive_write_disk 3
|
|
Packit |
08bd4c |
API allows you to write
|
|
Packit |
08bd4c |
.Xr archive_entry 3
|
|
Packit |
08bd4c |
objects to disk using the same API used by
|
|
Packit |
08bd4c |
.Xr archive_write 3 .
|
|
Packit |
08bd4c |
The
|
|
Packit |
08bd4c |
.Xr archive_write_disk 3
|
|
Packit |
08bd4c |
API is used internally by
|
|
Packit |
08bd4c |
.Fn archive_read_extract ;
|
|
Packit |
08bd4c |
using it directly can provide greater control over how entries
|
|
Packit |
08bd4c |
get written to disk.
|
|
Packit |
08bd4c |
This API also makes it possible to share code between
|
|
Packit |
08bd4c |
archive-to-archive copy and archive-to-disk extraction
|
|
Packit |
08bd4c |
operations.
|
|
Packit |
08bd4c |
.Sh READING ENTRIES FROM DISK
|
|
Packit |
08bd4c |
The
|
|
Packit |
08bd4c |
.Xr archive_read_disk 3
|
|
Packit |
08bd4c |
supports for populating
|
|
Packit |
08bd4c |
.Xr archive_entry 3
|
|
Packit |
08bd4c |
objects from information in the filesystem.
|
|
Packit |
08bd4c |
This includes the information accessible from the
|
|
Packit |
08bd4c |
.Xr stat 2
|
|
Packit |
08bd4c |
system call as well as ACLs, extended attributes,
|
|
Packit |
08bd4c |
and other metadata.
|
|
Packit |
08bd4c |
The
|
|
Packit |
08bd4c |
.Xr archive_read_disk 3
|
|
Packit |
08bd4c |
API also supports iterating over directory trees,
|
|
Packit |
08bd4c |
which allows directories of files to be read using
|
|
Packit |
08bd4c |
an API compatible with
|
|
Packit |
08bd4c |
the
|
|
Packit |
08bd4c |
.Xr archive_read 3
|
|
Packit |
08bd4c |
API.
|
|
Packit |
08bd4c |
.Sh DESCRIPTION
|
|
Packit |
08bd4c |
Detailed descriptions of each function are provided by the
|
|
Packit |
08bd4c |
corresponding manual pages.
|
|
Packit |
08bd4c |
.Pp
|
|
Packit |
08bd4c |
All of the functions utilize an opaque
|
|
Packit |
08bd4c |
.Tn struct archive
|
|
Packit |
08bd4c |
datatype that provides access to the archive contents.
|
|
Packit |
08bd4c |
.Pp
|
|
Packit |
08bd4c |
The
|
|
Packit |
08bd4c |
.Tn struct archive_entry
|
|
Packit |
08bd4c |
structure contains a complete description of a single archive
|
|
Packit |
08bd4c |
entry.
|
|
Packit |
08bd4c |
It uses an opaque interface that is fully documented in
|
|
Packit |
08bd4c |
.Xr archive_entry 3 .
|
|
Packit |
08bd4c |
.Pp
|
|
Packit |
08bd4c |
Users familiar with historic formats should be aware that the newer
|
|
Packit |
08bd4c |
variants have eliminated most restrictions on the length of textual fields.
|
|
Packit |
08bd4c |
Clients should not assume that filenames, link names, user names, or
|
|
Packit |
08bd4c |
group names are limited in length.
|
|
Packit |
08bd4c |
In particular, pax interchange format can easily accommodate pathnames
|
|
Packit |
08bd4c |
in arbitrary character sets that exceed
|
|
Packit |
08bd4c |
.Va PATH_MAX .
|
|
Packit |
08bd4c |
.Sh RETURN VALUES
|
|
Packit |
08bd4c |
Most functions return
|
|
Packit |
08bd4c |
.Cm ARCHIVE_OK
|
|
Packit |
08bd4c |
(zero) on success, non-zero on error.
|
|
Packit |
08bd4c |
The return value indicates the general severity of the error, ranging
|
|
Packit |
08bd4c |
from
|
|
Packit |
08bd4c |
.Cm ARCHIVE_WARN ,
|
|
Packit |
08bd4c |
which indicates a minor problem that should probably be reported
|
|
Packit |
08bd4c |
to the user, to
|
|
Packit |
08bd4c |
.Cm ARCHIVE_FATAL ,
|
|
Packit |
08bd4c |
which indicates a serious problem that will prevent any further
|
|
Packit |
08bd4c |
operations on this archive.
|
|
Packit |
08bd4c |
On error, the
|
|
Packit |
08bd4c |
.Fn archive_errno
|
|
Packit |
08bd4c |
function can be used to retrieve a numeric error code (see
|
|
Packit |
08bd4c |
.Xr errno 2 ) .
|
|
Packit |
08bd4c |
The
|
|
Packit |
08bd4c |
.Fn archive_error_string
|
|
Packit |
08bd4c |
returns a textual error message suitable for display.
|
|
Packit |
08bd4c |
.Pp
|
|
Packit |
08bd4c |
.Fn archive_read_new
|
|
Packit |
08bd4c |
and
|
|
Packit |
08bd4c |
.Fn archive_write_new
|
|
Packit |
08bd4c |
return pointers to an allocated and initialized
|
|
Packit |
08bd4c |
.Tn struct archive
|
|
Packit |
08bd4c |
object.
|
|
Packit |
08bd4c |
.Pp
|
|
Packit |
08bd4c |
.Fn archive_read_data
|
|
Packit |
08bd4c |
and
|
|
Packit |
08bd4c |
.Fn archive_write_data
|
|
Packit |
08bd4c |
return a count of the number of bytes actually read or written.
|
|
Packit |
08bd4c |
A value of zero indicates the end of the data for this entry.
|
|
Packit |
08bd4c |
A negative value indicates an error, in which case the
|
|
Packit |
08bd4c |
.Fn archive_errno
|
|
Packit |
08bd4c |
and
|
|
Packit |
08bd4c |
.Fn archive_error_string
|
|
Packit |
08bd4c |
functions can be used to obtain more information.
|
|
Packit |
08bd4c |
.Sh ENVIRONMENT
|
|
Packit |
08bd4c |
There are character set conversions within the
|
|
Packit |
08bd4c |
.Xr archive_entry 3
|
|
Packit |
08bd4c |
functions that are impacted by the currently-selected locale.
|
|
Packit |
08bd4c |
.Sh SEE ALSO
|
|
Packit |
08bd4c |
.Xr tar 1 ,
|
|
Packit |
08bd4c |
.Xr archive_entry 3 ,
|
|
Packit |
08bd4c |
.Xr archive_read 3 ,
|
|
Packit |
08bd4c |
.Xr archive_util 3 ,
|
|
Packit |
08bd4c |
.Xr archive_write 3 ,
|
|
Packit |
08bd4c |
.Xr tar 5
|
|
Packit |
08bd4c |
.Sh HISTORY
|
|
Packit |
08bd4c |
The
|
|
Packit |
08bd4c |
.Nm libarchive
|
|
Packit |
08bd4c |
library first appeared in
|
|
Packit |
08bd4c |
.Fx 5.3 .
|
|
Packit |
08bd4c |
.Sh AUTHORS
|
|
Packit |
08bd4c |
.An -nosplit
|
|
Packit |
08bd4c |
The
|
|
Packit |
08bd4c |
.Nm libarchive
|
|
Packit |
08bd4c |
library was originally written by
|
|
Packit |
08bd4c |
.An Tim Kientzle Aq kientzle@acm.org .
|
|
Packit |
08bd4c |
.Sh BUGS
|
|
Packit |
08bd4c |
Some archive formats support information that is not supported by
|
|
Packit |
08bd4c |
.Tn struct archive_entry .
|
|
Packit |
08bd4c |
Such information cannot be fully archived or restored using this library.
|
|
Packit |
08bd4c |
This includes, for example, comments, character sets,
|
|
Packit |
08bd4c |
or the arbitrary key/value pairs that can appear in
|
|
Packit |
08bd4c |
pax interchange format archives.
|
|
Packit |
08bd4c |
.Pp
|
|
Packit |
08bd4c |
Conversely, of course, not all of the information that can be
|
|
Packit |
08bd4c |
stored in an
|
|
Packit |
08bd4c |
.Tn struct archive_entry
|
|
Packit |
08bd4c |
is supported by all formats.
|
|
Packit |
08bd4c |
For example, cpio formats do not support nanosecond timestamps;
|
|
Packit |
08bd4c |
old tar formats do not support large device numbers.
|
|
Packit |
08bd4c |
.Pp
|
|
Packit |
08bd4c |
The ISO9660 reader cannot yet read all ISO9660 images;
|
|
Packit |
08bd4c |
it should learn how to seek.
|
|
Packit |
08bd4c |
.Pp
|
|
Packit |
08bd4c |
The AR writer requires the client program to use
|
|
Packit |
08bd4c |
two passes, unlike all other libarchive writers.
|