stat.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #ifndef __GBLIBC_SYS_STAT_H
  2. #define __GBLIBC_SYS_STAT_H
  3. #include <stdint.h>
  4. #include <bits/alltypes.h>
  5. #include <sys/types.h>
  6. #define STATX_TYPE (1 << 0)
  7. #define STATX_MODE (1 << 1)
  8. #define STATX_NLINK (1 << 2)
  9. #define STATX_UID (1 << 3)
  10. #define STATX_GID (1 << 4)
  11. #define STATX_ATIME (1 << 5)
  12. #define STATX_MTIME (1 << 6)
  13. #define STATX_CTIME (1 << 7)
  14. #define STATX_INO (1 << 8)
  15. #define STATX_SIZE (1 << 9)
  16. #define STATX_BLOCKS (1 << 10)
  17. #define STATX_BASIC_STATS (0x7ff)
  18. #define STATX_BTIME (1 << 11)
  19. #define S_IFMT 0170000
  20. #define S_IFSOCK 0140000
  21. #define S_IFLNK 0120000
  22. #define S_IFREG 0100000
  23. #define S_IFBLK 0060000
  24. #define S_IFDIR 0040000
  25. #define S_IFCHR 0020000
  26. #define S_IFIFO 0010000
  27. #define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK)
  28. #define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK)
  29. #define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
  30. #define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK)
  31. #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
  32. #define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR)
  33. #define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO)
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37. struct statx_timestamp {
  38. int64_t tv_sec;
  39. uint32_t tv_nsec;
  40. int32_t __reserved;
  41. };
  42. struct statx {
  43. uint32_t stx_mask;
  44. uint32_t stx_blksize;
  45. uint64_t stx_attributes;
  46. uint32_t stx_nlink;
  47. uint32_t stx_uid;
  48. uint32_t stx_gid;
  49. uint16_t stx_mode;
  50. uint16_t __spare0[1];
  51. uint64_t stx_ino;
  52. uint64_t stx_size;
  53. uint64_t stx_blocks;
  54. uint64_t stx_attributes_mask;
  55. struct statx_timestamp stx_atime;
  56. struct statx_timestamp stx_btime;
  57. struct statx_timestamp stx_ctime;
  58. struct statx_timestamp stx_mtime;
  59. uint32_t stx_rdev_major;
  60. uint32_t stx_rdev_minor;
  61. uint32_t stx_dev_major;
  62. uint32_t stx_dev_minor;
  63. uint64_t stx_mnt_id;
  64. uint64_t stx_dio_alignment[13];
  65. };
  66. struct stat {
  67. dev_t st_dev;
  68. ino_t st_ino;
  69. nlink_t st_nlink;
  70. mode_t st_mode;
  71. uid_t st_uid;
  72. gid_t st_gid;
  73. dev_t st_rdev;
  74. off_t st_size;
  75. blksize_t st_blksize;
  76. blkcnt_t st_blocks;
  77. struct timespec st_atim;
  78. struct timespec st_mtim;
  79. struct timespec st_ctim;
  80. long __padding[3];
  81. };
  82. int stat(const char* pathname, struct stat* statbuf);
  83. int fstat(int fd, struct stat* statbuf);
  84. mode_t umask(mode_t mask);
  85. #ifdef __cplusplus
  86. }
  87. #endif
  88. #endif