stat.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  3. *
  4. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  5. */
  6. #ifndef _SYS_STAT_H
  7. # error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
  8. #endif
  9. #include <bits/align64bit.h>
  10. #include <bits/wordsize.h>
  11. #include <endian.h>
  12. /* Versions of the `struct stat' data structure. */
  13. #define _STAT_VER_LINUX_OLD 1
  14. #define _STAT_VER_KERNEL 1
  15. #define _STAT_VER_SVR4 2
  16. #define _STAT_VER_LINUX 3
  17. #define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
  18. /* Versions of the `xmknod' interface. */
  19. #define _MKNOD_VER_LINUX 1
  20. #define _MKNOD_VER_SVR4 2
  21. #define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
  22. /*
  23. * This struct is exactly the same with the stat64 one because kvx is 64 bit
  24. */
  25. struct stat
  26. {
  27. unsigned long long st_dev; /* Device. */
  28. unsigned long long st_ino; /* 32bit file serial number. */
  29. unsigned int st_mode; /* File mode. */
  30. unsigned int st_nlink; /* Link count. */
  31. unsigned int st_uid; /* User ID of the file's owner. */
  32. unsigned int st_gid; /* Group ID of the file's group.*/
  33. unsigned long long st_rdev; /* Device number, if device. */
  34. unsigned long long _pad1;
  35. __off_t st_size; /* SIze of file, in bytes. */
  36. int st_blksize; /* Optimal block size for I/O. */
  37. int __pad2;
  38. long long st_blocks; /* Number 512-byte blocks allocated */
  39. #if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
  40. /* Nanosecond resolution timestamps are stored in a format
  41. equivalent to 'struct timespec'. This is the type used
  42. whenever possible but the Unix namespace rules do not allow the
  43. identifier 'timespec' to appear in the <sys/stat.h> header.
  44. Therefore we have to handle the use of this header in strictly
  45. standard-compliant sources special. */
  46. struct timespec st_atim; /* Time of last access. */
  47. struct timespec st_mtim; /* Time of last modification. */
  48. struct timespec st_ctim; /* Time of last status change. */
  49. # define st_atime st_atim.tv_sec /* Backward compatibility. */
  50. # define st_mtime st_mtim.tv_sec
  51. # define st_ctime st_ctim.tv_sec
  52. #else
  53. long int st_atime; /* Time of last access. */
  54. unsigned long int st_atime_nsec;
  55. long int st_mtime; /* Time of last modification. */
  56. unsigned long int st_mtime_nsec;
  57. long int st_ctime; /* Time of last status change. */
  58. unsigned long int st_ctime_nsec;
  59. #endif
  60. unsigned int __uclibc_unused4;
  61. unsigned int __uclibc_unused5;
  62. } __ARCH_64BIT_ALIGNMENT__;
  63. #ifdef __USE_LARGEFILE64
  64. struct stat64
  65. {
  66. unsigned long long st_dev; /* Device. */
  67. unsigned long long st_ino; /* 32bit file serial number. */
  68. unsigned int st_mode; /* File mode. */
  69. unsigned int st_nlink; /* Link count. */
  70. unsigned int st_uid; /* User ID of the file's owner. */
  71. unsigned int st_gid; /* Group ID of the file's group.*/
  72. unsigned long long st_rdev; /* Device number, if device. */
  73. unsigned long long __pad3;
  74. long long st_size; /* Size of file, in bytes. */
  75. int st_blksize; /* Optimal block size for I/O. */
  76. int __pad4;
  77. long long st_blocks; /* Number 512-byte blocks allocated */
  78. # if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
  79. /* Nanosecond resolution timestamps are stored in a format
  80. equivalent to 'struct timespec'. This is the type used
  81. whenever possible but the Unix namespace rules do not allow the
  82. identifier 'timespec' to appear in the <sys/stat.h> header.
  83. Therefore we have to handle the use of this header in strictly
  84. standard-compliant sources special. */
  85. struct timespec st_atim; /* Time of last access. */
  86. struct timespec st_mtim; /* Time of last modification. */
  87. struct timespec st_ctim; /* Time of last status change. */
  88. # else
  89. long int st_atime; /* Time of last access. */
  90. unsigned long int st_atime_nsec;
  91. long int st_mtime; /* Time of last modification. */
  92. unsigned long int st_mtime_nsec;
  93. long int st_ctime; /* Time of last status change. */
  94. unsigned long int st_ctime_nsec;
  95. # endif
  96. unsigned int __uclibc_unused4;
  97. unsigned int __uclibc_unused5;
  98. };
  99. #endif
  100. /* Tell code we have these members. */
  101. #define _STATBUF_ST_BLKSIZE
  102. #define _STATBUF_ST_RDEV
  103. /* Nanosecond resolution time values are supported. */
  104. #define _STATBUF_ST_NSEC
  105. /* Encoding of the file mode. */
  106. #define __S_IFMT 0170000 /* These bits determine file type. */
  107. /* File types. */
  108. #define __S_IFDIR 0040000 /* Directory. */
  109. #define __S_IFCHR 0020000 /* Character device. */
  110. #define __S_IFBLK 0060000 /* Block device. */
  111. #define __S_IFREG 0100000 /* Regular file. */
  112. #define __S_IFIFO 0010000 /* FIFO. */
  113. #define __S_IFLNK 0120000 /* Symbolic link. */
  114. #define __S_IFSOCK 0140000 /* Socket. */
  115. /* POSIX.1b objects. Note that these macros always evaluate to zero. But
  116. they do it by enforcing the correct use of the macros. */
  117. #define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
  118. #define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
  119. #define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
  120. /* Protection bits. */
  121. #define __S_ISUID 04000 /* Set user ID on execution. */
  122. #define __S_ISGID 02000 /* Set group ID on execution. */
  123. #define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
  124. #define __S_IREAD 0400 /* Read by owner. */
  125. #define __S_IWRITE 0200 /* Write by owner. */
  126. #define __S_IEXEC 0100 /* Execute by owner. */
  127. #ifdef __USE_ATFILE
  128. # define UTIME_NOW ((1l << 30) - 1l)
  129. # define UTIME_OMIT ((1l << 30) - 2l)
  130. #endif