xref: /minix3/lib/libc/sys/stat.2 (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc.\"	$NetBSD: stat.2,v 1.57 2014/04/10 17:11:15 wiz Exp $
22fe8fb19SBen Gras.\"
32fe8fb19SBen Gras.\" Copyright (c) 1980, 1991, 1993, 1994
42fe8fb19SBen Gras.\"	The Regents of the University of California.  All rights reserved.
52fe8fb19SBen Gras.\"
62fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without
72fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions
82fe8fb19SBen Gras.\" are met:
92fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright
102fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer.
112fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
122fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer in the
132fe8fb19SBen Gras.\"    documentation and/or other materials provided with the distribution.
142fe8fb19SBen Gras.\" 3. Neither the name of the University nor the names of its contributors
152fe8fb19SBen Gras.\"    may be used to endorse or promote products derived from this software
162fe8fb19SBen Gras.\"    without specific prior written permission.
172fe8fb19SBen Gras.\"
182fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
192fe8fb19SBen Gras.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
202fe8fb19SBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
212fe8fb19SBen Gras.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
222fe8fb19SBen Gras.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
232fe8fb19SBen Gras.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
242fe8fb19SBen Gras.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
252fe8fb19SBen Gras.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
262fe8fb19SBen Gras.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
272fe8fb19SBen Gras.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
282fe8fb19SBen Gras.\" SUCH DAMAGE.
292fe8fb19SBen Gras.\"
302fe8fb19SBen Gras.\"     @(#)stat.2	8.4 (Berkeley) 5/1/95
312fe8fb19SBen Gras.\"
32*0a6a1f1dSLionel Sambuc.Dd April 10, 2014
332fe8fb19SBen Gras.Dt STAT 2
342fe8fb19SBen Gras.Os
352fe8fb19SBen Gras.Sh NAME
362fe8fb19SBen Gras.Nm stat ,
372fe8fb19SBen Gras.Nm lstat ,
3884d9c625SLionel Sambuc.Nm fstat ,
3984d9c625SLionel Sambuc.Nm fstatat ,
402fe8fb19SBen Gras.Nd get file status
412fe8fb19SBen Gras.Sh LIBRARY
422fe8fb19SBen Gras.Lb libc
432fe8fb19SBen Gras.Sh SYNOPSIS
442fe8fb19SBen Gras.In sys/stat.h
452fe8fb19SBen Gras.Ft int
462fe8fb19SBen Gras.Fn stat "const char *path" "struct stat *sb"
472fe8fb19SBen Gras.Ft int
482fe8fb19SBen Gras.Fn lstat "const char *path" "struct stat *sb"
492fe8fb19SBen Gras.Ft int
502fe8fb19SBen Gras.Fn fstat "int fd" "struct stat *sb"
5184d9c625SLionel Sambuc.In sys/stat.h
5284d9c625SLionel Sambuc.In fcntl.h
5384d9c625SLionel Sambuc.Ft int
5484d9c625SLionel Sambuc.Fn fstatat "int fd" "const char *path" "struct stat *sb" "int flag"
552fe8fb19SBen Gras.Sh DESCRIPTION
562fe8fb19SBen GrasThe
572fe8fb19SBen Gras.Fn stat
582fe8fb19SBen Grasfunction obtains information about the file pointed to by
592fe8fb19SBen Gras.Fa path .
602fe8fb19SBen GrasRead, write or execute
612fe8fb19SBen Graspermission of the named file is not required, but all directories
622fe8fb19SBen Graslisted in the path name leading to the file must be searchable.
632fe8fb19SBen Gras.Pp
642fe8fb19SBen GrasThe function
652fe8fb19SBen Gras.Fn lstat
662fe8fb19SBen Grasis like
672fe8fb19SBen Gras.Fn stat
682fe8fb19SBen Grasexcept in the case where the named file is a symbolic link,
692fe8fb19SBen Grasin which case
702fe8fb19SBen Gras.Fn lstat
712fe8fb19SBen Grasreturns information about the link,
722fe8fb19SBen Graswhile
732fe8fb19SBen Gras.Fn stat
742fe8fb19SBen Grasreturns information about the file the link references.
752fe8fb19SBen GrasThe
762fe8fb19SBen Gras.Fn fstat
772fe8fb19SBen Grasfunction obtains the same information about an open file
782fe8fb19SBen Grasknown by the file descriptor
792fe8fb19SBen Gras.Fa fd .
802fe8fb19SBen Gras.Pp
8184d9c625SLionel Sambuc.Fn fstatat
8284d9c625SLionel Sambucworks the same way as
8384d9c625SLionel Sambuc.Fn stat
8484d9c625SLionel Sambuc(or
8584d9c625SLionel Sambuc.Fn lstat
8684d9c625SLionel Sambucif
8784d9c625SLionel Sambuc.Dv AT_SYMLINK_NOFOLLOW
8884d9c625SLionel Sambucis set in
8984d9c625SLionel Sambuc.Fa flag )
9084d9c625SLionel Sambucexcept if
9184d9c625SLionel Sambuc.Fa path
9284d9c625SLionel Sambucis relative.
9384d9c625SLionel SambucIn that case, it is looked up from a directory whose file
9484d9c625SLionel Sambucdescriptor was passed as
9584d9c625SLionel Sambuc.Fa fd .
9684d9c625SLionel SambucSearch permission is required on this directory.
9784d9c625SLionel Sambuc.\"    (These alternatives await a decision about the semantics of O_SEARCH)
9884d9c625SLionel Sambuc.\" Search permission is required on this directory
9984d9c625SLionel Sambuc.\" except if
10084d9c625SLionel Sambuc.\" .Fa fd
10184d9c625SLionel Sambuc.\" was opened with the
10284d9c625SLionel Sambuc.\" .Dv O_SEARCH
10384d9c625SLionel Sambuc.\" flag.
10484d9c625SLionel Sambuc.\"    - or -
10584d9c625SLionel Sambuc.\" This file descriptor must have been opened with the
10684d9c625SLionel Sambuc.\" .Dv O_SEARCH
10784d9c625SLionel Sambuc.\" flag.
10884d9c625SLionel Sambuc.Fa fd
10984d9c625SLionel Sambuccan be set to
11084d9c625SLionel Sambuc.Dv AT_FDCWD
11184d9c625SLionel Sambucin order to specify the current directory.
11284d9c625SLionel Sambuc.Pp
1132fe8fb19SBen GrasThe
1142fe8fb19SBen Gras.Fa sb
1152fe8fb19SBen Grasargument is a pointer to a
1162fe8fb19SBen Gras.Fa stat
1172fe8fb19SBen Grasstructure
1182fe8fb19SBen Grasas defined by
1192fe8fb19SBen Gras.In sys/stat.h
1202fe8fb19SBen Grasand into which information is placed concerning the file.
1212fe8fb19SBen Gras.Ss The Standard Structure
1222fe8fb19SBen GrasThe following standards-compliant fields are defined in the structure:
1232fe8fb19SBen Gras.Bl -column -offset indent \
1242fe8fb19SBen Gras"nlink_t " "st_nlink " "Description"
1252fe8fb19SBen Gras.It Sy Type Ta Sy Entry Ta Sy Description
1262fe8fb19SBen Gras.It Vt dev_t Ta st_dev Ta device ID containing the file
127*0a6a1f1dSLionel Sambuc.It Vt ino_t Ta st_ino Ta serial number of the file (inode number)
1282fe8fb19SBen Gras.It Vt mode_t Ta st_mode Ta mode of the file
1292fe8fb19SBen Gras.It Vt nlink_t Ta st_nlink Ta number of hard links to the file
1302fe8fb19SBen Gras.It Vt uid_t Ta st_uid Ta user ID of the owner
1312fe8fb19SBen Gras.It Vt gid_t Ta st_gid Ta group ID of the owner
1322fe8fb19SBen Gras.It Vt dev_t Ta st_rdev Ta device type (character or block special)
1332fe8fb19SBen Gras.It Vt off_t Ta st_size Ta size of the file in bytes
1342fe8fb19SBen Gras.It Vt time_t Ta st_atime Ta time of last access
1352fe8fb19SBen Gras.It Vt time_t Ta st_mtime Ta time of last data modification
1362fe8fb19SBen Gras.It Vt time_t Ta st_ctime Ta  time of last file status change
1372fe8fb19SBen Gras.It Vt blksize_t Ta st_blksize Ta preferred I/O block size (fs-specific)
138f14fb602SLionel Sambuc.It Vt blkcnt_t Ta st_blocks Ta blocks allocated for the file
1392fe8fb19SBen Gras.El
1402fe8fb19SBen Gras.Pp
1412fe8fb19SBen GrasThese are specified in the
1422fe8fb19SBen Gras.St -p1003.1-2004
1432fe8fb19SBen Grasstandard.
1442fe8fb19SBen GrasThe
1452fe8fb19SBen Gras.Va st_ino
1462fe8fb19SBen Grasand
1472fe8fb19SBen Gras.Va st_dev
148f14fb602SLionel Sambucfields taken together uniquely identify the file within the system.
1492fe8fb19SBen GrasMost of the types are defined in
1502fe8fb19SBen Gras.Xr types 3 .
1512fe8fb19SBen Gras.Pp
1522fe8fb19SBen GrasThe time-related fields are:
1532fe8fb19SBen Gras.Bl -tag -width st_blksize -offset indent
1542fe8fb19SBen Gras.It Va st_atime
1552fe8fb19SBen GrasTime when file data was last accessed.
1562fe8fb19SBen GrasChanged by the
1572fe8fb19SBen Gras.Xr mknod 2 ,
1582fe8fb19SBen Gras.Xr utimes 2 ,
1592fe8fb19SBen Grasand
1602fe8fb19SBen Gras.Xr read 2
1612fe8fb19SBen Grassystem calls.
1622fe8fb19SBen Gras.It Va st_mtime
1632fe8fb19SBen GrasTime when file data was last modified.
1642fe8fb19SBen GrasChanged by the
1652fe8fb19SBen Gras.Xr mknod 2 ,
1662fe8fb19SBen Gras.Xr utimes 2 ,
1672fe8fb19SBen Grasand
1682fe8fb19SBen Gras.Xr write 2
1692fe8fb19SBen Grassystem calls.
1702fe8fb19SBen Gras.It Va st_ctime
1712fe8fb19SBen GrasTime when file status was last changed (file metadata modification).
1722fe8fb19SBen GrasChanged by the
1732fe8fb19SBen Gras.Xr chflags 2 ,
1742fe8fb19SBen Gras.Xr chmod 2 ,
1752fe8fb19SBen Gras.Xr chown 2 ,
1762fe8fb19SBen Gras.Xr link 2 ,
1772fe8fb19SBen Gras.Xr mknod 2 ,
1782fe8fb19SBen Gras.Xr rename 2 ,
1792fe8fb19SBen Gras.Xr unlink 2 ,
1802fe8fb19SBen Gras.Xr utimes 2 ,
1812fe8fb19SBen Grasand
1822fe8fb19SBen Gras.Xr write 2
1832fe8fb19SBen Grassystem calls.
1842fe8fb19SBen Gras.El
1852fe8fb19SBen Gras.Pp
1862fe8fb19SBen GrasThe size-related fields of the
1872fe8fb19SBen Gras.Fa struct stat
1882fe8fb19SBen Grasare as follows:
1892fe8fb19SBen Gras.Bl -tag -width st_blksize -offset indent
1902fe8fb19SBen Gras.It Va st_size
1912fe8fb19SBen GrasThe size of the file in bytes.
1922fe8fb19SBen GrasThe meaning of the size reported for a directory is file system
1932fe8fb19SBen Grasdependent.
1942fe8fb19SBen GrasSome file systems (e.g. FFS) return the total size used for the
1952fe8fb19SBen Grasdirectory metadata, possibly including free slots; others (notably
1962fe8fb19SBen GrasZFS) return the number of entries in the directory.
1972fe8fb19SBen GrasSome may also return other things or always report zero.
1982fe8fb19SBen Gras.It Va st_blksize
1992fe8fb19SBen GrasThe optimal I/O block size for the file.
2002fe8fb19SBen Gras.It Va st_blocks
2012fe8fb19SBen GrasThe actual number of blocks allocated for the file in 512-byte units.
2022fe8fb19SBen GrasAs short symbolic links are stored in the inode, this number may
2032fe8fb19SBen Grasbe zero.
2042fe8fb19SBen Gras.El
2052fe8fb19SBen Gras.Pp
2062fe8fb19SBen GrasThe status information word
2072fe8fb19SBen Gras.Fa st_mode
2082fe8fb19SBen Grascontains bits that define the access mode (see
2092fe8fb19SBen Gras.Xr chmod 2 )
2102fe8fb19SBen Grasand the type (see
2112fe8fb19SBen Gras.Xr dirent 3 )
2122fe8fb19SBen Grasof the file.
2132fe8fb19SBen GrasThe following macros can be used to test
2142fe8fb19SBen Graswhether a file is of the specified type.
2152fe8fb19SBen GrasThe value
2162fe8fb19SBen Gras.Fa m
2172fe8fb19SBen Grassupplied to the macros is the value of
2182fe8fb19SBen Gras.Va st_mode .
2192fe8fb19SBen Gras.Bl -tag -width "S_ISSOCK(m)" -offset indent
2202fe8fb19SBen Gras.It Fn S_ISBLK "m"
2212fe8fb19SBen GrasTest for a block special file.
2222fe8fb19SBen Gras.It Fn S_ISCHR "m"
2232fe8fb19SBen GrasTest for a character special file.
2242fe8fb19SBen Gras.It Fn S_ISDIR "m"
2252fe8fb19SBen GrasTest for a directory.
2262fe8fb19SBen Gras.It Fn S_ISFIFO "m"
2272fe8fb19SBen GrasTest for a pipe or FIFO special file.
2282fe8fb19SBen Gras.It Fn S_ISREG "m"
2292fe8fb19SBen GrasTest for a regular file.
2302fe8fb19SBen Gras.It Fn S_ISLNK "m"
2312fe8fb19SBen GrasTest for a symbolic link.
2322fe8fb19SBen Gras.It Fn S_ISSOCK "m"
2332fe8fb19SBen GrasTest for a socket.
2342fe8fb19SBen Gras.El
2352fe8fb19SBen Gras.Pp
2362fe8fb19SBen GrasThe macros evaluate to a non-zero value if the test
2372fe8fb19SBen Grasis true or to the value 0 if the test is false.
2382fe8fb19SBen Gras.Ss NetBSD Extensions
2392fe8fb19SBen GrasThe following additional
2402fe8fb19SBen Gras.Nx
2412fe8fb19SBen Grasspecific fields are present:
2422fe8fb19SBen Gras.Bl -column -offset indent \
2432fe8fb19SBen Gras"uint32_t" "st_birthtimensec" "Description"
2442fe8fb19SBen Gras.It Sy Type Ta Sy Entry Ta Sy Description
2452fe8fb19SBen Gras.It Vt long Ta st_atimensec Ta last access (nanoseconds)
2462fe8fb19SBen Gras.It Vt long Ta st_mtimensec Ta last modification (nanoseconds)
2472fe8fb19SBen Gras.It Vt long Ta st_ctimensec Ta last status change (nanoseconds)
2482fe8fb19SBen Gras.It Vt time_t Ta st_birthtime Ta time of inode creation
2492fe8fb19SBen Gras.It Vt long Ta st_birthtimensec Ta inode creation (nanoseconds)
2502fe8fb19SBen Gras.It Vt uint32_t Ta st_flags Ta user defined flags for the file
2512fe8fb19SBen Gras.It Vt uint32_t Ta st_gen Ta file generation number
2522fe8fb19SBen Gras.\"
2532fe8fb19SBen Gras.\" XXX: What is this?
2542fe8fb19SBen Gras.\"
2552fe8fb19SBen Gras.It Vt uint32_t Ta st_spare[2] Ta implementation detail
2562fe8fb19SBen Gras.El
2572fe8fb19SBen Gras.Pp
2582fe8fb19SBen GrasHowever, if
2592fe8fb19SBen Gras_NETBSD_SOURCE
2602fe8fb19SBen Grasis furthermore defined, instead of the above,
2612fe8fb19SBen Grasthe following are present in the structure:
2622fe8fb19SBen Gras.Bl -column -offset indent \
2632fe8fb19SBen Gras"struct timespec " "st_birthtimensec" "Description"
2642fe8fb19SBen Gras.It Sy Type Ta Sy Entry Ta Sy Description
2652fe8fb19SBen Gras.It Vt struct timespec Ta st_atimespec Ta time of last access
2662fe8fb19SBen Gras.It Vt struct timespec Ta st_mtimespec Ta time of last modification
2672fe8fb19SBen Gras.It Vt struct timespec Ta st_birthtimespec Ta time of creation
2682fe8fb19SBen Gras.It Vt uint32_t Ta st_flags Ta user defined flags
2692fe8fb19SBen Gras.It Vt uint32_t Ta st_gen Ta file generation number
2702fe8fb19SBen Gras.\"
2712fe8fb19SBen Gras.\" XXX: What is this?
2722fe8fb19SBen Gras.\"
2732fe8fb19SBen Gras.It Vt uint32_t Ta st_spare[2] Ta implementation detail
2742fe8fb19SBen Gras.El
2752fe8fb19SBen Gras.Pp
2762fe8fb19SBen GrasIn this case the following macros are provided for convenience:
2772fe8fb19SBen Gras.Bd -literal -offset indent
2782fe8fb19SBen Gras#if defined(_NETBSD_SOURCE)
2792fe8fb19SBen Gras  #define st_atime                st_atimespec.tv_sec
2802fe8fb19SBen Gras  #define st_atimensec            st_atimespec.tv_nsec
2812fe8fb19SBen Gras  #define st_mtime                st_mtimespec.tv_sec
2822fe8fb19SBen Gras  #define st_mtimensec            st_mtimespec.tv_nsec
2832fe8fb19SBen Gras  #define st_ctime                st_ctimespec.tv_sec
2842fe8fb19SBen Gras  #define st_ctimensec            st_ctimespec.tv_nsec
2852fe8fb19SBen Gras  #define st_birthtime            st_birthtimespec.tv_sec
2862fe8fb19SBen Gras  #define st_birthtimensec        st_birthtimespec.tv_nsec
2872fe8fb19SBen Gras#endif
2882fe8fb19SBen Gras.Ed
2892fe8fb19SBen Gras.Pp
2902fe8fb19SBen GrasThe status information word
2912fe8fb19SBen Gras.Fa st_flags
2922fe8fb19SBen Grashas the following bits:
2932fe8fb19SBen Gras.Bl -column -offset indent \
2942fe8fb19SBen Gras"struct timespec " "st_birthtimensec"
2952fe8fb19SBen Gras.It Sy Constant Ta Sy Description
2962fe8fb19SBen Gras.It Dv UF_NODUMP Ta do not dump a file
2972fe8fb19SBen Gras.It Dv UF_IMMUTABLE Ta file may not be changed
2982fe8fb19SBen Gras.It Dv UF_APPEND Ta writes to file may only append
2992fe8fb19SBen Gras.It Dv UF_OPAQUE Ta directory is opaque wrt. union
3002fe8fb19SBen Gras.It Dv SF_ARCHIVED Ta file is archived
3012fe8fb19SBen Gras.It Dv SF_IMMUTABLE Ta file may not be changed
3022fe8fb19SBen Gras.It Dv SF_APPEND Ta writes to file may only append
3032fe8fb19SBen Gras.El
3042fe8fb19SBen Gras.Pp
3052fe8fb19SBen GrasFor a description of the flags, see
3062fe8fb19SBen Gras.Xr chflags 2 .
3072fe8fb19SBen Gras.Sh RETURN VALUES
30884d9c625SLionel Sambuc.Rv -std stat lstat fstat fstatat
3092fe8fb19SBen Gras.Sh COMPATIBILITY
3102fe8fb19SBen GrasPrevious versions of the system used different types for the
3112fe8fb19SBen Gras.Li st_dev ,
3122fe8fb19SBen Gras.Li st_uid ,
3132fe8fb19SBen Gras.Li st_gid ,
3142fe8fb19SBen Gras.Li st_rdev ,
3152fe8fb19SBen Gras.Li st_size ,
3162fe8fb19SBen Gras.Li st_blksize
3172fe8fb19SBen Grasand
3182fe8fb19SBen Gras.Li st_blocks
3192fe8fb19SBen Grasfields.
3202fe8fb19SBen Gras.Sh ERRORS
32184d9c625SLionel Sambuc.Fn stat ,
3222fe8fb19SBen Gras.Fn lstat
32384d9c625SLionel Sambucand
32484d9c625SLionel Sambuc.Fn fstatat
3252fe8fb19SBen Graswill fail if:
3262fe8fb19SBen Gras.Bl -tag -width Er
3272fe8fb19SBen Gras.It Bq Er EACCES
3282fe8fb19SBen GrasSearch permission is denied for a component of the path prefix.
3292fe8fb19SBen Gras.It Bq Er EBADF
330f14fb602SLionel SambucA badly formed vnode was encountered.
3312fe8fb19SBen GrasThis can happen if a file system information node is incorrect.
3322fe8fb19SBen Gras.It Bq Er EFAULT
3332fe8fb19SBen Gras.Fa sb
3342fe8fb19SBen Grasor
33584d9c625SLionel Sambuc.Fa path
3362fe8fb19SBen Graspoints to an invalid address.
3372fe8fb19SBen Gras.It Bq Er EIO
3382fe8fb19SBen GrasAn I/O error occurred while reading from or writing to the file system.
3392fe8fb19SBen Gras.It Bq Er ELOOP
3402fe8fb19SBen GrasToo many symbolic links were encountered in translating the pathname.
3412fe8fb19SBen Gras.It Bq Er ENAMETOOLONG
3422fe8fb19SBen GrasA component of a pathname exceeded
3432fe8fb19SBen Gras.Brq Dv NAME_MAX
3442fe8fb19SBen Grascharacters, or an entire path name exceeded
3452fe8fb19SBen Gras.Brq Dv PATH_MAX
3462fe8fb19SBen Grascharacters.
3472fe8fb19SBen Gras.It Bq Er ENOENT
3482fe8fb19SBen GrasThe named file does not exist.
3492fe8fb19SBen Gras.It Bq Er ENOTDIR
3502fe8fb19SBen GrasA component of the path prefix is not a directory.
3512fe8fb19SBen Gras.It Bq Er ENXIO
3522fe8fb19SBen GrasThe named file is a character special or block
3532fe8fb19SBen Grasspecial file, and the device associated with this special file
3542fe8fb19SBen Grasdoes not exist.
3552fe8fb19SBen Gras.El
3562fe8fb19SBen Gras.Pp
35784d9c625SLionel SambucIn addition,
35884d9c625SLionel Sambuc.Fn fstatat
35984d9c625SLionel Sambucwill fail if:
36084d9c625SLionel Sambuc.Bl -tag -width Er
36184d9c625SLionel Sambuc.It Bq Er EBADF
36284d9c625SLionel Sambuc.Fa path
36384d9c625SLionel Sambucdoes not specify an absolute path and
36484d9c625SLionel Sambuc.Fa fd
36584d9c625SLionel Sambucis neither
36684d9c625SLionel Sambuc.Dv AT_FDCWD
36784d9c625SLionel Sambucnor a valid file descriptor open for reading or searching.
36884d9c625SLionel Sambuc.It Bq Er ENOTDIR
36984d9c625SLionel Sambuc.Fa path
37084d9c625SLionel Sambucis not an absolute path and
37184d9c625SLionel Sambuc.Fa fd
37284d9c625SLionel Sambucis a file descriptor associated with a non-directory file.
37384d9c625SLionel Sambuc.El
37484d9c625SLionel Sambuc.Pp
3752fe8fb19SBen Gras.Fn fstat
3762fe8fb19SBen Graswill fail if:
3772fe8fb19SBen Gras.Bl -tag -width Er
3782fe8fb19SBen Gras.It Bq Er EBADF
3792fe8fb19SBen Gras.Fa fd
3802fe8fb19SBen Grasis not a valid open file descriptor.
3812fe8fb19SBen Gras.It Bq Er EFAULT
3822fe8fb19SBen Gras.Fa sb
3832fe8fb19SBen Graspoints to an invalid address.
3842fe8fb19SBen Gras.It Bq Er EIO
3852fe8fb19SBen GrasAn I/O error occurred while reading from or writing to the file system.
3862fe8fb19SBen Gras.El
3872fe8fb19SBen Gras.Sh SEE ALSO
3882fe8fb19SBen Gras.Xr chflags 2 ,
3892fe8fb19SBen Gras.Xr chmod 2 ,
3902fe8fb19SBen Gras.Xr chown 2 ,
3912fe8fb19SBen Gras.Xr utimes 2 ,
3922fe8fb19SBen Gras.Xr dirent 3 ,
3932fe8fb19SBen Gras.Xr types 3 ,
3942fe8fb19SBen Gras.Xr symlink 7
3952fe8fb19SBen Gras.Sh STANDARDS
39684d9c625SLionel Sambuc.Fn stat ,
39784d9c625SLionel Sambuc.Fn lstat ,
39884d9c625SLionel Sambucand
39984d9c625SLionel Sambuc.Fn fstat
40084d9c625SLionel Sambucconform to
4012fe8fb19SBen Gras.St -p1003.1-2004 .
40284d9c625SLionel Sambuc.Fn fstatat
40384d9c625SLionel Sambucconforms to
40484d9c625SLionel Sambuc.St -p1003.1-2008 .
4052fe8fb19SBen Gras.Sh HISTORY
4062fe8fb19SBen GrasA
4072fe8fb19SBen Gras.Fn stat
4082fe8fb19SBen Grasfunction call appeared in
4092fe8fb19SBen Gras.At v2 .
4102fe8fb19SBen GrasA
4112fe8fb19SBen Gras.Fn lstat
4122fe8fb19SBen Grasfunction call appeared in
4132fe8fb19SBen Gras.Bx 4.2 .
4142fe8fb19SBen Gras.Sh BUGS
4152fe8fb19SBen GrasApplying
4162fe8fb19SBen Gras.Fn fstat
4172fe8fb19SBen Grasto a socket (and thus to a pipe)
4182fe8fb19SBen Grasreturns a zero'd buffer,
4192fe8fb19SBen Grasexcept for the blocksize field,
4202fe8fb19SBen Grasand a unique device and file serial number.
421