inode(7) Miscellaneous Information Manual inode(7) inode - (inode), . stat(2) ( ), stat, statx(2), statx. , , , , stat(2) statx(2): , stat.st_dev; statx.stx_dev_minor statx.stx_dev_major ( ) , . ( ) ( ) . stat.st_ino; statx.stx_ino . (. ., , - ). . stat.st_mode; statx.stx_mode . stat.st_nlink; statx.stx_nlink . link(2). stat.st_uid; statx.stx_uid , . . chown(2). stat.st_gid; statx.stx_gid , . , set-group-ID ( ). chown(2). , stat.st_rdev; statx.stx_rdev_minor statx.stx_rdev_major () , . stat.st_size; statx.stx_size ( ) . , , . / stat.st_blksize; statx.stx_blksize <<>> / ( // ). , stat.st_blocks; statx.stx_blocks ( 512 ), ( , st_size/512, (holes)). POSIX.1 , st_blocks stat . 512 ; -- 1024. , . (atime) stat.st_atime; statx.stx_atime . , , execve(2), mknod(2), pipe(2), utime(2) read(2) ( ). , mmap(2), , . , atime ( noatime, nodiratime relatime mount(8) mount(2)). , atime , O_NOATIME; open(2). (btime) ( stat); statx.stx_btime . . btime UNIX Linux. (mtime) stat.st_mtime; statx.stx_mtime . , , mknod(2), truncate(2), utime(2) write(2) ( ). , mtime . mtime , , . (ctime) stat.st_ctime; statx.stx_ctime . (. ., , , , . .). The timestamp fields report time measured with a zero point at the Epoch, 1970-01-01 00:00:00 +0000, UTC (see time(7)). XFS, JFS, Btrfs ext4 ( Linux 2.6.23). ext2, ext3 Reiserfs. stat statx , . stat(2) statx(2). , , stat statx 0. stat.st_mode ( statx(2) -- statx.stx_mode ) . POSIX stat.st_mode S_IFMT ( ) (file type), 12 , 07777, (file mode bits) 9 (0777) (file permission bits). : S_IFMT 0170000 S_IFSOCK 0140000 socket S_IFLNK 0120000 S_IFREG 0100000 S_IFBLK 0060000 S_IFDIR 0040000 S_IFCHR 0020000 S_IFIFO 0010000 FIFO , () : stat(pathname, &sb); if ((sb.st_mode & S_IFMT) == S_IFREG) { /* */ } , POSIX , st_mode : S_ISREG(m) ? S_ISDIR(m) ? S_ISCHR(m) ? S_ISBLK(m) ? S_ISFIFO(m) FIFO ( )? S_ISLNK(m) ? ( POSIX.1-1996.) S_ISSOCK(m) ? ( POSIX.1-1996.) The preceding code snippet could thus be rewritten as: stat(pathname, &sb); if (S_ISREG(sb.st_mode)) { /* */ } , : _BSD_SOURCE ( glibc 2.19 ), _SVID_SOURCE ( glibc 2.19 ) _DEFAULT_SOURCE ( glibc 2.20 ). , , S_IFSOCK S_ISSOCK(), _XOPEN_SOURCE. S_IFSOCK _XOPEN_SOURCE 500 ( glibc 2.24) _XOPEN_SOURCE _XOPEN_SOURCE_EXTENDED . S_ISSOCK() , : _BSD_SOURCE ( glibc 2.19 ), _DEFAULT_SOURCE ( glibc 2.20 ), _XOPEN_SOURCE 500 _POSIX_C_SOURCE 200112L ( glibc 2.24) _XOPEN_SOURCE _XOPEN_SOURCE_EXTENDED . st_mode: S_ISUID 04000 set-user-ID ( execve(2)) S_ISGID 02000 set-group-ID ( ) S_ISVTX 01000 ( ) S_IRWXU 00700 , S_IRUSR 00400 S_IWUSR 00200 S_IXUSR 00100 S_IRWXG 00070 , S_IRGRP 00040 S_IWGRP 00020 S_IXGRP 00010 S_IRWXO 00007 ( ) , S_IROTH 00004 S_IWOTH 00002 S_IXOTH 00001 set-group-ID (S_ISGID) . , BSD: , , ID , ID , S_ISGID. set-group-ID ID , , , execve(2). (S_IXGRP), set-group-ID (mandatory) /. (sticky) (S_ISVTX) , , . POSIX.1-2008. POSIX.1-2001. POSIX.1-1990 did not describe the S_IFMT, S_IFSOCK, S_IFLNK, S_IFREG, S_IFBLK, S_IFDIR, S_IFCHR, S_IFIFO, and S_ISVTX constants, but instead specified the use of the macros S_ISDIR() and so on. The S_ISLNK() and S_ISSOCK() macros were not in POSIX.1-1996; the former is from SVID 4, the latter from SUSv2. UNIX V7 (and later systems) had S_IREAD, S_IWRITE, S_IEXEC, and where POSIX prescribes the synonyms S_IRUSR, S_IWUSR, and S_IXUSR. For pseudofiles that are autogenerated by the kernel, the file size (stat.st_size; statx.stx_size) reported by the kernel is not accurate. For example, the value 0 is returned for many files under the /proc directory, while various files under /sys report a size of 4096 bytes, even though the file content is smaller. For such files, one should simply try to read as many bytes as possible (and append '\0' to the returned buffer if it is to be interpreted as a string). . stat(1), stat(2), statx(2), symlink(7) Azamat Hackimov , Dmitriy S. Seregin , Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . inode(7)