1
0

stat.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. #ifndef _SYS_STAT_H
  2. #define _SYS_STAT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <features.h>
  7. #define __NEED_dev_t
  8. #define __NEED_ino_t
  9. #define __NEED_mode_t
  10. #define __NEED_nlink_t
  11. #define __NEED_uid_t
  12. #define __NEED_gid_t
  13. #define __NEED_off_t
  14. #define __NEED_time_t
  15. #define __NEED_blksize_t
  16. #define __NEED_blkcnt_t
  17. #define __NEED_struct_timespec
  18. #ifdef _GNU_SOURCE
  19. #define __NEED_int64_t
  20. #define __NEED_uint64_t
  21. #define __NEED_uint32_t
  22. #define __NEED_uint16_t
  23. #endif
  24. #include <bits/alltypes.h>
  25. #include <bits/stat.h>
  26. #define st_atime st_atim.tv_sec
  27. #define st_mtime st_mtim.tv_sec
  28. #define st_ctime st_ctim.tv_sec
  29. #define S_IFMT 0170000
  30. #define S_IFDIR 0040000
  31. #define S_IFCHR 0020000
  32. #define S_IFBLK 0060000
  33. #define S_IFREG 0100000
  34. #define S_IFIFO 0010000
  35. #define S_IFLNK 0120000
  36. #define S_IFSOCK 0140000
  37. #define S_TYPEISMQ(buf) 0
  38. #define S_TYPEISSEM(buf) 0
  39. #define S_TYPEISSHM(buf) 0
  40. #define S_TYPEISTMO(buf) 0
  41. #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
  42. #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
  43. #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
  44. #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
  45. #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
  46. #define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
  47. #define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
  48. #ifndef S_IRUSR
  49. #define S_ISUID 04000
  50. #define S_ISGID 02000
  51. #define S_ISVTX 01000
  52. #define S_IRUSR 0400
  53. #define S_IWUSR 0200
  54. #define S_IXUSR 0100
  55. #define S_IRWXU 0700
  56. #define S_IRGRP 0040
  57. #define S_IWGRP 0020
  58. #define S_IXGRP 0010
  59. #define S_IRWXG 0070
  60. #define S_IROTH 0004
  61. #define S_IWOTH 0002
  62. #define S_IXOTH 0001
  63. #define S_IRWXO 0007
  64. #endif
  65. #define UTIME_NOW 0x3fffffff
  66. #define UTIME_OMIT 0x3ffffffe
  67. int stat(const char *__restrict, struct stat *__restrict);
  68. int fstat(int, struct stat *);
  69. int lstat(const char *__restrict, struct stat *__restrict);
  70. int fstatat(int, const char *__restrict, struct stat *__restrict, int);
  71. int chmod(const char *, mode_t);
  72. int fchmod(int, mode_t);
  73. int fchmodat(int, const char *, mode_t, int);
  74. mode_t umask(mode_t);
  75. int mkdir(const char *, mode_t);
  76. int mkfifo(const char *, mode_t);
  77. int mkdirat(int, const char *, mode_t);
  78. int mkfifoat(int, const char *, mode_t);
  79. #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  80. int mknod(const char *, mode_t, dev_t);
  81. int mknodat(int, const char *, mode_t, dev_t);
  82. #endif
  83. int futimens(int, const struct timespec [2]);
  84. int utimensat(int, const char *, const struct timespec [2], int);
  85. #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  86. int lchmod(const char *, mode_t);
  87. #define S_IREAD S_IRUSR
  88. #define S_IWRITE S_IWUSR
  89. #define S_IEXEC S_IXUSR
  90. #endif
  91. #if defined(_GNU_SOURCE)
  92. #define STATX_TYPE 1U
  93. #define STATX_MODE 2U
  94. #define STATX_NLINK 4U
  95. #define STATX_UID 8U
  96. #define STATX_GID 0x10U
  97. #define STATX_ATIME 0x20U
  98. #define STATX_MTIME 0x40U
  99. #define STATX_CTIME 0x80U
  100. #define STATX_INO 0x100U
  101. #define STATX_SIZE 0x200U
  102. #define STATX_BLOCKS 0x400U
  103. #define STATX_BASIC_STATS 0x7ffU
  104. #define STATX_BTIME 0x800U
  105. #define STATX_ALL 0xfffU
  106. #define STATX_MNT_ID 0x1000U
  107. #define STATX_DIOALIGN 0x2000U
  108. #define STATX_MNT_ID_UNIQUE 0x4000U
  109. #define STATX_ATTR_COMPRESSED 0x4
  110. #define STATX_ATTR_IMMUTABLE 0x10
  111. #define STATX_ATTR_APPEND 0x20
  112. #define STATX_ATTR_NODUMP 0x40
  113. #define STATX_ATTR_ENCRYPTED 0x800
  114. #define STATX_ATTR_AUTOMOUNT 0x1000
  115. #define STATX_ATTR_MOUNT_ROOT 0x2000
  116. #define STATX_ATTR_VERITY 0x100000
  117. #define STATX_ATTR_DAX 0x200000
  118. struct statx_timestamp {
  119. int64_t tv_sec;
  120. uint32_t tv_nsec, __pad;
  121. };
  122. struct statx {
  123. uint32_t stx_mask;
  124. uint32_t stx_blksize;
  125. uint64_t stx_attributes;
  126. uint32_t stx_nlink;
  127. uint32_t stx_uid;
  128. uint32_t stx_gid;
  129. uint16_t stx_mode;
  130. uint16_t __pad0[1];
  131. uint64_t stx_ino;
  132. uint64_t stx_size;
  133. uint64_t stx_blocks;
  134. uint64_t stx_attributes_mask;
  135. struct statx_timestamp stx_atime;
  136. struct statx_timestamp stx_btime;
  137. struct statx_timestamp stx_ctime;
  138. struct statx_timestamp stx_mtime;
  139. uint32_t stx_rdev_major;
  140. uint32_t stx_rdev_minor;
  141. uint32_t stx_dev_major;
  142. uint32_t stx_dev_minor;
  143. uint64_t stx_mnt_id;
  144. uint32_t stx_dio_mem_align;
  145. uint32_t stx_dio_offset_align;
  146. uint64_t stx_subvol;
  147. uint64_t __pad1[11];
  148. };
  149. int statx(int, const char *__restrict, int, unsigned, struct statx *__restrict);
  150. #endif
  151. #if defined(_LARGEFILE64_SOURCE)
  152. #define stat64 stat
  153. #define fstat64 fstat
  154. #define lstat64 lstat
  155. #define fstatat64 fstatat
  156. #define blkcnt64_t blkcnt_t
  157. #define fsblkcnt64_t fsblkcnt_t
  158. #define fsfilcnt64_t fsfilcnt_t
  159. #define ino64_t ino_t
  160. #define off64_t off_t
  161. #endif
  162. #if _REDIR_TIME64
  163. __REDIR(stat, __stat_time64);
  164. __REDIR(fstat, __fstat_time64);
  165. __REDIR(lstat, __lstat_time64);
  166. __REDIR(fstatat, __fstatat_time64);
  167. __REDIR(futimens, __futimens_time64);
  168. __REDIR(utimensat, __utimensat_time64);
  169. #endif
  170. #ifdef __cplusplus
  171. }
  172. #endif
  173. #endif