Blame doc/wiki/ManPageArchiveReadDisk3.wiki

Packit Service 1d0348
ARCHIVE_READ_DISK(3) manual page 
Packit Service 1d0348
== NAME == 
Packit Service 1d0348
'''archive_read_disk_new''', 
Packit Service 1d0348
'''archive_read_disk_set_behavior''', 
Packit Service 1d0348
'''archive_read_disk_set_symlink_logical''', 
Packit Service 1d0348
'''archive_read_disk_set_symlink_physical''', 
Packit Service 1d0348
'''archive_read_disk_set_symlink_hybrid''', 
Packit Service 1d0348
'''archive_read_disk_entry_from_file''', 
Packit Service 1d0348
'''archive_read_disk_gname''', 
Packit Service 1d0348
'''archive_read_disk_uname''', 
Packit Service 1d0348
'''archive_read_disk_set_uname_lookup''', 
Packit Service 1d0348
'''archive_read_disk_set_gname_lookup''', 
Packit Service 1d0348
'''archive_read_disk_set_standard_lookup''' 
Packit Service 1d0348
- functions for reading objects from disk 
Packit Service 1d0348
== LIBRARY == 
Packit Service 1d0348
Streaming Archive Library (libarchive, -larchive) 
Packit Service 1d0348
== SYNOPSIS == 
Packit Service 1d0348
'''<nowiki>#include <archive.h></nowiki>''' 
Packit Service 1d0348

Packit Service 1d0348
''struct archive *'' 
Packit Service 1d0348

Packit Service 1d0348
'''archive_read_disk_new'''(''void''); 
Packit Service 1d0348

Packit Service 1d0348
''int'' 
Packit Service 1d0348

Packit Service 1d0348
'''archive_read_disk_set_behavior'''(''struct archive *'', ''int''); 
Packit Service 1d0348

Packit Service 1d0348
''int'' 
Packit Service 1d0348

Packit Service 1d0348
'''archive_read_disk_set_symlink_logical'''(''struct archive *''); 
Packit Service 1d0348

Packit Service 1d0348
''int'' 
Packit Service 1d0348

Packit Service 1d0348
'''archive_read_disk_set_symlink_physical'''(''struct archive *''); 
Packit Service 1d0348

Packit Service 1d0348
''int'' 
Packit Service 1d0348

Packit Service 1d0348
'''archive_read_disk_set_symlink_hybrid'''(''struct archive *''); 
Packit Service 1d0348

Packit Service 1d0348
''const char *'' 
Packit Service 1d0348

Packit Service 1d0348
'''archive_read_disk_gname'''(''struct archive *'', ''gid_t''); 
Packit Service 1d0348

Packit Service 1d0348
''const char *'' 
Packit Service 1d0348

Packit Service 1d0348
'''archive_read_disk_uname'''(''struct archive *'', ''uid_t''); 
Packit Service 1d0348

Packit Service 1d0348
''int'' 
Packit Service 1d0348

Packit Service 1d0348
'''archive_read_disk_set_gname_lookup'''(''struct archive *'', ''void *'', ''const char *(*lookup)(void *, gid_t)'', ''void (*cleanup)(void *)''); 
Packit Service 1d0348

Packit Service 1d0348
''int'' 
Packit Service 1d0348

Packit Service 1d0348
'''archive_read_disk_set_uname_lookup'''(''struct archive *'', ''void *'', ''const char *(*lookup)(void *, uid_t)'', ''void (*cleanup)(void *)''); 
Packit Service 1d0348

Packit Service 1d0348
''int'' 
Packit Service 1d0348

Packit Service 1d0348
'''archive_read_disk_set_standard_lookup'''(''struct archive *''); 
Packit Service 1d0348

Packit Service 1d0348
''int'' 
Packit Service 1d0348

