Blame libarchive/archive_entry_stat.3

Packit Service 1d0348
.\" Copyright (c) 2010 Joerg Sonnenberger
Packit Service 1d0348
.\" All rights reserved.
Packit Service 1d0348
.\"
Packit Service 1d0348
.\" Redistribution and use in source and binary forms, with or without
Packit Service 1d0348
.\" modification, are permitted provided that the following conditions
Packit Service 1d0348
.\" are met:
Packit Service 1d0348
.\" 1. Redistributions of source code must retain the above copyright
Packit Service 1d0348
.\"    notice, this list of conditions and the following disclaimer.
Packit Service 1d0348
.\" 2. Redistributions in binary form must reproduce the above copyright
Packit Service 1d0348
.\"    notice, this list of conditions and the following disclaimer in the
Packit Service 1d0348
.\"    documentation and/or other materials provided with the distribution.
Packit Service 1d0348
.\"
Packit Service 1d0348
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
Packit Service 1d0348
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit Service 1d0348
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit Service 1d0348
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
Packit Service 1d0348
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit Service 1d0348
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
Packit Service 1d0348
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
Packit Service 1d0348
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
Packit Service 1d0348
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
Packit Service 1d0348
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
Packit Service 1d0348
.\" SUCH DAMAGE.
Packit Service 1d0348
.\"
Packit Service 1d0348
.Dd February 2, 2012
Packit Service 1d0348
.Dt ARCHIVE_ENTRY_STAT 3
Packit Service 1d0348
.Os
Packit Service 1d0348
.Sh NAME
Packit Service 1d0348
.Nm archive_entry_stat ,
Packit Service 1d0348
.Nm archive_entry_copy_stat ,
Packit Service 1d0348
.Nm archive_entry_filetype ,
Packit Service 1d0348
.Nm archive_entry_set_filetype ,
Packit Service 1d0348
.Nm archive_entry_mode ,
Packit Service 1d0348
.Nm archive_entry_set_mode ,
Packit Service 1d0348
.Nm archive_entry_size ,
Packit Service 1d0348
.Nm archive_entry_size_is_set ,
Packit Service 1d0348
.Nm archive_entry_set_size ,
Packit Service 1d0348
.Nm archive_entry_unset_size ,
Packit Service 1d0348
.Nm archive_entry_dev ,
Packit Service 1d0348
.Nm archive_entry_set_dev ,
Packit Service 1d0348
.Nm archive_entry_dev_is_set ,
Packit Service 1d0348
.Nm archive_entry_devmajor ,
Packit Service 1d0348
.Nm archive_entry_set_devmajor ,
Packit Service 1d0348
.Nm archive_entry_devminor ,
Packit Service 1d0348
.Nm archive_entry_set_devminor ,
Packit Service 1d0348
.Nm archive_entry_ino ,
Packit Service 1d0348
.Nm archive_entry_set_ino ,
Packit Service 1d0348
.Nm archive_entry_ino_is_set ,
Packit Service 1d0348
.Nm archive_entry_ino64 ,
Packit Service 1d0348
.Nm archive_entry_set_ino64 ,
Packit Service 1d0348
.Nm archive_entry_nlink ,
Packit Service 1d0348
.Nm archive_entry_rdev ,
Packit Service 1d0348
.Nm archive_entry_set_rdev ,
Packit Service 1d0348
.Nm archive_entry_rdevmajor ,
Packit Service 1d0348
.Nm archive_entry_set_rdevmajor ,
Packit Service 1d0348
.Nm archive_entry_rdevminor ,
Packit Service 1d0348
.Nm archive_entry_set_rdevminor ,
Packit Service 1d0348
.Nd accessor functions for manipulating archive entry descriptions
Packit Service 1d0348
.Sh LIBRARY
Packit Service 1d0348
Streaming Archive Library (libarchive, -larchive)
Packit Service 1d0348
.Sh SYNOPSIS
Packit Service 1d0348
.In archive_entry.h
Packit Service 1d0348
.Ft const struct stat *
Packit Service 1d0348
.Fn archive_entry_stat "struct archive_entry *a"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_copy_stat "struct archive_entry *a" "const struct stat *sb"
Packit Service 1d0348
.Ft mode_t
Packit Service 1d0348
.Fn archive_entry_filetype "struct archive_entry *a"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_set_filetype "struct archive_entry *a" "unsigned int type"
Packit Service 1d0348
.Ft mode_t
Packit Service 1d0348
.Fn archive_entry_mode "struct archive_entry *a"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_set_mode "struct archive_entry *a" "mode_t mode"
Packit Service 1d0348
.Ft int64_t
Packit Service 1d0348
.Fn archive_entry_size "struct archive_entry *a"
Packit Service 1d0348
.Ft int
Packit Service 1d0348
.Fn archive_entry_size_is_set "struct archive_entry *a"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_set_size "struct archive_entry *a" "int64_t size"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_unset_size "struct archive_entry *a"
Packit Service 1d0348
.Ft dev_t
Packit Service 1d0348
.Fn archive_entry_dev "struct archive_entry *a"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_set_dev "struct archive_entry *a" "dev_t dev"
Packit Service 1d0348
.Ft int
Packit Service 1d0348
.Fn archive_entry_dev_is_set "struct archive_entry *a"
Packit Service 1d0348
.Ft dev_t
Packit Service 1d0348
.Fn archive_entry_devmajor "struct archive_entry *a"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_set_devmajor "struct archive_entry *a" "dev_t major"
Packit Service 1d0348
.Ft dev_t
Packit Service 1d0348
.Fn archive_entry_devminor "struct archive_entry *a"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_set_devminor "struct archive_entry *a" "dev_t minor"
Packit Service 1d0348
.Ft ino_t
Packit Service 1d0348
.Fn archive_entry_ino "struct archive_entry *a"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_set_ino "struct archive_entry *a" "unsigned long ino"
Packit Service 1d0348
.Ft int
Packit Service 1d0348
.Fn archive_entry_ino_is_set "struct archive_entry *a"
Packit Service 1d0348
.Ft int64_t
Packit Service 1d0348
.Fn archive_entry_ino64 "struct archive_entry *a"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_set_ino64 "struct archive_entry *a" "int64_t ino"
Packit Service 1d0348
.Ft unsigned int
Packit Service 1d0348
.Fn archive_entry_nlink "struct archive_entry *a"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_set_nlink "struct archive_entry *a" "unsigned int count"
Packit Service 1d0348
.Ft dev_t
Packit Service 1d0348
.Fn archive_entry_rdev "struct archive_entry *a"
Packit Service 1d0348
.Ft dev_t
Packit Service 1d0348
.Fn archive_entry_rdevmajor "struct archive_entry *a"
Packit Service 1d0348
.Ft dev_t
Packit Service 1d0348
.Fn archive_entry_rdevminor "struct archive_entry *a"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_set_rdev "struct archive_entry *a" "dev_t dev"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_set_rdevmajor "struct archive_entry *a" "dev_t major"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_set_rdevminor "struct archive_entry *a" "dev_t minor"
Packit Service 1d0348
.Sh DESCRIPTION
Packit Service 1d0348
.Ss Copying to and from Vt struct stat
Packit Service 1d0348
The function
Packit Service 1d0348
.Fn archive_entry_stat
Packit Service 1d0348
converts the various fields stored in the archive entry to the format
Packit Service 1d0348
used by
Packit Service 1d0348
.Xr stat 2 .
Packit Service 1d0348
The return value remains valid until either
Packit Service 1d0348
.Fn archive_entry_clear
Packit Service 1d0348
or
Packit Service 1d0348
.Fn archive_entry_free
Packit Service 1d0348
is called.
Packit Service 1d0348
It is not affected by calls to the set accessor functions.
Packit Service 1d0348
It currently sets the following values in
Packit Service 1d0348
.Vt struct stat :
Packit Service 1d0348
.Vt st_atime ,
Packit Service 1d0348
.Vt st_ctime ,
Packit Service 1d0348
.Vt st_dev ,
Packit Service 1d0348
.Vt st_gid ,
Packit Service 1d0348
.Vt st_ino ,
Packit Service 1d0348
.Vt st_mode ,
Packit Service 1d0348
.Vt st_mtime ,
Packit Service 1d0348
.Vt st_nlink ,
Packit Service 1d0348
.Vt st_rdev ,
Packit Service 1d0348
.Vt st_size ,
Packit Service 1d0348
.Vt st_uid .
Packit Service 1d0348
In addition,
Packit Service 1d0348
.Vt st_birthtime
Packit Service 1d0348
and high-precision information for time-related fields
Packit Service 1d0348
will be included on platforms that support it.
Packit Service 1d0348
.Pp
Packit Service 1d0348
The function
Packit Service 1d0348
.Fn archive_entry_copy_stat
Packit Service 1d0348
copies fields from the platform's
Packit Service 1d0348
.Vt struct stat .
Packit Service 1d0348
Fields not provided by
Packit Service 1d0348
.Vt struct stat
Packit Service 1d0348
are unchanged.
Packit Service 1d0348
.Ss General accessor functions
Packit Service 1d0348
The functions
Packit Service 1d0348
.Fn archive_entry_filetype
Packit Service 1d0348
and
Packit Service 1d0348
.Fn archive_entry_set_filetype
Packit Service 1d0348
get respectively set the filetype.
Packit Service 1d0348
The file type is one of the following constants:
Packit Service 1d0348
.Bl -tag -width "AE_IFSOCK" -compact -offset indent
Packit Service 1d0348
.It AE_IFREG
Packit Service 1d0348
Regular file
Packit Service 1d0348
.It AE_IFLNK
Packit Service 1d0348
Symbolic link
Packit Service 1d0348
.It AE_IFSOCK
Packit Service 1d0348
Socket
Packit Service 1d0348
.It AE_IFCHR
Packit Service 1d0348
Character device
Packit Service 1d0348
.It AE_IFBLK
Packit Service 1d0348
Block device
Packit Service 1d0348
.It AE_IFDIR
Packit Service 1d0348
Directory
Packit Service 1d0348
.It AE_IFIFO
Packit Service 1d0348
Named pipe (fifo)
Packit Service 1d0348
.El
Packit Service 1d0348
Not all file types are supported by all platforms.
Packit Service 1d0348
The constants used by
Packit Service 1d0348
.Xr stat 2
Packit Service 1d0348
may have different numeric values from the
Packit Service 1d0348
corresponding constants above.
Packit Service 1d0348
.Pp
Packit Service 1d0348
The functions
Packit Service 1d0348
.Fn archive_entry_mode
Packit Service 1d0348
and
Packit Service 1d0348
.Fn archive_entry_set_mode
Packit Service 1d0348
get/set a combination of file type and permissions and provide the
Packit Service 1d0348
equivalent of
Packit Service 1d0348
.Va st_mode .
Packit Service 1d0348
Use of
Packit Service 1d0348
.Fn archive_entry_filetype
Packit Service 1d0348
and
Packit Service 1d0348
.Fn archive_entry_perm
Packit Service 1d0348
for getting and
Packit Service 1d0348
.Fn archive_entry_set_filetype
Packit Service 1d0348
and
Packit Service 1d0348
.Fn archive_entry_set_perm
Packit Service 1d0348
for setting is recommended.
Packit Service 1d0348
.Pp
Packit Service 1d0348
The function
Packit Service 1d0348
.Fn archive_entry_size
Packit Service 1d0348
returns the file size, if it has been set, and 0 otherwise.
Packit Service 1d0348
.Fn archive_entry_size
Packit Service 1d0348
can be used to query that status.
Packit Service 1d0348
.Fn archive_entry_set_size
Packit Service 1d0348
and
Packit Service 1d0348
.Fn archive_entry_unset_size
Packit Service 1d0348
set and unset the size, respectively.
Packit Service 1d0348
.Pp
Packit Service 1d0348
The number of references (hardlinks) can be obtained by calling
Packit Service 1d0348
.Fn archive_entry_nlinks
Packit Service 1d0348
and set with
Packit Service 1d0348
.Fn archive_entry_set_nlinks .
Packit Service 1d0348
.Ss Identifying unique files
Packit Service 1d0348
The functions
Packit Service 1d0348
.Fn archive_entry_dev
Packit Service 1d0348
and
Packit Service 1d0348
.Fn archive_entry_ino64
Packit Service 1d0348
are used by
Packit Service 1d0348
.Xr archive_entry_linkify 3
Packit Service 1d0348
to find hardlinks.
Packit Service 1d0348
The pair of device and inode is supposed to identify hardlinked files.
Packit Service 1d0348
.Pp
Packit Service 1d0348
The device major and minor number can be obtained independently using
Packit Service 1d0348
.Fn archive_entry_devmajor
Packit Service 1d0348
and
Packit Service 1d0348
.Fn archive_entry_devminor .
Packit Service 1d0348
The device can be set either via
Packit Service 1d0348
.Fn archive_entry_set_dev
Packit Service 1d0348
or by the combination of major and minor number using
Packit Service 1d0348
.Fn archive_entry_set_devmajor
Packit Service 1d0348
and
Packit Service 1d0348
.Fn archive_entry_set_devminor .
Packit Service 1d0348
.Pp
Packit Service 1d0348
The inode number can be obtained using
Packit Service 1d0348
.Fn archive_entry_ino .
Packit Service 1d0348
This is a legacy interface that uses the platform
Packit Service 1d0348
.Vt ino_t ,
Packit Service 1d0348
which may be very small.
Packit Service 1d0348
To set the inode number,
Packit Service 1d0348
.Fn archive_entry_set_ino64
Packit Service 1d0348
is the preferred interface.
Packit Service 1d0348
.Ss Accessor functions for block and character devices
Packit Service 1d0348
Block and character devices are characterised either using a device number
Packit Service 1d0348
or a pair of major and minor number.
Packit Service 1d0348
The combined device number can be obtained with
Packit Service 1d0348
.Fn archive_device_rdev
Packit Service 1d0348
and set with
Packit Service 1d0348
.Fn archive_device_set_rdev .
Packit Service 1d0348
The major and minor numbers are accessed by
Packit Service 1d0348
.Fn archive_device_rdevmajor ,
Packit Service 1d0348
.Fn archive_device_rdevminor
Packit Service 1d0348
.Fn archive_device_set_rdevmajor
Packit Service 1d0348
and
Packit Service 1d0348
.Fn archive_device_set_rdevminor .
Packit Service 1d0348
.Pp
Packit Service 1d0348
The process of splitting the combined device number into major and
Packit Service 1d0348
minor number and the reverse process of combing them differs between
Packit Service 1d0348
platforms.
Packit Service 1d0348
Some archive formats use the combined form, while other formats use
Packit Service 1d0348
the split form.
Packit Service 1d0348
.Sh SEE ALSO
Packit Service 1d0348
.Xr archive_entry_acl 3 ,
Packit Service 1d0348
.Xr archive_entry_perms 3 ,
Packit Service 1d0348
.Xr archive_entry_time 3 ,
Packit Service 1d0348
.Xr libarchive 3 ,
Packit Service 1d0348
.Xr stat 2