stat(5) File Formats Manual stat(5)
stat: stat.h - data returned by the stat() function
The header defines the structure of the data returned by the functions and The structure contains at least the following members:
dev_t st_dev ID of device containing file
ino_t st_ino file serial number
mode_t st_mode mode of file (see below)
nlink_t st_nlink number of links to the file
uid_t st_uid user ID of file
gid_t st_gid group ID of file
dev_t st_rdev device ID (if file is character or block special)
off_t st_size file size in bytes (if file is a regular file)
time_t st_atime time of last access
int st_natime Reserved, DO NOT USE; field may change.
time_t st_mtime time of last data modification
int st_nmtime Reserved, DO NOT USE; field may change.
time_t st_ctime time of last status change
int st_nctime Reserved, DO NOT USE; field may change.
long st_blksize a filesystem-specific preferred I/O block size
for this object. In some filesystem types, this
may vary from file to file
blkcnt_t st_blocks number of blocks of a filesystem-specific size
allocated for this object
short st_fstype type of filesystem this file is in; see vfs-
dev_t st_realdev real device number of device containing the inode
for this file
File serial number and device ID taken together uniquely identify the file within the system. The and types are defined as described in
Times are given in seconds since the Epoch.
The following symbolic names for the values of are also defined:
S_IFMT 0170000 type of file
S_IFSOCK 0140000 socket
S_IFLNK 0120000 symbolic link
S_IFNWK 0110000 network special
S_IFREG 0100000 regular (ordinary)
S_IFBLK 0060000 block special
S_IFDIR 0040000 directory
S_IFCHR 0020000 character special
S_IFIFO 0010000 FIFO special (named pipe)
File mode bits: miscellaneous
S_CDF 0004000 directory is a context-dependent file
S_ISUID 0004000 set user id on execution
S_ISGID 0002000 set group id on execution
S_ENFMT 0002000 set file-locking mode to enforced
S_ISVTX 0001000 set sticky bit on a directory file
File mode bits: permissions
S_IRWXU 0000700 owner's file access permission bits
S_IRUSR 0000400 read access permission for owner
S_IWUSR 0000200 write access permission for owner
S_IXUSR 0000100 execute/search access permission for owner
S_IRWXG 0000070 group's file access permission bits
S_IRGRP 0000040 read access permission for group
S_IWGRP 0000020 write access permission for group
S_IXGRP 0000010 execute/search access permission for group
S_IRWXO 0000007 others' access permission bits
S_IROTH 0000004 read access permission for others
S_IWOTH 0000002 write access permission for others
S_IXOTH 0000001 execute/search access permission for others
File mode bits: obsolete permission names
S_IREAD 0000400 read access permission for owner
S_IWRITE 0000200 write access permission for owner
S_IEXEC 0000100 execute/search access permission for owner
The bits defined by and are unique. is the bitwise OR of and is the bitwise OR of and is the bitwise OR of and
Implementations may OR other implementation-dependent bits into and but they will not overlap any of the other bits defined in this docu-
ment. The file permission bits are defined to be those corresponding to the bitwise inclusive OR of and
The following macros will test whether a file is of the specified type. The value m supplied to the macros is the value of from a struc-
ture. The macro evaluates to a non-zero value if the test is true, 0 if the test is false.
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_ISCDF(m) Test for a context-dependent file
S_ISNWK(m) Test for a network special
S_ISSOCK(m) Test for a socket
The following are declared as functions and may also be defined as macros:
Use of the macros is recommended for determining the type of a file.
For 32-bit applications, will be truncated to its least significant 32-bits for file systems that use 64-bit values.
chmod(2), chown(2), link(2), mkdir(2), mkfifo(3C), mknod(2), stat(2), symlink(2), umask(2), utime(2), types(5).
First released in Issue 1.
Derived from Issue 1 of the SVID.
The following changes are incorporated for alignment with the ISO POSIX-1 standard:
o The function declarations in this header are expanded to full ISO C prototypes.
o The section is expanded to indicate (a) how files are uniquely identified within the system, (b) that times are given in units
of seconds since the Epoch, (c) rules governing the definition and use of the file mode bits, and (d) usage of the file type test
Other changes are incorporated as follows:
o Reference to the header is added for the definitions of and This has been marked as an extension.
o References to the file and modes are removed.
o The descriptions of the members of the structure in the section are corrected.
Issue 4, Version 2
The following changes are incorporated for X/OPEN UNIX conformance:
o The and members are added to the structure.
o The value of is defined.
o The file mode bit and the file type test macro is defined.
o The and functions are added to the list of functions declared in this header.