.\" 2007-06-08 mtk: Added example program
.\" 2007-07-05 mtk: Added details on underlying system call interfaces
.\"
-.TH STAT 2 2010-12-03 "Linux" "Linux Programmer's Manual"
+.TH STAT 2 2011-10-04 "Linux" "Linux Programmer's Manual"
.SH NAME
stat, fstat, lstat \- get file status
.SH SYNOPSIS
.SH DESCRIPTION
.PP
These functions return information about a file.
-No permissions are required on the file itself, but \(em in the case of
+No permissions are required on the file itself, but\(emin the case of
.BR stat ()
and
.BR lstat ()
.I st_size
field gives the size of the file (if it is a regular
file or a symbolic link) in bytes.
-The size of a symlink is the length of the pathname
-it contains, without a trailing null byte.
+The size of a symbolic link is the length of the pathname
+it contains, without a terminating null byte.
The
.I st_blocks
.\" .BR lstat ()
.\" error conditions EINTR, EMULTIHOP, ENOLINK, and EOVERFLOW.
+According to POSIX.1-2001,
+.BR lstat ()
+on a symbolic link need return valid information only in the
+.I st_size
+field and the file-type component of the
+.IR st_mode
+field of the
+.IR stat
+structure.
+POSIX.-2008 tightens the specification, requiring
+.BR lstat ()
+to return valid information in all fields except the permission bits in
+.IR st_mode .
+
Use of the
.I st_blocks
and
.I any
header files).
.LP
-POSIX does not describe the
+POSIX.1-1990 did not describe the
.BR S_IFMT ,
.BR S_IFSOCK ,
.BR S_IFLNK ,
.BR S_IFCHR ,
.BR S_IFIFO ,
.B S_ISVTX
-bits, but instead demands the use of
+constants, but instead demanded the use of
the macros
.BR S_ISDIR (),
etc.
The
+.BR S_IF*
+constants are present in POSIX.1-2011 and later.
+
+The
.BR S_ISLNK ()
and
.BR S_ISSOCK ()
.BR lstat ()
will generally not trigger automounter action, whereas
.BR stat ()
-will.
+will (but see
+.BR fstatat (2)).
For most files under the
.I /proc