xref: /xnu-10002.41.9/bsd/sys/stat.h (revision 699cd48037512bf4380799317ca44ca453c82f57)
1*699cd480SApple OSS Distributions /*
2*699cd480SApple OSS Distributions  * Copyright (c) 2000-2014 Apple Inc. All rights reserved.
3*699cd480SApple OSS Distributions  *
4*699cd480SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*699cd480SApple OSS Distributions  *
6*699cd480SApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*699cd480SApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*699cd480SApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*699cd480SApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*699cd480SApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*699cd480SApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*699cd480SApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*699cd480SApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*699cd480SApple OSS Distributions  *
15*699cd480SApple OSS Distributions  * Please obtain a copy of the License at
16*699cd480SApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*699cd480SApple OSS Distributions  *
18*699cd480SApple OSS Distributions  * The Original Code and all software distributed under the License are
19*699cd480SApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*699cd480SApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*699cd480SApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*699cd480SApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*699cd480SApple OSS Distributions  * Please see the License for the specific language governing rights and
24*699cd480SApple OSS Distributions  * limitations under the License.
25*699cd480SApple OSS Distributions  *
26*699cd480SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*699cd480SApple OSS Distributions  */
28*699cd480SApple OSS Distributions /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
29*699cd480SApple OSS Distributions /*-
30*699cd480SApple OSS Distributions  * Copyright (c) 1982, 1986, 1989, 1993
31*699cd480SApple OSS Distributions  *	The Regents of the University of California.  All rights reserved.
32*699cd480SApple OSS Distributions  * (c) UNIX System Laboratories, Inc.
33*699cd480SApple OSS Distributions  * All or some portions of this file are derived from material licensed
34*699cd480SApple OSS Distributions  * to the University of California by American Telephone and Telegraph
35*699cd480SApple OSS Distributions  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
36*699cd480SApple OSS Distributions  * the permission of UNIX System Laboratories, Inc.
37*699cd480SApple OSS Distributions  *
38*699cd480SApple OSS Distributions  * Redistribution and use in source and binary forms, with or without
39*699cd480SApple OSS Distributions  * modification, are permitted provided that the following conditions
40*699cd480SApple OSS Distributions  * are met:
41*699cd480SApple OSS Distributions  * 1. Redistributions of source code must retain the above copyright
42*699cd480SApple OSS Distributions  *    notice, this list of conditions and the following disclaimer.
43*699cd480SApple OSS Distributions  * 2. Redistributions in binary form must reproduce the above copyright
44*699cd480SApple OSS Distributions  *    notice, this list of conditions and the following disclaimer in the
45*699cd480SApple OSS Distributions  *    documentation and/or other materials provided with the distribution.
46*699cd480SApple OSS Distributions  * 3. All advertising materials mentioning features or use of this software
47*699cd480SApple OSS Distributions  *    must display the following acknowledgement:
48*699cd480SApple OSS Distributions  *	This product includes software developed by the University of
49*699cd480SApple OSS Distributions  *	California, Berkeley and its contributors.
50*699cd480SApple OSS Distributions  * 4. Neither the name of the University nor the names of its contributors
51*699cd480SApple OSS Distributions  *    may be used to endorse or promote products derived from this software
52*699cd480SApple OSS Distributions  *    without specific prior written permission.
53*699cd480SApple OSS Distributions  *
54*699cd480SApple OSS Distributions  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55*699cd480SApple OSS Distributions  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56*699cd480SApple OSS Distributions  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57*699cd480SApple OSS Distributions  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58*699cd480SApple OSS Distributions  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59*699cd480SApple OSS Distributions  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60*699cd480SApple OSS Distributions  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61*699cd480SApple OSS Distributions  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62*699cd480SApple OSS Distributions  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63*699cd480SApple OSS Distributions  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64*699cd480SApple OSS Distributions  * SUCH DAMAGE.
65*699cd480SApple OSS Distributions  *
66*699cd480SApple OSS Distributions  *	@(#)stat.h	8.9 (Berkeley) 8/17/94
67*699cd480SApple OSS Distributions  */
68*699cd480SApple OSS Distributions 
69*699cd480SApple OSS Distributions 
70*699cd480SApple OSS Distributions #ifndef _SYS_STAT_H_
71*699cd480SApple OSS Distributions #define _SYS_STAT_H_
72*699cd480SApple OSS Distributions 
73*699cd480SApple OSS Distributions #include <sys/_types.h>
74*699cd480SApple OSS Distributions #include <sys/cdefs.h>
75*699cd480SApple OSS Distributions #ifdef KERNEL
76*699cd480SApple OSS Distributions #include <machine/types.h>
77*699cd480SApple OSS Distributions #else /* !KERNEL */
78*699cd480SApple OSS Distributions #include <Availability.h>
79*699cd480SApple OSS Distributions #endif /* KERNEL */
80*699cd480SApple OSS Distributions 
81*699cd480SApple OSS Distributions /* [XSI] The timespec structure may be defined as described in <time.h> */
82*699cd480SApple OSS Distributions #include <sys/_types/_timespec.h>
83*699cd480SApple OSS Distributions #ifdef KERNEL
84*699cd480SApple OSS Distributions #include <sys/_types/_user64_timespec.h>
85*699cd480SApple OSS Distributions #include <sys/_types/_user32_timespec.h>
86*699cd480SApple OSS Distributions #endif /* KERNEL */
87*699cd480SApple OSS Distributions 
88*699cd480SApple OSS Distributions /*
89*699cd480SApple OSS Distributions  * [XSI] The blkcnt_t, blksize_t, dev_t, ino_t, mode_t, nlink_t, uid_t,
90*699cd480SApple OSS Distributions  * gid_t, off_t, and time_t types shall be defined as described in
91*699cd480SApple OSS Distributions  * <sys/types.h>.
92*699cd480SApple OSS Distributions  */
93*699cd480SApple OSS Distributions #include <sys/_types/_blkcnt_t.h>
94*699cd480SApple OSS Distributions #include <sys/_types/_blksize_t.h>
95*699cd480SApple OSS Distributions #include <sys/_types/_dev_t.h>                  /* device number */
96*699cd480SApple OSS Distributions #include <sys/_types/_ino_t.h>
97*699cd480SApple OSS Distributions 
98*699cd480SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
99*699cd480SApple OSS Distributions #include <sys/_types/_ino64_t.h>
100*699cd480SApple OSS Distributions #endif /* !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) */
101*699cd480SApple OSS Distributions 
102*699cd480SApple OSS Distributions #include <sys/_types/_mode_t.h>
103*699cd480SApple OSS Distributions #include <sys/_types/_nlink_t.h>
104*699cd480SApple OSS Distributions #include <sys/_types/_uid_t.h>
105*699cd480SApple OSS Distributions #include <sys/_types/_gid_t.h>
106*699cd480SApple OSS Distributions #include <sys/_types/_off_t.h>
107*699cd480SApple OSS Distributions #include <sys/_types/_time_t.h>
108*699cd480SApple OSS Distributions 
109*699cd480SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
110*699cd480SApple OSS Distributions /*
111*699cd480SApple OSS Distributions  * XXX So deprecated, it would make your head spin
112*699cd480SApple OSS Distributions  *
113*699cd480SApple OSS Distributions  * The old stat structure.  In fact, this is not used by the kernel at all,
114*699cd480SApple OSS Distributions  * and should not be used by user space, and should be removed from this
115*699cd480SApple OSS Distributions  * header file entirely (along with the unused cvtstat() prototype in
116*699cd480SApple OSS Distributions  * vnode_internal.h).
117*699cd480SApple OSS Distributions  */
118*699cd480SApple OSS Distributions struct ostat {
119*699cd480SApple OSS Distributions 	__uint16_t      st_dev;         /* inode's device */
120*699cd480SApple OSS Distributions 	ino_t           st_ino;         /* inode's number */
121*699cd480SApple OSS Distributions 	mode_t          st_mode;        /* inode protection mode */
122*699cd480SApple OSS Distributions 	nlink_t         st_nlink;       /* number of hard links */
123*699cd480SApple OSS Distributions 	__uint16_t      st_uid;         /* user ID of the file's owner */
124*699cd480SApple OSS Distributions 	__uint16_t      st_gid;         /* group ID of the file's group */
125*699cd480SApple OSS Distributions 	__uint16_t      st_rdev;        /* device type */
126*699cd480SApple OSS Distributions 	__int32_t       st_size;        /* file size, in bytes */
127*699cd480SApple OSS Distributions 	struct  timespec st_atimespec;  /* time of last access */
128*699cd480SApple OSS Distributions 	struct  timespec st_mtimespec;  /* time of last data modification */
129*699cd480SApple OSS Distributions 	struct  timespec st_ctimespec;  /* time of last file status change */
130*699cd480SApple OSS Distributions 	__int32_t       st_blksize;     /* optimal blocksize for I/O */
131*699cd480SApple OSS Distributions 	__int32_t       st_blocks;      /* blocks allocated for file */
132*699cd480SApple OSS Distributions 	__uint32_t      st_flags;       /* user defined flags for file */
133*699cd480SApple OSS Distributions 	__uint32_t      st_gen;         /* file generation number */
134*699cd480SApple OSS Distributions };
135*699cd480SApple OSS Distributions 
136*699cd480SApple OSS Distributions #define __DARWIN_STRUCT_STAT64_TIMES \
137*699cd480SApple OSS Distributions 	struct timespec st_atimespec;           /* time of last access */ \
138*699cd480SApple OSS Distributions 	struct timespec st_mtimespec;           /* time of last data modification */ \
139*699cd480SApple OSS Distributions 	struct timespec st_ctimespec;           /* time of last status change */ \
140*699cd480SApple OSS Distributions 	struct timespec st_birthtimespec;       /* time of file creation(birth) */
141*699cd480SApple OSS Distributions 
142*699cd480SApple OSS Distributions #else /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
143*699cd480SApple OSS Distributions 
144*699cd480SApple OSS Distributions #define __DARWIN_STRUCT_STAT64_TIMES \
145*699cd480SApple OSS Distributions 	time_t		st_atime;               /* [XSI] Time of last access */ \
146*699cd480SApple OSS Distributions 	long		st_atimensec;           /* nsec of last access */ \
147*699cd480SApple OSS Distributions 	time_t		st_mtime;               /* [XSI] Last data modification time */ \
148*699cd480SApple OSS Distributions 	long		st_mtimensec;           /* last data modification nsec */ \
149*699cd480SApple OSS Distributions 	time_t		st_ctime;               /* [XSI] Time of last status change */ \
150*699cd480SApple OSS Distributions 	long		st_ctimensec;           /* nsec of last status change */ \
151*699cd480SApple OSS Distributions 	time_t		st_birthtime;           /*  File creation time(birth)  */ \
152*699cd480SApple OSS Distributions 	long		st_birthtimensec;       /* nsec of File creation time */
153*699cd480SApple OSS Distributions 
154*699cd480SApple OSS Distributions #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
155*699cd480SApple OSS Distributions 
156*699cd480SApple OSS Distributions /*
157*699cd480SApple OSS Distributions  * This structure is used as the second parameter to the fstat64(),
158*699cd480SApple OSS Distributions  * lstat64(), and stat64() functions, and for struct stat when
159*699cd480SApple OSS Distributions  * __DARWIN_64_BIT_INO_T is set. __DARWIN_STRUCT_STAT64 is defined
160*699cd480SApple OSS Distributions  * above, depending on whether we use struct timespec or the direct
161*699cd480SApple OSS Distributions  * components.
162*699cd480SApple OSS Distributions  *
163*699cd480SApple OSS Distributions  * This is simillar to stat except for 64bit inode number
164*699cd480SApple OSS Distributions  * number instead of 32bit ino_t and the addition of create(birth) time.
165*699cd480SApple OSS Distributions  */
166*699cd480SApple OSS Distributions #define __DARWIN_STRUCT_STAT64 { \
167*699cd480SApple OSS Distributions 	dev_t		st_dev;                 /* [XSI] ID of device containing file */ \
168*699cd480SApple OSS Distributions 	mode_t		st_mode;                /* [XSI] Mode of file (see below) */ \
169*699cd480SApple OSS Distributions 	nlink_t		st_nlink;               /* [XSI] Number of hard links */ \
170*699cd480SApple OSS Distributions 	__darwin_ino64_t st_ino;                /* [XSI] File serial number */ \
171*699cd480SApple OSS Distributions 	uid_t		st_uid;                 /* [XSI] User ID of the file */ \
172*699cd480SApple OSS Distributions 	gid_t		st_gid;                 /* [XSI] Group ID of the file */ \
173*699cd480SApple OSS Distributions 	dev_t		st_rdev;                /* [XSI] Device ID */ \
174*699cd480SApple OSS Distributions 	__DARWIN_STRUCT_STAT64_TIMES \
175*699cd480SApple OSS Distributions 	off_t		st_size;                /* [XSI] file size, in bytes */ \
176*699cd480SApple OSS Distributions 	blkcnt_t	st_blocks;              /* [XSI] blocks allocated for file */ \
177*699cd480SApple OSS Distributions 	blksize_t	st_blksize;             /* [XSI] optimal blocksize for I/O */ \
178*699cd480SApple OSS Distributions 	__uint32_t	st_flags;               /* user defined flags for file */ \
179*699cd480SApple OSS Distributions 	__uint32_t	st_gen;                 /* file generation number */ \
180*699cd480SApple OSS Distributions 	__int32_t	st_lspare;              /* RESERVED: DO NOT USE! */ \
181*699cd480SApple OSS Distributions 	__int64_t	st_qspare[2];           /* RESERVED: DO NOT USE! */ \
182*699cd480SApple OSS Distributions }
183*699cd480SApple OSS Distributions 
184*699cd480SApple OSS Distributions /*
185*699cd480SApple OSS Distributions  * [XSI] This structure is used as the second parameter to the fstat(),
186*699cd480SApple OSS Distributions  * lstat(), and stat() functions.
187*699cd480SApple OSS Distributions  */
188*699cd480SApple OSS Distributions #if __DARWIN_64_BIT_INO_T
189*699cd480SApple OSS Distributions 
190*699cd480SApple OSS Distributions struct stat __DARWIN_STRUCT_STAT64;
191*699cd480SApple OSS Distributions 
192*699cd480SApple OSS Distributions #else /* !__DARWIN_64_BIT_INO_T */
193*699cd480SApple OSS Distributions 
194*699cd480SApple OSS Distributions struct stat {
195*699cd480SApple OSS Distributions 	dev_t           st_dev;         /* [XSI] ID of device containing file */
196*699cd480SApple OSS Distributions 	ino_t           st_ino;         /* [XSI] File serial number */
197*699cd480SApple OSS Distributions 	mode_t          st_mode;        /* [XSI] Mode of file (see below) */
198*699cd480SApple OSS Distributions 	nlink_t         st_nlink;       /* [XSI] Number of hard links */
199*699cd480SApple OSS Distributions 	uid_t           st_uid;         /* [XSI] User ID of the file */
200*699cd480SApple OSS Distributions 	gid_t           st_gid;         /* [XSI] Group ID of the file */
201*699cd480SApple OSS Distributions 	dev_t           st_rdev;        /* [XSI] Device ID */
202*699cd480SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
203*699cd480SApple OSS Distributions 	struct  timespec st_atimespec;  /* time of last access */
204*699cd480SApple OSS Distributions 	struct  timespec st_mtimespec;  /* time of last data modification */
205*699cd480SApple OSS Distributions 	struct  timespec st_ctimespec;  /* time of last status change */
206*699cd480SApple OSS Distributions #else
207*699cd480SApple OSS Distributions 	time_t          st_atime;       /* [XSI] Time of last access */
208*699cd480SApple OSS Distributions 	long            st_atimensec;   /* nsec of last access */
209*699cd480SApple OSS Distributions 	time_t          st_mtime;       /* [XSI] Last data modification time */
210*699cd480SApple OSS Distributions 	long            st_mtimensec;   /* last data modification nsec */
211*699cd480SApple OSS Distributions 	time_t          st_ctime;       /* [XSI] Time of last status change */
212*699cd480SApple OSS Distributions 	long            st_ctimensec;   /* nsec of last status change */
213*699cd480SApple OSS Distributions #endif
214*699cd480SApple OSS Distributions 	off_t           st_size;        /* [XSI] file size, in bytes */
215*699cd480SApple OSS Distributions 	blkcnt_t        st_blocks;      /* [XSI] blocks allocated for file */
216*699cd480SApple OSS Distributions 	blksize_t       st_blksize;     /* [XSI] optimal blocksize for I/O */
217*699cd480SApple OSS Distributions 	__uint32_t      st_flags;       /* user defined flags for file */
218*699cd480SApple OSS Distributions 	__uint32_t      st_gen;         /* file generation number */
219*699cd480SApple OSS Distributions 	__int32_t       st_lspare;      /* RESERVED: DO NOT USE! */
220*699cd480SApple OSS Distributions 	__int64_t       st_qspare[2];   /* RESERVED: DO NOT USE! */
221*699cd480SApple OSS Distributions };
222*699cd480SApple OSS Distributions 
223*699cd480SApple OSS Distributions #endif /* __DARWIN_64_BIT_INO_T */
224*699cd480SApple OSS Distributions 
225*699cd480SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
226*699cd480SApple OSS Distributions 
227*699cd480SApple OSS Distributions #if !__DARWIN_ONLY_64_BIT_INO_T
228*699cd480SApple OSS Distributions 
229*699cd480SApple OSS Distributions struct stat64 __DARWIN_STRUCT_STAT64;
230*699cd480SApple OSS Distributions 
231*699cd480SApple OSS Distributions #endif /* !__DARWIN_ONLY_64_BIT_INO_T */
232*699cd480SApple OSS Distributions 
233*699cd480SApple OSS Distributions #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
234*699cd480SApple OSS Distributions 
235*699cd480SApple OSS Distributions 
236*699cd480SApple OSS Distributions #ifdef KERNEL
237*699cd480SApple OSS Distributions #ifdef BSD_KERNEL_PRIVATE
238*699cd480SApple OSS Distributions /* LP64 version of struct stat.  time_t (see timespec) is a long and must
239*699cd480SApple OSS Distributions  * grow when we're dealing with a 64-bit process.
240*699cd480SApple OSS Distributions  * WARNING - keep in sync with struct stat
241*699cd480SApple OSS Distributions  */
242*699cd480SApple OSS Distributions 
243*699cd480SApple OSS Distributions struct user64_stat {
244*699cd480SApple OSS Distributions 	dev_t           st_dev;         /* [XSI] ID of device containing file */
245*699cd480SApple OSS Distributions 	ino_t           st_ino;         /* [XSI] File serial number */
246*699cd480SApple OSS Distributions 	mode_t          st_mode;        /* [XSI] Mode of file (see below) */
247*699cd480SApple OSS Distributions 	nlink_t         st_nlink;       /* [XSI] Number of hard links */
248*699cd480SApple OSS Distributions 	uid_t           st_uid;         /* [XSI] User ID of the file */
249*699cd480SApple OSS Distributions 	gid_t           st_gid;         /* [XSI] Group ID of the file */
250*699cd480SApple OSS Distributions 	dev_t           st_rdev;        /* [XSI] Device ID */
251*699cd480SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
252*699cd480SApple OSS Distributions 	struct  user64_timespec st_atimespec; /* time of last access */
253*699cd480SApple OSS Distributions 	struct  user64_timespec st_mtimespec; /* time of last data modification */
254*699cd480SApple OSS Distributions 	struct  user64_timespec st_ctimespec; /* time of last status change */
255*699cd480SApple OSS Distributions #else
256*699cd480SApple OSS Distributions 	user64_time_t   st_atime;       /* [XSI] Time of last access */
257*699cd480SApple OSS Distributions 	user64_long_t   st_atimensec;   /* nsec of last access */
258*699cd480SApple OSS Distributions 	user64_time_t   st_mtime;       /* [XSI] Last data modification */
259*699cd480SApple OSS Distributions 	user64_long_t   st_mtimensec;   /* last data modification nsec */
260*699cd480SApple OSS Distributions 	user64_time_t   st_ctime;       /* [XSI] Time of last status change */
261*699cd480SApple OSS Distributions 	user64_long_t   st_ctimensec;   /* nsec of last status change */
262*699cd480SApple OSS Distributions #endif
263*699cd480SApple OSS Distributions 	off_t           st_size;        /* [XSI] File size, in bytes */
264*699cd480SApple OSS Distributions 	blkcnt_t        st_blocks;      /* [XSI] Blocks allocated for file */
265*699cd480SApple OSS Distributions 	blksize_t       st_blksize;     /* [XSI] Optimal blocksize for I/O */
266*699cd480SApple OSS Distributions 	__uint32_t      st_flags;       /* user defined flags for file */
267*699cd480SApple OSS Distributions 	__uint32_t      st_gen;         /* file generation number */
268*699cd480SApple OSS Distributions 	__int32_t       st_lspare;      /* RESERVED: DO NOT USE! */
269*699cd480SApple OSS Distributions 	__int64_t       st_qspare[2];   /* RESERVED: DO NOT USE! */
270*699cd480SApple OSS Distributions };
271*699cd480SApple OSS Distributions 
272*699cd480SApple OSS Distributions /* ILP32 version of struct stat.
273*699cd480SApple OSS Distributions  * WARNING - keep in sync with struct stat
274*699cd480SApple OSS Distributions  */
275*699cd480SApple OSS Distributions 
276*699cd480SApple OSS Distributions struct user32_stat {
277*699cd480SApple OSS Distributions 	dev_t           st_dev;         /* [XSI] ID of device containing file */
278*699cd480SApple OSS Distributions 	ino_t           st_ino;         /* [XSI] File serial number */
279*699cd480SApple OSS Distributions 	mode_t          st_mode;        /* [XSI] Mode of file (see below) */
280*699cd480SApple OSS Distributions 	nlink_t         st_nlink;       /* [XSI] Number of hard links */
281*699cd480SApple OSS Distributions 	uid_t           st_uid;         /* [XSI] User ID of the file */
282*699cd480SApple OSS Distributions 	gid_t           st_gid;         /* [XSI] Group ID of the file */
283*699cd480SApple OSS Distributions 	dev_t           st_rdev;        /* [XSI] Device ID */
284*699cd480SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
285*699cd480SApple OSS Distributions 	struct  user32_timespec st_atimespec; /* time of last access */
286*699cd480SApple OSS Distributions 	struct  user32_timespec st_mtimespec; /* time of last data modification */
287*699cd480SApple OSS Distributions 	struct  user32_timespec st_ctimespec; /* time of last status change */
288*699cd480SApple OSS Distributions #else
289*699cd480SApple OSS Distributions 	user32_time_t   st_atime;       /* [XSI] Time of last access */
290*699cd480SApple OSS Distributions 	user32_long_t   st_atimensec;   /* nsec of last access */
291*699cd480SApple OSS Distributions 	user32_time_t   st_mtime;       /* [XSI] Last data modification */
292*699cd480SApple OSS Distributions 	user32_long_t   st_mtimensec;   /* last data modification nsec */
293*699cd480SApple OSS Distributions 	user32_time_t   st_ctime;       /* [XSI] Time of last status change */
294*699cd480SApple OSS Distributions 	user32_long_t   st_ctimensec;   /* nsec of last status change */
295*699cd480SApple OSS Distributions #endif
296*699cd480SApple OSS Distributions 	off_t           st_size;        /* [XSI] File size, in bytes */
297*699cd480SApple OSS Distributions 	blkcnt_t        st_blocks;      /* [XSI] Blocks allocated for file */
298*699cd480SApple OSS Distributions 	blksize_t       st_blksize;     /* [XSI] Optimal blocksize for I/O */
299*699cd480SApple OSS Distributions 	__uint32_t      st_flags;       /* user defined flags for file */
300*699cd480SApple OSS Distributions 	__uint32_t      st_gen;         /* file generation number */
301*699cd480SApple OSS Distributions 	__int32_t       st_lspare;      /* RESERVED: DO NOT USE! */
302*699cd480SApple OSS Distributions 	__int64_t       st_qspare[2];   /* RESERVED: DO NOT USE! */
303*699cd480SApple OSS Distributions };
304*699cd480SApple OSS Distributions 
305*699cd480SApple OSS Distributions extern void munge_user64_stat(struct stat *sbp, struct user64_stat *usbp);
306*699cd480SApple OSS Distributions extern void munge_user32_stat(struct stat *sbp, struct user32_stat *usbp);
307*699cd480SApple OSS Distributions 
308*699cd480SApple OSS Distributions 
309*699cd480SApple OSS Distributions struct user64_stat64 {
310*699cd480SApple OSS Distributions 	dev_t           st_dev;                                 /* [XSI] ID of device containing file */
311*699cd480SApple OSS Distributions 	mode_t          st_mode;                                /* [XSI] Mode of file (see below) */
312*699cd480SApple OSS Distributions 	nlink_t         st_nlink;                               /* [XSI] Number of hard links */
313*699cd480SApple OSS Distributions 	ino64_t         st_ino;                                 /* [XSI] File serial number */
314*699cd480SApple OSS Distributions 	uid_t           st_uid;                                 /* [XSI] User ID of the file */
315*699cd480SApple OSS Distributions 	gid_t           st_gid;                                 /* [XSI] Group ID of the file */
316*699cd480SApple OSS Distributions 	dev_t           st_rdev;                                /* [XSI] Device ID */
317*699cd480SApple OSS Distributions #ifndef _POSIX_C_SOURCE
318*699cd480SApple OSS Distributions 	struct user64_timespec st_atimespec;            /* time of last access */
319*699cd480SApple OSS Distributions 	struct user64_timespec st_mtimespec;            /* time of last data modification */
320*699cd480SApple OSS Distributions 	struct user64_timespec st_ctimespec;            /* time of last status change */
321*699cd480SApple OSS Distributions 	struct user64_timespec st_birthtimespec;        /* time of file creation(birth) */
322*699cd480SApple OSS Distributions #else
323*699cd480SApple OSS Distributions 	user64_time_t   st_atime;                               /* [XSI] Time of last access */
324*699cd480SApple OSS Distributions 	user64_long_t   st_atimensec;                   /* nsec of last access */
325*699cd480SApple OSS Distributions 	user64_time_t   st_mtime;                               /* [XSI] Last data modification time */
326*699cd480SApple OSS Distributions 	user64_long_t   st_mtimensec;                   /* last data modification nsec */
327*699cd480SApple OSS Distributions 	user64_time_t   st_ctime;                               /* [XSI] Time of last status change */
328*699cd480SApple OSS Distributions 	user64_long_t   st_ctimensec;                   /* nsec of last status change */
329*699cd480SApple OSS Distributions 	user64_time_t   st_birthtime;                   /*  File creation time(birth)  */
330*699cd480SApple OSS Distributions 	user64_long_t   st_birthtimensec;               /* nsec of File creation time */
331*699cd480SApple OSS Distributions #endif
332*699cd480SApple OSS Distributions 	off_t           st_size;                                /* [XSI] file size, in bytes */
333*699cd480SApple OSS Distributions 	blkcnt_t        st_blocks;                              /* [XSI] blocks allocated for file */
334*699cd480SApple OSS Distributions 	blksize_t       st_blksize;                             /* [XSI] optimal blocksize for I/O */
335*699cd480SApple OSS Distributions 	__uint32_t      st_flags;                               /* user defined flags for file */
336*699cd480SApple OSS Distributions 	__uint32_t      st_gen;                                 /* file generation number */
337*699cd480SApple OSS Distributions 	__uint32_t      st_lspare;                              /* RESERVED: DO NOT USE! */
338*699cd480SApple OSS Distributions 	__int64_t       st_qspare[2];                   /* RESERVED: DO NOT USE! */
339*699cd480SApple OSS Distributions };
340*699cd480SApple OSS Distributions 
341*699cd480SApple OSS Distributions struct user32_stat64 {
342*699cd480SApple OSS Distributions 	dev_t           st_dev;                                 /* [XSI] ID of device containing file */
343*699cd480SApple OSS Distributions 	mode_t          st_mode;                                /* [XSI] Mode of file (see below) */
344*699cd480SApple OSS Distributions 	nlink_t         st_nlink;                               /* [XSI] Number of hard links */
345*699cd480SApple OSS Distributions 	ino64_t         st_ino;                                 /* [XSI] File serial number */
346*699cd480SApple OSS Distributions 	uid_t           st_uid;                                 /* [XSI] User ID of the file */
347*699cd480SApple OSS Distributions 	gid_t           st_gid;                                 /* [XSI] Group ID of the file */
348*699cd480SApple OSS Distributions 	dev_t           st_rdev;                                /* [XSI] Device ID */
349*699cd480SApple OSS Distributions #ifndef _POSIX_C_SOURCE
350*699cd480SApple OSS Distributions 	struct user32_timespec st_atimespec;            /* time of last access */
351*699cd480SApple OSS Distributions 	struct user32_timespec st_mtimespec;            /* time of last data modification */
352*699cd480SApple OSS Distributions 	struct user32_timespec st_ctimespec;            /* time of last status change */
353*699cd480SApple OSS Distributions 	struct user32_timespec st_birthtimespec;        /* time of file creation(birth) */
354*699cd480SApple OSS Distributions #else
355*699cd480SApple OSS Distributions 	user32_time_t   st_atime;                               /* [XSI] Time of last access */
356*699cd480SApple OSS Distributions 	user32_long_t   st_atimensec;                   /* nsec of last access */
357*699cd480SApple OSS Distributions 	user32_time_t   st_mtime;                               /* [XSI] Last data modification time */
358*699cd480SApple OSS Distributions 	user32_long_t   st_mtimensec;                   /* last data modification nsec */
359*699cd480SApple OSS Distributions 	user32_time_t   st_ctime;                               /* [XSI] Time of last status change */
360*699cd480SApple OSS Distributions 	user32_long_t   st_ctimensec;                   /* nsec of last status change */
361*699cd480SApple OSS Distributions 	user32_time_t   st_birthtime;                   /*  File creation time(birth)  */
362*699cd480SApple OSS Distributions 	user32_long_t   st_birthtimensec;               /* nsec of File creation time */
363*699cd480SApple OSS Distributions #endif
364*699cd480SApple OSS Distributions 	off_t           st_size;                                /* [XSI] file size, in bytes */
365*699cd480SApple OSS Distributions 	blkcnt_t        st_blocks;                              /* [XSI] blocks allocated for file */
366*699cd480SApple OSS Distributions 	blksize_t       st_blksize;                             /* [XSI] optimal blocksize for I/O */
367*699cd480SApple OSS Distributions 	__uint32_t      st_flags;                               /* user defined flags for file */
368*699cd480SApple OSS Distributions 	__uint32_t      st_gen;                                 /* file generation number */
369*699cd480SApple OSS Distributions 	__uint32_t      st_lspare;                              /* RESERVED: DO NOT USE! */
370*699cd480SApple OSS Distributions 	__int64_t       st_qspare[2];                   /* RESERVED: DO NOT USE! */
371*699cd480SApple OSS Distributions #if defined(__x86_64__)
372*699cd480SApple OSS Distributions /*
373*699cd480SApple OSS Distributions  * This packing is required to ensure symmetry between userspace and kernelspace
374*699cd480SApple OSS Distributions  * when the kernel is 64-bit and the user application is 32-bit. All currently
375*699cd480SApple OSS Distributions  * supported ARM slices (arm64/armv7k/arm64_32) contain the same struct
376*699cd480SApple OSS Distributions  * alignment ABI so this packing isn't needed for ARM.
377*699cd480SApple OSS Distributions  */
378*699cd480SApple OSS Distributions } __attribute__((packed, aligned(4)));
379*699cd480SApple OSS Distributions #else
380*699cd480SApple OSS Distributions };
381*699cd480SApple OSS Distributions #endif
382*699cd480SApple OSS Distributions 
383*699cd480SApple OSS Distributions extern void munge_user64_stat64(struct stat64 *sbp, struct user64_stat64 *usbp);
384*699cd480SApple OSS Distributions extern void munge_user32_stat64(struct stat64 *sbp, struct user32_stat64 *usbp);
385*699cd480SApple OSS Distributions 
386*699cd480SApple OSS Distributions #endif /* BSD_KERNEL_PRIVATE */
387*699cd480SApple OSS Distributions 
388*699cd480SApple OSS Distributions #endif /* KERNEL */
389*699cd480SApple OSS Distributions 
390*699cd480SApple OSS Distributions 
391*699cd480SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
392*699cd480SApple OSS Distributions #define st_atime st_atimespec.tv_sec
393*699cd480SApple OSS Distributions #define st_mtime st_mtimespec.tv_sec
394*699cd480SApple OSS Distributions #define st_ctime st_ctimespec.tv_sec
395*699cd480SApple OSS Distributions #define st_birthtime st_birthtimespec.tv_sec
396*699cd480SApple OSS Distributions #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
397*699cd480SApple OSS Distributions 
398*699cd480SApple OSS Distributions /*
399*699cd480SApple OSS Distributions  * [XSI] The following are symbolic names for the values of type mode_t.  They
400*699cd480SApple OSS Distributions  * are bitmap values.
401*699cd480SApple OSS Distributions  */
402*699cd480SApple OSS Distributions #include <sys/_types/_s_ifmt.h>
403*699cd480SApple OSS Distributions 
404*699cd480SApple OSS Distributions /*
405*699cd480SApple OSS Distributions  * [XSI] The following macros shall be provided to test whether a file is
406*699cd480SApple OSS Distributions  * of the specified type.  The value m supplied to the macros is the value
407*699cd480SApple OSS Distributions  * of st_mode from a stat structure.  The macro shall evaluate to a non-zero
408*699cd480SApple OSS Distributions  * value if the test is true; 0 if the test is false.
409*699cd480SApple OSS Distributions  */
410*699cd480SApple OSS Distributions #define S_ISBLK(m)      (((m) & S_IFMT) == S_IFBLK)     /* block special */
411*699cd480SApple OSS Distributions #define S_ISCHR(m)      (((m) & S_IFMT) == S_IFCHR)     /* char special */
412*699cd480SApple OSS Distributions #define S_ISDIR(m)      (((m) & S_IFMT) == S_IFDIR)     /* directory */
413*699cd480SApple OSS Distributions #define S_ISFIFO(m)     (((m) & S_IFMT) == S_IFIFO)     /* fifo or socket */
414*699cd480SApple OSS Distributions #define S_ISREG(m)      (((m) & S_IFMT) == S_IFREG)     /* regular file */
415*699cd480SApple OSS Distributions #define S_ISLNK(m)      (((m) & S_IFMT) == S_IFLNK)     /* symbolic link */
416*699cd480SApple OSS Distributions #define S_ISSOCK(m)     (((m) & S_IFMT) == S_IFSOCK)    /* socket */
417*699cd480SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
418*699cd480SApple OSS Distributions #define S_ISWHT(m)      (((m) & S_IFMT) == S_IFWHT)     /* OBSOLETE: whiteout */
419*699cd480SApple OSS Distributions #endif
420*699cd480SApple OSS Distributions 
421*699cd480SApple OSS Distributions /*
422*699cd480SApple OSS Distributions  * [XSI] The implementation may implement message queues, semaphores, or
423*699cd480SApple OSS Distributions  * shared memory objects as distinct file types.  The following macros
424*699cd480SApple OSS Distributions  * shall be provided to test whether a file is of the specified type.
425*699cd480SApple OSS Distributions  * The value of the buf argument supplied to the macros is a pointer to
426*699cd480SApple OSS Distributions  * a stat structure.  The macro shall evaluate to a non-zero value if
427*699cd480SApple OSS Distributions  * the specified object is implemented as a distinct file type and the
428*699cd480SApple OSS Distributions  * specified file type is contained in the stat structure referenced by
429*699cd480SApple OSS Distributions  * buf.  Otherwise, the macro shall evaluate to zero.
430*699cd480SApple OSS Distributions  *
431*699cd480SApple OSS Distributions  * NOTE:	The current implementation does not do this, although
432*699cd480SApple OSS Distributions  *		this may change in future revisions, and co currently only
433*699cd480SApple OSS Distributions  *		provides these macros to ensure source compatability with
434*699cd480SApple OSS Distributions  *		implementations which do.
435*699cd480SApple OSS Distributions  */
436*699cd480SApple OSS Distributions #define S_TYPEISMQ(buf)         (0)     /* Test for a message queue */
437*699cd480SApple OSS Distributions #define S_TYPEISSEM(buf)        (0)     /* Test for a semaphore */
438*699cd480SApple OSS Distributions #define S_TYPEISSHM(buf)        (0)     /* Test for a shared memory object */
439*699cd480SApple OSS Distributions 
440*699cd480SApple OSS Distributions /*
441*699cd480SApple OSS Distributions  * [TYM] The implementation may implement typed memory objects as distinct
442*699cd480SApple OSS Distributions  * file types, and the following macro shall test whether a file is of the
443*699cd480SApple OSS Distributions  * specified type.  The value of the buf argument supplied to the macros is
444*699cd480SApple OSS Distributions  * a pointer to a stat structure.  The macro shall evaluate to a non-zero
445*699cd480SApple OSS Distributions  * value if the specified object is implemented as a distinct file type and
446*699cd480SApple OSS Distributions  * the specified file type is contained in the stat structure referenced by
447*699cd480SApple OSS Distributions  * buf.  Otherwise, the macro shall evaluate to zero.
448*699cd480SApple OSS Distributions  *
449*699cd480SApple OSS Distributions  * NOTE:	The current implementation does not do this, although
450*699cd480SApple OSS Distributions  *		this may change in future revisions, and co currently only
451*699cd480SApple OSS Distributions  *		provides this macro to ensure source compatability with
452*699cd480SApple OSS Distributions  *		implementations which do.
453*699cd480SApple OSS Distributions  */
454*699cd480SApple OSS Distributions #define S_TYPEISTMO(buf)        (0)     /* Test for a typed memory object */
455*699cd480SApple OSS Distributions 
456*699cd480SApple OSS Distributions 
457*699cd480SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
458*699cd480SApple OSS Distributions #define ACCESSPERMS     (S_IRWXU|S_IRWXG|S_IRWXO)       /* 0777 */
459*699cd480SApple OSS Distributions                                                         /* 7777 */
460*699cd480SApple OSS Distributions #define ALLPERMS        (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
461*699cd480SApple OSS Distributions /* 0666 */
462*699cd480SApple OSS Distributions #define DEFFILEMODE     (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
463*699cd480SApple OSS Distributions 
464*699cd480SApple OSS Distributions #define S_BLKSIZE       512             /* block size used in the stat struct */
465*699cd480SApple OSS Distributions 
466*699cd480SApple OSS Distributions /*
467*699cd480SApple OSS Distributions  * Definitions of flags stored in file flags word.
468*699cd480SApple OSS Distributions  *
469*699cd480SApple OSS Distributions  * Super-user and owner changeable flags.
470*699cd480SApple OSS Distributions  */
471*699cd480SApple OSS Distributions #define UF_SETTABLE     0x0000ffff      /* mask of owner changeable flags */
472*699cd480SApple OSS Distributions #define UF_NODUMP       0x00000001      /* do not dump file */
473*699cd480SApple OSS Distributions #define UF_IMMUTABLE    0x00000002      /* file may not be changed */
474*699cd480SApple OSS Distributions #define UF_APPEND       0x00000004      /* writes to file may only append */
475*699cd480SApple OSS Distributions #define UF_OPAQUE       0x00000008      /* directory is opaque wrt. union */
476*699cd480SApple OSS Distributions /*
477*699cd480SApple OSS Distributions  * The following bit is reserved for FreeBSD.  It is not implemented
478*699cd480SApple OSS Distributions  * in Mac OS X.
479*699cd480SApple OSS Distributions  */
480*699cd480SApple OSS Distributions /* #define UF_NOUNLINK	0x00000010 */	/* file may not be removed or renamed */
481*699cd480SApple OSS Distributions #define UF_COMPRESSED   0x00000020      /* file is compressed (some file-systems) */
482*699cd480SApple OSS Distributions 
483*699cd480SApple OSS Distributions /* UF_TRACKED is used for dealing with document IDs.  We no longer issue
484*699cd480SApple OSS Distributions  *  notifications for deletes or renames for files which have UF_TRACKED set. */
485*699cd480SApple OSS Distributions #define UF_TRACKED              0x00000040
486*699cd480SApple OSS Distributions 
487*699cd480SApple OSS Distributions #define UF_DATAVAULT    0x00000080      /* entitlement required for reading */
488*699cd480SApple OSS Distributions                                         /* and writing */
489*699cd480SApple OSS Distributions 
490*699cd480SApple OSS Distributions /* Bits 0x0100 through 0x4000 are currently undefined. */
491*699cd480SApple OSS Distributions #define UF_HIDDEN       0x00008000      /* hint that this item should not be */
492*699cd480SApple OSS Distributions                                         /* displayed in a GUI */
493*699cd480SApple OSS Distributions /*
494*699cd480SApple OSS Distributions  * Super-user changeable flags.
495*699cd480SApple OSS Distributions  */
496*699cd480SApple OSS Distributions #define SF_SUPPORTED    0x009f0000      /* mask of superuser supported flags */
497*699cd480SApple OSS Distributions #define SF_SETTABLE     0x3fff0000      /* mask of superuser changeable flags */
498*699cd480SApple OSS Distributions #define SF_SYNTHETIC    0xc0000000      /* mask of system read-only synthetic flags */
499*699cd480SApple OSS Distributions #define SF_ARCHIVED     0x00010000      /* file is archived */
500*699cd480SApple OSS Distributions #define SF_IMMUTABLE    0x00020000      /* file may not be changed */
501*699cd480SApple OSS Distributions #define SF_APPEND       0x00040000      /* writes to file may only append */
502*699cd480SApple OSS Distributions #define SF_RESTRICTED   0x00080000      /* entitlement required for writing */
503*699cd480SApple OSS Distributions #define SF_NOUNLINK     0x00100000      /* Item may not be removed, renamed or mounted on */
504*699cd480SApple OSS Distributions 
505*699cd480SApple OSS Distributions /*
506*699cd480SApple OSS Distributions  * The following two bits are reserved for FreeBSD.  They are not
507*699cd480SApple OSS Distributions  * implemented in Mac OS X.
508*699cd480SApple OSS Distributions  */
509*699cd480SApple OSS Distributions /* #define SF_SNAPSHOT	0x00200000 */	/* snapshot inode */
510*699cd480SApple OSS Distributions /* NOTE: There is no SF_HIDDEN bit. */
511*699cd480SApple OSS Distributions 
512*699cd480SApple OSS Distributions #define SF_FIRMLINK     0x00800000      /* file is a firmlink */
513*699cd480SApple OSS Distributions 
514*699cd480SApple OSS Distributions /*
515*699cd480SApple OSS Distributions  * Synthetic flags.
516*699cd480SApple OSS Distributions  *
517*699cd480SApple OSS Distributions  * These are read-only.  We keep them out of SF_SUPPORTED so that
518*699cd480SApple OSS Distributions  * attempts to set them will fail.
519*699cd480SApple OSS Distributions  */
520*699cd480SApple OSS Distributions #define SF_DATALESS     0x40000000     /* file is dataless object */
521*699cd480SApple OSS Distributions 
522*699cd480SApple OSS Distributions #ifdef PRIVATE
523*699cd480SApple OSS Distributions /*
524*699cd480SApple OSS Distributions  * Protected flags.
525*699cd480SApple OSS Distributions  *
526*699cd480SApple OSS Distributions  * These flags are read-write, but can only be changed using the safe
527*699cd480SApple OSS Distributions  * mechanism (FSIOC_CAS_BSDFLAGS).  The standard chflags(2) mechanism
528*699cd480SApple OSS Distributions  * will simply preserve these bits as they are in the inode.
529*699cd480SApple OSS Distributions  */
530*699cd480SApple OSS Distributions #define UF_SF_PROTECTED (UF_COMPRESSED)
531*699cd480SApple OSS Distributions #endif
532*699cd480SApple OSS Distributions 
533*699cd480SApple OSS Distributions #ifdef KERNEL
534*699cd480SApple OSS Distributions /*
535*699cd480SApple OSS Distributions  * Shorthand abbreviations of above.
536*699cd480SApple OSS Distributions  */
537*699cd480SApple OSS Distributions #define OPAQUE          (UF_OPAQUE)
538*699cd480SApple OSS Distributions #define APPEND          (UF_APPEND | SF_APPEND)
539*699cd480SApple OSS Distributions #define IMMUTABLE       (UF_IMMUTABLE | SF_IMMUTABLE)
540*699cd480SApple OSS Distributions #endif
541*699cd480SApple OSS Distributions #endif
542*699cd480SApple OSS Distributions 
543*699cd480SApple OSS Distributions #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
544*699cd480SApple OSS Distributions /*
545*699cd480SApple OSS Distributions  * Extended flags ("EF") returned by ATTR_CMNEXT_EXT_FLAGS from getattrlist/getattrlistbulk
546*699cd480SApple OSS Distributions  */
547*699cd480SApple OSS Distributions #define EF_MAY_SHARE_BLOCKS     0x00000001      /* file may share blocks with another file */
548*699cd480SApple OSS Distributions #define EF_NO_XATTRS            0x00000002      /* file has no xattrs at all */
549*699cd480SApple OSS Distributions #define EF_IS_SYNC_ROOT         0x00000004      /* file is a sync root for iCloud */
550*699cd480SApple OSS Distributions #define EF_IS_PURGEABLE         0x00000008      /* file is purgeable */
551*699cd480SApple OSS Distributions #define EF_IS_SPARSE            0x00000010      /* file has at least one sparse region */
552*699cd480SApple OSS Distributions #define EF_IS_SYNTHETIC         0x00000020      /* a synthetic directory/symlink */
553*699cd480SApple OSS Distributions #define EF_SHARES_ALL_BLOCKS    0x00000040      /* file shares all of its blocks with another file */
554*699cd480SApple OSS Distributions #endif
555*699cd480SApple OSS Distributions 
556*699cd480SApple OSS Distributions 
557*699cd480SApple OSS Distributions #ifndef KERNEL
558*699cd480SApple OSS Distributions 
559*699cd480SApple OSS Distributions __BEGIN_DECLS
560*699cd480SApple OSS Distributions /* [XSI] */
561*699cd480SApple OSS Distributions int     chmod(const char *, mode_t) __DARWIN_ALIAS(chmod);
562*699cd480SApple OSS Distributions int     fchmod(int, mode_t) __DARWIN_ALIAS(fchmod);
563*699cd480SApple OSS Distributions int     fstat(int, struct stat *) __DARWIN_INODE64(fstat);
564*699cd480SApple OSS Distributions int     lstat(const char *, struct stat *) __DARWIN_INODE64(lstat);
565*699cd480SApple OSS Distributions int     mkdir(const char *, mode_t);
566*699cd480SApple OSS Distributions int     mkfifo(const char *, mode_t);
567*699cd480SApple OSS Distributions int     stat(const char *, struct stat *) __DARWIN_INODE64(stat);
568*699cd480SApple OSS Distributions int     mknod(const char *, mode_t, dev_t);
569*699cd480SApple OSS Distributions mode_t  umask(mode_t);
570*699cd480SApple OSS Distributions 
571*699cd480SApple OSS Distributions #if __DARWIN_C_LEVEL >= 200809L
572*699cd480SApple OSS Distributions int     fchmodat(int, const char *, mode_t, int) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0);
573*699cd480SApple OSS Distributions int     fstatat(int, const char *, struct stat *, int) __DARWIN_INODE64(fstatat) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0);
574*699cd480SApple OSS Distributions int     mkdirat(int, const char *, mode_t) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0);
575*699cd480SApple OSS Distributions int     mkfifoat(int, const char *, mode_t) __API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0), watchos(9.0));
576*699cd480SApple OSS Distributions int     mknodat(int, const char *, mode_t, dev_t) __API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0), watchos(9.0));
577*699cd480SApple OSS Distributions 
578*699cd480SApple OSS Distributions #define UTIME_NOW       -1
579*699cd480SApple OSS Distributions #define UTIME_OMIT      -2
580*699cd480SApple OSS Distributions 
581*699cd480SApple OSS Distributions int     futimens(int __fd, const struct timespec __times[2]) __API_AVAILABLE(macosx(10.13), ios(11.0), tvos(11.0), watchos(4.0));
582*699cd480SApple OSS Distributions int     utimensat(int __fd, const char *__path, const struct timespec __times[2],
583*699cd480SApple OSS Distributions     int __flag) __API_AVAILABLE(macosx(10.13), ios(11.0), tvos(11.0), watchos(4.0));
584*699cd480SApple OSS Distributions #endif
585*699cd480SApple OSS Distributions __END_DECLS
586*699cd480SApple OSS Distributions 
587*699cd480SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
588*699cd480SApple OSS Distributions 
589*699cd480SApple OSS Distributions #include <sys/_types/_filesec_t.h>
590*699cd480SApple OSS Distributions 
591*699cd480SApple OSS Distributions __BEGIN_DECLS
592*699cd480SApple OSS Distributions int     chflags(const char *, __uint32_t);
593*699cd480SApple OSS Distributions int     chmodx_np(const char *, filesec_t);
594*699cd480SApple OSS Distributions int     fchflags(int, __uint32_t);
595*699cd480SApple OSS Distributions int     fchmodx_np(int, filesec_t);
596*699cd480SApple OSS Distributions int     fstatx_np(int, struct stat *, filesec_t) __DARWIN_INODE64(fstatx_np);
597*699cd480SApple OSS Distributions int     lchflags(const char *, __uint32_t) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
598*699cd480SApple OSS Distributions int     lchmod(const char *, mode_t) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
599*699cd480SApple OSS Distributions int     lstatx_np(const char *, struct stat *, filesec_t) __DARWIN_INODE64(lstatx_np);
600*699cd480SApple OSS Distributions int     mkdirx_np(const char *, filesec_t);
601*699cd480SApple OSS Distributions int     mkfifox_np(const char *, filesec_t);
602*699cd480SApple OSS Distributions int     statx_np(const char *, struct stat *, filesec_t) __DARWIN_INODE64(statx_np);
603*699cd480SApple OSS Distributions int     umaskx_np(filesec_t) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_6, __IPHONE_NA, __IPHONE_NA);
604*699cd480SApple OSS Distributions 
605*699cd480SApple OSS Distributions #if !__DARWIN_ONLY_64_BIT_INO_T
606*699cd480SApple OSS Distributions /* The following deprecated routines are simillar to stat and friends except provide struct stat64 instead of struct stat  */
607*699cd480SApple OSS Distributions int     fstatx64_np(int, struct stat64 *, filesec_t) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_NA, __IPHONE_NA);
608*699cd480SApple OSS Distributions int     lstatx64_np(const char *, struct stat64 *, filesec_t) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_NA, __IPHONE_NA);
609*699cd480SApple OSS Distributions int     statx64_np(const char *, struct stat64 *, filesec_t) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_NA, __IPHONE_NA);
610*699cd480SApple OSS Distributions int     fstat64(int, struct stat64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_NA, __IPHONE_NA);
611*699cd480SApple OSS Distributions int     lstat64(const char *, struct stat64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_NA, __IPHONE_NA);
612*699cd480SApple OSS Distributions int     stat64(const char *, struct stat64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_NA, __IPHONE_NA);
613*699cd480SApple OSS Distributions #endif /* !__DARWIN_ONLY_64_BIT_INO_T */
614*699cd480SApple OSS Distributions __END_DECLS
615*699cd480SApple OSS Distributions 
616*699cd480SApple OSS Distributions #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
617*699cd480SApple OSS Distributions 
618*699cd480SApple OSS Distributions #endif /* !KERNEL */
619*699cd480SApple OSS Distributions #endif /* !_SYS_STAT_H_ */
620