1*8269e767SBrooks Davis.\" Copyright (c) 1980, 1991, 1993, 1994 2*8269e767SBrooks Davis.\" The Regents of the University of California. All rights reserved. 3*8269e767SBrooks Davis.\" 4*8269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without 5*8269e767SBrooks Davis.\" modification, are permitted provided that the following conditions 6*8269e767SBrooks Davis.\" are met: 7*8269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright 8*8269e767SBrooks Davis.\" notice, this list of conditions and the following disclaimer. 9*8269e767SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright 10*8269e767SBrooks Davis.\" notice, this list of conditions and the following disclaimer in the 11*8269e767SBrooks Davis.\" documentation and/or other materials provided with the distribution. 12*8269e767SBrooks Davis.\" 3. Neither the name of the University nor the names of its contributors 13*8269e767SBrooks Davis.\" may be used to endorse or promote products derived from this software 14*8269e767SBrooks Davis.\" without specific prior written permission. 15*8269e767SBrooks Davis.\" 16*8269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17*8269e767SBrooks Davis.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18*8269e767SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19*8269e767SBrooks Davis.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20*8269e767SBrooks Davis.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21*8269e767SBrooks Davis.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22*8269e767SBrooks Davis.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23*8269e767SBrooks Davis.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24*8269e767SBrooks Davis.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25*8269e767SBrooks Davis.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26*8269e767SBrooks Davis.\" SUCH DAMAGE. 27*8269e767SBrooks Davis.\" 28*8269e767SBrooks Davis.Dd March 30, 2021 29*8269e767SBrooks Davis.Dt STAT 2 30*8269e767SBrooks Davis.Os 31*8269e767SBrooks Davis.Sh NAME 32*8269e767SBrooks Davis.Nm stat , 33*8269e767SBrooks Davis.Nm lstat , 34*8269e767SBrooks Davis.Nm fstat , 35*8269e767SBrooks Davis.Nm fstatat 36*8269e767SBrooks Davis.Nd get file status 37*8269e767SBrooks Davis.Sh LIBRARY 38*8269e767SBrooks Davis.Lb libc 39*8269e767SBrooks Davis.Sh SYNOPSIS 40*8269e767SBrooks Davis.In sys/stat.h 41*8269e767SBrooks Davis.Ft int 42*8269e767SBrooks Davis.Fn stat "const char * restrict path" "struct stat * restrict sb" 43*8269e767SBrooks Davis.Ft int 44*8269e767SBrooks Davis.Fn lstat "const char * restrict path" "struct stat * restrict sb" 45*8269e767SBrooks Davis.Ft int 46*8269e767SBrooks Davis.Fn fstat "int fd" "struct stat *sb" 47*8269e767SBrooks Davis.Ft int 48*8269e767SBrooks Davis.Fn fstatat "int fd" "const char *path" "struct stat *sb" "int flag" 49*8269e767SBrooks Davis.Sh DESCRIPTION 50*8269e767SBrooks DavisThe 51*8269e767SBrooks Davis.Fn stat 52*8269e767SBrooks Davissystem call obtains information about the file pointed to by 53*8269e767SBrooks Davis.Fa path . 54*8269e767SBrooks DavisRead, write or execute 55*8269e767SBrooks Davispermission of the named file is not required, but all directories 56*8269e767SBrooks Davislisted in the path name leading to the file must be searchable. 57*8269e767SBrooks Davis.Pp 58*8269e767SBrooks DavisThe 59*8269e767SBrooks Davis.Fn lstat 60*8269e767SBrooks Davissystem call is like 61*8269e767SBrooks Davis.Fn stat 62*8269e767SBrooks Davisexcept when the named file is a symbolic link, 63*8269e767SBrooks Davisin which case 64*8269e767SBrooks Davis.Fn lstat 65*8269e767SBrooks Davisreturns information about the link, 66*8269e767SBrooks Daviswhile 67*8269e767SBrooks Davis.Fn stat 68*8269e767SBrooks Davisreturns information about the file the link references. 69*8269e767SBrooks Davis.Pp 70*8269e767SBrooks DavisThe 71*8269e767SBrooks Davis.Fn fstat 72*8269e767SBrooks Davissystem call obtains the same information about an open file 73*8269e767SBrooks Davisknown by the file descriptor 74*8269e767SBrooks Davis.Fa fd . 75*8269e767SBrooks Davis.Pp 76*8269e767SBrooks DavisThe 77*8269e767SBrooks Davis.Fn fstatat 78*8269e767SBrooks Davissystem call is equivalent to 79*8269e767SBrooks Davis.Fn stat 80*8269e767SBrooks Davisand 81*8269e767SBrooks Davis.Fn lstat 82*8269e767SBrooks Davisexcept when the 83*8269e767SBrooks Davis.Fa path 84*8269e767SBrooks Davisspecifies a relative path. 85*8269e767SBrooks DavisFor 86*8269e767SBrooks Davis.Fn fstatat 87*8269e767SBrooks Davisand relative 88*8269e767SBrooks Davis.Fa path , 89*8269e767SBrooks Davisthe status is retrieved from a file relative to 90*8269e767SBrooks Davisthe directory associated with the file descriptor 91*8269e767SBrooks Davis.Fa fd 92*8269e767SBrooks Davisinstead of the current working directory. 93*8269e767SBrooks Davis.Pp 94*8269e767SBrooks DavisThe values for the 95*8269e767SBrooks Davis.Fa flag 96*8269e767SBrooks Davisare constructed by a bitwise-inclusive OR of flags from this list, 97*8269e767SBrooks Davisdefined in 98*8269e767SBrooks Davis.In fcntl.h : 99*8269e767SBrooks Davis.Bl -tag -width indent 100*8269e767SBrooks Davis.It Dv AT_SYMLINK_NOFOLLOW 101*8269e767SBrooks DavisIf 102*8269e767SBrooks Davis.Fa path 103*8269e767SBrooks Davisnames a symbolic link, the status of the symbolic link is returned. 104*8269e767SBrooks Davis.It Dv AT_RESOLVE_BENEATH 105*8269e767SBrooks DavisOnly walk paths below the starting directory. 106*8269e767SBrooks DavisSee the description of the 107*8269e767SBrooks Davis.Dv O_RESOLVE_BENEATH 108*8269e767SBrooks Davisflag in the 109*8269e767SBrooks Davis.Xr open 2 110*8269e767SBrooks Davismanual page. 111*8269e767SBrooks Davis.It Dv AT_EMPTY_PATH 112*8269e767SBrooks DavisIf the 113*8269e767SBrooks Davis.Fa path 114*8269e767SBrooks Davisargument is an empty string, operate on the file or directory 115*8269e767SBrooks Davisreferenced by the descriptor 116*8269e767SBrooks Davis.Fa fd . 117*8269e767SBrooks DavisIf 118*8269e767SBrooks Davis.Fa fd 119*8269e767SBrooks Davisis equal to 120*8269e767SBrooks Davis.Dv AT_FDCWD , 121*8269e767SBrooks Davisoperate on the current working directory. 122*8269e767SBrooks Davis.El 123*8269e767SBrooks Davis.Pp 124*8269e767SBrooks DavisIf 125*8269e767SBrooks Davis.Fn fstatat 126*8269e767SBrooks Davisis passed the special value 127*8269e767SBrooks Davis.Dv AT_FDCWD 128*8269e767SBrooks Davisin the 129*8269e767SBrooks Davis.Fa fd 130*8269e767SBrooks Davisparameter, the current working directory is used and the behavior is 131*8269e767SBrooks Davisidentical to a call to 132*8269e767SBrooks Davis.Fn stat 133*8269e767SBrooks Davisor 134*8269e767SBrooks Davis.Fn lstat 135*8269e767SBrooks Davisrespectively, depending on whether or not the 136*8269e767SBrooks Davis.Dv AT_SYMLINK_NOFOLLOW 137*8269e767SBrooks Davisbit is set in 138*8269e767SBrooks Davis.Fa flag . 139*8269e767SBrooks Davis.Pp 140*8269e767SBrooks DavisWhen 141*8269e767SBrooks Davis.Fn fstatat 142*8269e767SBrooks Davisis called with an absolute 143*8269e767SBrooks Davis.Fa path , 144*8269e767SBrooks Davisit ignores the 145*8269e767SBrooks Davis.Fa fd 146*8269e767SBrooks Davisargument. 147*8269e767SBrooks Davis.Pp 148*8269e767SBrooks DavisThe 149*8269e767SBrooks Davis.Fa sb 150*8269e767SBrooks Davisargument is a pointer to a 151*8269e767SBrooks Davis.Vt stat 152*8269e767SBrooks Davisstructure 153*8269e767SBrooks Davisas defined by 154*8269e767SBrooks Davis.In sys/stat.h 155*8269e767SBrooks Davisand into which information is placed concerning the file. 156*8269e767SBrooks Davis.Pp 157*8269e767SBrooks DavisThe fields of 158*8269e767SBrooks Davis.Vt "struct stat" 159*8269e767SBrooks Davisrelated to the file system are: 160*8269e767SBrooks Davis.Bl -tag -width ".Va st_nlink" 161*8269e767SBrooks Davis.It Va st_dev 162*8269e767SBrooks DavisNumeric ID of the device containing the file. 163*8269e767SBrooks Davis.It Va st_ino 164*8269e767SBrooks DavisThe file's inode number. 165*8269e767SBrooks Davis.It Va st_nlink 166*8269e767SBrooks DavisNumber of hard links to the file. 167*8269e767SBrooks Davis.It Va st_flags 168*8269e767SBrooks DavisFlags enabled for the file. 169*8269e767SBrooks DavisSee 170*8269e767SBrooks Davis.Xr chflags 2 171*8269e767SBrooks Davisfor the list of flags and their description. 172*8269e767SBrooks Davis.El 173*8269e767SBrooks Davis.Pp 174*8269e767SBrooks DavisThe 175*8269e767SBrooks Davis.Va st_dev 176*8269e767SBrooks Davisand 177*8269e767SBrooks Davis.Va st_ino 178*8269e767SBrooks Davisfields together identify the file uniquely within the system. 179*8269e767SBrooks Davis.Pp 180*8269e767SBrooks DavisThe time-related fields of 181*8269e767SBrooks Davis.Vt "struct stat" 182*8269e767SBrooks Davisare: 183*8269e767SBrooks Davis.Bl -tag -width ".Va st_birthtim" 184*8269e767SBrooks Davis.It Va st_atim 185*8269e767SBrooks DavisTime when file data was last accessed. 186*8269e767SBrooks DavisChanged implicitly by syscalls such as 187*8269e767SBrooks Davis.Xr read 2 188*8269e767SBrooks Davisand 189*8269e767SBrooks Davis.Xr readv 2 , 190*8269e767SBrooks Davisand explicitly by 191*8269e767SBrooks Davis.Xr utimes 2 . 192*8269e767SBrooks Davis.It Va st_mtim 193*8269e767SBrooks DavisTime when file data was last modified. 194*8269e767SBrooks DavisChanged implicitly by syscalls such as 195*8269e767SBrooks Davis.Xr truncate 2 , 196*8269e767SBrooks Davis.Xr write 2 , 197*8269e767SBrooks Davisand 198*8269e767SBrooks Davis.Xr writev 2 , 199*8269e767SBrooks Davisand explicitly by 200*8269e767SBrooks Davis.Xr utimes 2 . 201*8269e767SBrooks DavisAlso, any syscall which modifies directory content changes the 202*8269e767SBrooks Davis.Va st_mtim 203*8269e767SBrooks Davisfor the affected directory. 204*8269e767SBrooks DavisFor instance, 205*8269e767SBrooks Davis.Xr creat 2 , 206*8269e767SBrooks Davis.Xr mkdir 2 , 207*8269e767SBrooks Davis.Xr rename 2 , 208*8269e767SBrooks Davis.Xr link 2 , 209*8269e767SBrooks Davisand 210*8269e767SBrooks Davis.Xr unlink 2 . 211*8269e767SBrooks Davis.It Va st_ctim 212*8269e767SBrooks DavisTime when file status was last changed (inode data modification). 213*8269e767SBrooks DavisChanged implicitly by any syscall that affects file metadata, including 214*8269e767SBrooks Davis.Va st_mtim , 215*8269e767SBrooks Davissuch as 216*8269e767SBrooks Davis.Xr chflags 2 , 217*8269e767SBrooks Davis.Xr chmod 2 , 218*8269e767SBrooks Davis.Xr chown 2 , 219*8269e767SBrooks Davis.Xr truncate 2 , 220*8269e767SBrooks Davis.Xr utimes 2 , 221*8269e767SBrooks Davisand 222*8269e767SBrooks Davis.Xr write 2 . 223*8269e767SBrooks DavisAlso, any syscall which modifies directory content changes the 224*8269e767SBrooks Davis.Va st_ctim 225*8269e767SBrooks Davisfor the affected directory. 226*8269e767SBrooks DavisFor instance, 227*8269e767SBrooks Davis.Xr creat 2 , 228*8269e767SBrooks Davis.Xr mkdir 2 , 229*8269e767SBrooks Davis.Xr rename 2 , 230*8269e767SBrooks Davis.Xr link 2 , 231*8269e767SBrooks Davisand 232*8269e767SBrooks Davis.Xr unlink 2 . 233*8269e767SBrooks Davis.It Va st_birthtim 234*8269e767SBrooks DavisTime when the inode was created. 235*8269e767SBrooks Davis.El 236*8269e767SBrooks Davis.Pp 237*8269e767SBrooks DavisThese time-related macros are defined for compatibility: 238*8269e767SBrooks Davis.Bd -literal 239*8269e767SBrooks Davis#define st_atime st_atim.tv_sec 240*8269e767SBrooks Davis#define st_mtime st_mtim.tv_sec 241*8269e767SBrooks Davis#define st_ctime st_ctim.tv_sec 242*8269e767SBrooks Davis#ifndef _POSIX_SOURCE 243*8269e767SBrooks Davis#define st_birthtime st_birthtim.tv_sec 244*8269e767SBrooks Davis#endif 245*8269e767SBrooks Davis 246*8269e767SBrooks Davis#ifndef _POSIX_SOURCE 247*8269e767SBrooks Davis#define st_atimespec st_atim 248*8269e767SBrooks Davis#define st_mtimespec st_mtim 249*8269e767SBrooks Davis#define st_ctimespec st_ctim 250*8269e767SBrooks Davis#define st_birthtimespec st_birthtim 251*8269e767SBrooks Davis#endif 252*8269e767SBrooks Davis.Ed 253*8269e767SBrooks Davis.Pp 254*8269e767SBrooks DavisSize-related fields of the 255*8269e767SBrooks Davis.Vt "struct stat" 256*8269e767SBrooks Davisare: 257*8269e767SBrooks Davis.Bl -tag -width ".Va st_blksize" 258*8269e767SBrooks Davis.It Va st_size 259*8269e767SBrooks DavisFile size in bytes. 260*8269e767SBrooks Davis.It Va st_blksize 261*8269e767SBrooks DavisOptimal I/O block size for the file. 262*8269e767SBrooks Davis.It Va st_blocks 263*8269e767SBrooks DavisActual number of blocks allocated for the file in 512-byte units. 264*8269e767SBrooks DavisAs short symbolic links are stored in the inode, this number may 265*8269e767SBrooks Davisbe zero. 266*8269e767SBrooks Davis.El 267*8269e767SBrooks Davis.Pp 268*8269e767SBrooks DavisThe access-related fields of 269*8269e767SBrooks Davis.Vt "struct stat" 270*8269e767SBrooks Davisare: 271*8269e767SBrooks Davis.Bl -tag -width ".Va st_mode" 272*8269e767SBrooks Davis.It Va st_uid 273*8269e767SBrooks DavisUser ID of the file's owner. 274*8269e767SBrooks Davis.It Va st_gid 275*8269e767SBrooks DavisGroup ID of the file. 276*8269e767SBrooks Davis.It Va st_mode 277*8269e767SBrooks DavisStatus of the file (see below). 278*8269e767SBrooks Davis.El 279*8269e767SBrooks Davis.Pp 280*8269e767SBrooks DavisThe status information word 281*8269e767SBrooks Davis.Fa st_mode 282*8269e767SBrooks Davishas these bits: 283*8269e767SBrooks Davis.Bd -literal 284*8269e767SBrooks Davis#define S_IFMT 0170000 /* type of file mask */ 285*8269e767SBrooks Davis#define S_IFIFO 0010000 /* named pipe (fifo) */ 286*8269e767SBrooks Davis#define S_IFCHR 0020000 /* character special */ 287*8269e767SBrooks Davis#define S_IFDIR 0040000 /* directory */ 288*8269e767SBrooks Davis#define S_IFBLK 0060000 /* block special */ 289*8269e767SBrooks Davis#define S_IFREG 0100000 /* regular */ 290*8269e767SBrooks Davis#define S_IFLNK 0120000 /* symbolic link */ 291*8269e767SBrooks Davis#define S_IFSOCK 0140000 /* socket */ 292*8269e767SBrooks Davis#define S_IFWHT 0160000 /* whiteout */ 293*8269e767SBrooks Davis#define S_ISUID 0004000 /* set user id on execution */ 294*8269e767SBrooks Davis#define S_ISGID 0002000 /* set group id on execution */ 295*8269e767SBrooks Davis#define S_ISVTX 0001000 /* save swapped text even after use */ 296*8269e767SBrooks Davis#define S_IRWXU 0000700 /* RWX mask for owner */ 297*8269e767SBrooks Davis#define S_IRUSR 0000400 /* read permission, owner */ 298*8269e767SBrooks Davis#define S_IWUSR 0000200 /* write permission, owner */ 299*8269e767SBrooks Davis#define S_IXUSR 0000100 /* execute/search permission, owner */ 300*8269e767SBrooks Davis#define S_IRWXG 0000070 /* RWX mask for group */ 301*8269e767SBrooks Davis#define S_IRGRP 0000040 /* read permission, group */ 302*8269e767SBrooks Davis#define S_IWGRP 0000020 /* write permission, group */ 303*8269e767SBrooks Davis#define S_IXGRP 0000010 /* execute/search permission, group */ 304*8269e767SBrooks Davis#define S_IRWXO 0000007 /* RWX mask for other */ 305*8269e767SBrooks Davis#define S_IROTH 0000004 /* read permission, other */ 306*8269e767SBrooks Davis#define S_IWOTH 0000002 /* write permission, other */ 307*8269e767SBrooks Davis#define S_IXOTH 0000001 /* execute/search permission, other */ 308*8269e767SBrooks Davis.Ed 309*8269e767SBrooks Davis.Pp 310*8269e767SBrooks DavisFor a list of access modes, see 311*8269e767SBrooks Davis.In sys/stat.h , 312*8269e767SBrooks Davis.Xr access 2 313*8269e767SBrooks Davisand 314*8269e767SBrooks Davis.Xr chmod 2 . 315*8269e767SBrooks DavisThese macros are available to test whether a 316*8269e767SBrooks Davis.Va st_mode 317*8269e767SBrooks Davisvalue passed in the 318*8269e767SBrooks Davis.Fa m 319*8269e767SBrooks Davisargument corresponds to a file of the specified type: 320*8269e767SBrooks Davis.Bl -tag -width ".Fn S_ISFIFO m" 321*8269e767SBrooks Davis.It Fn S_ISBLK m 322*8269e767SBrooks DavisTest for a block special file. 323*8269e767SBrooks Davis.It Fn S_ISCHR m 324*8269e767SBrooks DavisTest for a character special file. 325*8269e767SBrooks Davis.It Fn S_ISDIR m 326*8269e767SBrooks DavisTest for a directory. 327*8269e767SBrooks Davis.It Fn S_ISFIFO m 328*8269e767SBrooks DavisTest for a pipe or FIFO special file. 329*8269e767SBrooks Davis.It Fn S_ISLNK m 330*8269e767SBrooks DavisTest for a symbolic link. 331*8269e767SBrooks Davis.It Fn S_ISREG m 332*8269e767SBrooks DavisTest for a regular file. 333*8269e767SBrooks Davis.It Fn S_ISSOCK m 334*8269e767SBrooks DavisTest for a socket. 335*8269e767SBrooks Davis.It Fn S_ISWHT m 336*8269e767SBrooks DavisTest for a whiteout. 337*8269e767SBrooks Davis.El 338*8269e767SBrooks Davis.Pp 339*8269e767SBrooks DavisThe macros evaluate to a non-zero value if the test is true 340*8269e767SBrooks Davisor to the value 0 if the test is false. 341*8269e767SBrooks Davis.Sh RETURN VALUES 342*8269e767SBrooks Davis.Rv -std 343*8269e767SBrooks Davis.Sh COMPATIBILITY 344*8269e767SBrooks DavisPrevious versions of the system used different types for the 345*8269e767SBrooks Davis.Va st_dev , 346*8269e767SBrooks Davis.Va st_uid , 347*8269e767SBrooks Davis.Va st_gid , 348*8269e767SBrooks Davis.Va st_rdev , 349*8269e767SBrooks Davis.Va st_size , 350*8269e767SBrooks Davis.Va st_blksize 351*8269e767SBrooks Davisand 352*8269e767SBrooks Davis.Va st_blocks 353*8269e767SBrooks Davisfields. 354*8269e767SBrooks Davis.Sh ERRORS 355*8269e767SBrooks DavisThe 356*8269e767SBrooks Davis.Fn stat 357*8269e767SBrooks Davisand 358*8269e767SBrooks Davis.Fn lstat 359*8269e767SBrooks Davissystem calls will fail if: 360*8269e767SBrooks Davis.Bl -tag -width Er 361*8269e767SBrooks Davis.It Bq Er EACCES 362*8269e767SBrooks DavisSearch permission is denied for a component of the path prefix. 363*8269e767SBrooks Davis.It Bq Er EFAULT 364*8269e767SBrooks DavisThe 365*8269e767SBrooks Davis.Fa sb 366*8269e767SBrooks Davisor 367*8269e767SBrooks Davis.Fa path 368*8269e767SBrooks Davisargument 369*8269e767SBrooks Davispoints to an invalid address. 370*8269e767SBrooks Davis.It Bq Er EIO 371*8269e767SBrooks DavisAn I/O error occurred while reading from or writing to the file system. 372*8269e767SBrooks Davis.It Bq Er EINTEGRITY 373*8269e767SBrooks DavisCorrupted data was detected while reading from the file system. 374*8269e767SBrooks Davis.It Bq Er ELOOP 375*8269e767SBrooks DavisToo many symbolic links were encountered in translating the pathname. 376*8269e767SBrooks Davis.It Bq Er ENAMETOOLONG 377*8269e767SBrooks DavisA component of a pathname exceeded 255 characters, 378*8269e767SBrooks Davisor an entire path name exceeded 1023 characters. 379*8269e767SBrooks Davis.It Bq Er ENOENT 380*8269e767SBrooks DavisThe named file does not exist. 381*8269e767SBrooks Davis.It Bq Er ENOTDIR 382*8269e767SBrooks DavisA component of the path prefix is not a directory. 383*8269e767SBrooks Davis.It Bq Er EOVERFLOW 384*8269e767SBrooks DavisThe file size in bytes cannot be 385*8269e767SBrooks Davisrepresented correctly in the structure pointed to by 386*8269e767SBrooks Davis.Fa sb . 387*8269e767SBrooks Davis.El 388*8269e767SBrooks Davis.Pp 389*8269e767SBrooks DavisThe 390*8269e767SBrooks Davis.Fn fstat 391*8269e767SBrooks Davissystem call will fail if: 392*8269e767SBrooks Davis.Bl -tag -width Er 393*8269e767SBrooks Davis.It Bq Er EBADF 394*8269e767SBrooks DavisThe 395*8269e767SBrooks Davis.Fa fd 396*8269e767SBrooks Davisargument 397*8269e767SBrooks Davisis not a valid open file descriptor. 398*8269e767SBrooks Davis.It Bq Er EFAULT 399*8269e767SBrooks DavisThe 400*8269e767SBrooks Davis.Fa sb 401*8269e767SBrooks Davisargument 402*8269e767SBrooks Davispoints to an invalid address. 403*8269e767SBrooks Davis.It Bq Er EIO 404*8269e767SBrooks DavisAn I/O error occurred while reading from or writing to the file system. 405*8269e767SBrooks Davis.It Bq Er EINTEGRITY 406*8269e767SBrooks DavisCorrupted data was detected while reading from the file system. 407*8269e767SBrooks Davis.It Bq Er EOVERFLOW 408*8269e767SBrooks DavisThe file size in bytes cannot be 409*8269e767SBrooks Davisrepresented correctly in the structure pointed to by 410*8269e767SBrooks Davis.Fa sb . 411*8269e767SBrooks Davis.El 412*8269e767SBrooks Davis.Pp 413*8269e767SBrooks DavisIn addition to the errors returned by the 414*8269e767SBrooks Davis.Fn lstat , 415*8269e767SBrooks Davisthe 416*8269e767SBrooks Davis.Fn fstatat 417*8269e767SBrooks Davismay fail if: 418*8269e767SBrooks Davis.Bl -tag -width Er 419*8269e767SBrooks Davis.It Bq Er EBADF 420*8269e767SBrooks DavisThe 421*8269e767SBrooks Davis.Fa path 422*8269e767SBrooks Davisargument does not specify an absolute path and the 423*8269e767SBrooks Davis.Fa fd 424*8269e767SBrooks Davisargument is neither 425*8269e767SBrooks Davis.Dv AT_FDCWD 426*8269e767SBrooks Davisnor a valid file descriptor open for searching. 427*8269e767SBrooks Davis.It Bq Er EINVAL 428*8269e767SBrooks DavisThe value of the 429*8269e767SBrooks Davis.Fa flag 430*8269e767SBrooks Davisargument is not valid. 431*8269e767SBrooks Davis.It Bq Er ENOTDIR 432*8269e767SBrooks DavisThe 433*8269e767SBrooks Davis.Fa path 434*8269e767SBrooks Davisargument is not an absolute path and 435*8269e767SBrooks Davis.Fa fd 436*8269e767SBrooks Davisis neither 437*8269e767SBrooks Davis.Dv AT_FDCWD 438*8269e767SBrooks Davisnor a file descriptor associated with a directory. 439*8269e767SBrooks Davis.It Bq Er ENOTCAPABLE 440*8269e767SBrooks Davis.Fa path 441*8269e767SBrooks Davisis an absolute path, 442*8269e767SBrooks Davisor contained a ".." component leading to a 443*8269e767SBrooks Davisdirectory outside of the directory hierarchy specified by 444*8269e767SBrooks Davis.Fa fd , 445*8269e767SBrooks Davisand the process is in capability mode or the 446*8269e767SBrooks Davis.Dv AT_RESOLVE_BENEATH 447*8269e767SBrooks Davisflag was specified. 448*8269e767SBrooks Davis.El 449*8269e767SBrooks Davis.Sh SEE ALSO 450*8269e767SBrooks Davis.Xr access 2 , 451*8269e767SBrooks Davis.Xr chmod 2 , 452*8269e767SBrooks Davis.Xr chown 2 , 453*8269e767SBrooks Davis.Xr fhstat 2 , 454*8269e767SBrooks Davis.Xr statfs 2 , 455*8269e767SBrooks Davis.Xr utimes 2 , 456*8269e767SBrooks Davis.Xr sticky 7 , 457*8269e767SBrooks Davis.Xr symlink 7 458*8269e767SBrooks Davis.Sh STANDARDS 459*8269e767SBrooks DavisThe 460*8269e767SBrooks Davis.Fn stat 461*8269e767SBrooks Davisand 462*8269e767SBrooks Davis.Fn fstat 463*8269e767SBrooks Davissystem calls are expected to conform to 464*8269e767SBrooks Davis.St -p1003.1-90 . 465*8269e767SBrooks DavisThe 466*8269e767SBrooks Davis.Fn fstatat 467*8269e767SBrooks Davissystem call follows The Open Group Extended API Set 2 specification. 468*8269e767SBrooks Davis.Sh HISTORY 469*8269e767SBrooks DavisThe 470*8269e767SBrooks Davis.Fn stat 471*8269e767SBrooks Davisand 472*8269e767SBrooks Davis.Fn fstat 473*8269e767SBrooks Davissystem calls appeared in 474*8269e767SBrooks Davis.At v1 . 475*8269e767SBrooks DavisThe 476*8269e767SBrooks Davis.Fn lstat 477*8269e767SBrooks Davissystem call appeared in 478*8269e767SBrooks Davis.Bx 4.2 . 479*8269e767SBrooks DavisThe 480*8269e767SBrooks Davis.Fn fstatat 481*8269e767SBrooks Davissystem call appeared in 482*8269e767SBrooks Davis.Fx 8.0 . 483*8269e767SBrooks Davis.Sh BUGS 484*8269e767SBrooks DavisApplying 485*8269e767SBrooks Davis.Fn fstat 486*8269e767SBrooks Davisto a socket 487*8269e767SBrooks Davisreturns a zeroed buffer, 488*8269e767SBrooks Davisexcept for the blocksize field, 489*8269e767SBrooks Davisand a unique device and inode number. 490