PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

sys/sys/stat.h

http://www.minix3.org/
C Header | 196 lines | 157 code | 27 blank | 12 comment | 15 complexity | d58678557edfeffe7bdcc81de8307d88 MD5 | raw file
Possible License(s): MIT, WTFPL, AGPL-1.0, BSD-3-Clause, GPL-3.0, LGPL-2.0, JSON, 0BSD
  1. #ifndef _SYS_STAT_H_
  2. #define _SYS_STAT_H_
  3. #include <sys/featuretest.h>
  4. #include <sys/types.h> /* XXX */
  5. #if defined(_NETBSD_SOURCE)
  6. #include <sys/time.h>
  7. #endif
  8. struct stat {
  9. big_dev_t st_dev; /* inode's device */
  10. big_mode_t st_mode; /* inode protection mode */
  11. big_ino_t st_ino; /* inode's number */
  12. big_nlink_t st_nlink; /* number of hard links */
  13. big_uid_t st_uid; /* user ID of the file's owner */
  14. big_gid_t st_gid; /* group ID of the file's group */
  15. big_dev_t st_rdev; /* device type */
  16. #if defined(_NETBSD_SOURCE)
  17. struct timespec st_atimespec;/* time of last access */
  18. struct timespec st_mtimespec;/* time of last data modification */
  19. struct timespec st_ctimespec;/* time of last file status change */
  20. struct timespec st_birthtimespec; /* time of creation */
  21. #else
  22. time_t st_atime; /* time of last access */
  23. long st_atimensec; /* nsec of last access */
  24. time_t st_mtime; /* time of last data modification */
  25. long st_mtimensec; /* nsec of last data modification */
  26. time_t st_ctime; /* time of last file status change */
  27. long st_ctimensec; /* nsec of last file status change */
  28. time_t st_birthtime; /* time of creation */
  29. long st_birthtimensec; /* nsec of time of creation */
  30. #endif
  31. big_off_t st_size; /* file size, in bytes */
  32. blkcnt_t st_blocks; /* blocks allocated for file */
  33. blksize_t st_blksize; /* optimal blocksize for I/O */
  34. u32_t st_flags; /* user defined flags for file */
  35. u32_t st_gen; /* file generation number */
  36. u32_t st_spare[2];
  37. };
  38. struct minix_prev_stat {
  39. short st_dev; /* major/minor device number */
  40. ino_t st_ino; /* i-node number */
  41. mode_t st_mode; /* file mode, protection bits, etc. */
  42. nlink_t st_nlink; /* # links; */
  43. short st_uid; /* uid of the file's owner */
  44. short int st_gid; /* gid; TEMPORARY HACK: should be gid_t */
  45. short st_rdev;
  46. off_t st_size; /* file size */
  47. time_t st_atime; /* time of last access */
  48. time_t st_mtime; /* time of last data modification */
  49. time_t st_ctime; /* time of last file status change */
  50. };
  51. #if defined(_NETBSD_SOURCE)
  52. /* XXX after updating stat struct we don't want to update all the code */
  53. #define st_atime st_atimespec.tv_sec
  54. #define st_mtime st_mtimespec.tv_sec
  55. #define st_ctime st_ctimespec.tv_sec
  56. #define st_birthtime st_birthtimespec.tv_sec
  57. #define st_atimensec st_atimespec.tv_nsec
  58. #define st_mtimensec st_mtimespec.tv_nsec
  59. #define st_ctimensec st_ctimespec.tv_nsec
  60. #define st_birthtimensec st_birthtimespec.tv_nsec
  61. #endif
  62. #define S_ISUID 0004000 /* set user id on execution */
  63. #define S_ISGID 0002000 /* set group id on execution */
  64. #if defined(_NETBSD_SOURCE)
  65. #define S_ISTXT 0001000 /* sticky bit */
  66. #endif
  67. #define S_IRWXU 0000700 /* RWX mask for owner */
  68. #define S_IRUSR 0000400 /* R for owner */
  69. #define S_IWUSR 0000200 /* W for owner */
  70. #define S_IXUSR 0000100 /* X for owner */
  71. #if defined(_NETBSD_SOURCE)
  72. #define S_IREAD S_IRUSR
  73. #define S_IWRITE S_IWUSR
  74. #define S_IEXEC S_IXUSR
  75. #endif
  76. #define S_IRWXG 0000070 /* RWX mask for group */
  77. #define S_IRGRP 0000040 /* R for group */
  78. #define S_IWGRP 0000020 /* W for group */
  79. #define S_IXGRP 0000010 /* X for group */
  80. #define S_IRWXO 0000007 /* RWX mask for other */
  81. #define S_IROTH 0000004 /* R for other */
  82. #define S_IWOTH 0000002 /* W for other */
  83. #define S_IXOTH 0000001 /* X for other */
  84. #define _S_IFMT 0170000 /* type of file mask */
  85. #define _S_IFIFO 0010000 /* named pipe (fifo) */
  86. #define _S_IFCHR 0020000 /* character special */
  87. #define _S_IFDIR 0040000 /* directory */
  88. #define _S_IFBLK 0060000 /* block special */
  89. #define _S_IFREG 0100000 /* regular */
  90. #define _S_IFLNK 0120000 /* symbolic link */
  91. #define _S_IFSOCK 0140000 /* socket */
  92. #define _S_ISVTX 0001000 /* save swapped text even after use */
  93. #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
  94. #define S_IFMT _S_IFMT
  95. #define S_IFIFO _S_IFIFO
  96. #define S_IFCHR _S_IFCHR
  97. #define S_IFDIR _S_IFDIR
  98. #define S_IFBLK _S_IFBLK
  99. #define S_IFREG _S_IFREG
  100. #define S_IFLNK _S_IFLNK
  101. #define S_ISVTX _S_ISVTX
  102. #endif
  103. #if ((_XOPEN_SOURCE - 0) >= 600) || defined(_NETBSD_SOURCE)
  104. #define S_IFSOCK _S_IFSOCK
  105. #endif
  106. #define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) /* directory */
  107. #define S_ISCHR(m) (((m) & _S_IFMT) == _S_IFCHR) /* char special */
  108. #define S_ISBLK(m) (((m) & _S_IFMT) == _S_IFBLK) /* block special */
  109. #define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) /* regular file */
  110. #define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO) /* fifo */
  111. #if ((_POSIX_C_SOURCE - 0) >= 200112L) || defined(_XOPEN_SOURCE) || \
  112. defined(_NETBSD_SOURCE)
  113. #define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK) /* symbolic link */
  114. #endif
  115. #if ((_POSIX_C_SOURCE - 0) >= 200112L) || ((_XOPEN_SOURCE - 0) >= 600) || \
  116. defined(_NETBSD_SOURCE)
  117. #define S_ISSOCK(m) (((m) & _S_IFMT) == _S_IFSOCK) /* socket */
  118. #endif
  119. #if defined(_NETBSD_SOURCE)
  120. #define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
  121. /* 7777 */
  122. #define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
  123. /* 0666 */
  124. #define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
  125. #define S_BLKSIZE 512 /* block size used in the stat struct */
  126. /*
  127. * Definitions of flags stored in file flags word.
  128. *
  129. * Super-user and owner changeable flags.
  130. */
  131. #define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */
  132. #define UF_NODUMP 0x00000001 /* do not dump file */
  133. #define UF_IMMUTABLE 0x00000002 /* file may not be changed */
  134. #define UF_APPEND 0x00000004 /* writes to file may only append */
  135. #define UF_OPAQUE 0x00000008 /* directory is opaque wrt. union */
  136. /*
  137. * Super-user changeable flags.
  138. */
  139. #define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */
  140. #define SF_ARCHIVED 0x00010000 /* file is archived */
  141. #define SF_IMMUTABLE 0x00020000 /* file may not be changed */
  142. #define SF_APPEND 0x00040000 /* writes to file may only append */
  143. #endif /* _NETBSD_SOURCE */
  144. #if defined(__minix)
  145. #include <machine/vmparam.h>
  146. /* Convenient constant to use when st_blocksize field is required. */
  147. #define MINIX_ST_BLKSIZE PAGE_SIZE
  148. #endif
  149. #include <sys/cdefs.h>
  150. #if !defined(_KERNEL) && !defined(_STANDALONE)
  151. __BEGIN_DECLS
  152. int chmod(const char *, mode_t);
  153. int mkdir(const char *, mode_t);
  154. int mkfifo(const char *, mode_t);
  155. #ifndef __LIBC12_SOURCE__
  156. int stat(const char *, struct stat *) __RENAME(__stat50);
  157. int fstat(int, struct stat *) __RENAME(__fstat50);
  158. #endif
  159. mode_t umask(mode_t);
  160. #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
  161. int fchmod(int, mode_t);
  162. #ifndef __LIBC12_SOURCE__
  163. int lstat(const char *, struct stat *) __RENAME(__lstat50);
  164. int mknod(const char *, mode_t, dev_t) __RENAME(__mknod50);
  165. #endif
  166. #endif /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */
  167. __END_DECLS
  168. #endif /* !_KERNEL && !_STANDALONE */
  169. #endif /* !_SYS_STAT_H_ */