struct_stat.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /* Definition for struct stat.
  2. Copyright (C) 2020-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library. If not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #if !defined _SYS_STAT_H && !defined _FCNTL_H
  16. # error "Never include <bits/struct_stat.h> directly; use <sys/stat.h> instead."
  17. #endif
  18. #ifndef _BITS_STRUCT_STAT_H
  19. #define _BITS_STRUCT_STAT_H 1
  20. struct stat
  21. {
  22. #ifdef __USE_TIME64_REDIRECTS
  23. # include <bits/struct_stat_time64_helper.h>
  24. #else
  25. __dev_t st_dev; /* Device. */
  26. # ifndef __x86_64__
  27. unsigned short int __pad1;
  28. # endif
  29. # if defined __x86_64__ || !defined __USE_FILE_OFFSET64
  30. __ino_t st_ino; /* File serial number. */
  31. # else
  32. __ino_t __st_ino; /* 32bit file serial number. */
  33. # endif
  34. # ifndef __x86_64__
  35. __mode_t st_mode; /* File mode. */
  36. __nlink_t st_nlink; /* Link count. */
  37. # else
  38. __nlink_t st_nlink; /* Link count. */
  39. __mode_t st_mode; /* File mode. */
  40. # endif
  41. __uid_t st_uid; /* User ID of the file's owner. */
  42. __gid_t st_gid; /* Group ID of the file's group.*/
  43. # ifdef __x86_64__
  44. int __pad0;
  45. # endif
  46. __dev_t st_rdev; /* Device number, if device. */
  47. # ifndef __x86_64__
  48. unsigned short int __pad2;
  49. # endif
  50. # if defined __x86_64__ || !defined __USE_FILE_OFFSET64
  51. __off_t st_size; /* Size of file, in bytes. */
  52. # else
  53. __off64_t st_size; /* Size of file, in bytes. */
  54. # endif
  55. __blksize_t st_blksize; /* Optimal block size for I/O. */
  56. # if defined __x86_64__ || !defined __USE_FILE_OFFSET64
  57. __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
  58. # else
  59. __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
  60. # endif
  61. # ifdef __USE_XOPEN2K8
  62. /* Nanosecond resolution timestamps are stored in a format
  63. equivalent to 'struct timespec'. This is the type used
  64. whenever possible but the Unix namespace rules do not allow the
  65. identifier 'timespec' to appear in the <sys/stat.h> header.
  66. Therefore we have to handle the use of this header in strictly
  67. standard-compliant sources special. */
  68. struct timespec st_atim; /* Time of last access. */
  69. struct timespec st_mtim; /* Time of last modification. */
  70. struct timespec st_ctim; /* Time of last status change. */
  71. # define st_atime st_atim.tv_sec /* Backward compatibility. */
  72. # define st_mtime st_mtim.tv_sec
  73. # define st_ctime st_ctim.tv_sec
  74. # else
  75. __time_t st_atime; /* Time of last access. */
  76. __syscall_ulong_t st_atimensec; /* Nscecs of last access. */
  77. __time_t st_mtime; /* Time of last modification. */
  78. __syscall_ulong_t st_mtimensec; /* Nsecs of last modification. */
  79. __time_t st_ctime; /* Time of last status change. */
  80. __syscall_ulong_t st_ctimensec; /* Nsecs of last status change. */
  81. # endif
  82. # ifdef __x86_64__
  83. __syscall_slong_t __glibc_reserved[3];
  84. # else
  85. # ifndef __USE_FILE_OFFSET64
  86. unsigned long int __glibc_reserved4;
  87. unsigned long int __glibc_reserved5;
  88. # else
  89. __ino64_t st_ino; /* File serial number. */
  90. # endif
  91. # endif
  92. #endif /* __USE_TIME64_REDIRECTS */
  93. };
  94. #ifdef __USE_LARGEFILE64
  95. /* Note stat64 has the same shape as stat for x86-64. */
  96. struct stat64
  97. {
  98. # ifdef __USE_TIME64_REDIRECTS
  99. # include <bits/struct_stat_time64_helper.h>
  100. # else
  101. __dev_t st_dev; /* Device. */
  102. # ifdef __x86_64__
  103. __ino64_t st_ino; /* File serial number. */
  104. __nlink_t st_nlink; /* Link count. */
  105. __mode_t st_mode; /* File mode. */
  106. # else
  107. unsigned int __pad1;
  108. __ino_t __st_ino; /* 32bit file serial number. */
  109. __mode_t st_mode; /* File mode. */
  110. __nlink_t st_nlink; /* Link count. */
  111. # endif
  112. __uid_t st_uid; /* User ID of the file's owner. */
  113. __gid_t st_gid; /* Group ID of the file's group.*/
  114. # ifdef __x86_64__
  115. int __pad0;
  116. __dev_t st_rdev; /* Device number, if device. */
  117. __off_t st_size; /* Size of file, in bytes. */
  118. # else
  119. __dev_t st_rdev; /* Device number, if device. */
  120. unsigned int __pad2;
  121. __off64_t st_size; /* Size of file, in bytes. */
  122. # endif
  123. __blksize_t st_blksize; /* Optimal block size for I/O. */
  124. __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */
  125. # ifdef __USE_XOPEN2K8
  126. /* Nanosecond resolution timestamps are stored in a format
  127. equivalent to 'struct timespec'. This is the type used
  128. whenever possible but the Unix namespace rules do not allow the
  129. identifier 'timespec' to appear in the <sys/stat.h> header.
  130. Therefore we have to handle the use of this header in strictly
  131. standard-compliant sources special. */
  132. struct timespec st_atim; /* Time of last access. */
  133. struct timespec st_mtim; /* Time of last modification. */
  134. struct timespec st_ctim; /* Time of last status change. */
  135. # else
  136. __time_t st_atime; /* Time of last access. */
  137. __syscall_ulong_t st_atimensec; /* Nscecs of last access. */
  138. __time_t st_mtime; /* Time of last modification. */
  139. __syscall_ulong_t st_mtimensec; /* Nsecs of last modification. */
  140. __time_t st_ctime; /* Time of last status change. */
  141. __syscall_ulong_t st_ctimensec; /* Nsecs of last status change. */
  142. # endif
  143. # ifdef __x86_64__
  144. __syscall_slong_t __glibc_reserved[3];
  145. # else
  146. __ino64_t st_ino; /* File serial number. */
  147. # endif
  148. # endif /* __USE_TIME64_REDIRECTS */
  149. };
  150. #endif
  151. /* Tell code we have these members. */
  152. #define _STATBUF_ST_BLKSIZE
  153. #define _STATBUF_ST_RDEV
  154. /* Nanosecond resolution time values are supported. */
  155. #define _STATBUF_ST_NSEC
  156. #endif /* _BITS_STRUCT_STAT_H */