xref: /freebsd/lib/libsys/stat.2 (revision 8269e767)
18269e767SBrooks Davis.\" Copyright (c) 1980, 1991, 1993, 1994
28269e767SBrooks Davis.\"	The Regents of the University of California.  All rights reserved.
38269e767SBrooks Davis.\"
48269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without
58269e767SBrooks Davis.\" modification, are permitted provided that the following conditions
68269e767SBrooks Davis.\" are met:
78269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright
88269e767SBrooks Davis.\"    notice, this list of conditions and the following disclaimer.
98269e767SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright
108269e767SBrooks Davis.\"    notice, this list of conditions and the following disclaimer in the
118269e767SBrooks Davis.\"    documentation and/or other materials provided with the distribution.
128269e767SBrooks Davis.\" 3. Neither the name of the University nor the names of its contributors
138269e767SBrooks Davis.\"    may be used to endorse or promote products derived from this software
148269e767SBrooks Davis.\"    without specific prior written permission.
158269e767SBrooks Davis.\"
168269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
178269e767SBrooks Davis.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
188269e767SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
198269e767SBrooks Davis.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
208269e767SBrooks Davis.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
218269e767SBrooks Davis.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
228269e767SBrooks Davis.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
238269e767SBrooks Davis.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
248269e767SBrooks Davis.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
258269e767SBrooks Davis.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
268269e767SBrooks Davis.\" SUCH DAMAGE.
278269e767SBrooks Davis.\"
288269e767SBrooks Davis.Dd March 30, 2021
298269e767SBrooks Davis.Dt STAT 2
308269e767SBrooks Davis.Os
318269e767SBrooks Davis.Sh NAME
328269e767SBrooks Davis.Nm stat ,
338269e767SBrooks Davis.Nm lstat ,
348269e767SBrooks Davis.Nm fstat ,
358269e767SBrooks Davis.Nm fstatat
368269e767SBrooks Davis.Nd get file status
378269e767SBrooks Davis.Sh LIBRARY
388269e767SBrooks Davis.Lb libc
398269e767SBrooks Davis.Sh SYNOPSIS
408269e767SBrooks Davis.In sys/stat.h
418269e767SBrooks Davis.Ft int
428269e767SBrooks Davis.Fn stat "const char * restrict path" "struct stat * restrict sb"
438269e767SBrooks Davis.Ft int
448269e767SBrooks Davis.Fn lstat "const char * restrict path" "struct stat * restrict sb"
458269e767SBrooks Davis.Ft int
468269e767SBrooks Davis.Fn fstat "int fd" "struct stat *sb"
478269e767SBrooks Davis.Ft int
488269e767SBrooks Davis.Fn fstatat "int fd" "const char *path" "struct stat *sb" "int flag"
498269e767SBrooks Davis.Sh DESCRIPTION
508269e767SBrooks DavisThe
518269e767SBrooks Davis.Fn stat
528269e767SBrooks Davissystem call obtains information about the file pointed to by
538269e767SBrooks Davis.Fa path .
548269e767SBrooks DavisRead, write or execute
558269e767SBrooks Davispermission of the named file is not required, but all directories
568269e767SBrooks Davislisted in the path name leading to the file must be searchable.
578269e767SBrooks Davis.Pp
588269e767SBrooks DavisThe
598269e767SBrooks Davis.Fn lstat
608269e767SBrooks Davissystem call is like
618269e767SBrooks Davis.Fn stat
628269e767SBrooks Davisexcept when the named file is a symbolic link,
638269e767SBrooks Davisin which case
648269e767SBrooks Davis.Fn lstat
658269e767SBrooks Davisreturns information about the link,
668269e767SBrooks Daviswhile
678269e767SBrooks Davis.Fn stat
688269e767SBrooks Davisreturns information about the file the link references.
698269e767SBrooks Davis.Pp
708269e767SBrooks DavisThe
718269e767SBrooks Davis.Fn fstat
728269e767SBrooks Davissystem call obtains the same information about an open file
738269e767SBrooks Davisknown by the file descriptor
748269e767SBrooks Davis.Fa fd .
758269e767SBrooks Davis.Pp
768269e767SBrooks DavisThe
778269e767SBrooks Davis.Fn fstatat
788269e767SBrooks Davissystem call is equivalent to
798269e767SBrooks Davis.Fn stat
808269e767SBrooks Davisand
818269e767SBrooks Davis.Fn lstat
828269e767SBrooks Davisexcept when the
838269e767SBrooks Davis.Fa path
848269e767SBrooks Davisspecifies a relative path.
858269e767SBrooks DavisFor
868269e767SBrooks Davis.Fn fstatat
878269e767SBrooks Davisand relative
888269e767SBrooks Davis.Fa path ,
898269e767SBrooks Davisthe status is retrieved from a file relative to
908269e767SBrooks Davisthe directory associated with the file descriptor
918269e767SBrooks Davis.Fa fd
928269e767SBrooks Davisinstead of the current working directory.
938269e767SBrooks Davis.Pp
948269e767SBrooks DavisThe values for the
958269e767SBrooks Davis.Fa flag
968269e767SBrooks Davisare constructed by a bitwise-inclusive OR of flags from this list,
978269e767SBrooks Davisdefined in
988269e767SBrooks Davis.In fcntl.h :
998269e767SBrooks Davis.Bl -tag -width indent
1008269e767SBrooks Davis.It Dv AT_SYMLINK_NOFOLLOW
1018269e767SBrooks DavisIf
1028269e767SBrooks Davis.Fa path
1038269e767SBrooks Davisnames a symbolic link, the status of the symbolic link is returned.
1048269e767SBrooks Davis.It Dv AT_RESOLVE_BENEATH
1058269e767SBrooks DavisOnly walk paths below the starting directory.
1068269e767SBrooks DavisSee the description of the
1078269e767SBrooks Davis.Dv O_RESOLVE_BENEATH
1088269e767SBrooks Davisflag in the
1098269e767SBrooks Davis.Xr open 2
1108269e767SBrooks Davismanual page.
1118269e767SBrooks Davis.It Dv AT_EMPTY_PATH
1128269e767SBrooks DavisIf the
1138269e767SBrooks Davis.Fa path
1148269e767SBrooks Davisargument is an empty string, operate on the file or directory
1158269e767SBrooks Davisreferenced by the descriptor
1168269e767SBrooks Davis.Fa fd .
1178269e767SBrooks DavisIf
1188269e767SBrooks Davis.Fa fd
1198269e767SBrooks Davisis equal to
1208269e767SBrooks Davis.Dv AT_FDCWD ,
1218269e767SBrooks Davisoperate on the current working directory.
1228269e767SBrooks Davis.El
1238269e767SBrooks Davis.Pp
1248269e767SBrooks DavisIf
1258269e767SBrooks Davis.Fn fstatat
1268269e767SBrooks Davisis passed the special value
1278269e767SBrooks Davis.Dv AT_FDCWD
1288269e767SBrooks Davisin the
1298269e767SBrooks Davis.Fa fd
1308269e767SBrooks Davisparameter, the current working directory is used and the behavior is
1318269e767SBrooks Davisidentical to a call to
1328269e767SBrooks Davis.Fn stat
1338269e767SBrooks Davisor
1348269e767SBrooks Davis.Fn lstat
1358269e767SBrooks Davisrespectively, depending on whether or not the
1368269e767SBrooks Davis.Dv AT_SYMLINK_NOFOLLOW
1378269e767SBrooks Davisbit is set in
1388269e767SBrooks Davis.Fa flag .
1398269e767SBrooks Davis.Pp
1408269e767SBrooks DavisWhen
1418269e767SBrooks Davis.Fn fstatat
1428269e767SBrooks Davisis called with an absolute
1438269e767SBrooks Davis.Fa path ,
1448269e767SBrooks Davisit ignores the
1458269e767SBrooks Davis.Fa fd
1468269e767SBrooks Davisargument.
1478269e767SBrooks Davis.Pp
1488269e767SBrooks DavisThe
1498269e767SBrooks Davis.Fa sb
1508269e767SBrooks Davisargument is a pointer to a
1518269e767SBrooks Davis.Vt stat
1528269e767SBrooks Davisstructure
1538269e767SBrooks Davisas defined by
1548269e767SBrooks Davis.In sys/stat.h
1558269e767SBrooks Davisand into which information is placed concerning the file.
1568269e767SBrooks Davis.Pp
1578269e767SBrooks DavisThe fields of
1588269e767SBrooks Davis.Vt "struct stat"
1598269e767SBrooks Davisrelated to the file system are:
1608269e767SBrooks Davis.Bl -tag -width ".Va st_nlink"
1618269e767SBrooks Davis.It Va st_dev
1628269e767SBrooks DavisNumeric ID of the device containing the file.
1638269e767SBrooks Davis.It Va st_ino
1648269e767SBrooks DavisThe file's inode number.
1658269e767SBrooks Davis.It Va st_nlink
1668269e767SBrooks DavisNumber of hard links to the file.
1678269e767SBrooks Davis.It Va st_flags
1688269e767SBrooks DavisFlags enabled for the file.
1698269e767SBrooks DavisSee
1708269e767SBrooks Davis.Xr chflags 2
1718269e767SBrooks Davisfor the list of flags and their description.
1728269e767SBrooks Davis.El
1738269e767SBrooks Davis.Pp
1748269e767SBrooks DavisThe
1758269e767SBrooks Davis.Va st_dev
1768269e767SBrooks Davisand
1778269e767SBrooks Davis.Va st_ino
1788269e767SBrooks Davisfields together identify the file uniquely within the system.
1798269e767SBrooks Davis.Pp
1808269e767SBrooks DavisThe time-related fields of
1818269e767SBrooks Davis.Vt "struct stat"
1828269e767SBrooks Davisare:
1838269e767SBrooks Davis.Bl -tag -width ".Va st_birthtim"
1848269e767SBrooks Davis.It Va st_atim
1858269e767SBrooks DavisTime when file data was last accessed.
1868269e767SBrooks DavisChanged implicitly by syscalls such as
1878269e767SBrooks Davis.Xr read 2
1888269e767SBrooks Davisand
1898269e767SBrooks Davis.Xr readv 2 ,
1908269e767SBrooks Davisand explicitly by
1918269e767SBrooks Davis.Xr utimes 2 .
1928269e767SBrooks Davis.It Va st_mtim
1938269e767SBrooks DavisTime when file data was last modified.
1948269e767SBrooks DavisChanged implicitly by syscalls such as
1958269e767SBrooks Davis.Xr truncate 2 ,
1968269e767SBrooks Davis.Xr write 2 ,
1978269e767SBrooks Davisand
1988269e767SBrooks Davis.Xr writev 2 ,
1998269e767SBrooks Davisand explicitly by
2008269e767SBrooks Davis.Xr utimes 2 .
2018269e767SBrooks DavisAlso, any syscall which modifies directory content changes the
2028269e767SBrooks Davis.Va st_mtim
2038269e767SBrooks Davisfor the affected directory.
2048269e767SBrooks DavisFor instance,
2058269e767SBrooks Davis.Xr creat 2 ,
2068269e767SBrooks Davis.Xr mkdir 2 ,
2078269e767SBrooks Davis.Xr rename 2 ,
2088269e767SBrooks Davis.Xr link 2 ,
2098269e767SBrooks Davisand
2108269e767SBrooks Davis.Xr unlink 2 .
2118269e767SBrooks Davis.It Va st_ctim
2128269e767SBrooks DavisTime when file status was last changed (inode data modification).
2138269e767SBrooks DavisChanged implicitly by any syscall that affects file metadata, including
2148269e767SBrooks Davis.Va st_mtim ,
2158269e767SBrooks Davissuch as
2168269e767SBrooks Davis.Xr chflags 2 ,
2178269e767SBrooks Davis.Xr chmod 2 ,
2188269e767SBrooks Davis.Xr chown 2 ,
2198269e767SBrooks Davis.Xr truncate 2 ,
2208269e767SBrooks Davis.Xr utimes 2 ,
2218269e767SBrooks Davisand
2228269e767SBrooks Davis.Xr write 2 .
2238269e767SBrooks DavisAlso, any syscall which modifies directory content changes the
2248269e767SBrooks Davis.Va st_ctim
2258269e767SBrooks Davisfor the affected directory.
2268269e767SBrooks DavisFor instance,
2278269e767SBrooks Davis.Xr creat 2 ,
2288269e767SBrooks Davis.Xr mkdir 2 ,
2298269e767SBrooks Davis.Xr rename 2 ,
2308269e767SBrooks Davis.Xr link 2 ,
2318269e767SBrooks Davisand
2328269e767SBrooks Davis.Xr unlink 2 .
2338269e767SBrooks Davis.It Va st_birthtim
2348269e767SBrooks DavisTime when the inode was created.
2358269e767SBrooks Davis.El
2368269e767SBrooks Davis.Pp
2378269e767SBrooks DavisThese time-related macros are defined for compatibility:
2388269e767SBrooks Davis.Bd -literal
2398269e767SBrooks Davis#define	st_atime		st_atim.tv_sec
2408269e767SBrooks Davis#define	st_mtime		st_mtim.tv_sec
2418269e767SBrooks Davis#define	st_ctime		st_ctim.tv_sec
2428269e767SBrooks Davis#ifndef _POSIX_SOURCE
2438269e767SBrooks Davis#define	st_birthtime		st_birthtim.tv_sec
2448269e767SBrooks Davis#endif
2458269e767SBrooks Davis
2468269e767SBrooks Davis#ifndef _POSIX_SOURCE
2478269e767SBrooks Davis#define	st_atimespec		st_atim
2488269e767SBrooks Davis#define	st_mtimespec		st_mtim
2498269e767SBrooks Davis#define	st_ctimespec		st_ctim
2508269e767SBrooks Davis#define	st_birthtimespec	st_birthtim
2518269e767SBrooks Davis#endif
2528269e767SBrooks Davis.Ed
2538269e767SBrooks Davis.Pp
2548269e767SBrooks DavisSize-related fields of the
2558269e767SBrooks Davis.Vt "struct stat"
2568269e767SBrooks Davisare:
2578269e767SBrooks Davis.Bl -tag -width ".Va st_blksize"
2588269e767SBrooks Davis.It Va st_size
2598269e767SBrooks DavisFile size in bytes.
2608269e767SBrooks Davis.It Va st_blksize
2618269e767SBrooks DavisOptimal I/O block size for the file.
2628269e767SBrooks Davis.It Va st_blocks
2638269e767SBrooks DavisActual number of blocks allocated for the file in 512-byte units.
2648269e767SBrooks DavisAs short symbolic links are stored in the inode, this number may
2658269e767SBrooks Davisbe zero.
2668269e767SBrooks Davis.El
2678269e767SBrooks Davis.Pp
2688269e767SBrooks DavisThe access-related fields of
2698269e767SBrooks Davis.Vt "struct stat"
2708269e767SBrooks Davisare:
2718269e767SBrooks Davis.Bl -tag -width ".Va st_mode"
2728269e767SBrooks Davis.It Va st_uid
2738269e767SBrooks DavisUser ID of the file's owner.
2748269e767SBrooks Davis.It Va st_gid
2758269e767SBrooks DavisGroup ID of the file.
2768269e767SBrooks Davis.It Va st_mode
2778269e767SBrooks DavisStatus of the file (see below).
2788269e767SBrooks Davis.El
2798269e767SBrooks Davis.Pp
2808269e767SBrooks DavisThe status information word
2818269e767SBrooks Davis.Fa st_mode
2828269e767SBrooks Davishas these bits:
2838269e767SBrooks Davis.Bd -literal
2848269e767SBrooks Davis#define S_IFMT   0170000  /* type of file mask */
2858269e767SBrooks Davis#define S_IFIFO  0010000  /* named pipe (fifo) */
2868269e767SBrooks Davis#define S_IFCHR  0020000  /* character special */
2878269e767SBrooks Davis#define S_IFDIR  0040000  /* directory */
2888269e767SBrooks Davis#define S_IFBLK  0060000  /* block special */
2898269e767SBrooks Davis#define S_IFREG  0100000  /* regular */
2908269e767SBrooks Davis#define S_IFLNK  0120000  /* symbolic link */
2918269e767SBrooks Davis#define S_IFSOCK 0140000  /* socket */
2928269e767SBrooks Davis#define S_IFWHT  0160000  /* whiteout */
2938269e767SBrooks Davis#define S_ISUID  0004000  /* set user id on execution */
2948269e767SBrooks Davis#define S_ISGID  0002000  /* set group id on execution */
2958269e767SBrooks Davis#define S_ISVTX  0001000  /* save swapped text even after use */
2968269e767SBrooks Davis#define S_IRWXU  0000700  /* RWX mask for owner */
2978269e767SBrooks Davis#define S_IRUSR  0000400  /* read permission, owner */
2988269e767SBrooks Davis#define S_IWUSR  0000200  /* write permission, owner */
2998269e767SBrooks Davis#define S_IXUSR  0000100  /* execute/search permission, owner */
3008269e767SBrooks Davis#define S_IRWXG  0000070  /* RWX mask for group */
3018269e767SBrooks Davis#define S_IRGRP  0000040  /* read permission, group */
3028269e767SBrooks Davis#define S_IWGRP  0000020  /* write permission, group */
3038269e767SBrooks Davis#define S_IXGRP  0000010  /* execute/search permission, group */
3048269e767SBrooks Davis#define S_IRWXO  0000007  /* RWX mask for other */
3058269e767SBrooks Davis#define S_IROTH  0000004  /* read permission, other */
3068269e767SBrooks Davis#define S_IWOTH  0000002  /* write permission, other */
3078269e767SBrooks Davis#define S_IXOTH  0000001  /* execute/search permission, other */
3088269e767SBrooks Davis.Ed
3098269e767SBrooks Davis.Pp
3108269e767SBrooks DavisFor a list of access modes, see
3118269e767SBrooks Davis.In sys/stat.h ,
3128269e767SBrooks Davis.Xr access 2
3138269e767SBrooks Davisand
3148269e767SBrooks Davis.Xr chmod 2 .
3158269e767SBrooks DavisThese macros are available to test whether a
3168269e767SBrooks Davis.Va st_mode
3178269e767SBrooks Davisvalue passed in the
3188269e767SBrooks Davis.Fa m
3198269e767SBrooks Davisargument corresponds to a file of the specified type:
3208269e767SBrooks Davis.Bl -tag -width ".Fn S_ISFIFO m"
3218269e767SBrooks Davis.It Fn S_ISBLK m
3228269e767SBrooks DavisTest for a block special file.
3238269e767SBrooks Davis.It Fn S_ISCHR m
3248269e767SBrooks DavisTest for a character special file.
3258269e767SBrooks Davis.It Fn S_ISDIR m
3268269e767SBrooks DavisTest for a directory.
3278269e767SBrooks Davis.It Fn S_ISFIFO m
3288269e767SBrooks DavisTest for a pipe or FIFO special file.
3298269e767SBrooks Davis.It Fn S_ISLNK m
3308269e767SBrooks DavisTest for a symbolic link.
3318269e767SBrooks Davis.It Fn S_ISREG m
3328269e767SBrooks DavisTest for a regular file.
3338269e767SBrooks Davis.It Fn S_ISSOCK m
3348269e767SBrooks DavisTest for a socket.
3358269e767SBrooks Davis.It Fn S_ISWHT m
3368269e767SBrooks DavisTest for a whiteout.
3378269e767SBrooks Davis.El
3388269e767SBrooks Davis.Pp
3398269e767SBrooks DavisThe macros evaluate to a non-zero value if the test is true
3408269e767SBrooks Davisor to the value 0 if the test is false.
3418269e767SBrooks Davis.Sh RETURN VALUES
3428269e767SBrooks Davis.Rv -std
3438269e767SBrooks Davis.Sh COMPATIBILITY
3448269e767SBrooks DavisPrevious versions of the system used different types for the
3458269e767SBrooks Davis.Va st_dev ,
3468269e767SBrooks Davis.Va st_uid ,
3478269e767SBrooks Davis.Va st_gid ,
3488269e767SBrooks Davis.Va st_rdev ,
3498269e767SBrooks Davis.Va st_size ,
3508269e767SBrooks Davis.Va st_blksize
3518269e767SBrooks Davisand
3528269e767SBrooks Davis.Va st_blocks
3538269e767SBrooks Davisfields.
3548269e767SBrooks Davis.Sh ERRORS
3558269e767SBrooks DavisThe
3568269e767SBrooks Davis.Fn stat
3578269e767SBrooks Davisand
3588269e767SBrooks Davis.Fn lstat
3598269e767SBrooks Davissystem calls will fail if:
3608269e767SBrooks Davis.Bl -tag -width Er
3618269e767SBrooks Davis.It Bq Er EACCES
3628269e767SBrooks DavisSearch permission is denied for a component of the path prefix.
3638269e767SBrooks Davis.It Bq Er EFAULT
3648269e767SBrooks DavisThe
3658269e767SBrooks Davis.Fa sb
3668269e767SBrooks Davisor
3678269e767SBrooks Davis.Fa path
3688269e767SBrooks Davisargument
3698269e767SBrooks Davispoints to an invalid address.
3708269e767SBrooks Davis.It Bq Er EIO
3718269e767SBrooks DavisAn I/O error occurred while reading from or writing to the file system.
3728269e767SBrooks Davis.It Bq Er EINTEGRITY
3738269e767SBrooks DavisCorrupted data was detected while reading from the file system.
3748269e767SBrooks Davis.It Bq Er ELOOP
3758269e767SBrooks DavisToo many symbolic links were encountered in translating the pathname.
3768269e767SBrooks Davis.It Bq Er ENAMETOOLONG
3778269e767SBrooks DavisA component of a pathname exceeded 255 characters,
3788269e767SBrooks Davisor an entire path name exceeded 1023 characters.
3798269e767SBrooks Davis.It Bq Er ENOENT
3808269e767SBrooks DavisThe named file does not exist.
3818269e767SBrooks Davis.It Bq Er ENOTDIR
3828269e767SBrooks DavisA component of the path prefix is not a directory.
3838269e767SBrooks Davis.It Bq Er EOVERFLOW
3848269e767SBrooks DavisThe file size in bytes cannot be
3858269e767SBrooks Davisrepresented correctly in the structure pointed to by
3868269e767SBrooks Davis.Fa sb .
3878269e767SBrooks Davis.El
3888269e767SBrooks Davis.Pp
3898269e767SBrooks DavisThe
3908269e767SBrooks Davis.Fn fstat
3918269e767SBrooks Davissystem call will fail if:
3928269e767SBrooks Davis.Bl -tag -width Er
3938269e767SBrooks Davis.It Bq Er EBADF
3948269e767SBrooks DavisThe
3958269e767SBrooks Davis.Fa fd
3968269e767SBrooks Davisargument
3978269e767SBrooks Davisis not a valid open file descriptor.
3988269e767SBrooks Davis.It Bq Er EFAULT
3998269e767SBrooks DavisThe
4008269e767SBrooks Davis.Fa sb
4018269e767SBrooks Davisargument
4028269e767SBrooks Davispoints to an invalid address.
4038269e767SBrooks Davis.It Bq Er EIO
4048269e767SBrooks DavisAn I/O error occurred while reading from or writing to the file system.
4058269e767SBrooks Davis.It Bq Er EINTEGRITY
4068269e767SBrooks DavisCorrupted data was detected while reading from the file system.
4078269e767SBrooks Davis.It Bq Er EOVERFLOW
4088269e767SBrooks DavisThe file size in bytes cannot be
4098269e767SBrooks Davisrepresented correctly in the structure pointed to by
4108269e767SBrooks Davis.Fa sb .
4118269e767SBrooks Davis.El
4128269e767SBrooks Davis.Pp
4138269e767SBrooks DavisIn addition to the errors returned by the
4148269e767SBrooks Davis.Fn lstat ,
4158269e767SBrooks Davisthe
4168269e767SBrooks Davis.Fn fstatat
4178269e767SBrooks Davismay fail if:
4188269e767SBrooks Davis.Bl -tag -width Er
4198269e767SBrooks Davis.It Bq Er EBADF
4208269e767SBrooks DavisThe
4218269e767SBrooks Davis.Fa path
4228269e767SBrooks Davisargument does not specify an absolute path and the
4238269e767SBrooks Davis.Fa fd
4248269e767SBrooks Davisargument is neither
4258269e767SBrooks Davis.Dv AT_FDCWD
4268269e767SBrooks Davisnor a valid file descriptor open for searching.
4278269e767SBrooks Davis.It Bq Er EINVAL
4288269e767SBrooks DavisThe value of the
4298269e767SBrooks Davis.Fa flag
4308269e767SBrooks Davisargument is not valid.
4318269e767SBrooks Davis.It Bq Er ENOTDIR
4328269e767SBrooks DavisThe
4338269e767SBrooks Davis.Fa path
4348269e767SBrooks Davisargument is not an absolute path and
4358269e767SBrooks Davis.Fa fd
4368269e767SBrooks Davisis neither
4378269e767SBrooks Davis.Dv AT_FDCWD
4388269e767SBrooks Davisnor a file descriptor associated with a directory.
4398269e767SBrooks Davis.It Bq Er ENOTCAPABLE
4408269e767SBrooks Davis.Fa path
4418269e767SBrooks Davisis an absolute path,
4428269e767SBrooks Davisor contained a ".." component leading to a
4438269e767SBrooks Davisdirectory outside of the directory hierarchy specified by
4448269e767SBrooks Davis.Fa fd ,
4458269e767SBrooks Davisand the process is in capability mode or the
4468269e767SBrooks Davis.Dv AT_RESOLVE_BENEATH
4478269e767SBrooks Davisflag was specified.
4488269e767SBrooks Davis.El
4498269e767SBrooks Davis.Sh SEE ALSO
4508269e767SBrooks Davis.Xr access 2 ,
4518269e767SBrooks Davis.Xr chmod 2 ,
4528269e767SBrooks Davis.Xr chown 2 ,
4538269e767SBrooks Davis.Xr fhstat 2 ,
4548269e767SBrooks Davis.Xr statfs 2 ,
4558269e767SBrooks Davis.Xr utimes 2 ,
4568269e767SBrooks Davis.Xr sticky 7 ,
4578269e767SBrooks Davis.Xr symlink 7
4588269e767SBrooks Davis.Sh STANDARDS
4598269e767SBrooks DavisThe
4608269e767SBrooks Davis.Fn stat
4618269e767SBrooks Davisand
4628269e767SBrooks Davis.Fn fstat
4638269e767SBrooks Davissystem calls are expected to conform to
4648269e767SBrooks Davis.St -p1003.1-90 .
4658269e767SBrooks DavisThe
4668269e767SBrooks Davis.Fn fstatat
4678269e767SBrooks Davissystem call follows The Open Group Extended API Set 2 specification.
4688269e767SBrooks Davis.Sh HISTORY
4698269e767SBrooks DavisThe
4708269e767SBrooks Davis.Fn stat
4718269e767SBrooks Davisand
4728269e767SBrooks Davis.Fn fstat
4738269e767SBrooks Davissystem calls appeared in
4748269e767SBrooks Davis.At v1 .
4758269e767SBrooks DavisThe
4768269e767SBrooks Davis.Fn lstat
4778269e767SBrooks Davissystem call appeared in
4788269e767SBrooks Davis.Bx 4.2 .
4798269e767SBrooks DavisThe
4808269e767SBrooks Davis.Fn fstatat
4818269e767SBrooks Davissystem call appeared in
4828269e767SBrooks Davis.Fx 8.0 .
4838269e767SBrooks Davis.Sh BUGS
4848269e767SBrooks DavisApplying
4858269e767SBrooks Davis.Fn fstat
4868269e767SBrooks Davisto a socket
4878269e767SBrooks Davisreturns a zeroed buffer,
4888269e767SBrooks Davisexcept for the blocksize field,
4898269e767SBrooks Davisand a unique device and inode number.
490