|
Packit |
7cfc04 |
'\" t
|
|
Packit |
7cfc04 |
.\" Copyright (c) 2017 Michael Kerrisk <mtk.manpages@gmail.com>
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_START(VERBATIM)
|
|
Packit |
7cfc04 |
.\" Permission is granted to make and distribute verbatim copies of this
|
|
Packit |
7cfc04 |
.\" manual provided the copyright notice and this permission notice are
|
|
Packit |
7cfc04 |
.\" preserved on all copies.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" Permission is granted to copy and distribute modified versions of this
|
|
Packit |
7cfc04 |
.\" manual under the conditions for verbatim copying, provided that the
|
|
Packit |
7cfc04 |
.\" entire resulting derived work is distributed under the terms of a
|
|
Packit |
7cfc04 |
.\" permission notice identical to this one.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
Packit |
7cfc04 |
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
Packit |
7cfc04 |
.\" responsibility for errors or omissions, or for damages resulting from
|
|
Packit |
7cfc04 |
.\" the use of the information contained herein. The author(s) may not
|
|
Packit |
7cfc04 |
.\" have taken the same level of care in the production of this manual,
|
|
Packit |
7cfc04 |
.\" which is licensed free of charge, as they might when working
|
|
Packit |
7cfc04 |
.\" professionally.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
Packit |
7cfc04 |
.\" the source, must acknowledge the copyright and authors of this work.
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_END
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.TH INODE 7 2017-09-15 "Linux" "Linux Programmer's Manual"
|
|
Packit |
7cfc04 |
.SH NAME
|
|
Packit |
7cfc04 |
inode \- file inode information
|
|
Packit |
7cfc04 |
.SH DESCRIPTION
|
|
Packit |
7cfc04 |
Each file has an inode containing metadata about the file.
|
|
Packit |
7cfc04 |
An application can retrieve this metadata using
|
|
Packit |
7cfc04 |
.BR stat (2)
|
|
Packit |
7cfc04 |
(or related calls), which returns a
|
|
Packit |
7cfc04 |
.I stat
|
|
Packit |
7cfc04 |
structure, or
|
|
Packit |
7cfc04 |
.BR statx (2),
|
|
Packit |
7cfc04 |
which returns a
|
|
Packit |
7cfc04 |
.I statx
|
|
Packit |
7cfc04 |
structure.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The following is a list of the information typically found in,
|
|
Packit |
7cfc04 |
or associated with, the file inode,
|
|
Packit |
7cfc04 |
with the names of the corresponding structure fields returned by
|
|
Packit |
7cfc04 |
.BR stat (2)
|
|
Packit |
7cfc04 |
and
|
|
Packit |
7cfc04 |
.BR statx (2):
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
Device where inode resides
|
|
Packit |
7cfc04 |
\fIstat.st_dev\fP; \fIstatx.stx_dev_minor\fP and \fIstatx.stx_dev_major\fP
|
|
Packit |
7cfc04 |
.IP
|
|
Packit |
7cfc04 |
Each inode (as well as the associated file) resides in a filesystem
|
|
Packit |
7cfc04 |
that is hosted on a device.
|
|
Packit |
7cfc04 |
That device is identified by the combination of its major ID
|
|
Packit |
7cfc04 |
(which identifies the general class of device)
|
|
Packit |
7cfc04 |
and minor ID (which identifies a specific instance in the general class).
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
Inode number
|
|
Packit |
7cfc04 |
\fIstat.st_ino\fP; \fIstatx.stx_ino\fP
|
|
Packit |
7cfc04 |
.IP
|
|
Packit |
7cfc04 |
Each file in a filesystem has a unique inode number.
|
|
Packit |
7cfc04 |
Inode numbers are guaranteed to be unique only within a filesystem
|
|
Packit |
7cfc04 |
(i.e., the same inode numbers may be used by different filesystems,
|
|
Packit |
7cfc04 |
which is the reason that hard links may not cross filesystem boundaries).
|
|
Packit |
7cfc04 |
This field contains the file's inode number.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
File type and mode
|
|
Packit |
7cfc04 |
\fIstat.st_mode\fP; \fIstatx.stx_mode\fP
|
|
Packit |
7cfc04 |
.IP
|
|
Packit |
7cfc04 |
See the discussion of file type and mode, below.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
Link count
|
|
Packit |
7cfc04 |
\fIstat.st_nlink\fP; \fIstatx.stx_nlink\fP
|
|
Packit |
7cfc04 |
.IP
|
|
Packit |
7cfc04 |
This field contains the number of hard links to the file.
|
|
Packit |
7cfc04 |
Additional links to an existing file are created using
|
|
Packit |
7cfc04 |
.BR link (2).
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
User ID
|
|
Packit |
7cfc04 |
.I st_uid
|
|
Packit |
7cfc04 |
\fIstat.st_uid\fP; \fIstatx.stx_uid\fP
|
|
Packit |
7cfc04 |
.IP
|
|
Packit |
7cfc04 |
This field records the user ID of the owner of the file.
|
|
Packit |
7cfc04 |
For newly created files,
|
|
Packit |
7cfc04 |
the file user ID is the effective user ID of the creating process.
|
|
Packit |
7cfc04 |
The user ID of a file can be changed using
|
|
Packit |
7cfc04 |
.BR chown (2).
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
Group ID
|
|
Packit |
7cfc04 |
\fIstat.st_gid\fP; \fIstatx.stx_gid\fP
|
|
Packit |
7cfc04 |
.IP
|
|
Packit |
7cfc04 |
The inode records the ID of the group owner of the file.
|
|
Packit |
7cfc04 |
For newly created files,
|
|
Packit |
7cfc04 |
the file group ID is either the group ID of the parent directory or
|
|
Packit |
7cfc04 |
the effective group ID of the creating process,
|
|
Packit |
7cfc04 |
depending on whether or not the set-group-ID bit
|
|
Packit |
7cfc04 |
is set on the parent directory (see below).
|
|
Packit |
7cfc04 |
The group ID of a file can be changed using
|
|
Packit |
7cfc04 |
.BR chown (2).
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
Device represented by this inode
|
|
Packit |
7cfc04 |
\fIstat.st_rdev\fP; \fIstatx.stx_rdev_minor\fP and \fIstatx.stx_rdev_major\fP
|
|
Packit |
7cfc04 |
.IP
|
|
Packit |
7cfc04 |
If this file (inode) represents a device,
|
|
Packit |
7cfc04 |
then the inode records the major and minor ID of that device.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
File size
|
|
Packit |
7cfc04 |
\fIstat.st_size\fP; \fIstatx.stx_size\fP
|
|
Packit |
7cfc04 |
.IP
|
|
Packit |
7cfc04 |
This field gives the size of the file (if it is a regular
|
|
Packit |
7cfc04 |
file or a symbolic link) in bytes.
|
|
Packit |
7cfc04 |
The size of a symbolic link is the length of the pathname
|
|
Packit |
7cfc04 |
it contains, without a terminating null byte.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
Preferred block size for I/O
|
|
Packit |
7cfc04 |
\fIstat.st_blksize\fP; \fIstatx.stx_blksize\fP
|
|
Packit |
7cfc04 |
.IP
|
|
Packit |
7cfc04 |
This field gives the "preferred" blocksize for efficient filesystem I/O.
|
|
Packit |
7cfc04 |
(Writing to a file in smaller chunks may cause
|
|
Packit |
7cfc04 |
an inefficient read-modify-rewrite.)
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
Number of blocks allocated to the file
|
|
Packit |
7cfc04 |
\fIstat.st_blocks\fP; \fIstatx.stx_size\fP
|
|
Packit |
7cfc04 |
.IP
|
|
Packit |
7cfc04 |
This field indicates the number of blocks allocated to the file,
|
|
Packit |
7cfc04 |
512-byte units,
|
|
Packit |
7cfc04 |
(This may be smaller than
|
|
Packit |
7cfc04 |
.IR st_size /512
|
|
Packit |
7cfc04 |
when the file has holes.)
|
|
Packit |
7cfc04 |
.IP
|
|
Packit |
7cfc04 |
The POSIX.1 standard notes
|
|
Packit |
7cfc04 |
.\" Rationale for sys/stat.h in POSIX.1-2008
|
|
Packit |
7cfc04 |
that the unit for the
|
|
Packit |
7cfc04 |
.I st_blocks
|
|
Packit |
7cfc04 |
member of the
|
|
Packit |
7cfc04 |
.I stat
|
|
Packit |
7cfc04 |
structure is not defined by the standard.
|
|
Packit |
7cfc04 |
On many implementations it is 512 bytes;
|
|
Packit |
7cfc04 |
on a few systems, a different unit is used, such as 1024.
|
|
Packit |
7cfc04 |
Furthermore, the unit may differ on a per-filesystem basis.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
Last access timestamp (atime)
|
|
Packit |
7cfc04 |
\fIstat.st_atime\fP; \fIstatx.stx_atime\fP
|
|
Packit |
7cfc04 |
.IP
|
|
Packit |
7cfc04 |
This is the file's last access timestamp.
|
|
Packit |
7cfc04 |
It is changed by file accesses, for example, by
|
|
Packit |
7cfc04 |
.BR execve (2),
|
|
Packit |
7cfc04 |
.BR mknod (2),
|
|
Packit |
7cfc04 |
.BR pipe (2),
|
|
Packit |
7cfc04 |
.BR utime (2),
|
|
Packit |
7cfc04 |
and
|
|
Packit |
7cfc04 |
.BR read (2)
|
|
Packit |
7cfc04 |
(of more than zero bytes).
|
|
Packit |
7cfc04 |
Other interfaces, such as
|
|
Packit |
7cfc04 |
.BR mmap (2),
|
|
Packit |
7cfc04 |
may or may not update the atime timestamp
|
|
Packit |
7cfc04 |
.IP
|
|
Packit |
7cfc04 |
Some filesystem types allow mounting in such a way that file
|
|
Packit |
7cfc04 |
and/or directory accesses do not cause an update of the atime timestamp.
|
|
Packit |
7cfc04 |
(See
|
|
Packit |
7cfc04 |
.IR noatime ,
|
|
Packit |
7cfc04 |
.IR nodiratime ,
|
|
Packit |
7cfc04 |
and
|
|
Packit |
7cfc04 |
.I relatime
|
|
Packit |
7cfc04 |
in
|
|
Packit |
7cfc04 |
.BR mount (8),
|
|
Packit |
7cfc04 |
and related information in
|
|
Packit |
7cfc04 |
.BR mount (2).)
|
|
Packit |
7cfc04 |
In addition, the atime timestamp
|
|
Packit |
7cfc04 |
is not updated if a file is opened with the
|
|
Packit |
7cfc04 |
.BR O_NOATIME
|
|
Packit |
7cfc04 |
flag; see
|
|
Packit |
7cfc04 |
.BR open (2).
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
File creation (birth) timestamp (btime)
|
|
Packit |
7cfc04 |
(not returned in the \fIstat\fP structure); \fIstatx.stx_btime\fP
|
|
Packit |
7cfc04 |
.IP
|
|
Packit |
7cfc04 |
The file's creation timestamp.
|
|
Packit |
7cfc04 |
This is set on file creation and not changed subsequently.
|
|
Packit |
7cfc04 |
.IP
|
|
Packit |
7cfc04 |
The btime timestamp was not historically present on UNIX systems
|
|
Packit |
7cfc04 |
and is not currently supported by most Linux filesystems.
|
|
Packit |
7cfc04 |
.\" FIXME Is it supported on ext4 and XFS?
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
Last modification timestamp (mtime)
|
|
Packit |
7cfc04 |
\fIstat.st_atime\fP; \fIstatx.stx_mtime\fP
|
|
Packit |
7cfc04 |
.IP
|
|
Packit |
7cfc04 |
This is the file's last modification timestamp.
|
|
Packit |
7cfc04 |
It is changed by file modifications, for example, by
|
|
Packit |
7cfc04 |
.BR mknod (2),
|
|
Packit |
7cfc04 |
.BR truncate (2),
|
|
Packit |
7cfc04 |
.BR utime (2),
|
|
Packit |
7cfc04 |
and
|
|
Packit |
7cfc04 |
.BR write (2)
|
|
Packit |
7cfc04 |
(of more than zero bytes).
|
|
Packit |
7cfc04 |
Moreover, the mtime timestamp
|
|
Packit |
7cfc04 |
of a directory is changed by the creation or deletion of files
|
|
Packit |
7cfc04 |
in that directory.
|
|
Packit |
7cfc04 |
The mtime timestamp is
|
|
Packit |
7cfc04 |
.I not
|
|
Packit |
7cfc04 |
changed for changes in owner, group, hard link count, or mode.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
Last status change timestamp (ctime)
|
|
Packit |
7cfc04 |
\fIstat.st_ctime\fP; \fIstatx.stx_ctime\fP
|
|
Packit |
7cfc04 |
.IP
|
|
Packit |
7cfc04 |
This is the file's last status change timestamp.
|
|
Packit |
7cfc04 |
It is changed by writing or by setting inode information
|
|
Packit |
7cfc04 |
(i.e., owner, group, link count, mode, etc.).
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
Nanosecond timestamps are supported on XFS, JFS, Btrfs, and
|
|
Packit |
7cfc04 |
ext4 (since Linux 2.6.23).
|
|
Packit |
7cfc04 |
.\" commit ef7f38359ea8b3e9c7f2cae9a4d4935f55ca9e80
|
|
Packit |
7cfc04 |
Nanosecond timestamps are not supported in ext2, ext3, and Reiserfs.
|
|
Packit |
7cfc04 |
On filesystems that do not support subsecond timestamps,
|
|
Packit |
7cfc04 |
the nanosecond fields in the
|
|
Packit |
7cfc04 |
.I stat
|
|
Packit |
7cfc04 |
and
|
|
Packit |
7cfc04 |
.I statx
|
|
Packit |
7cfc04 |
structures are returned with the value 0.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.SS The file type and mode
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
.I stat.st_mode
|
|
Packit |
7cfc04 |
field (for
|
|
Packit |
7cfc04 |
.BR statx (2),
|
|
Packit |
7cfc04 |
the
|
|
Packit |
7cfc04 |
.I statx.stx_mode
|
|
Packit |
7cfc04 |
field) contains the file type and mode.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
POSIX refers to the
|
|
Packit |
7cfc04 |
.I stat.st_mode
|
|
Packit |
7cfc04 |
bits corresponding to the mask
|
|
Packit |
7cfc04 |
.B S_IFMT
|
|
Packit |
7cfc04 |
(see below) as the
|
|
Packit |
7cfc04 |
.IR "file type" ,
|
|
Packit |
7cfc04 |
the 12 bits corresponding to the mask 07777 as the
|
|
Packit |
7cfc04 |
.IR "file mode bits"
|
|
Packit |
7cfc04 |
and the least significant 9 bits (0777) as the
|
|
Packit |
7cfc04 |
.IR "file permission bits" .
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The following mask values are defined for the file type:
|
|
Packit |
7cfc04 |
.in +4n
|
|
Packit |
7cfc04 |
.TS
|
|
Packit |
7cfc04 |
lB l l.
|
|
Packit |
7cfc04 |
S_IFMT 0170000 bit mask for the file type bit field
|
|
Packit |
7cfc04 |
|
|
Packit |
7cfc04 |
S_IFSOCK 0140000 socket
|
|
Packit |
7cfc04 |
S_IFLNK 0120000 symbolic link
|
|
Packit |
7cfc04 |
S_IFREG 0100000 regular file
|
|
Packit |
7cfc04 |
S_IFBLK 0060000 block device
|
|
Packit |
7cfc04 |
S_IFDIR 0040000 directory
|
|
Packit |
7cfc04 |
S_IFCHR 0020000 character device
|
|
Packit |
7cfc04 |
S_IFIFO 0010000 FIFO
|
|
Packit |
7cfc04 |
.TE
|
|
Packit |
7cfc04 |
.in
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
Thus, to test for a regular file (for example), one could write:
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.in +4n
|
|
Packit |
7cfc04 |
.EX
|
|
Packit |
7cfc04 |
stat(pathname, &sb);
|
|
Packit |
7cfc04 |
if ((sb.st_mode & S_IFMT) == S_IFREG) {
|
|
Packit |
7cfc04 |
/* Handle regular file */
|
|
Packit |
7cfc04 |
}
|
|
Packit |
7cfc04 |
.EE
|
|
Packit |
7cfc04 |
.in
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
Because tests of the above form are common, additional
|
|
Packit |
7cfc04 |
macros are defined by POSIX to allow the test of the file type in
|
|
Packit |
7cfc04 |
.I st_mode
|
|
Packit |
7cfc04 |
to be written more concisely:
|
|
Packit |
7cfc04 |
.RS 4
|
|
Packit |
7cfc04 |
.TP 1.2i
|
|
Packit |
7cfc04 |
.BR S_ISREG (m)
|
|
Packit |
7cfc04 |
is it a regular file?
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR S_ISDIR (m)
|
|
Packit |
7cfc04 |
directory?
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR S_ISCHR (m)
|
|
Packit |
7cfc04 |
character device?
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR S_ISBLK (m)
|
|
Packit |
7cfc04 |
block device?
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR S_ISFIFO (m)
|
|
Packit |
7cfc04 |
FIFO (named pipe)?
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR S_ISLNK (m)
|
|
Packit |
7cfc04 |
symbolic link? (Not in POSIX.1-1996.)
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR S_ISSOCK (m)
|
|
Packit |
7cfc04 |
socket? (Not in POSIX.1-1996.)
|
|
Packit |
7cfc04 |
.RE
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The preceding code snippet could thus be rewritten as:
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.in +4n
|
|
Packit |
7cfc04 |
.EX
|
|
Packit |
7cfc04 |
stat(pathname, &sb);
|
|
Packit |
7cfc04 |
if (S_ISREG(sb.st_mode)) {
|
|
Packit |
7cfc04 |
/* Handle regular file */
|
|
Packit |
7cfc04 |
}
|
|
Packit |
7cfc04 |
.EE
|
|
Packit |
7cfc04 |
.in
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The definitions of most of the above file type test macros
|
|
Packit |
7cfc04 |
are provided if any of the following feature test macros is defined:
|
|
Packit |
7cfc04 |
.BR _BSD_SOURCE
|
|
Packit |
7cfc04 |
(in glibc 2.19 and earlier),
|
|
Packit |
7cfc04 |
.BR _SVID_SOURCE
|
|
Packit |
7cfc04 |
(in glibc 2.19 and earlier),
|
|
Packit |
7cfc04 |
or
|
|
Packit |
7cfc04 |
.BR _DEFAULT_SOURCE
|
|
Packit |
7cfc04 |
(in glibc 2.20 and later).
|
|
Packit |
7cfc04 |
In addition, definitions of all of the above macros except
|
|
Packit |
7cfc04 |
.BR S_IFSOCK
|
|
Packit |
7cfc04 |
and
|
|
Packit |
7cfc04 |
.BR S_ISSOCK ()
|
|
Packit |
7cfc04 |
are provided if
|
|
Packit |
7cfc04 |
.BR _XOPEN_SOURCE
|
|
Packit |
7cfc04 |
is defined.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The definition of
|
|
Packit |
7cfc04 |
.BR S_IFSOCK
|
|
Packit |
7cfc04 |
can also be exposed either by defining
|
|
Packit |
7cfc04 |
.BR _XOPEN_SOURCE
|
|
Packit |
7cfc04 |
with a value of 500 or greater or (since glibc 2.24) by defining both
|
|
Packit |
7cfc04 |
.BR _XOPEN_SOURCE
|
|
Packit |
7cfc04 |
and
|
|
Packit |
7cfc04 |
.BR _XOPEN_SOURCE_EXTENDED .
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The definition of
|
|
Packit |
7cfc04 |
.BR S_ISSOCK ()
|
|
Packit |
7cfc04 |
is exposed if any of the following feature test macros is defined:
|
|
Packit |
7cfc04 |
.BR _BSD_SOURCE
|
|
Packit |
7cfc04 |
(in glibc 2.19 and earlier),
|
|
Packit |
7cfc04 |
.BR _DEFAULT_SOURCE
|
|
Packit |
7cfc04 |
(in glibc 2.20 and later),
|
|
Packit |
7cfc04 |
.BR _XOPEN_SOURCE
|
|
Packit |
7cfc04 |
with a value of 500 or greater,
|
|
Packit |
7cfc04 |
.BR _POSIX_C_SOURCE
|
|
Packit |
7cfc04 |
with a value of 200112L or greater, or (since glibc 2.24) by defining both
|
|
Packit |
7cfc04 |
.BR _XOPEN_SOURCE
|
|
Packit |
7cfc04 |
and
|
|
Packit |
7cfc04 |
.BR _XOPEN_SOURCE_EXTENDED .
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The following mask values are defined for
|
|
Packit |
7cfc04 |
the file mode component of the
|
|
Packit |
7cfc04 |
.I st_mode
|
|
Packit |
7cfc04 |
field:
|
|
Packit |
7cfc04 |
.in +4n
|
|
Packit |
7cfc04 |
.TS
|
|
Packit |
7cfc04 |
lB l l.
|
|
Packit |
7cfc04 |
S_ISUID 04000 set-user-ID bit
|
|
Packit |
7cfc04 |
S_ISGID 02000 set-group-ID bit (see below)
|
|
Packit |
7cfc04 |
S_ISVTX 01000 sticky bit (see below)
|
|
Packit |
7cfc04 |
|
|
Packit |
7cfc04 |
S_IRWXU 00700 owner has read, write, and execute permission
|
|
Packit |
7cfc04 |
S_IRUSR 00400 owner has read permission
|
|
Packit |
7cfc04 |
S_IWUSR 00200 owner has write permission
|
|
Packit |
7cfc04 |
S_IXUSR 00100 owner has execute permission
|
|
Packit |
7cfc04 |
|
|
Packit |
7cfc04 |
S_IRWXG 00070 group has read, write, and execute permission
|
|
Packit |
7cfc04 |
S_IRGRP 00040 group has read permission
|
|
Packit |
7cfc04 |
S_IWGRP 00020 group has write permission
|
|
Packit |
7cfc04 |
S_IXGRP 00010 group has execute permission
|
|
Packit |
7cfc04 |
|
|
Packit |
7cfc04 |
S_IRWXO 00007 T{
|
|
Packit |
7cfc04 |
others (not in group) have read, write, and execute permission
|
|
Packit |
7cfc04 |
T}
|
|
Packit |
7cfc04 |
S_IROTH 00004 others have read permission
|
|
Packit |
7cfc04 |
S_IWOTH 00002 others have write permission
|
|
Packit |
7cfc04 |
S_IXOTH 00001 others have execute permission
|
|
Packit |
7cfc04 |
.TE
|
|
Packit |
7cfc04 |
.in
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The set-group-ID bit
|
|
Packit |
7cfc04 |
.RB ( S_ISGID )
|
|
Packit |
7cfc04 |
has several special uses.
|
|
Packit |
7cfc04 |
For a directory, it indicates that BSD semantics is to be used
|
|
Packit |
7cfc04 |
for that directory: files created there inherit their group ID from
|
|
Packit |
7cfc04 |
the directory, not from the effective group ID of the creating process,
|
|
Packit |
7cfc04 |
and directories created there will also get the
|
|
Packit |
7cfc04 |
.B S_ISGID
|
|
Packit |
7cfc04 |
bit set.
|
|
Packit |
7cfc04 |
For a file that does not have the group execution bit
|
|
Packit |
7cfc04 |
.RB ( S_IXGRP )
|
|
Packit |
7cfc04 |
set,
|
|
Packit |
7cfc04 |
the set-group-ID bit indicates mandatory file/record locking.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The sticky bit
|
|
Packit |
7cfc04 |
.RB ( S_ISVTX )
|
|
Packit |
7cfc04 |
on a directory means that a file
|
|
Packit |
7cfc04 |
in that directory can be renamed or deleted only by the owner
|
|
Packit |
7cfc04 |
of the file, by the owner of the directory, and by a privileged
|
|
Packit |
7cfc04 |
process.
|
|
Packit |
7cfc04 |
.SH CONFORMING TO
|
|
Packit |
7cfc04 |
If you need to obtain the definition of the
|
|
Packit |
7cfc04 |
.IR blkcnt_t
|
|
Packit |
7cfc04 |
or
|
|
Packit |
7cfc04 |
.IR blksize_t
|
|
Packit |
7cfc04 |
types from
|
|
Packit |
7cfc04 |
.IR <sys/stat.h> ,
|
|
Packit |
7cfc04 |
then define
|
|
Packit |
7cfc04 |
.BR _XOPEN_SOURCE
|
|
Packit |
7cfc04 |
with the value 500 or greater (before including
|
|
Packit |
7cfc04 |
.I any
|
|
Packit |
7cfc04 |
header files).
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
POSIX.1-1990 did not describe the
|
|
Packit |
7cfc04 |
.BR S_IFMT ,
|
|
Packit |
7cfc04 |
.BR S_IFSOCK ,
|
|
Packit |
7cfc04 |
.BR S_IFLNK ,
|
|
Packit |
7cfc04 |
.BR S_IFREG ,
|
|
Packit |
7cfc04 |
.BR S_IFBLK ,
|
|
Packit |
7cfc04 |
.BR S_IFDIR ,
|
|
Packit |
7cfc04 |
.BR S_IFCHR ,
|
|
Packit |
7cfc04 |
.BR S_IFIFO ,
|
|
Packit |
7cfc04 |
.B S_ISVTX
|
|
Packit |
7cfc04 |
constants, but instead specified the use of
|
|
Packit |
7cfc04 |
the macros
|
|
Packit |
7cfc04 |
.BR S_ISDIR (),
|
|
Packit |
7cfc04 |
and so on.
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
.BR S_IF*
|
|
Packit |
7cfc04 |
constants are present in POSIX.1-2001 and later.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
.BR S_ISLNK ()
|
|
Packit |
7cfc04 |
and
|
|
Packit |
7cfc04 |
.BR S_ISSOCK ()
|
|
Packit |
7cfc04 |
macros were not in
|
|
Packit |
7cfc04 |
POSIX.1-1996, but both are present in POSIX.1-2001;
|
|
Packit |
7cfc04 |
the former is from SVID 4, the latter from SUSv2.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
UNIX\ V7 (and later systems) had
|
|
Packit |
7cfc04 |
.BR S_IREAD ,
|
|
Packit |
7cfc04 |
.BR S_IWRITE ,
|
|
Packit |
7cfc04 |
.BR S_IEXEC ,
|
|
Packit |
7cfc04 |
where POSIX
|
|
Packit |
7cfc04 |
prescribes the synonyms
|
|
Packit |
7cfc04 |
.BR S_IRUSR ,
|
|
Packit |
7cfc04 |
.BR S_IWUSR ,
|
|
Packit |
7cfc04 |
.BR S_IXUSR .
|
|
Packit |
7cfc04 |
.SH NOTES
|
|
Packit |
7cfc04 |
For pseudofiles that are autogenerated by the kernel, the file size
|
|
Packit |
7cfc04 |
(\fIstat.st_size\fP; \fIstatx.stx_size\fP)
|
|
Packit |
7cfc04 |
reported by the kernel is not accurate.
|
|
Packit |
7cfc04 |
For example, the value 0 is returned for many files under the
|
|
Packit |
7cfc04 |
.I /proc
|
|
Packit |
7cfc04 |
directory,
|
|
Packit |
7cfc04 |
while various files under
|
|
Packit |
7cfc04 |
.IR /sys
|
|
Packit |
7cfc04 |
report a size of 4096 bytes, even though the file content is smaller.
|
|
Packit |
7cfc04 |
For such files, one should simply try to read as many bytes as possible
|
|
Packit |
7cfc04 |
(and append \(aq\e0\(aq to the returned buffer
|
|
Packit |
7cfc04 |
if it is to be interpreted as a string).
|
|
Packit |
7cfc04 |
.IR st_atimensec .
|
|
Packit |
7cfc04 |
.SH SEE ALSO
|
|
Packit |
7cfc04 |
.BR stat (1),
|
|
Packit |
7cfc04 |
.BR stat (2),
|
|
Packit |
7cfc04 |
.BR statx (2),
|
|
Packit |
7cfc04 |
.BR symlink (7)
|
|
Packit |
7cfc04 |
.SH COLOPHON
|
|
Packit |
7cfc04 |
This page is part of release 4.15 of the Linux
|
|
Packit |
7cfc04 |
.I man-pages
|
|
Packit |
7cfc04 |
project.
|
|
Packit |
7cfc04 |
A description of the project,
|
|
Packit |
7cfc04 |
information about reporting bugs,
|
|
Packit |
7cfc04 |
and the latest version of this page,
|
|
Packit |
7cfc04 |
can be found at
|
|
Packit |
7cfc04 |
\%https://www.kernel.org/doc/man\-pages/.
|