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