Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/modules/include/sys/stat.h

  • Property svn:executable set to *
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.h8.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#include <Availability.h>
76
77/* [XSI] The timespec structure may be defined as described in <time.h> */
78#define __need_struct_timespec
79#include <sys/_structs.h>
80
81/*
82 * [XSI] The blkcnt_t, blksize_t, dev_t, ino_t, mode_t, nlink_t, uid_t,
83 * gid_t, off_t, and time_t types shall be defined as described in
84 * <sys/types.h>.
85 */
86#ifndef _BLKCNT_T
87typedef__darwin_blkcnt_tblkcnt_t;
88#define_BLKCNT_T
89#endif
90
91#ifndef _BLKSIZE_T
92typedef__darwin_blksize_tblksize_t;
93#define_BLKSIZE_T
94#endif
95
96#ifndef _DEV_T
97typedef__darwin_dev_tdev_t;/* device number */
98#define _DEV_T
99#endif
100
101#ifndef_INO_T
102typedef__darwin_ino_tino_t;/* inode number */
103#define _INO_T
104#endif
105
106#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
107#ifndef_INO64_T
108typedef__darwin_ino64_tino64_t;/* 64bit inode number */
109#define _INO64_T
110#endif
111#endif /* !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) */
112
113#ifndef_MODE_T
114typedef__darwin_mode_tmode_t;
115#define _MODE_T
116#endif
117
118#ifndef _NLINK_T
119typedef__uint16_tnlink_t;/* link count */
120#define_NLINK_T
121#endif
122
123#ifndef _UID_T
124typedef __darwin_uid_tuid_t;/* user id */
125#define _UID_T
126#endif
127
128#ifndef _GID_T
129typedef __darwin_gid_tgid_t;
130#define _GID_T
131#endif
132
133#ifndef _OFF_T
134typedef __darwin_off_toff_t;
135#define _OFF_T
136#endif
137
138#ifndef_TIME_T
139#define_TIME_T
140typedef__darwin_time_ttime_t;
141#endif
142
143
144#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
145/*
146 * XXX So deprecated, it would make your head spin
147 *
148 * The old stat structure. In fact, this is not used by the kernel at all,
149 * and should not be used by user space, and should be removed from this
150 * header file entirely (along with the unused cvtstat() prototype in
151 * vnode_internal.h).
152 */
153struct ostat {
154__uint16_tst_dev;/* inode's device */
155ino_tst_ino;/* inode's number */
156mode_tst_mode;/* inode protection mode */
157nlink_tst_nlink;/* number of hard links */
158__uint16_tst_uid;/* user ID of the file's owner */
159__uint16_tst_gid;/* group ID of the file's group */
160__uint16_tst_rdev;/* device type */
161__int32_tst_size;/* file size, in bytes */
162structtimespec st_atimespec;/* time of last access */
163structtimespec st_mtimespec;/* time of last data modification */
164structtimespec st_ctimespec;/* time of last file status change */
165__int32_tst_blksize;/* optimal blocksize for I/O */
166__int32_tst_blocks;/* blocks allocated for file */
167__uint32_tst_flags;/* user defined flags for file */
168__uint32_tst_gen;/* file generation number */
169};
170
171#define __DARWIN_STRUCT_STAT64_TIMES \
172struct timespec st_atimespec;/* time of last access */ \
173struct timespec st_mtimespec;/* time of last data modification */ \
174struct timespec st_ctimespec;/* time of last status change */ \
175struct timespec st_birthtimespec;/* time of file creation(birth) */
176
177#else /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
178
179#define __DARWIN_STRUCT_STAT64_TIMES \
180time_tst_atime;/* [XSI] Time of last access */ \
181longst_atimensec;/* nsec of last access */ \
182time_tst_mtime;/* [XSI] Last data modification time */ \
183longst_mtimensec;/* last data modification nsec */ \
184time_tst_ctime;/* [XSI] Time of last status change */ \
185longst_ctimensec;/* nsec of last status change */ \
186time_tst_birthtime;/* File creation time(birth) */ \
187longst_birthtimensec;/* nsec of File creation time */
188
189#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
190
191/*
192 * This structure is used as the second parameter to the fstat64(),
193 * lstat64(), and stat64() functions, and for struct stat when
194 * __DARWIN_64_BIT_INO_T is set. __DARWIN_STRUCT_STAT64 is defined
195 * above, depending on whether we use struct timespec or the direct
196 * components.
197 *
198 * This is simillar to stat except for 64bit inode number
199 * number instead of 32bit ino_t and the addition of create(birth) time.
200 */
201#define __DARWIN_STRUCT_STAT64 { \
202dev_tst_dev;/* [XSI] ID of device containing file */ \
203mode_tst_mode;/* [XSI] Mode of file (see below) */ \
204nlink_tst_nlink;/* [XSI] Number of hard links */ \
205__darwin_ino64_t st_ino;/* [XSI] File serial number */ \
206uid_tst_uid;/* [XSI] User ID of the file */ \
207gid_tst_gid;/* [XSI] Group ID of the file */ \
208dev_tst_rdev;/* [XSI] Device ID */ \
209__DARWIN_STRUCT_STAT64_TIMES \
210off_tst_size;/* [XSI] file size, in bytes */ \
211blkcnt_tst_blocks;/* [XSI] blocks allocated for file */ \
212blksize_tst_blksize;/* [XSI] optimal blocksize for I/O */ \
213__uint32_tst_flags;/* user defined flags for file */ \
214__uint32_tst_gen;/* file generation number */ \
215__int32_tst_lspare;/* RESERVED: DO NOT USE! */ \
216__int64_tst_qspare[2];/* RESERVED: DO NOT USE! */ \
217}
218
219/*
220 * [XSI] This structure is used as the second parameter to the fstat(),
221 * lstat(), and stat() functions.
222 */
223#if __DARWIN_64_BIT_INO_T
224
225struct stat __DARWIN_STRUCT_STAT64;
226
227#else /* !__DARWIN_64_BIT_INO_T */
228
229struct stat {
230dev_t st_dev;/* [XSI] ID of device containing file */
231ino_t st_ino;/* [XSI] File serial number */
232mode_t st_mode;/* [XSI] Mode of file (see below) */
233nlink_tst_nlink;/* [XSI] Number of hard links */
234uid_tst_uid;/* [XSI] User ID of the file */
235gid_tst_gid;/* [XSI] Group ID of the file */
236dev_tst_rdev;/* [XSI] Device ID */
237#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
238structtimespec st_atimespec;/* time of last access */
239structtimespec st_mtimespec;/* time of last data modification */
240structtimespec st_ctimespec;/* time of last status change */
241#else
242time_tst_atime;/* [XSI] Time of last access */
243longst_atimensec;/* nsec of last access */
244time_tst_mtime;/* [XSI] Last data modification time */
245longst_mtimensec;/* last data modification nsec */
246time_tst_ctime;/* [XSI] Time of last status change */
247longst_ctimensec;/* nsec of last status change */
248#endif
249off_tst_size;/* [XSI] file size, in bytes */
250blkcnt_tst_blocks;/* [XSI] blocks allocated for file */
251blksize_tst_blksize;/* [XSI] optimal blocksize for I/O */
252__uint32_tst_flags;/* user defined flags for file */
253__uint32_tst_gen;/* file generation number */
254__int32_tst_lspare;/* RESERVED: DO NOT USE! */
255__int64_tst_qspare[2];/* RESERVED: DO NOT USE! */
256};
257
258#endif /* __DARWIN_64_BIT_INO_T */
259
260#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
261
262#if !__DARWIN_ONLY_64_BIT_INO_T
263
264struct stat64 __DARWIN_STRUCT_STAT64;
265
266#endif /* !__DARWIN_ONLY_64_BIT_INO_T */
267
268#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
269
270
271
272
273#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
274#define st_atime st_atimespec.tv_sec
275#define st_mtime st_mtimespec.tv_sec
276#define st_ctime st_ctimespec.tv_sec
277#define st_birthtime st_birthtimespec.tv_sec
278#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
279
280/*
281 * [XSI] The following are symbolic names for the values of type mode_t. They
282 * are bitmap values.
283 */
284#ifndef S_IFMT
285/* File type */
286#defineS_IFMT0170000/* [XSI] type of file mask */
287#defineS_IFIFO0010000/* [XSI] named pipe (fifo) */
288#defineS_IFCHR0020000/* [XSI] character special */
289#defineS_IFDIR0040000/* [XSI] directory */
290#defineS_IFBLK0060000/* [XSI] block special */
291#defineS_IFREG0100000/* [XSI] regular */
292#defineS_IFLNK0120000/* [XSI] symbolic link */
293#defineS_IFSOCK0140000/* [XSI] socket */
294#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
295#defineS_IFWHT0160000/* OBSOLETE: whiteout */
296#endif
297
298/* File mode */
299/* Read, write, execute/search by owner */
300#defineS_IRWXU0000700/* [XSI] RWX mask for owner */
301#defineS_IRUSR0000400/* [XSI] R for owner */
302#defineS_IWUSR0000200/* [XSI] W for owner */
303#defineS_IXUSR0000100/* [XSI] X for owner */
304/* Read, write, execute/search by group */
305#defineS_IRWXG0000070/* [XSI] RWX mask for group */
306#defineS_IRGRP0000040/* [XSI] R for group */
307#defineS_IWGRP0000020/* [XSI] W for group */
308#defineS_IXGRP0000010/* [XSI] X for group */
309/* Read, write, execute/search by others */
310#defineS_IRWXO0000007/* [XSI] RWX mask for other */
311#defineS_IROTH0000004/* [XSI] R for other */
312#defineS_IWOTH0000002/* [XSI] W for other */
313#defineS_IXOTH0000001/* [XSI] X for other */
314
315#defineS_ISUID0004000/* [XSI] set user id on execution */
316#defineS_ISGID0002000/* [XSI] set group id on execution */
317#defineS_ISVTX0001000/* [XSI] directory restrcted delete */
318
319#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
320#defineS_ISTXTS_ISVTX/* sticky bit: not supported */
321#defineS_IREADS_IRUSR/* backward compatability */
322#defineS_IWRITES_IWUSR/* backward compatability */
323#defineS_IEXECS_IXUSR/* backward compatability */
324#endif
325#endif/* !S_IFMT */
326
327/*
328 * [XSI] The following macros shall be provided to test whether a file is
329 * of the specified type. The value m supplied to the macros is the value
330 * of st_mode from a stat structure. The macro shall evaluate to a non-zero
331 * value if the test is true; 0 if the test is false.
332 */
333#defineS_ISBLK(m)(((m) & S_IFMT) == S_IFBLK)/* block special */
334#defineS_ISCHR(m)(((m) & S_IFMT) == S_IFCHR)/* char special */
335#defineS_ISDIR(m)(((m) & S_IFMT) == S_IFDIR)/* directory */
336#defineS_ISFIFO(m)(((m) & S_IFMT) == S_IFIFO)/* fifo or socket */
337#defineS_ISREG(m)(((m) & S_IFMT) == S_IFREG)/* regular file */
338#defineS_ISLNK(m)(((m) & S_IFMT) == S_IFLNK)/* symbolic link */
339#defineS_ISSOCK(m)(((m) & S_IFMT) == S_IFSOCK)/* socket */
340#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
341#defineS_ISWHT(m)(((m) & S_IFMT) == S_IFWHT)/* OBSOLETE: whiteout */
342#endif
343
344/*
345 * [XSI] The implementation may implement message queues, semaphores, or
346 * shared memory objects as distinct file types. The following macros
347 * shall be provided to test whether a file is of the specified type.
348 * The value of the buf argument supplied to the macros is a pointer to
349 * a stat structure. The macro shall evaluate to a non-zero value if
350 * the specified object is implemented as a distinct file type and the
351 * specified file type is contained in the stat structure referenced by
352 * buf. Otherwise, the macro shall evaluate to zero.
353 *
354 * NOTE:The current implementation does not do this, although
355 *this may change in future revisions, and co currently only
356 *provides these macros to ensure source compatability with
357 *implementations which do.
358 */
359#defineS_TYPEISMQ(buf)(0)/* Test for a message queue */
360#defineS_TYPEISSEM(buf)(0)/* Test for a semaphore */
361#defineS_TYPEISSHM(buf)(0)/* Test for a shared memory object */
362
363/*
364 * [TYM] The implementation may implement typed memory objects as distinct
365 * file types, and the following macro shall test whether a file is of the
366 * specified type. The value of the buf argument supplied to the macros is
367 * a pointer to a stat structure. The macro shall evaluate to a non-zero
368 * value if the specified object is implemented as a distinct file type and
369 * the specified file type is contained in the stat structure referenced by
370 * buf. Otherwise, the macro shall evaluate to zero.
371 *
372 * NOTE:The current implementation does not do this, although
373 *this may change in future revisions, and co currently only
374 *provides this macro to ensure source compatability with
375 *implementations which do.
376 */
377#defineS_TYPEISTMO(buf)(0)/* Test for a typed memory object */
378
379
380#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
381#defineACCESSPERMS(S_IRWXU|S_IRWXG|S_IRWXO)/* 0777 */
382/* 7777 */
383#defineALLPERMS(S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
384/* 0666 */
385#defineDEFFILEMODE(S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
386
387#define S_BLKSIZE512/* block size used in the stat struct */
388
389/*
390 * Definitions of flags stored in file flags word.
391 *
392 * Super-user and owner changeable flags.
393 */
394#defineUF_SETTABLE0x0000ffff/* mask of owner changeable flags */
395#defineUF_NODUMP0x00000001/* do not dump file */
396#defineUF_IMMUTABLE0x00000002/* file may not be changed */
397#defineUF_APPEND0x00000004/* writes to file may only append */
398#define UF_OPAQUE0x00000008/* directory is opaque wrt. union */
399/*
400 * The following bit is reserved for FreeBSD. It is not implemented
401 * in Mac OS X.
402 */
403/* #define UF_NOUNLINK0x00000010 *//* file may not be removed or renamed */
404#define UF_COMPRESSED0x00000020/* file is hfs-compressed */
405#define UF_TRACKED0x00000040/* file renames and deletes are tracked */
406/* Bits 0x0080 through 0x4000 are currently undefined. */
407#define UF_HIDDEN0x00008000/* hint that this item should not be */
408/* displayed in a GUI */
409/*
410 * Super-user changeable flags.
411 */
412#defineSF_SETTABLE0xffff0000/* mask of superuser changeable flags */
413#defineSF_ARCHIVED0x00010000/* file is archived */
414#defineSF_IMMUTABLE0x00020000/* file may not be changed */
415#defineSF_APPEND0x00040000/* writes to file may only append */
416
417/*
418 * The following two bits are reserved for FreeBSD. They are not
419 * implemented in Mac OS X.
420 */
421/* #define SF_NOUNLINK0x00100000 *//* file may not be removed or renamed */
422/* #define SF_SNAPSHOT0x00200000 *//* snapshot inode */
423/* NOTE: There is no SF_HIDDEN bit. */
424
425#endif
426
427
428__BEGIN_DECLS
429/* [XSI] */
430intfstat(int, struct stat *) ;
431__END_DECLS
432#endif /* !_SYS_STAT_H_ */
433

Archive Download this file

Revision: 2182