1:
2:
3:
4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38:
39:
40: #ifndef _SYS_STAT_H_
41: #define _SYS_STAT_H_
42:
43: #include <sys/cdefs.h>
44: #include <sys/time.h>
45:
46: struct stat {
47: #if 1
48: mode_t st_mode;
49: u_int32_t st_blksize;
50: off_t st_size;
51: #else
52: dev_t st_dev;
53: ino_t st_ino;
54: mode_t st_mode;
55: nlink_t st_nlink;
56: uid_t st_uid;
57: gid_t st_gid;
58: dev_t st_rdev;
59: int32_t st_lspare0;
60: #if __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE
61: struct timespec st_atim;
62: struct timespec st_mtim;
63: struct timespec st_ctim;
64: #else
65: time_t st_atime;
66: long st_atimensec;
67: time_t st_mtime;
68: long st_mtimensec;
69: time_t st_ctime;
70: long st_ctimensec;
71: #endif
72: off_t st_size;
73: int64_t st_blocks;
74: u_int32_t st_blksize;
75: u_int32_t st_flags;
76: u_int32_t st_gen;
77: int32_t st_lspare1;
78: #if __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE
79: struct timespec __st_birthtim;
80: #else
81: time_t __st_birthtime;
82: long __st_birthtimensec;
83: #endif
84: int64_t st_qspare[2];
85: #endif
86: };
87: #if __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE
88: #define st_atime st_atim.tv_sec
89: #define st_mtime st_mtim.tv_sec
90: #define st_ctime st_ctim.tv_sec
91: #define __st_birthtime __st_birthtim.tv_sec
92: #endif
93: #if __BSD_VISIBLE
94: #define st_atimespec st_atim
95: #define st_atimensec st_atim.tv_nsec
96: #define st_mtimespec st_mtim
97: #define st_mtimensec st_mtim.tv_nsec
98: #define st_ctimespec st_ctim
99: #define st_ctimensec st_ctim.tv_nsec
100: #define __st_birthtimespec __st_birthtim
101: #define __st_birthtimensec __st_birthtim.tv_nsec
102: #endif
103:
104: #define S_ISUID 0004000
105: #define S_ISGID 0002000
106: #if __BSD_VISIBLE
107: #define S_ISTXT 0001000
108: #endif
109:
110: #define S_IRWXU 0000700
111: #define S_IRUSR 0000400
112: #define S_IWUSR 0000200
113: #define S_IXUSR 0000100
114:
115: #if __BSD_VISIBLE
116: #define S_IREAD S_IRUSR
117: #define S_IWRITE S_IWUSR
118: #define S_IEXEC S_IXUSR
119: #endif
120:
121: #define S_IRWXG 0000070
122: #define S_IRGRP 0000040
123: #define S_IWGRP 0000020
124: #define S_IXGRP 0000010
125:
126: #define S_IRWXO 0000007
127: #define S_IROTH 0000004
128: #define S_IWOTH 0000002
129: #define S_IXOTH 0000001
130:
131: #if __XPG_VISIBLE || __BSD_VISIBLE
132: #define S_IFMT 0170000
133: #define S_IFIFO 0010000
134: #define S_IFCHR 0020000
135: #define S_IFDIR 0040000
136: #define S_IFBLK 0060000
137: #define S_IFREG 0100000
138: #define S_IFLNK 0120000
139: #define S_IFSOCK 0140000
140: #define S_ISVTX 0001000
141: #endif
142:
143: #define S_ISDIR(m) ((m & 0170000) == 0040000)
144: #define S_ISCHR(m) ((m & 0170000) == 0020000)
145: #define S_ISBLK(m) ((m & 0170000) == 0060000)
146: #define S_ISREG(m) ((m & 0170000) == 0100000)
147: #define S_ISFIFO(m) ((m & 0170000) == 0010000)
148: #if __POSIX_VISIBLE >= 200112 || __BSD_VISIBLE
149: #define S_ISLNK(m) ((m & 0170000) == 0120000)
150: #define S_ISSOCK(m) ((m & 0170000) == 0140000)
151: #endif
152:
153: #if __BSD_VISIBLE
154: #define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
155:
156: #define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
157:
158: #define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
159:
160: #define S_BLKSIZE 512
161:
162: 163: 164: 165: 166:
167: #define UF_SETTABLE 0x0000ffff
168: #define UF_NODUMP 0x00000001
169: #define UF_IMMUTABLE 0x00000002
170: #define UF_APPEND 0x00000004
171: #define UF_OPAQUE 0x00000008
172: 173: 174:
175: #define SF_SETTABLE 0xffff0000
176: #define SF_ARCHIVED 0x00010000
177: #define SF_IMMUTABLE 0x00020000
178: #define SF_APPEND 0x00040000
179:
180: #ifdef _KERNEL
181: 182: 183:
184: #define OPAQUE (UF_OPAQUE)
185: #define APPEND (UF_APPEND | SF_APPEND)
186: #define IMMUTABLE (UF_IMMUTABLE | SF_IMMUTABLE)
187: #endif
188: #endif
189:
190: #if __POSIX_VISIBLE >= 200809
191: #define UTIME_NOW -2L
192: #define UTIME_OMIT -1L
193: #endif
194:
195: #ifndef _KERNEL
196: __BEGIN_DECLS
197: int chmod(const char *, mode_t);
198: int __libc_fstat(int, struct stat *);
199: int mknod(const char *, mode_t, dev_t);
200: int mkdir(const char *, mode_t);
201: int mkfifo(const char *, mode_t);
202: int stat(const char *, struct stat *);
203: mode_t umask(mode_t);
204: #if __POSIX_VISIBLE >= 200809
205: int fchmodat(int, const char *, mode_t, int);
206: int fstatat(int, const char *, struct stat *, int);
207: int mkdirat(int, const char *, mode_t);
208: int mkfifoat(int, const char *, mode_t);
209: int mknodat(int, const char *, mode_t, dev_t);
210: int utimensat(int, const char *, const struct timespec [2], int);
211: int futimens(int, const struct timespec [2]);
212: #endif
213: #if __BSD_VISIBLE
214: int chflags(const char *, unsigned int);
215: int fchflags(int, unsigned int);
216: int fchmod(int, mode_t);
217: int lstat(const char *, struct stat *);
218: int isfdtype(int, int);
219: #endif
220: __END_DECLS
221: #endif
222: #endif