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