1.\" Copyright (c) 2010 Joerg Sonnenberger 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.Dd May 12, 2008 26.Dt ARCHIVE_ENTRY 3 27.Os 28.Sh NAME 29.Nm archive_entry_stat , 30.Nm archive_entry_copy_stat , 31.Nm archive_entry_filetype , 32.Nm archive_entry_set_filetype , 33.Nm archive_entry_mode , 34.Nm archive_entry_set_mode , 35.Nm archive_entry_size , 36.Nm archive_entry_size_is_set , 37.Nm archive_entry_set_size , 38.Nm archive_entry_unset_size , 39.Nm archive_entry_dev , 40.Nm archive_entry_set_dev , 41.Nm archive_entry_dev_is_set , 42.Nm archive_entry_devmajor , 43.Nm archive_entry_set_devmajor , 44.Nm archive_entry_devminor , 45.Nm archive_entry_set_devminor , 46.Nm archive_entry_ino , 47.Nm archive_entry_set_ino , 48.Nm archive_entry_ino_is_set , 49.Nm archive_entry_ino64 , 50.Nm archive_entry_set_ino64 , 51.Nm archive_entry_nlink , 52.Nm archive_entry_rdev , 53.Nm archive_entry_set_rdev , 54.Nm archive_entry_rdevmajor , 55.Nm archive_entry_set_rdevmajor , 56.Nm archive_entry_rdevminor , 57.Nm archive_entry_set_rdevminor , 58.Nd accessor functions for manipulating archive entry descriptions 59.Sh SYNOPSIS 60.In archive_entry.h 61.Ft const struct stat * 62.Fn archive_entry_stat "struct archive_entry *a" 63.Ft void 64.Fn archive_entry_copy_stat "struct archive_entry *a" "const struct stat *sb" 65.Ft mode_t 66.Fn archive_entry_filetype "struct archive_entry *a" 67.Ft void 68.Fn archive_entry_set_filetype "struct archive_entry *a" "unsigned int type" 69.Ft mode_t 70.Fn archive_entry_mode "struct archive_entry *a" 71.Ft void 72.Fn archive_entry_set_mode "struct archive_entry *a" "mode_t mode" 73.Ft int64_t 74.Fn archive_entry_size "struct archive_entry *a" 75.Ft int 76.Fn archive_entry_size_is_set "struct archive_entry *a" 77.Ft void 78.Fn archive_entry_set_size "struct archive_entry *a" "int64_t size" 79.Ft void 80.Fn archive_entry_unset_size "struct archive_entry *a" 81.Ft dev_t 82.Fn archive_entry_dev "struct archive_entry *a" 83.Ft void 84.Fn archive_entry_set_dev "struct archive_entry *a" "dev_t dev" 85.Ft int 86.Fn archive_entry_dev_is_set "struct archive_entry *a" 87.Ft dev_t 88.Fn archive_entry_devmajor "struct archive_entry *a" 89.Ft void 90.Fn archive_entry_set_devmajor "struct archive_entry *a" "dev_t major" 91.Ft dev_t 92.Fn archive_entry_devminor "struct archive_entry *a" 93.Ft void 94.Fn archive_entry_set_devminor "struct archive_entry *a" "dev_t minor" 95.Ft ino_t 96.Fn archive_entry_ino "struct archive_entry *a" 97.Ft void 98.Fn archive_entry_set_ino "struct archive_entry *a" "unsigned long ino" 99.Ft int 100.Fn archive_entry_ino_is_set "struct archive_entry *a" 101.Ft int64_t 102.Fn archive_entry_ino64 "struct archive_entry *a" 103.Ft void 104.Fn archive_entry_set_ino64 "struct archive_entry *a" "int64_t ino" 105.Ft unsigned int 106.Fn archive_entry_nlink "struct archive_entry *a" 107.Ft void 108.Fn archive_entry_set_nlink "struct archive_entry *a" "unsigned int count" 109.Ft dev_t 110.Fn archive_entry_rdev "struct archive_entry *a" 111.Ft dev_t 112.Fn archive_entry_rdevmajor "struct archive_entry *a" 113.Ft dev_t 114.Fn archive_entry_rdevminor "struct archive_entry *a" 115.Ft void 116.Fn archive_entry_set_rdev "struct archive_entry *a" "dev_t dev" 117.Ft void 118.Fn archive_entry_set_rdevmajor "struct archive_entry *a" "dev_t major" 119.Ft void 120.Fn archive_entry_set_rdevminor "struct archive_entry *a" "dev_t minor" 121.Sh DESCRIPTION 122.Ss Copying to and from Vt struct stat 123The function 124.Fn archive_entry_stat 125converts the various fields stored in the archive entry to the format 126used by 127.Xr stat 2 . 128The return value remains valid until either 129.Fn archive_entry_clear 130or 131.Fn archive_entry_free 132is called. 133It is not affected by calls to the set accessor functions. 134It currently sets the following values in 135.Vt struct stat : 136.Vt st_atime , 137.Vt st_ctime , 138.Vt st_dev , 139.Vt st_gid , 140.Vt st_ino , 141.Vt st_mode , 142.Vt st_mtime , 143.Vt st_nlink , 144.Vt st_rdev , 145.Vt st_size , 146.Vt st_uid . 147In addition, 148.Vt st_birthtime 149and high-precision information for time-related fields 150will be included on platforms that support it. 151.Pp 152The function 153.Fn archive_entry_copy_stat 154copies fields from the platform's 155.Vt struct stat . 156Fields not provided by 157.Vt struct stat 158are unchanged. 159.Ss General accessor functions 160The functions 161.Fn archive_entry_filetype 162and 163.Fn archive_entry_set_filetype 164get respectively set the filetype. 165The file type is one of the following constants: 166.Bl -tag -width "AE_IFSOCK" -compact -offset indent 167.It AE_IFREG 168Regular file 169.It AE_IFLNK 170Symbolic link 171.It AE_IFSOCK 172Socket 173.It AE_IFCHR 174Character device 175.It AE_IFBLK 176Block device 177.It AE_IFDIR 178Directory 179.It AE_IFIFO 180Named pipe (fifo) 181.El 182Not all file types are supported by all platforms. 183The constants used by 184.Xr stat 2 185may have different numeric values from the 186corresponding constants above. 187.Pp 188The functions 189.Fn archive_entry_mode 190and 191.Fn archive_entry_set_mode 192get/set a combination of file type and permissions and provide the 193equivalent of 194.Va st_mode . 195Use of 196.Fn archive_entry_filetype 197and 198.Fn archive_entry_perm 199for getting and 200.Fn archive_entry_set_filetype 201and 202.Fn archive_entry_set_perm 203for setting is recommended. 204.Pp 205The function 206.Fn archive_entry_size 207returns the file size, if it has been set, and 0 otherwise. 208.Fn archive_entry_size 209can be used to query that status. 210.Fn archive_entry_set_size 211and 212.Fn archive_entry_unset_size 213set and unset the size, respectively. 214.Pp 215The number of references (hardlinks) can be obtained by calling 216.Fn archive_entry_nlinks 217and set with 218.Fn archive_entry_set_nlinks . 219.Ss Identifying unique files 220The functions 221.Fn archive_entry_dev 222and 223.Fn archive_entry_ino64 224are used by 225.Xr archive_entry_linkify 3 226to find hardlinks. 227The pair of device and inode is suppossed to identify hardlinked files. 228.Pp 229The device major and minor number can be obtained independently using 230.Fn archive_entry_devmajor 231and 232.Fn archive_entry_devminor . 233The device can be set either via 234.Fn archive_entry_set_dev 235or by the combination of major and minor number using 236.Fn archive_entry_set_devmajor 237and 238.Fn archive_entry_set_devminor . 239.Pp 240The inode number can be obtained using 241.Fn archive_entry_ino . 242This is a legacy interface that uses the platform 243.Vt ino_t , 244which may be very small. 245To set the inode number, 246.Fn archive_entry_set_ino64 247is the preferred interface. 248.Ss Accessor functions for block and character devices 249Block and character devices are characterised either using a device number 250or a pair of major and minor number. 251The combined device number can be obtained with 252.Fn archive_device_rdev 253and set with 254.Fn archive_device_set_rdev . 255The major and minor numbers are accessed by 256.Fn archive_device_rdevmajor , 257.Fn archive_device_rdevminor 258.Fn archive_device_set_rdevmajor 259and 260.Fn archive_device_set_rdevminor . 261.Pp 262The process of splitting the combined device number into major and 263minor number and the reverse process of combing them differs between 264platforms. 265Some archive formats use the combined form, while other formats use 266the split form. 267.Sh SEE ALSO 268.Xr archive 3 , 269.Xr archive_entry_acl 3 , 270.Xr archive_entry_perms 3 , 271.Xr archive_entry_time 3 , 272.Xr stat 2 273