stat.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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_ATTR_COMPRESSED 0x4
  107. #define STATX_ATTR_IMMUTABLE 0x10
  108. #define STATX_ATTR_APPEND 0x20
  109. #define STATX_ATTR_NODUMP 0x40
  110. #define STATX_ATTR_ENCRYPTED 0x800
  111. #define STATX_ATTR_AUTOMOUNT 0x1000
  112. #define STATX_ATTR_MOUNT_ROOT 0x2000
  113. #define STATX_ATTR_VERITY 0x100000
  114. #define STATX_ATTR_DAX 0x200000
  115. struct statx_timestamp {
  116. int64_t tv_sec;
  117. uint32_t tv_nsec, __pad;
  118. };
  119. struct statx {
  120. uint32_t stx_mask;
  121. uint32_t stx_blksize;
  122. uint64_t stx_attributes;
  123. uint32_t stx_nlink;
  124. uint32_t stx_uid;
  125. uint32_t stx_gid;
  126. uint16_t stx_mode;
  127. uint16_t __pad0[1];
  128. uint64_t stx_ino;
  129. uint64_t stx_size;
  130. uint64_t stx_blocks;
  131. uint64_t stx_attributes_mask;
  132. struct statx_timestamp stx_atime;
  133. struct statx_timestamp stx_btime;
  134. struct statx_timestamp stx_ctime;
  135. struct statx_timestamp stx_mtime;
  136. uint32_t stx_rdev_major;
  137. uint32_t stx_rdev_minor;
  138. uint32_t stx_dev_major;
  139. uint32_t stx_dev_minor;
  140. uint64_t __pad1[14];
  141. };
  142. int statx(int, const char *__restrict, int, unsigned, struct statx *__restrict);
  143. #endif
  144. #if defined(_LARGEFILE64_SOURCE)
  145. #define stat64 stat
  146. #define fstat64 fstat
  147. #define lstat64 lstat
  148. #define fstatat64 fstatat
  149. #define blkcnt64_t blkcnt_t
  150. #define fsblkcnt64_t fsblkcnt_t
  151. #define fsfilcnt64_t fsfilcnt_t
  152. #define ino64_t ino_t
  153. #define off64_t off_t
  154. #endif
  155. #if _REDIR_TIME64
  156. __REDIR(stat, __stat_time64);
  157. __REDIR(fstat, __fstat_time64);
  158. __REDIR(lstat, __lstat_time64);
  159. __REDIR(fstatat, __fstatat_time64);
  160. __REDIR(futimens, __futimens_time64);
  161. __REDIR(utimensat, __utimensat_time64);
  162. #endif
  163. #ifdef __cplusplus
  164. }
  165. #endif
  166. #endif