|ARCHIVE_WRITE_DISK(3)||Library Functions Manual||ARCHIVE_WRITE_DISK(3)|
struct archive *
archive *, int
archive *, dev_t,
archive *, void *, gid_t
(*)(void *, const char *gname, gid_t gid), void
archive *, void *, uid_t
(*)(void *, const char *uname, uid_t uid), void
archive_read() interface. The general process is to read struct archive_entry objects from an archive, then write those objects to a struct archive object created using the
archive_write_disk() family functions. This interface is deliberately very similar to the
archive_write() interface used to write objects to a streaming archive.
ARCHIVE_EXTRACT_OWNERis not specified, then SUID and SGID bits will only be restored if the default user and group IDs of newly-created objects on disk happen to match those specified in the archive entry. By default, only basic permissions are restored, and umask is obeyed.
ARCHIVE_EXTRACT_UNLINKis specified together with this option, the library will remove any intermediate symlinks it finds and return an error only if such symlink could not be removed.
ARCHIVE_OK(zero) on success, or one of several non-zero error codes for errors. Specific error codes include:
ARCHIVE_RETRYfor operations that might succeed if retried,
ARCHIVE_WARNfor unusual conditions that do not prevent further operations, and
ARCHIVE_FATALfor serious errors that make remaining operations impossible.
archive_write_disk_new() returns a pointer
to a newly-allocated struct archive object.
archive_write_data() returns a count of
the number of bytes actually written, or
libarchivelibrary first appeared in FreeBSD 5.3. The
archive_write_diskinterface was added to
libarchive 2.0and first appeared in FreeBSD 6.3.
libarchivelibrary was written by Tim Kientzle ⟨firstname.lastname@example.org⟩.
archive_write_header(), but final permissions are not set until
archive_write_close(). This separation is necessary to correctly handle borderline cases such as a non-writable directory containing files, but can cause unexpected results. In particular, directory permissions are not fully restored until the archive is closed. If you use chdir(2) to change the current directory between calls to
archive_read_extract() or before calling
archive_read_close(), you may confuse the permission-setting logic with the result that directory permissions are restored incorrectly.
The library attempts to create objects with filenames longer than
PATH_MAX by creating prefixes of the full path and
changing the current directory. Currently, this logic is limited in scope;
the fixup pass does not work correctly for such objects and the symlink
security check option disables the support for very long pathnames.
Restoring the path aa/../bb does create
each intermediate directory. In particular, the directory
aa is created as well as the final object
bb. In theory, this can be exploited to create an
entire directory hierarchy with a single request. Of course, this does not
work if the
ARCHIVE_EXTRACT_NODOTDOT option is
Implicit directories are always created obeying the current umask.
Explicit objects are created obeying the current umask unless
ARCHIVE_EXTRACT_PERM is specified, in which case
they current umask is ignored.
SGID and SUID bits are restored only if the correct user and group
could be set. If
ARCHIVE_EXTRACT_OWNER is not
specified, then no attempt is made to set the ownership. In this case, SGID
and SUID bits are restored only if the user and group of the final object
happen to match those specified in the entry.
The “standard” user-id and group-id lookup functions are not the defaults because getgrnam(3) and getpwnam(3) are sometimes too large for particular applications. The current design allows the application author to use a more compact implementation when appropriate.
There should be a corresponding
archive_read_disk interface that walks a directory
hierarchy and returns archive entry objects.
|April 3, 2017||Mac OS X 10.13|