stat.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /* Copyright (C) 1992,95,96,97,98,99,2000,2001 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  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 == _MIPS_SIM_ABI32
  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. /*
  55. * Actually this should be timestruc_t st_atime, st_mtime and
  56. * st_ctime but we don't have it under Linux.
  57. */
  58. __time_t st_atime; /* Time of last access. */
  59. long int __reserved0;
  60. __time_t st_mtime; /* Time of last modification. */
  61. long int __reserved1;
  62. __time_t st_ctime; /* Time of last status change. */
  63. long int __reserved2;
  64. __blksize_t st_blksize; /* Optimal block size for I/O. */
  65. #ifndef __USE_FILE_OFFSET64
  66. __blkcnt_t st_blocks; /* Number of 512-byte blocks allocated. */
  67. #else
  68. long int st_pad4;
  69. __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated. */
  70. #endif
  71. long int st_pad5[14];
  72. };
  73. #else /* N32 || N64 */
  74. /* The memory layout is the same as of struct stat64 of the 32-bit kernel. */
  75. struct stat {
  76. unsigned int st_dev;
  77. int st_pad1[3];
  78. __ino_t st_ino; /* File serial number. */
  79. __mode_t st_mode; /* File mode. */
  80. __nlink_t st_nlink; /* Link count. */
  81. __uid_t st_uid; /* User ID of the file's owner. */
  82. __gid_t st_gid; /* Group ID of the file's group.*/
  83. unsigned int st_rdev; /* Device number, if device. */
  84. int st_pad2[3];
  85. __off_t st_size; /* Size of file, in bytes. */
  86. /*
  87. * Actually this should be timestruc_t st_atime, st_mtime and
  88. * st_ctime but we don't have it under Linux.
  89. */
  90. int st_atime;
  91. int reserved0; /* Reserved for st_atime expansion */
  92. int st_mtime;
  93. int reserved1; /* Reserved for st_mtime expansion */
  94. int st_ctime;
  95. int reserved2; /* Reserved for st_ctime expansion */
  96. int st_blksize; /* Optimal block size for I/O. */
  97. int st_pad3;
  98. __blkcnt_t st_blocks; /* Number of 512-byte blocks allocated. */
  99. int st_pad4[14];
  100. };
  101. #endif /* N32 || N64 */
  102. #ifdef __USE_LARGEFILE64
  103. #if _MIPS_SIM == _MIPS_SIM_ABI32
  104. struct stat64
  105. {
  106. __dev_t st_dev;
  107. long int st_pad1[2];
  108. __ino64_t st_ino; /* File serial number. */
  109. __mode_t st_mode; /* File mode. */
  110. __nlink_t st_nlink; /* Link count. */
  111. __uid_t st_uid; /* User ID of the file's owner. */
  112. __gid_t st_gid; /* Group ID of the file's group.*/
  113. __dev_t st_rdev; /* Device number, if device. */
  114. long int st_pad2[2];
  115. __off64_t st_size; /* Size of file, in bytes. */
  116. /*
  117. * Actually this should be timestruc_t st_atime, st_mtime and
  118. * st_ctime but we don't have it under Linux.
  119. */
  120. __time_t st_atime; /* Time of last access. */
  121. long int __reserved0;
  122. __time_t st_mtime; /* Time of last modification. */
  123. long int __reserved1;
  124. __time_t st_ctime; /* Time of last status change. */
  125. long int __reserved2;
  126. __blksize_t st_blksize; /* Optimal block size for I/O. */
  127. long int st_pad3;
  128. __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated. */
  129. long int st_pad4[14];
  130. };
  131. #else /* N32 || N64 */
  132. /* stat64 of N32/N64 is just an alias of stat syscall. */
  133. struct stat64 {
  134. unsigned int st_dev;
  135. int st_pad1[3];
  136. __ino_t st_ino; /* File serial number. */
  137. __mode_t st_mode; /* File mode. */
  138. __nlink_t st_nlink; /* Link count. */
  139. __uid_t st_uid; /* User ID of the file's owner. */
  140. __gid_t st_gid; /* Group ID of the file's group.*/
  141. unsigned int st_rdev; /* Device number, if device. */
  142. int st_pad2[3];
  143. __off_t st_size; /* Size of file, in bytes. */
  144. /*
  145. * Actually this should be timestruc_t st_atime, st_mtime and
  146. * st_ctime but we don't have it under Linux.
  147. */
  148. int st_atime;
  149. int reserved0; /* Reserved for st_atime expansion */
  150. int st_mtime;
  151. int reserved1; /* Reserved for st_mtime expansion */
  152. int st_ctime;
  153. int reserved2; /* Reserved for st_ctime expansion */
  154. int st_blksize; /* Optimal block size for I/O. */
  155. int st_pad3;
  156. __blkcnt_t st_blocks; /* Number of 512-byte blocks allocated. */
  157. int st_pad4[14];
  158. };
  159. #endif /* N32 || N64 */
  160. #endif
  161. /* Tell code we have these members. */
  162. #define _STATBUF_ST_BLKSIZE
  163. #define _STATBUF_ST_RDEV
  164. /* Encoding of the file mode. */
  165. #define __S_IFMT 0170000 /* These bits determine file type. */
  166. /* File types. */
  167. #define __S_IFDIR 0040000 /* Directory. */
  168. #define __S_IFCHR 0020000 /* Character device. */
  169. #define __S_IFBLK 0060000 /* Block device. */
  170. #define __S_IFREG 0100000 /* Regular file. */
  171. #define __S_IFIFO 0010000 /* FIFO. */
  172. #define __S_IFLNK 0120000 /* Symbolic link. */
  173. #define __S_IFSOCK 0140000 /* Socket. */
  174. /* POSIX.1b objects. Note that these macros always evaluate to zero. But
  175. they do it by enforcing the correct use of the macros. */
  176. #define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
  177. #define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
  178. #define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
  179. /* Protection bits. */
  180. #define __S_ISUID 04000 /* Set user ID on execution. */
  181. #define __S_ISGID 02000 /* Set group ID on execution. */
  182. #define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
  183. #define __S_IREAD 0400 /* Read by owner. */
  184. #define __S_IWRITE 0200 /* Write by owner. */
  185. #define __S_IEXEC 0100 /* Execute by owner. */