1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux 1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 #ifndef _UAPI_LINUX_STAT_H 2 #ifndef _UAPI_LINUX_STAT_H 3 #define _UAPI_LINUX_STAT_H 3 #define _UAPI_LINUX_STAT_H 4 4 5 #include <linux/types.h> 5 #include <linux/types.h> 6 6 7 #if defined(__KERNEL__) || !defined(__GLIBC__) 7 #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) 8 8 9 #define S_IFMT 00170000 9 #define S_IFMT 00170000 10 #define S_IFSOCK 0140000 10 #define S_IFSOCK 0140000 11 #define S_IFLNK 0120000 11 #define S_IFLNK 0120000 12 #define S_IFREG 0100000 12 #define S_IFREG 0100000 13 #define S_IFBLK 0060000 13 #define S_IFBLK 0060000 14 #define S_IFDIR 0040000 14 #define S_IFDIR 0040000 15 #define S_IFCHR 0020000 15 #define S_IFCHR 0020000 16 #define S_IFIFO 0010000 16 #define S_IFIFO 0010000 17 #define S_ISUID 0004000 17 #define S_ISUID 0004000 18 #define S_ISGID 0002000 18 #define S_ISGID 0002000 19 #define S_ISVTX 0001000 19 #define S_ISVTX 0001000 20 20 21 #define S_ISLNK(m) (((m) & S_IFMT) == S_I 21 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) 22 #define S_ISREG(m) (((m) & S_IFMT) == S_I 22 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 23 #define S_ISDIR(m) (((m) & S_IFMT) == S_I 23 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 24 #define S_ISCHR(m) (((m) & S_IFMT) == S_I 24 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) 25 #define S_ISBLK(m) (((m) & S_IFMT) == S_I 25 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) 26 #define S_ISFIFO(m) (((m) & S_IFMT) == S_I 26 #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) 27 #define S_ISSOCK(m) (((m) & S_IFMT) == S_I 27 #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) 28 28 29 #define S_IRWXU 00700 29 #define S_IRWXU 00700 30 #define S_IRUSR 00400 30 #define S_IRUSR 00400 31 #define S_IWUSR 00200 31 #define S_IWUSR 00200 32 #define S_IXUSR 00100 32 #define S_IXUSR 00100 33 33 34 #define S_IRWXG 00070 34 #define S_IRWXG 00070 35 #define S_IRGRP 00040 35 #define S_IRGRP 00040 36 #define S_IWGRP 00020 36 #define S_IWGRP 00020 37 #define S_IXGRP 00010 37 #define S_IXGRP 00010 38 38 39 #define S_IRWXO 00007 39 #define S_IRWXO 00007 40 #define S_IROTH 00004 40 #define S_IROTH 00004 41 #define S_IWOTH 00002 41 #define S_IWOTH 00002 42 #define S_IXOTH 00001 42 #define S_IXOTH 00001 43 43 44 #endif 44 #endif 45 45 46 /* 46 /* 47 * Timestamp structure for the timestamps in s 47 * Timestamp structure for the timestamps in struct statx. 48 * 48 * 49 * tv_sec holds the number of seconds before ( 49 * tv_sec holds the number of seconds before (negative) or after (positive) 50 * 00:00:00 1st January 1970 UTC. 50 * 00:00:00 1st January 1970 UTC. 51 * 51 * 52 * tv_nsec holds a number of nanoseconds (0..9 52 * tv_nsec holds a number of nanoseconds (0..999,999,999) after the tv_sec time. 53 * 53 * 54 * __reserved is held in case we need a yet fi 54 * __reserved is held in case we need a yet finer resolution. 55 */ 55 */ 56 struct statx_timestamp { 56 struct statx_timestamp { 57 __s64 tv_sec; 57 __s64 tv_sec; 58 __u32 tv_nsec; 58 __u32 tv_nsec; 59 __s32 __reserved; 59 __s32 __reserved; 60 }; 60 }; 61 61 62 /* 62 /* 63 * Structures for the extended file attribute 63 * Structures for the extended file attribute retrieval system call 64 * (statx()). 64 * (statx()). 65 * 65 * 66 * The caller passes a mask of what they're sp 66 * The caller passes a mask of what they're specifically interested in as a 67 * parameter to statx(). What statx() actuall 67 * parameter to statx(). What statx() actually got will be indicated in 68 * st_mask upon return. 68 * st_mask upon return. 69 * 69 * 70 * For each bit in the mask argument: 70 * For each bit in the mask argument: 71 * 71 * 72 * - if the datum is not supported: 72 * - if the datum is not supported: 73 * 73 * 74 * - the bit will be cleared, and 74 * - the bit will be cleared, and 75 * 75 * 76 * - the datum will be set to an appropriate 76 * - the datum will be set to an appropriate fabricated value if one is 77 * available (eg. CIFS can take a default 77 * available (eg. CIFS can take a default uid and gid), otherwise 78 * 78 * 79 * - the field will be cleared; 79 * - the field will be cleared; 80 * 80 * 81 * - otherwise, if explicitly requested: 81 * - otherwise, if explicitly requested: 82 * 82 * 83 * - the datum will be synchronised to the s 83 * - the datum will be synchronised to the server if AT_STATX_FORCE_SYNC is 84 * set or if the datum is considered out o 84 * set or if the datum is considered out of date, and 85 * 85 * 86 * - the field will be filled in and the bit 86 * - the field will be filled in and the bit will be set; 87 * 87 * 88 * - otherwise, if not requested, but availabl 88 * - otherwise, if not requested, but available in approximate form without any 89 * effort, it will be filled in anyway, and 89 * effort, it will be filled in anyway, and the bit will be set upon return 90 * (it might not be up to date, however, and 90 * (it might not be up to date, however, and no attempt will be made to 91 * synchronise the internal state first); 91 * synchronise the internal state first); 92 * 92 * 93 * - otherwise the field and the bit will be c 93 * - otherwise the field and the bit will be cleared before returning. 94 * 94 * 95 * Items in STATX_BASIC_STATS may be marked un 95 * Items in STATX_BASIC_STATS may be marked unavailable on return, but they 96 * will have values installed for compatibilit 96 * will have values installed for compatibility purposes so that stat() and 97 * co. can be emulated in userspace. 97 * co. can be emulated in userspace. 98 */ 98 */ 99 struct statx { 99 struct statx { 100 /* 0x00 */ 100 /* 0x00 */ 101 __u32 stx_mask; /* What result 101 __u32 stx_mask; /* What results were written [uncond] */ 102 __u32 stx_blksize; /* Preferred g 102 __u32 stx_blksize; /* Preferred general I/O size [uncond] */ 103 __u64 stx_attributes; /* Flags conve 103 __u64 stx_attributes; /* Flags conveying information about the file [uncond] */ 104 /* 0x10 */ 104 /* 0x10 */ 105 __u32 stx_nlink; /* Number of h 105 __u32 stx_nlink; /* Number of hard links */ 106 __u32 stx_uid; /* User ID of 106 __u32 stx_uid; /* User ID of owner */ 107 __u32 stx_gid; /* Group ID of 107 __u32 stx_gid; /* Group ID of owner */ 108 __u16 stx_mode; /* File mode * 108 __u16 stx_mode; /* File mode */ 109 __u16 __spare0[1]; 109 __u16 __spare0[1]; 110 /* 0x20 */ 110 /* 0x20 */ 111 __u64 stx_ino; /* Inode numbe 111 __u64 stx_ino; /* Inode number */ 112 __u64 stx_size; /* File size * 112 __u64 stx_size; /* File size */ 113 __u64 stx_blocks; /* Number of 5 113 __u64 stx_blocks; /* Number of 512-byte blocks allocated */ 114 __u64 stx_attributes_mask; /* Mask t 114 __u64 stx_attributes_mask; /* Mask to show what's supported in stx_attributes */ 115 /* 0x40 */ 115 /* 0x40 */ 116 struct statx_timestamp stx_atime; 116 struct statx_timestamp stx_atime; /* Last access time */ 117 struct statx_timestamp stx_btime; 117 struct statx_timestamp stx_btime; /* File creation time */ 118 struct statx_timestamp stx_ctime; 118 struct statx_timestamp stx_ctime; /* Last attribute change time */ 119 struct statx_timestamp stx_mtime; 119 struct statx_timestamp stx_mtime; /* Last data modification time */ 120 /* 0x80 */ 120 /* 0x80 */ 121 __u32 stx_rdev_major; /* Device ID o 121 __u32 stx_rdev_major; /* Device ID of special file [if bdev/cdev] */ 122 __u32 stx_rdev_minor; 122 __u32 stx_rdev_minor; 123 __u32 stx_dev_major; /* ID of devic 123 __u32 stx_dev_major; /* ID of device containing file [uncond] */ 124 __u32 stx_dev_minor; 124 __u32 stx_dev_minor; 125 /* 0x90 */ 125 /* 0x90 */ 126 __u64 stx_mnt_id; 126 __u64 stx_mnt_id; 127 __u32 stx_dio_mem_align; /* Mem 127 __u32 stx_dio_mem_align; /* Memory buffer alignment for direct I/O */ 128 __u32 stx_dio_offset_align; /* Fil 128 __u32 stx_dio_offset_align; /* File offset alignment for direct I/O */ 129 /* 0xa0 */ 129 /* 0xa0 */ 130 __u64 stx_subvol; /* Subvolume i 130 __u64 stx_subvol; /* Subvolume identifier */ 131 __u32 stx_atomic_write_unit_min; 131 __u32 stx_atomic_write_unit_min; /* Min atomic write unit in bytes */ 132 __u32 stx_atomic_write_unit_max; 132 __u32 stx_atomic_write_unit_max; /* Max atomic write unit in bytes */ 133 /* 0xb0 */ 133 /* 0xb0 */ 134 __u32 stx_atomic_write_segments_max; 134 __u32 stx_atomic_write_segments_max; /* Max atomic write segment count */ 135 __u32 __spare1[1]; 135 __u32 __spare1[1]; 136 /* 0xb8 */ 136 /* 0xb8 */ 137 __u64 __spare3[9]; /* Spare space 137 __u64 __spare3[9]; /* Spare space for future expansion */ 138 /* 0x100 */ 138 /* 0x100 */ 139 }; 139 }; 140 140 141 /* 141 /* 142 * Flags to be stx_mask 142 * Flags to be stx_mask 143 * 143 * 144 * Query request/result mask for statx() and s 144 * Query request/result mask for statx() and struct statx::stx_mask. 145 * 145 * 146 * These bits should be set in the mask argume 146 * These bits should be set in the mask argument of statx() to request 147 * particular items when calling statx(). 147 * particular items when calling statx(). 148 */ 148 */ 149 #define STATX_TYPE 0x00000001U 149 #define STATX_TYPE 0x00000001U /* Want/got stx_mode & S_IFMT */ 150 #define STATX_MODE 0x00000002U 150 #define STATX_MODE 0x00000002U /* Want/got stx_mode & ~S_IFMT */ 151 #define STATX_NLINK 0x00000004U 151 #define STATX_NLINK 0x00000004U /* Want/got stx_nlink */ 152 #define STATX_UID 0x00000008U 152 #define STATX_UID 0x00000008U /* Want/got stx_uid */ 153 #define STATX_GID 0x00000010U 153 #define STATX_GID 0x00000010U /* Want/got stx_gid */ 154 #define STATX_ATIME 0x00000020U 154 #define STATX_ATIME 0x00000020U /* Want/got stx_atime */ 155 #define STATX_MTIME 0x00000040U 155 #define STATX_MTIME 0x00000040U /* Want/got stx_mtime */ 156 #define STATX_CTIME 0x00000080U 156 #define STATX_CTIME 0x00000080U /* Want/got stx_ctime */ 157 #define STATX_INO 0x00000100U 157 #define STATX_INO 0x00000100U /* Want/got stx_ino */ 158 #define STATX_SIZE 0x00000200U 158 #define STATX_SIZE 0x00000200U /* Want/got stx_size */ 159 #define STATX_BLOCKS 0x00000400U 159 #define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */ 160 #define STATX_BASIC_STATS 0x000007ffU 160 #define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */ 161 #define STATX_BTIME 0x00000800U 161 #define STATX_BTIME 0x00000800U /* Want/got stx_btime */ 162 #define STATX_MNT_ID 0x00001000U 162 #define STATX_MNT_ID 0x00001000U /* Got stx_mnt_id */ 163 #define STATX_DIOALIGN 0x00002000U 163 #define STATX_DIOALIGN 0x00002000U /* Want/got direct I/O alignment info */ 164 #define STATX_MNT_ID_UNIQUE 0x00004000U 164 #define STATX_MNT_ID_UNIQUE 0x00004000U /* Want/got extended stx_mount_id */ 165 #define STATX_SUBVOL 0x00008000U 165 #define STATX_SUBVOL 0x00008000U /* Want/got stx_subvol */ 166 #define STATX_WRITE_ATOMIC 0x00010000U 166 #define STATX_WRITE_ATOMIC 0x00010000U /* Want/got atomic_write_* fields */ 167 167 168 #define STATX__RESERVED 0x80000000U 168 #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ 169 169 170 #ifndef __KERNEL__ 170 #ifndef __KERNEL__ 171 /* 171 /* 172 * This is deprecated, and shall remain the sa 172 * This is deprecated, and shall remain the same value in the future. To avoid 173 * confusion please use the equivalent (STATX_ 173 * confusion please use the equivalent (STATX_BASIC_STATS | STATX_BTIME) 174 * instead. 174 * instead. 175 */ 175 */ 176 #define STATX_ALL 0x00000fffU 176 #define STATX_ALL 0x00000fffU 177 #endif 177 #endif 178 178 179 /* 179 /* 180 * Attributes to be found in stx_attributes an 180 * Attributes to be found in stx_attributes and masked in stx_attributes_mask. 181 * 181 * 182 * These give information about the features o 182 * These give information about the features or the state of a file that might 183 * be of use to ordinary userspace programs su 183 * be of use to ordinary userspace programs such as GUIs or ls rather than 184 * specialised tools. 184 * specialised tools. 185 * 185 * 186 * Note that the flags marked [I] correspond t 186 * Note that the flags marked [I] correspond to the FS_IOC_SETFLAGS flags 187 * semantically. Where possible, the numerica 187 * semantically. Where possible, the numerical value is picked to correspond 188 * also. Note that the DAX attribute indicate 188 * also. Note that the DAX attribute indicates that the file is in the CPU 189 * direct access state. It does not correspon 189 * direct access state. It does not correspond to the per-inode flag that 190 * some filesystems support. 190 * some filesystems support. 191 * 191 * 192 */ 192 */ 193 #define STATX_ATTR_COMPRESSED 0x0000 193 #define STATX_ATTR_COMPRESSED 0x00000004 /* [I] File is compressed by the fs */ 194 #define STATX_ATTR_IMMUTABLE 0x0000 194 #define STATX_ATTR_IMMUTABLE 0x00000010 /* [I] File is marked immutable */ 195 #define STATX_ATTR_APPEND 0x0000 195 #define STATX_ATTR_APPEND 0x00000020 /* [I] File is append-only */ 196 #define STATX_ATTR_NODUMP 0x0000 196 #define STATX_ATTR_NODUMP 0x00000040 /* [I] File is not to be dumped */ 197 #define STATX_ATTR_ENCRYPTED 0x0000 197 #define STATX_ATTR_ENCRYPTED 0x00000800 /* [I] File requires key to decrypt in fs */ 198 #define STATX_ATTR_AUTOMOUNT 0x0000 198 #define STATX_ATTR_AUTOMOUNT 0x00001000 /* Dir: Automount trigger */ 199 #define STATX_ATTR_MOUNT_ROOT 0x0000 199 #define STATX_ATTR_MOUNT_ROOT 0x00002000 /* Root of a mount */ 200 #define STATX_ATTR_VERITY 0x0010 200 #define STATX_ATTR_VERITY 0x00100000 /* [I] Verity protected file */ 201 #define STATX_ATTR_DAX 0x0020 201 #define STATX_ATTR_DAX 0x00200000 /* File is currently in DAX state */ 202 #define STATX_ATTR_WRITE_ATOMIC 0x0040 202 #define STATX_ATTR_WRITE_ATOMIC 0x00400000 /* File supports atomic write operations */ 203 203 204 204 205 #endif /* _UAPI_LINUX_STAT_H */ 205 #endif /* _UAPI_LINUX_STAT_H */ 206 206
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.