stat.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. /* Copyright (C) 1992, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
  2. 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, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #ifndef _SYS_STAT_H
  17. # error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
  18. #endif
  19. #include <bits/wordsize.h>
  20. /* Versions of the `struct stat' data structure. */
  21. #define _STAT_VER_LINUX_OLD 1
  22. #define _STAT_VER_KERNEL 1
  23. #define _STAT_VER_SVR4 2
  24. #define _STAT_VER_LINUX 3
  25. #if __WORDSIZE == 32
  26. # define _STAT_VER _STAT_VER_LINUX
  27. #else
  28. # define _STAT_VER _STAT_VER_KERNEL
  29. #endif
  30. /* Versions of the `xmknod' interface. */
  31. #define _MKNOD_VER_LINUX 1
  32. #define _MKNOD_VER_SVR4 2
  33. #define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
  34. #if __WORDSIZE == 32
  35. struct stat
  36. {
  37. __dev_t st_dev; /* Device. */
  38. # ifndef __USE_FILE_OFFSET64
  39. unsigned short int __pad1;
  40. __ino_t st_ino; /* File serial number. */
  41. # else
  42. __ino64_t st_ino; /* File serial number. */
  43. # endif
  44. __mode_t st_mode; /* File mode. */
  45. __nlink_t st_nlink; /* Link count. */
  46. __uid_t st_uid; /* User ID of the file's owner. */
  47. __gid_t st_gid; /* Group ID of the file's group.*/
  48. __dev_t st_rdev; /* Device number, if device. */
  49. unsigned short int __pad2;
  50. # ifndef __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. # ifndef __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. #if 0 /*def __USE_MISC*/
  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. unsigned long int st_atimensec; /* Nscecs of last access. */
  77. __time_t st_mtime; /* Time of last modification. */
  78. unsigned long int st_mtimensec; /* Nsecs of last modification. */
  79. __time_t st_ctime; /* Time of last status change. */
  80. unsigned long int st_ctimensec; /* Nsecs of last status change. */
  81. #endif
  82. unsigned long int __unused4;
  83. unsigned long int __unused5;
  84. };
  85. # ifdef __USE_LARGEFILE64
  86. struct stat64
  87. {
  88. __dev_t st_dev; /* Device. */
  89. __ino64_t st_ino; /* File serial number. */
  90. __mode_t st_mode; /* File mode. */
  91. __nlink_t st_nlink; /* Link count. */
  92. __uid_t st_uid; /* User ID of the file's owner. */
  93. __gid_t st_gid; /* Group ID of the file's group.*/
  94. __dev_t st_rdev; /* Device number, if device. */
  95. unsigned short int __pad2;
  96. __off64_t st_size; /* Size of file, in bytes. */
  97. __blksize_t st_blksize; /* Optimal block size for I/O. */
  98. __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
  99. #if 0 /*def __USE_MISC*/
  100. /* Nanosecond resolution timestamps are stored in a format
  101. equivalent to 'struct timespec'. This is the type used
  102. whenever possible but the Unix namespace rules do not allow the
  103. identifier 'timespec' to appear in the <sys/stat.h> header.
  104. Therefore we have to handle the use of this header in strictly
  105. standard-compliant sources special. */
  106. struct timespec st_atim; /* Time of last access. */
  107. struct timespec st_mtim; /* Time of last modification. */
  108. struct timespec st_ctim; /* Time of last status change. */
  109. # define st_atime st_atim.tv_sec /* Backward compatibility. */
  110. # define st_mtime st_mtim.tv_sec
  111. # define st_ctime st_ctim.tv_sec
  112. #else
  113. __time_t st_atime; /* Time of last access. */
  114. unsigned long int st_atimensec; /* Nscecs of last access. */
  115. __time_t st_mtime; /* Time of last modification. */
  116. unsigned long int st_mtimensec; /* Nsecs of last modification. */
  117. __time_t st_ctime; /* Time of last status change. */
  118. unsigned long int st_ctimensec; /* Nsecs of last status change. */
  119. #endif
  120. unsigned long int __unused4;
  121. unsigned long int __unused5;
  122. };
  123. # endif /* __USE_LARGEFILE64 */
  124. #else /* __WORDSIZE == 32 */
  125. struct stat
  126. {
  127. __dev_t st_dev; /* Device. */
  128. # ifndef __USE_FILE_OFFSET64
  129. __ino_t st_ino; /* File serial number. */
  130. # else
  131. __ino64_t st_ino; /* File serial number. */
  132. # endif
  133. __nlink_t st_nlink; /* Link count. */
  134. __mode_t st_mode; /* File mode. */
  135. __uid_t st_uid; /* User ID of the file's owner. */
  136. __gid_t st_gid; /* Group ID of the file's group.*/
  137. int __pad2;
  138. __dev_t st_rdev; /* Device number, if device. */
  139. # ifndef __USE_FILE_OFFSET64
  140. __off_t st_size; /* Size of file, in bytes. */
  141. # else
  142. __off64_t st_size; /* Size of file, in bytes. */
  143. # endif
  144. __blksize_t st_blksize; /* Optimal block size for I/O. */
  145. # ifndef __USE_FILE_OFFSET64
  146. __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
  147. # else
  148. __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
  149. # endif
  150. #if 0 /*def __USE_MISC*/
  151. /* Nanosecond resolution timestamps are stored in a format
  152. equivalent to 'struct timespec'. This is the type used
  153. whenever possible but the Unix namespace rules do not allow the
  154. identifier 'timespec' to appear in the <sys/stat.h> header.
  155. Therefore we have to handle the use of this header in strictly
  156. standard-compliant sources special. */
  157. struct timespec st_atim; /* Time of last access. */
  158. struct timespec st_mtim; /* Time of last modification. */
  159. struct timespec st_ctim; /* Time of last status change. */
  160. # define st_atime st_atim.tv_sec /* Backward compatibility. */
  161. # define st_mtime st_mtim.tv_sec
  162. # define st_ctime st_ctim.tv_sec
  163. #else
  164. __time_t st_atime; /* Time of last access. */
  165. unsigned long int st_atimensec; /* Nscecs of last access. */
  166. __time_t st_mtime; /* Time of last modification. */
  167. unsigned long int st_mtimensec; /* Nsecs of last modification. */
  168. __time_t st_ctime; /* Time of last status change. */
  169. unsigned long int st_ctimensec; /* Nsecs of last status change. */
  170. #endif
  171. unsigned long int __unused4;
  172. unsigned long int __unused5;
  173. unsigned long int __unused6;
  174. };
  175. # ifdef __USE_LARGEFILE64
  176. struct stat64
  177. {
  178. __dev_t st_dev; /* Device. */
  179. __ino64_t st_ino; /* File serial number. */
  180. __nlink_t st_nlink; /* Link count. */
  181. __mode_t st_mode; /* File mode. */
  182. __uid_t st_uid; /* User ID of the file's owner. */
  183. __gid_t st_gid; /* Group ID of the file's group.*/
  184. int __pad2;
  185. __dev_t st_rdev; /* Device number, if device. */
  186. __off64_t st_size; /* Size of file, in bytes. */
  187. __blksize_t st_blksize; /* Optimal block size for I/O. */
  188. __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
  189. #if 0 /*def __USE_MISC*/
  190. /* Nanosecond resolution timestamps are stored in a format
  191. equivalent to 'struct timespec'. This is the type used
  192. whenever possible but the Unix namespace rules do not allow the
  193. identifier 'timespec' to appear in the <sys/stat.h> header.
  194. Therefore we have to handle the use of this header in strictly
  195. standard-compliant sources special. */
  196. struct timespec st_atim; /* Time of last access. */
  197. struct timespec st_mtim; /* Time of last modification. */
  198. struct timespec st_ctim; /* Time of last status change. */
  199. # define st_atime st_atim.tv_sec /* Backward compatibility. */
  200. # define st_mtime st_mtim.tv_sec
  201. # define st_ctime st_ctim.tv_sec
  202. #else
  203. __time_t st_atime; /* Time of last access. */
  204. unsigned long int st_atimensec; /* Nscecs of last access. */
  205. __time_t st_mtime; /* Time of last modification. */
  206. unsigned long int st_mtimensec; /* Nsecs of last modification. */
  207. __time_t st_ctime; /* Time of last status change. */
  208. unsigned long int st_ctimensec; /* Nsecs of last status change. */
  209. #endif
  210. unsigned long int __unused4;
  211. unsigned long int __unused5;
  212. unsigned long int __unused6;
  213. };
  214. # endif /* __USE_LARGEFILE64 */
  215. #endif
  216. /* Tell code we have these members. */
  217. #define _STATBUF_ST_BLKSIZE
  218. #define _STATBUF_ST_RDEV
  219. /* Nanosecond resolution time values are supported. */
  220. #define _STATBUF_ST_NSEC
  221. /* Encoding of the file mode. */
  222. #define __S_IFMT 0170000 /* These bits determine file type. */
  223. /* File types. */
  224. #define __S_IFDIR 0040000 /* Directory. */
  225. #define __S_IFCHR 0020000 /* Character device. */
  226. #define __S_IFBLK 0060000 /* Block device. */
  227. #define __S_IFREG 0100000 /* Regular file. */
  228. #define __S_IFIFO 0010000 /* FIFO. */
  229. #define __S_IFLNK 0120000 /* Symbolic link. */
  230. #define __S_IFSOCK 0140000 /* Socket. */
  231. /* POSIX.1b objects. Note that these macros always evaluate to zero. But
  232. they do it by enforcing the correct use of the macros. */
  233. #define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
  234. #define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
  235. #define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
  236. /* Protection bits. */
  237. #define __S_ISUID 04000 /* Set user ID on execution. */
  238. #define __S_ISGID 02000 /* Set group ID on execution. */
  239. #define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
  240. #define __S_IREAD 0400 /* Read by owner. */
  241. #define __S_IWRITE 0200 /* Write by owner. */
  242. #define __S_IEXEC 0100 /* Execute by owner. */