1994-05-27 05:00:24 +00:00
|
|
|
.\" Copyright (c) 1980, 1991, 1993, 1994
|
|
|
|
.\" The Regents of the University of California. All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
2017-02-28 23:42:47 +00:00
|
|
|
.\" 3. Neither the name of the University nor the names of its contributors
|
1994-05-27 05:00:24 +00:00
|
|
|
.\" may be used to endorse or promote products derived from this software
|
|
|
|
.\" without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
1997-03-11 11:35:56 +00:00
|
|
|
.\" @(#)stat.2 8.4 (Berkeley) 5/1/95
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1994-05-27 05:00:24 +00:00
|
|
|
.\"
|
2018-12-05 17:28:40 +00:00
|
|
|
.Dd December 5, 2018
|
1994-05-27 05:00:24 +00:00
|
|
|
.Dt STAT 2
|
2001-07-10 13:41:46 +00:00
|
|
|
.Os
|
1994-05-27 05:00:24 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm stat ,
|
|
|
|
.Nm lstat ,
|
2008-04-16 13:03:12 +00:00
|
|
|
.Nm fstat ,
|
|
|
|
.Nm fstatat
|
1994-05-27 05:00:24 +00:00
|
|
|
.Nd get file status
|
2000-04-21 09:42:15 +00:00
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libc
|
1994-05-27 05:00:24 +00:00
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In sys/stat.h
|
1994-05-27 05:00:24 +00:00
|
|
|
.Ft int
|
2016-01-14 01:33:16 +00:00
|
|
|
.Fn stat "const char * restrict path" "struct stat * restrict sb"
|
1994-05-27 05:00:24 +00:00
|
|
|
.Ft int
|
2016-01-14 01:33:16 +00:00
|
|
|
.Fn lstat "const char * restrict path" "struct stat * restrict sb"
|
1994-05-27 05:00:24 +00:00
|
|
|
.Ft int
|
|
|
|
.Fn fstat "int fd" "struct stat *sb"
|
2008-04-16 13:03:12 +00:00
|
|
|
.Ft int
|
2019-03-13 15:18:14 +00:00
|
|
|
.Fn fstatat "int fd" "const char *path" "struct stat *sb" "int flag"
|
1994-05-27 05:00:24 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Fn stat
|
2002-12-18 09:22:32 +00:00
|
|
|
system call obtains information about the file pointed to by
|
1994-05-27 05:00:24 +00:00
|
|
|
.Fa path .
|
|
|
|
Read, write or execute
|
|
|
|
permission of the named file is not required, but all directories
|
|
|
|
listed in the path name leading to the file must be searchable.
|
|
|
|
.Pp
|
2002-07-15 19:56:24 +00:00
|
|
|
The
|
|
|
|
.Fn lstat
|
2002-12-18 09:22:32 +00:00
|
|
|
system call is like
|
1994-05-27 05:00:24 +00:00
|
|
|
.Fn stat
|
2017-06-23 18:38:27 +00:00
|
|
|
except when the named file is a symbolic link,
|
1994-05-27 05:00:24 +00:00
|
|
|
in which case
|
|
|
|
.Fn lstat
|
|
|
|
returns information about the link,
|
|
|
|
while
|
|
|
|
.Fn stat
|
|
|
|
returns information about the file the link references.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn fstat
|
2002-12-18 09:22:32 +00:00
|
|
|
system call obtains the same information about an open file
|
1994-05-27 05:00:24 +00:00
|
|
|
known by the file descriptor
|
|
|
|
.Fa fd .
|
|
|
|
.Pp
|
|
|
|
The
|
2008-04-16 13:03:12 +00:00
|
|
|
.Fn fstatat
|
|
|
|
system call is equivalent to
|
|
|
|
.Fn stat
|
|
|
|
and
|
|
|
|
.Fn lstat
|
2017-06-23 18:38:27 +00:00
|
|
|
except when the
|
2008-04-16 13:03:12 +00:00
|
|
|
.Fa path
|
2018-11-11 01:46:48 +00:00
|
|
|
specifies a relative path, or the
|
|
|
|
.Dv AT_BENEATH
|
|
|
|
flag is provided.
|
|
|
|
For
|
|
|
|
.Fn fstatat
|
|
|
|
and relative
|
|
|
|
.Fa path ,
|
|
|
|
the status is retrieved from a file relative to
|
2008-04-16 13:03:12 +00:00
|
|
|
the directory associated with the file descriptor
|
|
|
|
.Fa fd
|
|
|
|
instead of the current working directory.
|
2018-11-11 01:46:48 +00:00
|
|
|
For
|
|
|
|
.Dv AT_BENEATH
|
|
|
|
and absolute
|
|
|
|
.Fa path ,
|
|
|
|
the status is retrieved from a file specified by the
|
|
|
|
.Fa path ,
|
|
|
|
but additional permission checks are performed, see below.
|
2008-04-16 13:03:12 +00:00
|
|
|
.Pp
|
|
|
|
The values for the
|
|
|
|
.Fa flag
|
2017-06-23 18:38:27 +00:00
|
|
|
are constructed by a bitwise-inclusive OR of flags from this list,
|
2008-04-16 13:03:12 +00:00
|
|
|
defined in
|
|
|
|
.In fcntl.h :
|
|
|
|
.Bl -tag -width indent
|
|
|
|
.It Dv AT_SYMLINK_NOFOLLOW
|
|
|
|
If
|
|
|
|
.Fa path
|
|
|
|
names a symbolic link, the status of the symbolic link is returned.
|
2018-10-25 22:16:34 +00:00
|
|
|
.It Dv AT_BENEATH
|
2018-11-11 01:46:48 +00:00
|
|
|
Only stat files and directories below the topping directory.
|
2018-10-25 22:16:34 +00:00
|
|
|
See the description of the
|
|
|
|
.Dv O_BENEATH
|
|
|
|
flag in the
|
|
|
|
.Xr open 2
|
|
|
|
manual page.
|
2008-04-16 13:03:12 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Fn fstatat
|
|
|
|
is passed the special value
|
|
|
|
.Dv AT_FDCWD
|
|
|
|
in the
|
|
|
|
.Fa fd
|
|
|
|
parameter, the current working directory is used and the behavior is
|
|
|
|
identical to a call to
|
|
|
|
.Fn stat
|
|
|
|
or
|
|
|
|
.Fn lstat
|
|
|
|
respectively, depending on whether or not the
|
|
|
|
.Dv AT_SYMLINK_NOFOLLOW
|
|
|
|
bit is set in
|
|
|
|
.Fa flag .
|
|
|
|
.Pp
|
2018-11-11 01:46:48 +00:00
|
|
|
When
|
|
|
|
.Fn fstatat
|
|
|
|
is called with an absolute
|
|
|
|
.Fa path
|
|
|
|
without the
|
|
|
|
.Dv AT_BENEATH
|
|
|
|
flag, it ignores the
|
|
|
|
.Fa fd
|
|
|
|
argument.
|
|
|
|
When
|
|
|
|
.Dv AT_BENEATH
|
|
|
|
is specified with an absolute
|
|
|
|
.Fa path ,
|
|
|
|
a directory passed by the
|
|
|
|
.Fa fd
|
|
|
|
argument is used as the topping point for the resolution.
|
|
|
|
.Pp
|
2008-04-16 13:03:12 +00:00
|
|
|
The
|
1994-05-27 05:00:24 +00:00
|
|
|
.Fa sb
|
|
|
|
argument is a pointer to a
|
2002-07-15 20:07:09 +00:00
|
|
|
.Vt stat
|
1994-05-27 05:00:24 +00:00
|
|
|
structure
|
|
|
|
as defined by
|
2003-09-08 19:57:22 +00:00
|
|
|
.In sys/stat.h
|
1994-05-27 05:00:24 +00:00
|
|
|
and into which information is placed concerning the file.
|
|
|
|
.Pp
|
2004-11-15 14:16:31 +00:00
|
|
|
The fields of
|
|
|
|
.Vt "struct stat"
|
2017-06-23 18:38:27 +00:00
|
|
|
related to the file system are:
|
2004-11-15 14:16:31 +00:00
|
|
|
.Bl -tag -width ".Va st_nlink"
|
|
|
|
.It Va st_dev
|
2017-06-23 18:38:27 +00:00
|
|
|
Numeric ID of the device containing the file.
|
2004-11-15 14:16:31 +00:00
|
|
|
.It Va st_ino
|
|
|
|
The file's inode number.
|
|
|
|
.It Va st_nlink
|
2017-06-23 18:38:27 +00:00
|
|
|
Number of hard links to the file.
|
2017-06-16 15:09:43 +00:00
|
|
|
.It Va st_flags
|
2017-06-23 18:38:27 +00:00
|
|
|
Flags enabled for the file.
|
2017-06-16 15:09:43 +00:00
|
|
|
See
|
|
|
|
.Xr chflags 2
|
|
|
|
for the list of flags and their description.
|
2004-11-15 14:16:31 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Va st_dev
|
|
|
|
and
|
|
|
|
.Va st_ino
|
|
|
|
fields together identify the file uniquely within the system.
|
|
|
|
.Pp
|
1994-05-27 05:00:24 +00:00
|
|
|
The time-related fields of
|
2004-11-15 13:58:52 +00:00
|
|
|
.Vt "struct stat"
|
2017-06-23 18:38:27 +00:00
|
|
|
are:
|
2010-03-28 13:13:22 +00:00
|
|
|
.Bl -tag -width ".Va st_birthtim"
|
|
|
|
.It Va st_atim
|
2017-06-23 18:38:27 +00:00
|
|
|
Time when file data was last accessed.
|
2018-12-05 17:28:40 +00:00
|
|
|
Changed implicitly by syscalls such as
|
1994-05-27 05:00:24 +00:00
|
|
|
.Xr read 2
|
2003-10-20 13:52:22 +00:00
|
|
|
and
|
2018-12-05 17:28:40 +00:00
|
|
|
.Xr readv 2 ,
|
|
|
|
and explicitly by
|
|
|
|
.Xr utimes 2 .
|
2010-03-28 13:13:22 +00:00
|
|
|
.It Va st_mtim
|
2017-06-23 18:38:27 +00:00
|
|
|
Time when file data was last modified.
|
2018-12-05 17:28:40 +00:00
|
|
|
Changed implicitly by syscalls such as
|
|
|
|
.Xr truncate 2 ,
|
|
|
|
.Xr write 2 ,
|
|
|
|
and
|
|
|
|
.Xr writev 2 ,
|
|
|
|
and explicitly by
|
|
|
|
.Xr utimes 2 .
|
|
|
|
Also, any syscall which modifies directory content changes the
|
|
|
|
.Va st_mtim
|
|
|
|
for the affected directory.
|
|
|
|
For instance,
|
|
|
|
.Xr creat 2 ,
|
2003-10-20 13:52:22 +00:00
|
|
|
.Xr mkdir 2 ,
|
2018-12-05 17:28:40 +00:00
|
|
|
.Xr rename 2 ,
|
|
|
|
.Xr link 2 ,
|
2003-10-20 13:52:22 +00:00
|
|
|
and
|
2018-12-05 17:28:40 +00:00
|
|
|
.Xr unlink 2 .
|
2010-03-28 13:13:22 +00:00
|
|
|
.It Va st_ctim
|
1994-05-27 05:00:24 +00:00
|
|
|
Time when file status was last changed (inode data modification).
|
2018-12-05 17:28:40 +00:00
|
|
|
Changed implicitly by any syscall that affects file metadata, including
|
|
|
|
.Va st_mtim ,
|
|
|
|
such as
|
2003-10-20 13:52:22 +00:00
|
|
|
.Xr chflags 2 ,
|
1994-05-27 05:00:24 +00:00
|
|
|
.Xr chmod 2 ,
|
|
|
|
.Xr chown 2 ,
|
2018-12-05 17:28:40 +00:00
|
|
|
.Xr truncate 2 ,
|
|
|
|
.Xr utimes 2 ,
|
|
|
|
and
|
|
|
|
.Xr write 2 .
|
|
|
|
Also, any syscall which modifies directory content changes the
|
|
|
|
.Va st_ctim
|
|
|
|
for the affected directory.
|
|
|
|
For instance,
|
2003-10-20 13:52:22 +00:00
|
|
|
.Xr creat 2 ,
|
|
|
|
.Xr mkdir 2 ,
|
1994-05-27 05:00:24 +00:00
|
|
|
.Xr rename 2 ,
|
2018-12-05 17:28:40 +00:00
|
|
|
.Xr link 2 ,
|
2003-10-20 13:52:22 +00:00
|
|
|
and
|
2018-12-05 17:28:40 +00:00
|
|
|
.Xr unlink 2 .
|
2010-03-28 13:13:22 +00:00
|
|
|
.It Va st_birthtim
|
2003-05-13 08:10:05 +00:00
|
|
|
Time when the inode was created.
|
1994-05-27 05:00:24 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
2017-06-23 18:38:27 +00:00
|
|
|
These time-related macros are defined for compatibility:
|
1997-01-11 21:45:57 +00:00
|
|
|
.Bd -literal
|
2010-03-28 13:13:22 +00:00
|
|
|
#define st_atime st_atim.tv_sec
|
|
|
|
#define st_mtime st_mtim.tv_sec
|
|
|
|
#define st_ctime st_ctim.tv_sec
|
|
|
|
#ifndef _POSIX_SOURCE
|
|
|
|
#define st_birthtime st_birthtim.tv_sec
|
|
|
|
#endif
|
|
|
|
|
1997-01-11 21:45:57 +00:00
|
|
|
#ifndef _POSIX_SOURCE
|
2010-03-28 13:13:22 +00:00
|
|
|
#define st_atimespec st_atim
|
|
|
|
#define st_mtimespec st_mtim
|
|
|
|
#define st_ctimespec st_ctim
|
|
|
|
#define st_birthtimespec st_birthtim
|
1997-01-11 21:45:57 +00:00
|
|
|
#endif
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2017-06-23 18:38:27 +00:00
|
|
|
Size-related fields of the
|
2002-12-19 09:40:28 +00:00
|
|
|
.Vt "struct stat"
|
2017-06-23 18:38:27 +00:00
|
|
|
are:
|
2004-11-15 13:45:13 +00:00
|
|
|
.Bl -tag -width ".Va st_blksize"
|
2004-11-15 14:16:31 +00:00
|
|
|
.It Va st_size
|
2017-06-23 18:38:27 +00:00
|
|
|
File size in bytes.
|
2004-11-15 13:45:13 +00:00
|
|
|
.It Va st_blksize
|
2017-06-23 18:38:27 +00:00
|
|
|
Optimal I/O block size for the file.
|
2004-11-15 13:45:13 +00:00
|
|
|
.It Va st_blocks
|
2017-06-23 18:38:27 +00:00
|
|
|
Actual number of blocks allocated for the file in 512-byte units.
|
1994-05-27 05:00:24 +00:00
|
|
|
As short symbolic links are stored in the inode, this number may
|
|
|
|
be zero.
|
|
|
|
.El
|
|
|
|
.Pp
|
2004-11-15 14:16:31 +00:00
|
|
|
The access-related fields of
|
|
|
|
.Vt "struct stat"
|
2017-06-23 18:38:27 +00:00
|
|
|
are:
|
2004-11-15 14:16:31 +00:00
|
|
|
.Bl -tag -width ".Va st_mode"
|
|
|
|
.It Va st_uid
|
2017-06-23 18:38:27 +00:00
|
|
|
User ID of the file's owner.
|
2004-11-15 14:16:31 +00:00
|
|
|
.It Va st_gid
|
2017-06-23 18:38:27 +00:00
|
|
|
Group ID of the file.
|
2004-11-15 14:16:31 +00:00
|
|
|
.It Va st_mode
|
|
|
|
Status of the file (see below).
|
|
|
|
.El
|
|
|
|
.Pp
|
1994-05-27 05:00:24 +00:00
|
|
|
The status information word
|
|
|
|
.Fa st_mode
|
2017-06-23 18:38:27 +00:00
|
|
|
has these bits:
|
1994-05-27 05:00:24 +00:00
|
|
|
.Bd -literal
|
2006-10-12 13:35:07 +00:00
|
|
|
#define S_IFMT 0170000 /* type of file mask */
|
2002-07-15 08:58:16 +00:00
|
|
|
#define S_IFIFO 0010000 /* named pipe (fifo) */
|
|
|
|
#define S_IFCHR 0020000 /* character special */
|
|
|
|
#define S_IFDIR 0040000 /* directory */
|
|
|
|
#define S_IFBLK 0060000 /* block special */
|
|
|
|
#define S_IFREG 0100000 /* regular */
|
|
|
|
#define S_IFLNK 0120000 /* symbolic link */
|
|
|
|
#define S_IFSOCK 0140000 /* socket */
|
|
|
|
#define S_IFWHT 0160000 /* whiteout */
|
|
|
|
#define S_ISUID 0004000 /* set user id on execution */
|
|
|
|
#define S_ISGID 0002000 /* set group id on execution */
|
|
|
|
#define S_ISVTX 0001000 /* save swapped text even after use */
|
2006-10-12 13:35:07 +00:00
|
|
|
#define S_IRWXU 0000700 /* RWX mask for owner */
|
2002-07-15 08:58:16 +00:00
|
|
|
#define S_IRUSR 0000400 /* read permission, owner */
|
|
|
|
#define S_IWUSR 0000200 /* write permission, owner */
|
|
|
|
#define S_IXUSR 0000100 /* execute/search permission, owner */
|
2006-10-12 13:35:07 +00:00
|
|
|
#define S_IRWXG 0000070 /* RWX mask for group */
|
|
|
|
#define S_IRGRP 0000040 /* read permission, group */
|
|
|
|
#define S_IWGRP 0000020 /* write permission, group */
|
|
|
|
#define S_IXGRP 0000010 /* execute/search permission, group */
|
|
|
|
#define S_IRWXO 0000007 /* RWX mask for other */
|
|
|
|
#define S_IROTH 0000004 /* read permission, other */
|
|
|
|
#define S_IWOTH 0000002 /* write permission, other */
|
|
|
|
#define S_IXOTH 0000001 /* execute/search permission, other */
|
1994-05-27 05:00:24 +00:00
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
For a list of access modes, see
|
2003-09-08 19:57:22 +00:00
|
|
|
.In sys/stat.h ,
|
1994-05-27 05:00:24 +00:00
|
|
|
.Xr access 2
|
|
|
|
and
|
|
|
|
.Xr chmod 2 .
|
2017-06-23 18:38:27 +00:00
|
|
|
These macros are available to test whether a
|
2004-11-15 13:37:56 +00:00
|
|
|
.Va st_mode
|
|
|
|
value passed in the
|
2005-01-11 20:50:51 +00:00
|
|
|
.Fa m
|
2004-11-15 13:37:56 +00:00
|
|
|
argument corresponds to a file of the specified type:
|
|
|
|
.Bl -tag -width ".Fn S_ISFIFO m"
|
|
|
|
.It Fn S_ISBLK m
|
|
|
|
Test for a block special file.
|
|
|
|
.It Fn S_ISCHR m
|
|
|
|
Test for a character special file.
|
|
|
|
.It Fn S_ISDIR m
|
|
|
|
Test for a directory.
|
|
|
|
.It Fn S_ISFIFO m
|
|
|
|
Test for a pipe or FIFO special file.
|
|
|
|
.It Fn S_ISLNK m
|
|
|
|
Test for a symbolic link.
|
|
|
|
.It Fn S_ISREG m
|
|
|
|
Test for a regular file.
|
|
|
|
.It Fn S_ISSOCK m
|
|
|
|
Test for a socket.
|
|
|
|
.It Fn S_ISWHT m
|
|
|
|
Test for a whiteout.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The macros evaluate to a non-zero value if the test is true
|
|
|
|
or to the value 0 if the test is false.
|
1994-05-27 05:00:24 +00:00
|
|
|
.Sh RETURN VALUES
|
2001-08-31 09:57:38 +00:00
|
|
|
.Rv -std
|
1994-05-27 05:00:24 +00:00
|
|
|
.Sh COMPATIBILITY
|
|
|
|
Previous versions of the system used different types for the
|
2004-11-15 13:45:13 +00:00
|
|
|
.Va st_dev ,
|
|
|
|
.Va st_uid ,
|
|
|
|
.Va st_gid ,
|
|
|
|
.Va st_rdev ,
|
|
|
|
.Va st_size ,
|
|
|
|
.Va st_blksize
|
1994-05-27 05:00:24 +00:00
|
|
|
and
|
2004-11-15 13:45:13 +00:00
|
|
|
.Va st_blocks
|
1994-05-27 05:00:24 +00:00
|
|
|
fields.
|
|
|
|
.Sh ERRORS
|
2002-07-15 19:56:24 +00:00
|
|
|
The
|
|
|
|
.Fn stat
|
1994-05-27 05:00:24 +00:00
|
|
|
and
|
|
|
|
.Fn lstat
|
2002-12-18 09:22:32 +00:00
|
|
|
system calls will fail if:
|
2000-05-04 13:09:25 +00:00
|
|
|
.Bl -tag -width Er
|
1994-05-27 05:00:24 +00:00
|
|
|
.It Bq Er EACCES
|
|
|
|
Search permission is denied for a component of the path prefix.
|
|
|
|
.It Bq Er EFAULT
|
2002-12-19 09:40:28 +00:00
|
|
|
The
|
2000-11-22 16:02:00 +00:00
|
|
|
.Fa sb
|
1994-05-27 05:00:24 +00:00
|
|
|
or
|
2002-12-18 13:33:04 +00:00
|
|
|
.Fa path
|
2002-12-19 09:40:28 +00:00
|
|
|
argument
|
1994-05-27 05:00:24 +00:00
|
|
|
points to an invalid address.
|
|
|
|
.It Bq Er EIO
|
|
|
|
An I/O error occurred while reading from or writing to the file system.
|
2001-08-31 23:06:28 +00:00
|
|
|
.It Bq Er ELOOP
|
|
|
|
Too many symbolic links were encountered in translating the pathname.
|
|
|
|
.It Bq Er ENAMETOOLONG
|
|
|
|
A component of a pathname exceeded 255 characters,
|
|
|
|
or an entire path name exceeded 1023 characters.
|
|
|
|
.It Bq Er ENOENT
|
|
|
|
The named file does not exist.
|
|
|
|
.It Bq Er ENOTDIR
|
|
|
|
A component of the path prefix is not a directory.
|
|
|
|
.It Bq Er EOVERFLOW
|
|
|
|
The file size in bytes cannot be
|
|
|
|
represented correctly in the structure pointed to by
|
|
|
|
.Fa sb .
|
1994-05-27 05:00:24 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
2002-07-15 19:56:24 +00:00
|
|
|
The
|
|
|
|
.Fn fstat
|
2002-12-18 09:22:32 +00:00
|
|
|
system call will fail if:
|
2010-10-21 12:27:13 +00:00
|
|
|
.Bl -tag -width Er
|
1994-05-27 05:00:24 +00:00
|
|
|
.It Bq Er EBADF
|
2002-12-19 09:40:28 +00:00
|
|
|
The
|
1994-05-27 05:00:24 +00:00
|
|
|
.Fa fd
|
2002-12-19 09:40:28 +00:00
|
|
|
argument
|
1994-05-27 05:00:24 +00:00
|
|
|
is not a valid open file descriptor.
|
|
|
|
.It Bq Er EFAULT
|
2002-12-19 09:40:28 +00:00
|
|
|
The
|
2000-11-22 16:02:00 +00:00
|
|
|
.Fa sb
|
2002-12-19 09:40:28 +00:00
|
|
|
argument
|
1994-05-27 05:00:24 +00:00
|
|
|
points to an invalid address.
|
|
|
|
.It Bq Er EIO
|
|
|
|
An I/O error occurred while reading from or writing to the file system.
|
2001-08-31 23:06:28 +00:00
|
|
|
.It Bq Er EOVERFLOW
|
|
|
|
The file size in bytes cannot be
|
|
|
|
represented correctly in the structure pointed to by
|
|
|
|
.Fa sb .
|
1994-05-27 05:00:24 +00:00
|
|
|
.El
|
2008-04-16 13:03:12 +00:00
|
|
|
.Pp
|
|
|
|
In addition to the errors returned by the
|
|
|
|
.Fn lstat ,
|
|
|
|
the
|
|
|
|
.Fn fstatat
|
|
|
|
may fail if:
|
|
|
|
.Bl -tag -width Er
|
|
|
|
.It Bq Er EBADF
|
|
|
|
The
|
|
|
|
.Fa path
|
|
|
|
argument does not specify an absolute path and the
|
|
|
|
.Fa fd
|
|
|
|
argument is neither
|
|
|
|
.Dv AT_FDCWD
|
|
|
|
nor a valid file descriptor open for searching.
|
|
|
|
.It Bq Er EINVAL
|
|
|
|
The value of the
|
|
|
|
.Fa flag
|
|
|
|
argument is not valid.
|
|
|
|
.It Bq Er ENOTDIR
|
|
|
|
The
|
|
|
|
.Fa path
|
|
|
|
argument is not an absolute path and
|
|
|
|
.Fa fd
|
|
|
|
is neither
|
|
|
|
.Dv AT_FDCWD
|
|
|
|
nor a file descriptor associated with a directory.
|
2018-10-25 22:16:34 +00:00
|
|
|
.It Bq Er ENOTCAPABLE
|
2018-11-11 01:46:48 +00:00
|
|
|
.Fa path
|
|
|
|
is an absolute path,
|
|
|
|
or contained a ".." component leading to a
|
|
|
|
directory outside of the directory hierarchy specified by
|
|
|
|
.Fa fd ,
|
|
|
|
and the process is in capability mode.
|
|
|
|
.It Bq Er ENOTCAPABLE
|
2018-10-25 22:16:34 +00:00
|
|
|
The
|
|
|
|
.Dv AT_BENEATH
|
2018-11-11 01:46:48 +00:00
|
|
|
flag was provided to
|
|
|
|
.Fn fstatat ,
|
|
|
|
and the absolute
|
2018-10-25 22:16:34 +00:00
|
|
|
.Fa path
|
2018-11-11 01:46:48 +00:00
|
|
|
does not have its tail fully contained under the topping directory,
|
|
|
|
or the relative
|
2018-10-25 22:16:34 +00:00
|
|
|
.Fa path
|
2018-11-11 01:46:48 +00:00
|
|
|
escapes it.
|
2008-04-16 13:03:12 +00:00
|
|
|
.El
|
1994-05-27 05:00:24 +00:00
|
|
|
.Sh SEE ALSO
|
1998-01-02 19:22:52 +00:00
|
|
|
.Xr access 2 ,
|
1994-05-27 05:00:24 +00:00
|
|
|
.Xr chmod 2 ,
|
|
|
|
.Xr chown 2 ,
|
2006-01-10 23:24:47 +00:00
|
|
|
.Xr fhstat 2 ,
|
2006-06-13 12:49:14 +00:00
|
|
|
.Xr statfs 2 ,
|
1996-09-23 22:24:39 +00:00
|
|
|
.Xr utimes 2 ,
|
2011-05-13 16:29:57 +00:00
|
|
|
.Xr sticky 7 ,
|
|
|
|
.Xr symlink 7
|
1994-05-27 05:00:24 +00:00
|
|
|
.Sh STANDARDS
|
|
|
|
The
|
|
|
|
.Fn stat
|
|
|
|
and
|
|
|
|
.Fn fstat
|
2002-12-18 09:22:32 +00:00
|
|
|
system calls are expected to conform to
|
1996-12-02 20:03:58 +00:00
|
|
|
.St -p1003.1-90 .
|
2008-04-16 13:03:12 +00:00
|
|
|
The
|
2011-11-17 13:14:07 +00:00
|
|
|
.Fn fstatat
|
2008-04-16 13:03:12 +00:00
|
|
|
system call follows The Open Group Extended API Set 2 specification.
|
1994-05-27 05:00:24 +00:00
|
|
|
.Sh HISTORY
|
2002-12-18 09:22:32 +00:00
|
|
|
The
|
1996-08-29 21:24:19 +00:00
|
|
|
.Fn stat
|
2002-12-18 09:22:32 +00:00
|
|
|
and
|
1996-08-29 21:24:19 +00:00
|
|
|
.Fn fstat
|
2002-12-18 09:22:32 +00:00
|
|
|
system calls appeared in
|
2017-12-01 22:26:36 +00:00
|
|
|
.At v1 .
|
2002-12-18 09:22:32 +00:00
|
|
|
The
|
1996-08-22 23:31:07 +00:00
|
|
|
.Fn lstat
|
2002-12-18 09:22:32 +00:00
|
|
|
system call appeared in
|
1994-05-27 05:00:24 +00:00
|
|
|
.Bx 4.2 .
|
2008-04-16 13:03:12 +00:00
|
|
|
The
|
|
|
|
.Fn fstatat
|
|
|
|
system call appeared in
|
|
|
|
.Fx 8.0 .
|
2005-01-20 09:17:07 +00:00
|
|
|
.Sh BUGS
|
|
|
|
Applying
|
|
|
|
.Fn fstat
|
2012-06-02 10:50:25 +00:00
|
|
|
to a socket
|
2005-01-20 09:17:07 +00:00
|
|
|
returns a zeroed buffer,
|
|
|
|
except for the blocksize field,
|
|
|
|
and a unique device and inode number.
|