]> git.saurik.com Git - apple/xnu.git/blob - bsd/sys/stat.h
xnu-1228.9.59.tar.gz
[apple/xnu.git] / bsd / sys / stat.h
1 /*
2 * Copyright (c) 2000-2008 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
29 /*-
30 * Copyright (c) 1982, 1986, 1989, 1993
31 * The Regents of the University of California. All rights reserved.
32 * (c) UNIX System Laboratories, Inc.
33 * All or some portions of this file are derived from material licensed
34 * to the University of California by American Telephone and Telegraph
35 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
36 * the permission of UNIX System Laboratories, Inc.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 3. All advertising materials mentioning features or use of this software
47 * must display the following acknowledgement:
48 * This product includes software developed by the University of
49 * California, Berkeley and its contributors.
50 * 4. Neither the name of the University nor the names of its contributors
51 * may be used to endorse or promote products derived from this software
52 * without specific prior written permission.
53 *
54 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * SUCH DAMAGE.
65 *
66 * @(#)stat.h 8.9 (Berkeley) 8/17/94
67 */
68
69
70 #ifndef _SYS_STAT_H_
71 #define _SYS_STAT_H_
72
73 #include <sys/_types.h>
74 #include <sys/cdefs.h>
75 #ifdef KERNEL
76 #include <machine/types.h>
77 #else /* !KERNEL */
78 #include <Availability.h>
79 #endif /* KERNEL */
80
81 /* [XSI] The timespec structure may be defined as described in <time.h> */
82 #define __need_struct_timespec
83 #ifdef KERNEL
84 #define __need_struct_user_timespec
85 #endif /* KERNEL */
86 #include <sys/_structs.h>
87
88 /*
89 * [XSI] The blkcnt_t, blksize_t, dev_t, ino_t, mode_t, nlink_t, uid_t,
90 * gid_t, off_t, and time_t types shall be defined as described in
91 * <sys/types.h>.
92 */
93 #ifndef _BLKCNT_T
94 typedef __darwin_blkcnt_t blkcnt_t;
95 #define _BLKCNT_T
96 #endif
97
98 #ifndef _BLKSIZE_T
99 typedef __darwin_blksize_t blksize_t;
100 #define _BLKSIZE_T
101 #endif
102
103 #ifndef _DEV_T
104 typedef __darwin_dev_t dev_t; /* device number */
105 #define _DEV_T
106 #endif
107
108 #ifndef _INO_T
109 typedef __darwin_ino_t ino_t; /* inode number */
110 #define _INO_T
111 #endif
112
113 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
114 #ifndef _INO64_T
115 typedef __darwin_ino64_t ino64_t; /* 64bit inode number */
116 #define _INO64_T
117 #endif
118 #endif /* !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) */
119
120 #ifndef _MODE_T
121 typedef __darwin_mode_t mode_t;
122 #define _MODE_T
123 #endif
124
125 #ifndef _NLINK_T
126 typedef __uint16_t nlink_t; /* link count */
127 #define _NLINK_T
128 #endif
129
130 #ifndef _UID_T
131 typedef __darwin_uid_t uid_t; /* user id */
132 #define _UID_T
133 #endif
134
135 #ifndef _GID_T
136 typedef __darwin_gid_t gid_t;
137 #define _GID_T
138 #endif
139
140 #ifndef _OFF_T
141 typedef __darwin_off_t off_t;
142 #define _OFF_T
143 #endif
144
145 #ifndef _TIME_T
146 #define _TIME_T
147 typedef __darwin_time_t time_t;
148 #endif
149
150
151 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
152 /*
153 * XXX So deprecated, it would make your head spin
154 *
155 * The old stat structure. In fact, this is not used by the kernel at all,
156 * and should not be used by user space, and should be removed from this
157 * header file entirely (along with the unused cvtstat() prototype in
158 * vnode_internal.h).
159 */
160 struct ostat {
161 __uint16_t st_dev; /* inode's device */
162 ino_t st_ino; /* inode's number */
163 mode_t st_mode; /* inode protection mode */
164 nlink_t st_nlink; /* number of hard links */
165 __uint16_t st_uid; /* user ID of the file's owner */
166 __uint16_t st_gid; /* group ID of the file's group */
167 __uint16_t st_rdev; /* device type */
168 __int32_t st_size; /* file size, in bytes */
169 struct timespec st_atimespec; /* time of last access */
170 struct timespec st_mtimespec; /* time of last data modification */
171 struct timespec st_ctimespec; /* time of last file status change */
172 __int32_t st_blksize; /* optimal blocksize for I/O */
173 __int32_t st_blocks; /* blocks allocated for file */
174 __uint32_t st_flags; /* user defined flags for file */
175 __uint32_t st_gen; /* file generation number */
176 };
177
178 #define __DARWIN_STRUCT_STAT64_TIMES \
179 struct timespec st_atimespec; /* time of last access */ \
180 struct timespec st_mtimespec; /* time of last data modification */ \
181 struct timespec st_ctimespec; /* time of last status change */ \
182 struct timespec st_birthtimespec; /* time of file creation(birth) */
183
184 #else /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
185
186 #define __DARWIN_STRUCT_STAT64_TIMES \
187 time_t st_atime; /* [XSI] Time of last access */ \
188 long st_atimensec; /* nsec of last access */ \
189 time_t st_mtime; /* [XSI] Last data modification time */ \
190 long st_mtimensec; /* last data modification nsec */ \
191 time_t st_ctime; /* [XSI] Time of last status change */ \
192 long st_ctimensec; /* nsec of last status change */ \
193 time_t st_birthtime; /* File creation time(birth) */ \
194 long st_birthtimensec; /* nsec of File creation time */
195
196 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
197
198 /*
199 * This structure is used as the second parameter to the fstat64(),
200 * lstat64(), and stat64() functions, and for struct stat when
201 * __DARWIN_64_BIT_INO_T is set. __DARWIN_STRUCT_STAT64 is defined
202 * above, depending on whether we use struct timespec or the direct
203 * components.
204 *
205 * This is simillar to stat except for 64bit inode number
206 * number instead of 32bit ino_t and the addition of create(birth) time.
207 */
208 #define __DARWIN_STRUCT_STAT64 { \
209 dev_t st_dev; /* [XSI] ID of device containing file */ \
210 mode_t st_mode; /* [XSI] Mode of file (see below) */ \
211 nlink_t st_nlink; /* [XSI] Number of hard links */ \
212 __darwin_ino64_t st_ino; /* [XSI] File serial number */ \
213 uid_t st_uid; /* [XSI] User ID of the file */ \
214 gid_t st_gid; /* [XSI] Group ID of the file */ \
215 dev_t st_rdev; /* [XSI] Device ID */ \
216 __DARWIN_STRUCT_STAT64_TIMES \
217 off_t st_size; /* [XSI] file size, in bytes */ \
218 blkcnt_t st_blocks; /* [XSI] blocks allocated for file */ \
219 blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */ \
220 __uint32_t st_flags; /* user defined flags for file */ \
221 __uint32_t st_gen; /* file generation number */ \
222 __int32_t st_lspare; /* RESERVED: DO NOT USE! */ \
223 __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */ \
224 }
225
226 /*
227 * [XSI] This structure is used as the second parameter to the fstat(),
228 * lstat(), and stat() functions.
229 */
230 #if __DARWIN_64_BIT_INO_T
231
232 struct stat __DARWIN_STRUCT_STAT64;
233
234 #else /* !__DARWIN_64_BIT_INO_T */
235
236 struct stat {
237 dev_t st_dev; /* [XSI] ID of device containing file */
238 ino_t st_ino; /* [XSI] File serial number */
239 mode_t st_mode; /* [XSI] Mode of file (see below) */
240 nlink_t st_nlink; /* [XSI] Number of hard links */
241 uid_t st_uid; /* [XSI] User ID of the file */
242 gid_t st_gid; /* [XSI] Group ID of the file */
243 dev_t st_rdev; /* [XSI] Device ID */
244 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
245 struct timespec st_atimespec; /* time of last access */
246 struct timespec st_mtimespec; /* time of last data modification */
247 struct timespec st_ctimespec; /* time of last status change */
248 #else
249 time_t st_atime; /* [XSI] Time of last access */
250 long st_atimensec; /* nsec of last access */
251 time_t st_mtime; /* [XSI] Last data modification time */
252 long st_mtimensec; /* last data modification nsec */
253 time_t st_ctime; /* [XSI] Time of last status change */
254 long st_ctimensec; /* nsec of last status change */
255 #endif
256 off_t st_size; /* [XSI] file size, in bytes */
257 blkcnt_t st_blocks; /* [XSI] blocks allocated for file */
258 blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */
259 __uint32_t st_flags; /* user defined flags for file */
260 __uint32_t st_gen; /* file generation number */
261 __int32_t st_lspare; /* RESERVED: DO NOT USE! */
262 __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */
263 };
264
265 #endif /* __DARWIN_64_BIT_INO_T */
266
267 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
268
269 #if !__DARWIN_ONLY_64_BIT_INO_T
270
271 struct stat64 __DARWIN_STRUCT_STAT64;
272
273 #endif /* !__DARWIN_ONLY_64_BIT_INO_T */
274
275 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
276
277
278 #ifdef KERNEL
279 /* LP64 version of struct stat. time_t (see timespec) is a long and must
280 * grow when we're dealing with a 64-bit process.
281 * WARNING - keep in sync with struct stat
282 */
283
284 struct user_stat {
285 dev_t st_dev; /* [XSI] ID of device containing file */
286 ino_t st_ino; /* [XSI] File serial number */
287 mode_t st_mode; /* [XSI] Mode of file (see below) */
288 nlink_t st_nlink; /* [XSI] Number of hard links */
289 uid_t st_uid; /* [XSI] User ID of the file */
290 gid_t st_gid; /* [XSI] Group ID of the file */
291 dev_t st_rdev; /* [XSI] Device ID */
292 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
293 struct user_timespec st_atimespec; /* time of last access */
294 struct user_timespec st_mtimespec; /* time of last data modification */
295 struct user_timespec st_ctimespec; /* time of last status change */
296 #else
297 user_time_t st_atime; /* [XSI] Time of last access */
298 __int64_t st_atimensec; /* nsec of last access */
299 user_time_t st_mtime; /* [XSI] Last data modification */
300 __int64_t st_mtimensec; /* last data modification nsec */
301 user_time_t st_ctime; /* [XSI] Time of last status change */
302 __int64_t st_ctimensec; /* nsec of last status change */
303 #endif
304 off_t st_size; /* [XSI] File size, in bytes */
305 blkcnt_t st_blocks; /* [XSI] Blocks allocated for file */
306 blksize_t st_blksize; /* [XSI] Optimal blocksize for I/O */
307 __uint32_t st_flags; /* user defined flags for file */
308 __uint32_t st_gen; /* file generation number */
309 __int32_t st_lspare; /* RESERVED: DO NOT USE! */
310 __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */
311 };
312
313 extern void munge_stat(struct stat *sbp, struct user_stat *usbp);
314
315
316 struct user_stat64 {
317 dev_t st_dev; /* [XSI] ID of device containing file */
318 mode_t st_mode; /* [XSI] Mode of file (see below) */
319 nlink_t st_nlink; /* [XSI] Number of hard links */
320 ino64_t st_ino; /* [XSI] File serial number */
321 uid_t st_uid; /* [XSI] User ID of the file */
322 gid_t st_gid; /* [XSI] Group ID of the file */
323 dev_t st_rdev; /* [XSI] Device ID */
324 #ifndef _POSIX_C_SOURCE
325 struct user_timespec st_atimespec; /* time of last access */
326 struct user_timespec st_mtimespec; /* time of last data modification */
327 struct user_timespec st_ctimespec; /* time of last status change */
328 struct user_timespec st_birthtimespec; /* time of file creation(birth) */
329 #else
330 user_time_t st_atime; /* [XSI] Time of last access */
331 __int64_t st_atimensec; /* nsec of last access */
332 user_time_t st_mtime; /* [XSI] Last data modification time */
333 __int64_t st_mtimensec; /* last data modification nsec */
334 user_time_t st_ctime; /* [XSI] Time of last status change */
335 __int64_t st_ctimensec; /* nsec of last status change */
336 user_time_t st_birthtime; /* File creation time(birth) */
337 __int64_t st_birthtimensec; /* nsec of File creation time */
338 #endif
339 off_t st_size; /* [XSI] file size, in bytes */
340 blkcnt_t st_blocks; /* [XSI] blocks allocated for file */
341 blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */
342 __uint32_t st_flags; /* user defined flags for file */
343 __uint32_t st_gen; /* file generation number */
344 __uint32_t st_lspare; /* RESERVED: DO NOT USE! */
345 __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */
346 };
347
348 extern void munge_stat64(struct stat64 *sbp, struct user_stat64 *usbp);
349
350 #endif // KERNEL
351
352
353 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
354 #define st_atime st_atimespec.tv_sec
355 #define st_mtime st_mtimespec.tv_sec
356 #define st_ctime st_ctimespec.tv_sec
357 #define st_birthtime st_birthtimespec.tv_sec
358 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
359
360 /*
361 * [XSI] The following are symbolic names for the values of type mode_t. They
362 * are bitmap values.
363 */
364 #ifndef S_IFMT
365 /* File type */
366 #define S_IFMT 0170000 /* [XSI] type of file mask */
367 #define S_IFIFO 0010000 /* [XSI] named pipe (fifo) */
368 #define S_IFCHR 0020000 /* [XSI] character special */
369 #define S_IFDIR 0040000 /* [XSI] directory */
370 #define S_IFBLK 0060000 /* [XSI] block special */
371 #define S_IFREG 0100000 /* [XSI] regular */
372 #define S_IFLNK 0120000 /* [XSI] symbolic link */
373 #define S_IFSOCK 0140000 /* [XSI] socket */
374 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
375 #define S_IFWHT 0160000 /* whiteout */
376 #define S_IFXATTR 0200000 /* extended attribute */
377 #endif
378
379 /* File mode */
380 /* Read, write, execute/search by owner */
381 #define S_IRWXU 0000700 /* [XSI] RWX mask for owner */
382 #define S_IRUSR 0000400 /* [XSI] R for owner */
383 #define S_IWUSR 0000200 /* [XSI] W for owner */
384 #define S_IXUSR 0000100 /* [XSI] X for owner */
385 /* Read, write, execute/search by group */
386 #define S_IRWXG 0000070 /* [XSI] RWX mask for group */
387 #define S_IRGRP 0000040 /* [XSI] R for group */
388 #define S_IWGRP 0000020 /* [XSI] W for group */
389 #define S_IXGRP 0000010 /* [XSI] X for group */
390 /* Read, write, execute/search by others */
391 #define S_IRWXO 0000007 /* [XSI] RWX mask for other */
392 #define S_IROTH 0000004 /* [XSI] R for other */
393 #define S_IWOTH 0000002 /* [XSI] W for other */
394 #define S_IXOTH 0000001 /* [XSI] X for other */
395
396 #define S_ISUID 0004000 /* [XSI] set user id on execution */
397 #define S_ISGID 0002000 /* [XSI] set group id on execution */
398 #define S_ISVTX 0001000 /* [XSI] directory restrcted delete */
399
400 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
401 #define S_ISTXT S_ISVTX /* sticky bit: not supported */
402 #define S_IREAD S_IRUSR /* backward compatability */
403 #define S_IWRITE S_IWUSR /* backward compatability */
404 #define S_IEXEC S_IXUSR /* backward compatability */
405 #endif
406 #endif /* !S_IFMT */
407
408 /*
409 * [XSI] The following macros shall be provided to test whether a file is
410 * of the specified type. The value m supplied to the macros is the value
411 * of st_mode from a stat structure. The macro shall evaluate to a non-zero
412 * value if the test is true; 0 if the test is false.
413 */
414 #define S_ISBLK(m) (((m) & 0170000) == 0060000) /* block special */
415 #define S_ISCHR(m) (((m) & 0170000) == 0020000) /* char special */
416 #define S_ISDIR(m) (((m) & 0170000) == 0040000) /* directory */
417 #define S_ISFIFO(m) (((m) & 0170000) == 0010000) /* fifo or socket */
418 #define S_ISREG(m) (((m) & 0170000) == 0100000) /* regular file */
419 #define S_ISLNK(m) (((m) & 0170000) == 0120000) /* symbolic link */
420 #define S_ISSOCK(m) (((m) & 0170000) == 0140000) /* socket */
421 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
422 #define S_ISWHT(m) (((m) & 0170000) == 0160000) /* whiteout */
423 #define S_ISXATTR(m) (((m) & 0200000) == 0200000) /* extended attribute */
424 #endif
425
426 /*
427 * [XSI] The implementation may implement message queues, semaphores, or
428 * shared memory objects as distinct file types. The following macros
429 * shall be provided to test whether a file is of the specified type.
430 * The value of the buf argument supplied to the macros is a pointer to
431 * a stat structure. The macro shall evaluate to a non-zero value if
432 * the specified object is implemented as a distinct file type and the
433 * specified file type is contained in the stat structure referenced by
434 * buf. Otherwise, the macro shall evaluate to zero.
435 *
436 * NOTE: The current implementation does not do this, although
437 * this may change in future revisions, and co currently only
438 * provides these macros to ensure source compatability with
439 * implementations which do.
440 */
441 #define S_TYPEISMQ(buf) (0) /* Test for a message queue */
442 #define S_TYPEISSEM(buf) (0) /* Test for a semaphore */
443 #define S_TYPEISSHM(buf) (0) /* Test for a shared memory object */
444
445 /*
446 * [TYM] The implementation may implement typed memory objects as distinct
447 * file types, and the following macro shall test whether a file is of the
448 * specified type. The value of the buf argument supplied to the macros is
449 * a pointer to a stat structure. The macro shall evaluate to a non-zero
450 * value if the specified object is implemented as a distinct file type and
451 * the specified file type is contained in the stat structure referenced by
452 * buf. Otherwise, the macro shall evaluate to zero.
453 *
454 * NOTE: The current implementation does not do this, although
455 * this may change in future revisions, and co currently only
456 * provides this macro to ensure source compatability with
457 * implementations which do.
458 */
459 #define S_TYPEISTMO(buf) (0) /* Test for a typed memory object */
460
461
462 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
463 #define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
464 /* 7777 */
465 #define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
466 /* 0666 */
467 #define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
468
469 #define S_BLKSIZE 512 /* block size used in the stat struct */
470
471 /*
472 * Definitions of flags stored in file flags word.
473 *
474 * Super-user and owner changeable flags.
475 */
476 #define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */
477 #define UF_NODUMP 0x00000001 /* do not dump file */
478 #define UF_IMMUTABLE 0x00000002 /* file may not be changed */
479 #define UF_APPEND 0x00000004 /* writes to file may only append */
480 #define UF_OPAQUE 0x00000008 /* directory is opaque wrt. union */
481 /*
482 * The following bit is reserved for FreeBSD. It is not implemented
483 * in Mac OS X.
484 */
485 /* #define UF_NOUNLINK 0x00000010 */ /* file may not be removed or renamed */
486 /* Bits 0x0020 through 0x4000 are currently undefined. */
487 #define UF_HIDDEN 0x00008000 /* hint that this item should not be */
488 /* displayed in a GUI */
489 /*
490 * Super-user changeable flags.
491 */
492 #define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */
493 #define SF_ARCHIVED 0x00010000 /* file is archived */
494 #define SF_IMMUTABLE 0x00020000 /* file may not be changed */
495 #define SF_APPEND 0x00040000 /* writes to file may only append */
496 /*
497 * The following two bits are reserved for FreeBSD. They are not
498 * implemented in Mac OS X.
499 */
500 /* #define SF_NOUNLINK 0x00100000 */ /* file may not be removed or renamed */
501 /* #define SF_SNAPSHOT 0x00200000 */ /* snapshot inode */
502 /* NOTE: There is no SF_HIDDEN bit. */
503
504 #ifdef KERNEL
505 /*
506 * Shorthand abbreviations of above.
507 */
508 #define OPAQUE (UF_OPAQUE)
509 #define APPEND (UF_APPEND | SF_APPEND)
510 #define IMMUTABLE (UF_IMMUTABLE | SF_IMMUTABLE)
511 #endif
512 #endif
513
514 #ifndef KERNEL
515
516 __BEGIN_DECLS
517 /* [XSI] */
518 int chmod(const char *, mode_t) __DARWIN_ALIAS(chmod);
519 int fchmod(int, mode_t) __DARWIN_ALIAS(fchmod);
520 int fstat(int, struct stat *) __DARWIN_INODE64(fstat);
521 int lstat(const char *, struct stat *) __DARWIN_INODE64(lstat);
522 int mkdir(const char *, mode_t);
523 int mkfifo(const char *, mode_t);
524 int stat(const char *, struct stat *) __DARWIN_INODE64(stat);
525 int mknod(const char *, mode_t, dev_t);
526 mode_t umask(mode_t);
527
528 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
529 #ifndef _FILESEC_T
530 struct _filesec;
531 typedef struct _filesec *filesec_t;
532 #define _FILESEC_T
533 #endif
534 int chflags(const char *, __uint32_t);
535 int chmodx_np(const char *, filesec_t);
536 int fchflags(int, __uint32_t);
537 int fchmodx_np(int, filesec_t);
538 int fstatx_np(int, struct stat *, filesec_t) __DARWIN_INODE64(fstatx_np);
539 int lchflags(const char *, __uint32_t);
540 int lchmod(const char *, mode_t);
541 int lstatx_np(const char *, struct stat *, filesec_t) __DARWIN_INODE64(lstatx_np);
542 int mkdirx_np(const char *, filesec_t);
543 int mkfifox_np(const char *, filesec_t);
544 int statx_np(const char *, struct stat *, filesec_t) __DARWIN_INODE64(statx_np);
545 int umaskx_np(filesec_t);
546
547 #if !__DARWIN_ONLY_64_BIT_INO_T
548 /* The following deprecated routines are simillar to stat and friends except provide struct stat64 instead of struct stat */
549 int fstatx64_np(int, struct stat64 *, filesec_t) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA);
550 int lstatx64_np(const char *, struct stat64 *, filesec_t) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA);
551 int statx64_np(const char *, struct stat64 *, filesec_t) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA);
552 int fstat64(int, struct stat64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA);
553 int lstat64(const char *, struct stat64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA);
554 int stat64(const char *, struct stat64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA);
555 #endif /* !__DARWIN_ONLY_64_BIT_INO_T */
556 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
557
558 __END_DECLS
559 #endif /* !KERNEL */
560 #endif /* !_SYS_STAT_H_ */