stat.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. #if __WORDSIZE == 32
  25. # define _STAT_VER_LINUX 3
  26. # define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
  27. #else
  28. # define _STAT_VER _STAT_VER_KERNEL /* The one defined below. */
  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. __time_t st_atime; /* Time of last access. */
  62. unsigned long int __unused1; /* Reserved for atime.nanoseconds. */
  63. __time_t st_mtime; /* Time of last modification. */
  64. unsigned long int __unused2; /* Reserved for mtime.nanoseconds. */
  65. __time_t st_ctime; /* Time of last status change. */
  66. unsigned long int __unused3; /* Reserved for ctime.nanoseconds. */
  67. unsigned long int __unused4;
  68. unsigned long int __unused5;
  69. };
  70. # ifdef __USE_LARGEFILE64
  71. struct stat64
  72. {
  73. __dev_t st_dev; /* Device. */
  74. __ino64_t st_ino; /* File serial number. */
  75. __mode_t st_mode; /* File mode. */
  76. __nlink_t st_nlink; /* Link count. */
  77. __uid_t st_uid; /* User ID of the file's owner. */
  78. __gid_t st_gid; /* Group ID of the file's group.*/
  79. __dev_t st_rdev; /* Device number, if device. */
  80. unsigned short int __pad2;
  81. __off64_t st_size; /* Size of file, in bytes. */
  82. __blksize_t st_blksize; /* Optimal block size for I/O. */
  83. __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
  84. __time_t st_atime; /* Time of last access. */
  85. unsigned long int __unused1; /* Reserved for atime.nanoseconds. */
  86. __time_t st_mtime; /* Time of last modification. */
  87. unsigned long int __unused2; /* Reserved for mtime.nanoseconds. */
  88. __time_t st_ctime; /* Time of last status change. */
  89. unsigned long int __unused3; /* Reserved for ctime.nanoseconds. */
  90. unsigned long int __unused4;
  91. unsigned long int __unused5;
  92. };
  93. # endif /* __USE_LARGEFILE64 */
  94. #else /* __WORDSIZE == 32 */
  95. struct stat
  96. {
  97. __dev_t st_dev; /* Device. */
  98. # ifndef __USE_FILE_OFFSET64
  99. __ino_t st_ino; /* File serial number. */
  100. # else
  101. __ino64_t st_ino; /* File serial number. */
  102. # endif
  103. __nlink_t st_nlink; /* Link count. */
  104. __mode_t st_mode; /* File mode. */
  105. __uid_t st_uid; /* User ID of the file's owner. */
  106. __gid_t st_gid; /* Group ID of the file's group.*/
  107. int __pad2;
  108. __dev_t st_rdev; /* Device number, if device. */
  109. # ifndef __USE_FILE_OFFSET64
  110. __off_t st_size; /* Size of file, in bytes. */
  111. # else
  112. __off64_t st_size; /* Size of file, in bytes. */
  113. # endif
  114. __blksize_t st_blksize; /* Optimal block size for I/O. */
  115. # ifndef __USE_FILE_OFFSET64
  116. __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
  117. # else
  118. __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
  119. # endif
  120. __time_t st_atime; /* Time of last access. */
  121. unsigned long int __unused1; /* Reserved for atime.nanoseconds. */
  122. __time_t st_mtime; /* Time of last modification. */
  123. unsigned long int __unused2; /* Reserved for mtime.nanoseconds. */
  124. __time_t st_ctime; /* Time of last status change. */
  125. unsigned long int __unused3; /* Reserved for ctime.nanoseconds. */
  126. unsigned long int __unused4;
  127. unsigned long int __unused5;
  128. unsigned long int __unused6;
  129. };
  130. # ifdef __USE_LARGEFILE64
  131. struct stat64
  132. {
  133. __dev_t st_dev; /* Device. */
  134. __ino64_t st_ino; /* File serial number. */
  135. __nlink_t st_nlink; /* Link count. */
  136. __mode_t st_mode; /* File mode. */
  137. __uid_t st_uid; /* User ID of the file's owner. */
  138. __gid_t st_gid; /* Group ID of the file's group.*/
  139. int __pad2;
  140. __dev_t st_rdev; /* Device number, if device. */
  141. __off64_t st_size; /* Size of file, in bytes. */
  142. __blksize_t st_blksize; /* Optimal block size for I/O. */
  143. __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
  144. __time_t st_atime; /* Time of last access. */
  145. unsigned long int __unused1; /* Reserved for atime.nanoseconds. */
  146. __time_t st_mtime; /* Time of last modification. */
  147. unsigned long int __unused2; /* Reserved for mtime.nanoseconds. */
  148. __time_t st_ctime; /* Time of last status change. */
  149. unsigned long int __unused3; /* Reserved for ctime.nanoseconds. */
  150. unsigned long int __unused4;
  151. unsigned long int __unused5;
  152. unsigned long int __unused6;
  153. };
  154. # endif /* __USE_LARGEFILE64 */
  155. #endif
  156. /* Tell code we have these members. */
  157. #define _STATBUF_ST_BLKSIZE
  158. #define _STATBUF_ST_RDEV
  159. /* Encoding of the file mode. */
  160. #define __S_IFMT 0170000 /* These bits determine file type. */
  161. /* File types. */
  162. #define __S_IFDIR 0040000 /* Directory. */
  163. #define __S_IFCHR 0020000 /* Character device. */
  164. #define __S_IFBLK 0060000 /* Block device. */
  165. #define __S_IFREG 0100000 /* Regular file. */
  166. #define __S_IFIFO 0010000 /* FIFO. */
  167. #define __S_IFLNK 0120000 /* Symbolic link. */
  168. #define __S_IFSOCK 0140000 /* Socket. */
  169. /* POSIX.1b objects. Note that these macros always evaluate to zero. But
  170. they do it by enforcing the correct use of the macros. */
  171. #define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
  172. #define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
  173. #define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
  174. /* Protection bits. */
  175. #define __S_ISUID 04000 /* Set user ID on execution. */
  176. #define __S_ISGID 02000 /* Set group ID on execution. */
  177. #define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
  178. #define __S_IREAD 0400 /* Read by owner. */
  179. #define __S_IWRITE 0200 /* Write by owner. */
  180. #define __S_IEXEC 0100 /* Execute by owner. */