stat.h 5.9 KB

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