Packit Service 1d0348
'''archive_read_disk_entry_from_file'''(''struct archive *'', ''struct archive_entry *'', ''int fd'', ''const struct stat *''); 
Packit Service 1d0348
== DESCRIPTION == 
Packit Service 1d0348
These functions provide an API for reading information about 
Packit Service 1d0348
objects on disk. 
Packit Service 1d0348
In particular, they provide an interface for populating 
Packit Service 1d0348
'''struct archive_entry''' 
Packit Service 1d0348
objects. 
Packit Service 1d0348
Packit Service 1d0348
'''archive_read_disk_new'''()
Packit Service 1d0348
Allocates and initializes a 
Packit Service 1d0348
'''struct archive''' 
Packit Service 1d0348
object suitable for reading object information from disk. 
Packit Service 1d0348
'''archive_read_disk_set_behavior'''()
Packit Service 1d0348
Configures various behavior options when reading entries from disk. 
Packit Service 1d0348
The flags field consists of a bitwise OR of one or more of the 
Packit Service 1d0348
following values: 
Packit Service 1d0348
Packit Service 1d0348
'''ARCHIVE_READDISK_HONOR_NODUMP'''
Packit Service 1d0348
Skip files and directories with the nodump file attribute (file flag) set. 
Packit Service 1d0348
By default, the nodump file atrribute is ignored. 
Packit Service 1d0348
'''ARCHIVE_READDISK_MAC_COPYFILE'''
Packit Service 1d0348
Mac OS X specific. Read metadata (ACLs and extended attributes) with 
Packit Service 1d0348
[[copyfile(3)|http://www.freebsd.org/cgi/man.cgi?query=copyfile&sektion=3]]. 
Packit Service 1d0348
By default, metadata is read using 
Packit Service 1d0348
[[copyfile(3)|http://www.freebsd.org/cgi/man.cgi?query=copyfile&sektion=3]]. 
Packit Service 1d0348
'''ARCHIVE_READDISK_NO_ACL'''
Packit Service 1d0348
Do not read Access Control Lists. 
Packit Service 1d0348
By default, ACLs are read from disk. 
Packit Service 1d0348
'''ARCHIVE_READDISK_NO_FFLAGS'''
Packit Service 1d0348
Do not read file attributes (file flags). 
Packit Service 1d0348
By default, file attributes are read from disk. 
Packit Service 1d0348
See 
Packit Service 1d0348
[[chattr(1)|http://www.freebsd.org/cgi/man.cgi?query=chattr&sektion=1]] 
Packit Service 1d0348
(Linux) 
Packit Service 1d0348
or 
Packit Service 1d0348
[[chflags(1)|http://www.freebsd.org/cgi/man.cgi?query=chflags&sektion=1]] 
Packit Service 1d0348
(FreeBSD, Mac OS X) 
Packit Service 1d0348
for more information on file attributes. 
Packit Service 1d0348
'''ARCHIVE_READDISK_NO_TRAVERSE_MOUNTS'''
Packit Service 1d0348
Do not traverse mount points. 
Packit Service 1d0348
By defaut, moint points are traversed. 
Packit Service 1d0348
'''ARCHIVE_READDISK_NO_XATTR'''
Packit Service 1d0348
Do not read extended file attributes (xattrs). 
Packit Service 1d0348
By default, extended file attributes are read from disk. 
Packit Service 1d0348
See 
Packit Service 1d0348
[[xattr(7)|http://www.freebsd.org/cgi/man.cgi?query=xattr&sektion=7]] 
Packit Service 1d0348
(Linux,) 
Packit Service 1d0348
[[xattr(2)|http://www.freebsd.org/cgi/man.cgi?query=xattr&sektion=2]] 
Packit Service 1d0348
(Mac OS X,) 
Packit Service 1d0348
or 
Packit Service 1d0348
[[getextattr(8)|http://www.freebsd.org/cgi/man.cgi?query=getextattr&sektion=8]] 
Packit Service 1d0348
(FreeBSD) 
Packit Service 1d0348
for more information on extended file attributes. 
Packit Service 1d0348
'''ARCHIVE_READDISK_RESTORE_ATIME'''
Packit Service 1d0348
Restore access time of traversed files. 
Packit Service 1d0348
By default, access time of traversed files is not restored. 
Packit Service 1d0348
 
Packit Service 1d0348
Packit Service 1d0348
'''archive_read_disk_set_symlink_logical'''(), 
Packit Service 1d0348
'''archive_read_disk_set_symlink_physical'''(), 
Packit Service 1d0348
'''archive_read_disk_set_symlink_hybrid'''() 
Packit Service 1d0348
 
Packit Service 1d0348
This sets the mode used for handling symbolic links. 
Packit Service 1d0348
The 
Packit Service 1d0348
"logical" 
Packit Service 1d0348
mode follows all symbolic links. 
Packit Service 1d0348
The 
Packit Service 1d0348
"physical" 
Packit Service 1d0348
mode does not follow any symbolic links. 
Packit Service 1d0348
The 
Packit Service 1d0348
"hybrid" 
Packit Service 1d0348
mode currently behaves identically to the 
Packit Service 1d0348
"logical" 
Packit Service 1d0348
mode. 
Packit Service 1d0348
Packit Service 1d0348
'''archive_read_disk_gname'''(), 
Packit Service 1d0348
'''archive_read_disk_uname'''() 
Packit Service 1d0348
 
Packit Service 1d0348
Returns a user or group name given a gid or uid value. 
Packit Service 1d0348
By default, these always return a NULL string. 
Packit Service 1d0348
Packit Service 1d0348
'''archive_read_disk_set_gname_lookup'''(), 
Packit Service 1d0348
'''archive_read_disk_set_uname_lookup'''() 
Packit Service 1d0348
 
Packit Service 1d0348
These allow you to override the functions used for 
Packit Service 1d0348
user and group name lookups. 
Packit Service 1d0348
You may also provide a 
Packit Service 1d0348
'''void *''' 
Packit Service 1d0348
pointer to a private data structure and a cleanup function for 
Packit Service 1d0348
that data. 
Packit Service 1d0348
The cleanup function will be invoked when the 
Packit Service 1d0348
'''struct archive''' 
Packit Service 1d0348
object is destroyed or when new lookup functions are registered. 
Packit Service 1d0348
'''archive_read_disk_set_standard_lookup'''()
Packit Service 1d0348
This convenience function installs a standard set of user 
Packit Service 1d0348
and group name lookup functions. 
Packit Service 1d0348
These functions use 
Packit Service 1d0348
[[getpwuid(3)|http://www.freebsd.org/cgi/man.cgi?query=getpwuid&sektion=3]] 
Packit Service 1d0348
and 
Packit Service 1d0348
[[getgrgid(3)|http://www.freebsd.org/cgi/man.cgi?query=getgrgid&sektion=3]] 
Packit Service 1d0348
to convert ids to names, defaulting to NULL if the names cannot 
Packit Service 1d0348
be looked up. 
Packit Service 1d0348
These functions also implement a simple memory cache to reduce 
Packit Service 1d0348
the number of calls to 
Packit Service 1d0348
[[getpwuid(3)|http://www.freebsd.org/cgi/man.cgi?query=getpwuid&sektion=3]] 
Packit Service 1d0348
and 
Packit Service 1d0348
[[getgrgid(3)|http://www.freebsd.org/cgi/man.cgi?query=getgrgid&sektion=3]]. 
Packit Service 1d0348
'''archive_read_disk_entry_from_file'''()
Packit Service 1d0348
Populates a 
Packit Service 1d0348
'''struct archive_entry''' 
Packit Service 1d0348
object with information about a particular file. 
Packit Service 1d0348
The 
Packit Service 1d0348
'''archive_entry''' 
Packit Service 1d0348
object must have already been created with 
Packit Service 1d0348
[[ManPagerchiventryew3]] 
Packit Service 1d0348
and at least one of the source path or path fields must already be set. 
Packit Service 1d0348
(If both are set, the source path will be used.) 
Packit Service 1d0348
Packit Service 1d0348
Information is read from disk using the path name from the 
Packit Service 1d0348
'''struct archive_entry''' 
Packit Service 1d0348
object. 
Packit Service 1d0348
If a file descriptor is provided, some information will be obtained using 
Packit Service 1d0348
that file descriptor, on platforms that support the appropriate 
Packit Service 1d0348
system calls. 
Packit Service 1d0348
Packit Service 1d0348
If a pointer to a 
Packit Service 1d0348
'''struct stat''' 
Packit Service 1d0348
is provided, information from that structure will be used instead 
Packit Service 1d0348
of reading from the disk where appropriate. 
Packit Service 1d0348
This can provide performance benefits in scenarios where 
Packit Service 1d0348
'''struct stat''' 
Packit Service 1d0348
information has already been read from the disk as a side effect 
Packit Service 1d0348
of some other operation. 
Packit Service 1d0348
(For example, directory traversal libraries often provide this information.) 
Packit Service 1d0348
Packit Service 1d0348
Where necessary, user and group ids are converted to user and group names 
Packit Service 1d0348
using the currently registered lookup functions above. 
Packit Service 1d0348
This affects the file ownership fields and ACL values in the 
Packit Service 1d0348
'''struct archive_entry''' 
Packit Service 1d0348
object. 
Packit Service 1d0348
 
Packit Service 1d0348
More information about the 
Packit Service 1d0348
''struct'' archive 
Packit Service 1d0348
object and the overall design of the library can be found in the 
Packit Service 1d0348
[[ManPageibarchive3]] 
Packit Service 1d0348
overview. 
Packit Service 1d0348
== EXAMPLE == 
Packit Service 1d0348
The following illustrates basic usage of the library by 
Packit Service 1d0348
showing how to use it to copy an item on disk into an archive. 
Packit Service 1d0348
```text
Packit Service 1d0348
void
Packit Service 1d0348
file_to_archive(struct archive *a, const char *name)
Packit Service 1d0348
{
Packit Service 1d0348
  char buff[8192];
Packit Service 1d0348
  size_t bytes_read;
Packit Service 1d0348
  struct archive *ard;
Packit Service 1d0348
  struct archive_entry *entry;
Packit Service 1d0348
  int fd;
Packit Service 1d0348
  ard = archive_read_disk_new();
Packit Service 1d0348
  archive_read_disk_set_standard_lookup(ard);
Packit Service 1d0348
  entry = archive_entry_new();
Packit Service 1d0348
  fd = open(name, O_RDONLY);
Packit Service 1d0348
  if (fd < 0)
Packit Service 1d0348
     return;
Packit Service 1d0348
  archive_entry_copy_pathname(entry, name);
Packit Service 1d0348
  archive_read_disk_entry_from_file(ard, entry, fd, NULL);
Packit Service 1d0348
  archive_write_header(a, entry);
Packit Service 1d0348
  while ((bytes_read = read(fd, buff, sizeof(buff))) > 0)
Packit Service 1d0348
    archive_write_data(a, buff, bytes_read);
Packit Service 1d0348
  archive_write_finish_entry(a);
Packit Service 1d0348
  archive_read_free(ard);
Packit Service 1d0348
  archive_entry_free(entry);
Packit Service 1d0348
}
Packit Service 1d0348
```
Packit Service 1d0348
== RETURN VALUES == 
Packit Service 1d0348
Most functions return 
Packit Service 1d0348
'''ARCHIVE_OK''' 
Packit Service 1d0348
(zero) on success, or one of several negative 
Packit Service 1d0348
error codes for errors. 
Packit Service 1d0348
Specific error codes include: 
Packit Service 1d0348
'''ARCHIVE_RETRY''' 
Packit Service 1d0348
for operations that might succeed if retried, 
Packit Service 1d0348
'''ARCHIVE_WARN''' 
Packit Service 1d0348
for unusual conditions that do not prevent further operations, and 
Packit Service 1d0348
'''ARCHIVE_FATAL''' 
Packit Service 1d0348
for serious errors that make remaining operations impossible. 
Packit Service 1d0348
Packit Service 1d0348
'''archive_read_disk_new'''() 
Packit Service 1d0348
returns a pointer to a newly-allocated 
Packit Service 1d0348
'''struct archive''' 
Packit Service 1d0348
object or NULL if the allocation failed for any reason. 
Packit Service 1d0348
Packit Service 1d0348
'''archive_read_disk_gname'''() 
Packit Service 1d0348
and 
Packit Service 1d0348
'''archive_read_disk_uname'''() 
Packit Service 1d0348
return 
Packit Service 1d0348
'''const char *''' 
Packit Service 1d0348
pointers to the textual name or NULL if the lookup failed for any reason. 
Packit Service 1d0348
The returned pointer points to internal storage that 
Packit Service 1d0348
may be reused on the next call to either of these functions; 
Packit Service 1d0348
callers should copy the string if they need to continue accessing it. 
Packit Service 1d0348
== ERRORS == 
Packit Service 1d0348
Detailed error codes and textual descriptions are available from the 
Packit Service 1d0348
'''archive_errno'''() 
Packit Service 1d0348
and 
Packit Service 1d0348
'''archive_error_string'''() 
Packit Service 1d0348
functions. 
Packit Service 1d0348
== SEE ALSO == 
Packit Service 1d0348
[[ManPagerchiveead3]], 
Packit Service 1d0348
[[ManPagerchivetil3]], 
Packit Service 1d0348
[[ManPagerchiverite3]], 
Packit Service 1d0348
[[ManPagerchiveriteisk3]], 
Packit Service 1d0348
[[ManPageBsdtar1]], 
Packit Service 1d0348
[[ManPageibarchive3]] 
Packit Service 1d0348
== HISTORY == 
Packit Service 1d0348
The 
Packit Service 1d0348
'''libarchive''' 
Packit Service 1d0348
library first appeared in 
Packit Service 1d0348
FreeBSD 5.3. 
Packit Service 1d0348
The 
Packit Service 1d0348
'''archive_read_disk''' 
Packit Service 1d0348
interface was added to 
Packit Service 1d0348
'''libarchive''' 2.6 
Packit Service 1d0348
and first appeared in 
Packit Service 1d0348
FreeBSD 8.0. 
Packit Service 1d0348
== AUTHORS == 
Packit Service 1d0348
The 
Packit Service 1d0348
'''libarchive''' 
Packit Service 1d0348
library was written by 
Packit Service 1d0348
Tim Kientzle  <kientzle@FreeBSD.org.> 
Packit Service 1d0348
== BUGS == 
Packit Service 1d0348
The 
Packit Service 1d0348
"standard" 
Packit Service 1d0348
user name and group name lookup functions are not the defaults because 
Packit Service 1d0348
[[getgrgid(3)|http://www.freebsd.org/cgi/man.cgi?query=getgrgid&sektion=3]] 
Packit Service 1d0348
and 
Packit Service 1d0348
[[getpwuid(3)|http://www.freebsd.org/cgi/man.cgi?query=getpwuid&sektion=3]] 
Packit Service 1d0348
are sometimes too large for particular applications. 
Packit Service 1d0348
The current design allows the application author to use a more 
Packit Service 1d0348
compact implementation when appropriate. 
Packit Service 1d0348
Packit Service 1d0348
The full list of metadata read from disk by 
Packit Service 1d0348
'''archive_read_disk_entry_from_file'''() 
Packit Service 1d0348
is necessarily system-dependent. 
Packit Service 1d0348
Packit Service 1d0348
The 
Packit Service 1d0348
'''archive_read_disk_entry_from_file'''() 
Packit Service 1d0348
function reads as much information as it can from disk. 
Packit Service 1d0348
Some method should be provided to limit this so that clients who 
Packit Service 1d0348
do not need ACLs, for instance, can avoid the extra work needed 
Packit Service 1d0348
to look up such information. 
Packit Service 1d0348
Packit Service 1d0348
This API should provide a set of methods for walking a directory tree. 
Packit Service 1d0348
That would make it a direct parallel of the 
Packit Service 1d0348
[[ManPagerchiveead3]] 
Packit Service 1d0348
API. 
Packit Service 1d0348
When such methods are implemented, the 
Packit Service 1d0348
"hybrid" 
Packit Service 1d0348
symbolic link mode will make sense.