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