The following standards-compliant fields are defined in the structure:
dev_t
st_dev
device ID containing the file
ino_t
st_ino
serial number of the file
mode_t
st_mode
mode of the file
nlink_t
st_nlink
number of hard links to the file
uid_t
st_uid
user ID of the owner
gid_t
st_gid
group ID of the owner
dev_t
st_rdev
device type (character or block special)
off_t
st_size
size of the file in bytes
time_t
st_atime
time of last access
time_t
st_mtime
time of last data modification
time_t
st_ctime
time of last file status change
blksize_t
st_blksize
preferred I/O block size (fs-specific)
blkcnt_t
st_block
blocks allocated for the file
These are specified in the IEEE Std 1003.1-2004 (“POSIX.1”) standard. The
st_ino and
st_dev fields taken together to uniquely identify the file within the system. Most of the types are defined in
types(3).
The time-related fields are:
The size-related fields of the
struct stat are as follows:
st_size
The size of the file in bytes. A directory will be a multiple of the size of the
dirent(3) structure. Some file systems (notably ZFS) return the number of entries in the directory instead of the size in bytes.
st_blksize
The optimal I/O block size for the file.
st_blocks
The actual number of blocks allocated for the file in 512-byte units. As short symbolic links are stored in the inode, this number may be zero.
The status information word
st_mode contains bits that define the access mode (see
chmod(2)) and the type (see
dirent(3)) of the file. The following macros can be used to test whether a file is of the specified type. The value
m supplied to the macros is the value of
st_mode.
S_ISBLK(m)
Test for a block special file.
S_ISCHR(m)
Test for a character special file.
S_ISDIR(m)
Test for a directory.
S_ISFIFO(m)
Test for a pipe or FIFO special file.
S_ISREG(m)
Test for a regular file.
S_ISLNK(m)
Test for a symbolic link.
S_ISSOCK(m)
Test for a socket.
The macros evaluate to a non-zero value if the test is true or to the value 0 if the test is false.