stat.h 9.8 KB

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