16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2607ca46eSDavid Howells #ifndef _UAPI_LINUX_STAT_H 3607ca46eSDavid Howells #define _UAPI_LINUX_STAT_H 4607ca46eSDavid Howells 5a528d35eSDavid Howells #include <linux/types.h> 6607ca46eSDavid Howells 7607ca46eSDavid Howells #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) 8607ca46eSDavid Howells 9607ca46eSDavid Howells #define S_IFMT 00170000 10607ca46eSDavid Howells #define S_IFSOCK 0140000 11607ca46eSDavid Howells #define S_IFLNK 0120000 12607ca46eSDavid Howells #define S_IFREG 0100000 13607ca46eSDavid Howells #define S_IFBLK 0060000 14607ca46eSDavid Howells #define S_IFDIR 0040000 15607ca46eSDavid Howells #define S_IFCHR 0020000 16607ca46eSDavid Howells #define S_IFIFO 0010000 17607ca46eSDavid Howells #define S_ISUID 0004000 18607ca46eSDavid Howells #define S_ISGID 0002000 19607ca46eSDavid Howells #define S_ISVTX 0001000 20607ca46eSDavid Howells 21607ca46eSDavid Howells #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) 22607ca46eSDavid Howells #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 23607ca46eSDavid Howells #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 24607ca46eSDavid Howells #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) 25607ca46eSDavid Howells #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) 26607ca46eSDavid Howells #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) 27607ca46eSDavid Howells #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) 28607ca46eSDavid Howells 29607ca46eSDavid Howells #define S_IRWXU 00700 30607ca46eSDavid Howells #define S_IRUSR 00400 31607ca46eSDavid Howells #define S_IWUSR 00200 32607ca46eSDavid Howells #define S_IXUSR 00100 33607ca46eSDavid Howells 34607ca46eSDavid Howells #define S_IRWXG 00070 35607ca46eSDavid Howells #define S_IRGRP 00040 36607ca46eSDavid Howells #define S_IWGRP 00020 37607ca46eSDavid Howells #define S_IXGRP 00010 38607ca46eSDavid Howells 39607ca46eSDavid Howells #define S_IRWXO 00007 40607ca46eSDavid Howells #define S_IROTH 00004 41607ca46eSDavid Howells #define S_IWOTH 00002 42607ca46eSDavid Howells #define S_IXOTH 00001 43607ca46eSDavid Howells 44607ca46eSDavid Howells #endif 45607ca46eSDavid Howells 46a528d35eSDavid Howells /* 47a528d35eSDavid Howells * Timestamp structure for the timestamps in struct statx. 48a528d35eSDavid Howells * 49a528d35eSDavid Howells * tv_sec holds the number of seconds before (negative) or after (positive) 50a528d35eSDavid Howells * 00:00:00 1st January 1970 UTC. 51a528d35eSDavid Howells * 521741937dSDmitry V. Levin * tv_nsec holds a number of nanoseconds (0..999,999,999) after the tv_sec time. 53a528d35eSDavid Howells * 54a528d35eSDavid Howells * __reserved is held in case we need a yet finer resolution. 55a528d35eSDavid Howells */ 56a528d35eSDavid Howells struct statx_timestamp { 57a528d35eSDavid Howells __s64 tv_sec; 581741937dSDmitry V. Levin __u32 tv_nsec; 59a528d35eSDavid Howells __s32 __reserved; 60a528d35eSDavid Howells }; 61a528d35eSDavid Howells 62a528d35eSDavid Howells /* 63a528d35eSDavid Howells * Structures for the extended file attribute retrieval system call 64a528d35eSDavid Howells * (statx()). 65a528d35eSDavid Howells * 66a528d35eSDavid Howells * The caller passes a mask of what they're specifically interested in as a 67a528d35eSDavid Howells * parameter to statx(). What statx() actually got will be indicated in 68a528d35eSDavid Howells * st_mask upon return. 69a528d35eSDavid Howells * 70a528d35eSDavid Howells * For each bit in the mask argument: 71a528d35eSDavid Howells * 72a528d35eSDavid Howells * - if the datum is not supported: 73a528d35eSDavid Howells * 74a528d35eSDavid Howells * - the bit will be cleared, and 75a528d35eSDavid Howells * 76a528d35eSDavid Howells * - the datum will be set to an appropriate fabricated value if one is 77a528d35eSDavid Howells * available (eg. CIFS can take a default uid and gid), otherwise 78a528d35eSDavid Howells * 79a528d35eSDavid Howells * - the field will be cleared; 80a528d35eSDavid Howells * 81a528d35eSDavid Howells * - otherwise, if explicitly requested: 82a528d35eSDavid Howells * 83a528d35eSDavid Howells * - the datum will be synchronised to the server if AT_STATX_FORCE_SYNC is 84a528d35eSDavid Howells * set or if the datum is considered out of date, and 85a528d35eSDavid Howells * 86a528d35eSDavid Howells * - the field will be filled in and the bit will be set; 87a528d35eSDavid Howells * 88a528d35eSDavid Howells * - otherwise, if not requested, but available in approximate form without any 89a528d35eSDavid Howells * effort, it will be filled in anyway, and the bit will be set upon return 90a528d35eSDavid Howells * (it might not be up to date, however, and no attempt will be made to 91a528d35eSDavid Howells * synchronise the internal state first); 92a528d35eSDavid Howells * 93a528d35eSDavid Howells * - otherwise the field and the bit will be cleared before returning. 94a528d35eSDavid Howells * 95a528d35eSDavid Howells * Items in STATX_BASIC_STATS may be marked unavailable on return, but they 96a528d35eSDavid Howells * will have values installed for compatibility purposes so that stat() and 97a528d35eSDavid Howells * co. can be emulated in userspace. 98a528d35eSDavid Howells */ 99a528d35eSDavid Howells struct statx { 100a528d35eSDavid Howells /* 0x00 */ 101a528d35eSDavid Howells __u32 stx_mask; /* What results were written [uncond] */ 102a528d35eSDavid Howells __u32 stx_blksize; /* Preferred general I/O size [uncond] */ 103a528d35eSDavid Howells __u64 stx_attributes; /* Flags conveying information about the file [uncond] */ 104a528d35eSDavid Howells /* 0x10 */ 105a528d35eSDavid Howells __u32 stx_nlink; /* Number of hard links */ 106a528d35eSDavid Howells __u32 stx_uid; /* User ID of owner */ 107a528d35eSDavid Howells __u32 stx_gid; /* Group ID of owner */ 108a528d35eSDavid Howells __u16 stx_mode; /* File mode */ 109a528d35eSDavid Howells __u16 __spare0[1]; 110a528d35eSDavid Howells /* 0x20 */ 111a528d35eSDavid Howells __u64 stx_ino; /* Inode number */ 112a528d35eSDavid Howells __u64 stx_size; /* File size */ 113a528d35eSDavid Howells __u64 stx_blocks; /* Number of 512-byte blocks allocated */ 1143209f68bSDavid Howells __u64 stx_attributes_mask; /* Mask to show what's supported in stx_attributes */ 115a528d35eSDavid Howells /* 0x40 */ 116a528d35eSDavid Howells struct statx_timestamp stx_atime; /* Last access time */ 117a528d35eSDavid Howells struct statx_timestamp stx_btime; /* File creation time */ 118a528d35eSDavid Howells struct statx_timestamp stx_ctime; /* Last attribute change time */ 119a528d35eSDavid Howells struct statx_timestamp stx_mtime; /* Last data modification time */ 120a528d35eSDavid Howells /* 0x80 */ 121a528d35eSDavid Howells __u32 stx_rdev_major; /* Device ID of special file [if bdev/cdev] */ 122a528d35eSDavid Howells __u32 stx_rdev_minor; 123a528d35eSDavid Howells __u32 stx_dev_major; /* ID of device containing file [uncond] */ 124a528d35eSDavid Howells __u32 stx_dev_minor; 125a528d35eSDavid Howells /* 0x90 */ 126fa2fcf4fSMiklos Szeredi __u64 stx_mnt_id; 127825cf206SEric Biggers __u32 stx_dio_mem_align; /* Memory buffer alignment for direct I/O */ 128825cf206SEric Biggers __u32 stx_dio_offset_align; /* File offset alignment for direct I/O */ 129*2a82bb02SKent Overstreet __u64 stx_subvol; /* Subvolume identifier */ 130fa2fcf4fSMiklos Szeredi /* 0xa0 */ 131*2a82bb02SKent Overstreet __u64 __spare3[11]; /* Spare space for future expansion */ 132a528d35eSDavid Howells /* 0x100 */ 133a528d35eSDavid Howells }; 134a528d35eSDavid Howells 135a528d35eSDavid Howells /* 136a528d35eSDavid Howells * Flags to be stx_mask 137a528d35eSDavid Howells * 138a528d35eSDavid Howells * Query request/result mask for statx() and struct statx::stx_mask. 139a528d35eSDavid Howells * 140a528d35eSDavid Howells * These bits should be set in the mask argument of statx() to request 141a528d35eSDavid Howells * particular items when calling statx(). 142a528d35eSDavid Howells */ 143a528d35eSDavid Howells #define STATX_TYPE 0x00000001U /* Want/got stx_mode & S_IFMT */ 144a528d35eSDavid Howells #define STATX_MODE 0x00000002U /* Want/got stx_mode & ~S_IFMT */ 145a528d35eSDavid Howells #define STATX_NLINK 0x00000004U /* Want/got stx_nlink */ 146a528d35eSDavid Howells #define STATX_UID 0x00000008U /* Want/got stx_uid */ 147a528d35eSDavid Howells #define STATX_GID 0x00000010U /* Want/got stx_gid */ 148a528d35eSDavid Howells #define STATX_ATIME 0x00000020U /* Want/got stx_atime */ 149a528d35eSDavid Howells #define STATX_MTIME 0x00000040U /* Want/got stx_mtime */ 150a528d35eSDavid Howells #define STATX_CTIME 0x00000080U /* Want/got stx_ctime */ 151a528d35eSDavid Howells #define STATX_INO 0x00000100U /* Want/got stx_ino */ 152a528d35eSDavid Howells #define STATX_SIZE 0x00000200U /* Want/got stx_size */ 153a528d35eSDavid Howells #define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */ 154a528d35eSDavid Howells #define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */ 155a528d35eSDavid Howells #define STATX_BTIME 0x00000800U /* Want/got stx_btime */ 156fa2fcf4fSMiklos Szeredi #define STATX_MNT_ID 0x00001000U /* Got stx_mnt_id */ 157825cf206SEric Biggers #define STATX_DIOALIGN 0x00002000U /* Want/got direct I/O alignment info */ 15898d2b430SMiklos Szeredi #define STATX_MNT_ID_UNIQUE 0x00004000U /* Want/got extended stx_mount_id */ 159*2a82bb02SKent Overstreet #define STATX_SUBVOL 0x00008000U /* Want/got stx_subvol */ 160581701b7SMiklos Szeredi 16147071aeeSDavid Howells #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ 162a528d35eSDavid Howells 163581701b7SMiklos Szeredi #ifndef __KERNEL__ 164581701b7SMiklos Szeredi /* 165581701b7SMiklos Szeredi * This is deprecated, and shall remain the same value in the future. To avoid 166581701b7SMiklos Szeredi * confusion please use the equivalent (STATX_BASIC_STATS | STATX_BTIME) 167581701b7SMiklos Szeredi * instead. 168581701b7SMiklos Szeredi */ 169581701b7SMiklos Szeredi #define STATX_ALL 0x00000fffU 170581701b7SMiklos Szeredi #endif 171581701b7SMiklos Szeredi 172a528d35eSDavid Howells /* 1733209f68bSDavid Howells * Attributes to be found in stx_attributes and masked in stx_attributes_mask. 174a528d35eSDavid Howells * 175a528d35eSDavid Howells * These give information about the features or the state of a file that might 176a528d35eSDavid Howells * be of use to ordinary userspace programs such as GUIs or ls rather than 177a528d35eSDavid Howells * specialised tools. 178a528d35eSDavid Howells * 17972d1249eSEric Sandeen * Note that the flags marked [I] correspond to the FS_IOC_SETFLAGS flags 180a528d35eSDavid Howells * semantically. Where possible, the numerical value is picked to correspond 18172d1249eSEric Sandeen * also. Note that the DAX attribute indicates that the file is in the CPU 18272d1249eSEric Sandeen * direct access state. It does not correspond to the per-inode flag that 18372d1249eSEric Sandeen * some filesystems support. 18472d1249eSEric Sandeen * 185a528d35eSDavid Howells */ 186a528d35eSDavid Howells #define STATX_ATTR_COMPRESSED 0x00000004 /* [I] File is compressed by the fs */ 187a528d35eSDavid Howells #define STATX_ATTR_IMMUTABLE 0x00000010 /* [I] File is marked immutable */ 188a528d35eSDavid Howells #define STATX_ATTR_APPEND 0x00000020 /* [I] File is append-only */ 189a528d35eSDavid Howells #define STATX_ATTR_NODUMP 0x00000040 /* [I] File is not to be dumped */ 190a528d35eSDavid Howells #define STATX_ATTR_ENCRYPTED 0x00000800 /* [I] File requires key to decrypt in fs */ 191a528d35eSDavid Howells #define STATX_ATTR_AUTOMOUNT 0x00001000 /* Dir: Automount trigger */ 19280340fe3SMiklos Szeredi #define STATX_ATTR_MOUNT_ROOT 0x00002000 /* Root of a mount */ 1933ad2522cSEric Biggers #define STATX_ATTR_VERITY 0x00100000 /* [I] Verity protected file */ 19472d1249eSEric Sandeen #define STATX_ATTR_DAX 0x00200000 /* File is currently in DAX state */ 195a528d35eSDavid Howells 196607ca46eSDavid Howells 197607ca46eSDavid Howells #endif /* _UAPI_LINUX_STAT_H */ 198