Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/modules/include/fcntl.h

  • Property svn:executable set to *
1/*
2 * Copyright (c) 2000-2007 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) 1983, 1990, 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 *@(#)fcntl.h8.3 (Berkeley) 1/21/94
67 */
68
69
70#ifndef _SYS_FCNTL_H_
71#define_SYS_FCNTL_H_
72
73/*
74 * This file includes the definitions for open and fcntl
75 * described by POSIX for <fcntl.h>; it also includes
76 * related kernel definitions.
77 */
78#include <sys/_types.h>
79#include <sys/cdefs.h>
80#include <Availability.h>
81
82/* We should not be exporting size_t here. Temporary for gcc bootstrapping. */
83#ifndef _SIZE_T
84#define _SIZE_T
85typedef __darwin_size_tsize_t;
86#endif
87
88#ifndef_MODE_T
89typedef__darwin_mode_tmode_t;
90#define _MODE_T
91#endif
92
93#ifndef _OFF_T
94typedef __darwin_off_toff_t;
95#define _OFF_T
96#endif
97
98#ifndef _PID_T
99typedef __darwin_pid_tpid_t;
100#define _PID_T
101#endif
102
103/*
104 * File status flags: these are used by open(2), fcntl(2).
105 * They are also used (indirectly) in the kernel file structure f_flags,
106 * which is a superset of the open/fcntl flags. Open flags and f_flags
107 * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags).
108 * Open/fcntl flags begin with O_; kernel-internal flags begin with F.
109 */
110/* open-only flags */
111#defineO_RDONLY0x0000/* open for reading only */
112#defineO_WRONLY0x0001/* open for writing only */
113#defineO_RDWR0x0002/* open for reading and writing */
114#defineO_ACCMODE0x0003/* mask for above modes */
115
116/*
117 * Kernel encoding of open mode; separate read and write bits that are
118 * independently testable: 1 greater than the above.
119 *
120 * XXX
121 * FREAD and FWRITE are excluded from the #ifdef KERNEL so that TIOCFLUSH,
122 * which was documented to use FREAD/FWRITE, continues to work.
123 */
124#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
125#defineFREAD0x0001
126#defineFWRITE0x0002
127#endif
128#defineO_NONBLOCK0x0004/* no delay */
129#defineO_APPEND0x0008/* set append mode */
130#ifndef O_SYNC/* allow simultaneous inclusion of <aio.h> */
131#defineO_SYNC0x0080/* synch I/O file integrity */
132#endif
133#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
134#defineO_SHLOCK0x0010/* open with shared file lock */
135#defineO_EXLOCK0x0020/* open with exclusive file lock */
136#defineO_ASYNC0x0040/* signal pgrp when data ready */
137#defineO_FSYNCO_SYNC/* source compatibility: do not use */
138#define O_NOFOLLOW 0x0100 /* don't follow symlinks */
139#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
140#defineO_CREAT0x0200/* create if nonexistant */
141#defineO_TRUNC0x0400/* truncate to zero length */
142#defineO_EXCL0x0800/* error if already exists */
143#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
144#defineO_EVTONLY0x8000/* descriptor requested for event notifications only */
145#endif
146
147
148#defineO_NOCTTY0x20000/* don't assign controlling terminal */
149
150
151#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
152#define O_DIRECTORY0x100000
153#define O_SYMLINK0x200000/* allow open of a symlink */
154#endif
155
156#ifndef O_DSYNC/* allow simultaneous inclusion of <aio.h> */
157#defineO_DSYNC0x400000/* synch I/O data integrity */
158#endif
159
160
161#if __DARWIN_C_LEVEL >= 200809L
162#defineO_CLOEXEC0x1000000/* implicitly set FD_CLOEXEC */
163#endif
164
165
166
167/* Data Protection Flags */
168#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
169#define O_DP_GETRAWENCRYPTED0x0001
170#endif
171
172
173
174/*
175 * The O_* flags used to have only F* names, which were used in the kernel
176 * and by fcntl. We retain the F* names for the kernel f_flags field
177 * and for backward compatibility for fcntl.
178 */
179#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
180#defineFAPPENDO_APPEND/* kernel/compat */
181#defineFASYNCO_ASYNC/* kernel/compat */
182#defineFFSYNCO_FSYNC/* kernel */
183#defineFFDSYNCO_DSYNC/* kernel */
184#defineFNONBLOCKO_NONBLOCK/* kernel */
185#defineFNDELAYO_NONBLOCK/* compat */
186#defineO_NDELAYO_NONBLOCK/* compat */
187#endif
188
189/*
190 * Flags used for copyfile(2)
191 */
192
193#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
194#define CPF_OVERWRITE 1
195#define CPF_IGNORE_MODE 2
196#define CPF_MASK (CPF_OVERWRITE|CPF_IGNORE_MODE)
197#endif
198
199/*
200 * Constants used for fcntl(2)
201 */
202
203/* command values */
204#defineF_DUPFD0/* duplicate file descriptor */
205#defineF_GETFD1/* get file descriptor flags */
206#defineF_SETFD2/* set file descriptor flags */
207#defineF_GETFL3/* get file status flags */
208#defineF_SETFL4/* set file status flags */
209#defineF_GETOWN5/* get SIGIO/SIGURG proc/pgrp */
210#define F_SETOWN6/* set SIGIO/SIGURG proc/pgrp */
211#defineF_GETLK7/* get record locking information */
212#defineF_SETLK8/* set record locking information */
213#defineF_SETLKW9/* F_SETLK; wait if blocked */
214#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
215#define F_FLUSH_DATA 40
216#define F_CHKCLEAN 41 /* Used for regression test */
217#define F_PREALLOCATE 42/* Preallocate storage */
218#define F_SETSIZE 43/* Truncate a file without zeroing space */
219#define F_RDADVISE 44 /* Issue an advisory read async with no copy to user */
220#define F_RDAHEAD 45 /* turn read ahead off/on for this fd */
221#define F_READBOOTSTRAP 46 /* Read bootstrap from disk */
222#define F_WRITEBOOTSTRAP 47 /* Write bootstrap on disk */
223#define F_NOCACHE 48 /* turn data caching off/on for this fd */
224#define F_LOG2PHYS49/* file offset to device offset */
225#define F_GETPATH 50 /* return the full path of the fd */
226#define F_FULLFSYNC 51/* fsync + ask the drive to flush to the media */
227#define F_PATHPKG_CHECK 52 /* find which component (if any) is a package */
228#define F_FREEZE_FS 53 /* "freeze" all fs operations */
229#define F_THAW_FS 54 /* "thaw" all fs operations */
230#defineF_GLOBAL_NOCACHE 55/* turn data caching off/on (globally) for this file */
231
232
233#define F_ADDSIGS59/* add detached signatures */
234
235#define F_MARKDEPENDENCY 60 /* this process hosts the device supporting the fs backing this fd */
236
237#define F_ADDFILESIGS61/* add signature from same file (used by dyld for shared libs) */
238
239#define F_NODIRECT62/* used in conjunction with F_NOCACHE to indicate that DIRECT, synchonous writes */
240 /* should not be used (i.e. its ok to temporaily create cached pages) */
241
242#define F_GETPROTECTIONCLASS63/* Get the protection class of a file from the EA, returns int */
243#define F_SETPROTECTIONCLASS64/* Set the protection class of a file for the EA, requires int */
244
245#define F_LOG2PHYS_EXT 65/* file offset to device offset, extended */
246
247#defineF_GETLKPID66/* get record locking information, per-process */
248
249/* See F_DUPFD_CLOEXEC below for 67 */
250
251
252#define F_SETBACKINGSTORE70/* Mark the file as being the backing store for another filesystem */
253#define F_GETPATH_MTMINFO71 /* return the full path of the FD, but error in specific mtmd circumstances */
254
255/* 72 is free. It used to be F_GETENCRYPTEDDATA, which is now removed. */
256
257#define F_SETNOSIGPIPE73/* No SIGPIPE generated on EPIPE */
258#define F_GETNOSIGPIPE74/* Status of SIGPIPE for this fd */
259
260#define F_TRANSCODEKEY75 /* For some cases, we need to rewrap the key for AKS/MKB */
261
262#define F_SINGLE_WRITER76/* file being written to a by single writer... if throttling enabled, writes */
263 /* may be broken into smaller chunks with throttling in between */
264
265#define F_GETPROTECTIONLEVEL77/* Get the protection version number for this filesystem */
266
267
268// FS-specific fcntl()'s numbers begin at 0x00010000 and go up
269#define FCNTL_FS_SPECIFIC_BASE 0x00010000
270
271#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
272
273#if __DARWIN_C_LEVEL >= 200809L
274#defineF_DUPFD_CLOEXEC67/* mark the dup with FD_CLOEXEC */
275#endif
276
277/* file descriptor flags (F_GETFD, F_SETFD) */
278#defineFD_CLOEXEC1/* close-on-exec flag */
279
280/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
281#defineF_RDLCK1/* shared or read lock */
282#defineF_UNLCK2/* unlock */
283#defineF_WRLCK3/* exclusive or write lock */
284
285/*
286 * [XSI] The values used for l_whence shall be defined as described
287 * in <unistd.h>
288 */
289#ifndef SEEK_SET
290#defineSEEK_SET0/* set file offset to offset */
291#defineSEEK_CUR1/* set file offset to current plus offset */
292#defineSEEK_END2/* set file offset to EOF plus offset */
293#endif/* !SEEK_SET */
294
295/*
296 * [XSI] The symbolic names for file modes for use as values of mode_t
297 * shall be defined as described in <sys/stat.h>
298 */
299#ifndef S_IFMT
300/* File type */
301#defineS_IFMT0170000/* [XSI] type of file mask */
302#defineS_IFIFO0010000/* [XSI] named pipe (fifo) */
303#defineS_IFCHR0020000/* [XSI] character special */
304#defineS_IFDIR0040000/* [XSI] directory */
305#defineS_IFBLK0060000/* [XSI] block special */
306#defineS_IFREG0100000/* [XSI] regular */
307#defineS_IFLNK0120000/* [XSI] symbolic link */
308#defineS_IFSOCK0140000/* [XSI] socket */
309#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
310#defineS_IFWHT0160000/* OBSOLETE: whiteout */
311#endif
312
313/* File mode */
314/* Read, write, execute/search by owner */
315#defineS_IRWXU0000700/* [XSI] RWX mask for owner */
316#defineS_IRUSR0000400/* [XSI] R for owner */
317#defineS_IWUSR0000200/* [XSI] W for owner */
318#defineS_IXUSR0000100/* [XSI] X for owner */
319/* Read, write, execute/search by group */
320#defineS_IRWXG0000070/* [XSI] RWX mask for group */
321#defineS_IRGRP0000040/* [XSI] R for group */
322#defineS_IWGRP0000020/* [XSI] W for group */
323#defineS_IXGRP0000010/* [XSI] X for group */
324/* Read, write, execute/search by others */
325#defineS_IRWXO0000007/* [XSI] RWX mask for other */
326#defineS_IROTH0000004/* [XSI] R for other */
327#defineS_IWOTH0000002/* [XSI] W for other */
328#defineS_IXOTH0000001/* [XSI] X for other */
329
330#defineS_ISUID0004000/* [XSI] set user id on execution */
331#defineS_ISGID0002000/* [XSI] set group id on execution */
332#defineS_ISVTX0001000/* [XSI] directory restrcted delete */
333
334#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
335#defineS_ISTXTS_ISVTX/* sticky bit: not supported */
336#defineS_IREADS_IRUSR/* backward compatability */
337#defineS_IWRITES_IWUSR/* backward compatability */
338#defineS_IEXECS_IXUSR/* backward compatability */
339#endif
340#endif/* !S_IFMT */
341
342#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
343/* allocate flags (F_PREALLOCATE) */
344
345#define F_ALLOCATECONTIG 0x00000002 /* allocate contigious space */
346#define F_ALLOCATEALL 0x00000004/* allocate all requested space or no space at all */
347
348/* Position Modes (fst_posmode) for F_PREALLOCATE */
349
350#define F_PEOFPOSMODE 3/* Make it past all of the SEEK pos modes so that */
351/* we can keep them in sync should we desire */
352#define F_VOLPOSMODE4/* specify volume starting postion */
353#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
354
355/*
356 * Advisory file segment locking data type -
357 * information passed to system by user
358 */
359struct flock {
360off_tl_start;/* starting offset */
361off_tl_len;/* len = 0 means until end of file */
362pid_tl_pid;/* lock owner */
363shortl_type;/* lock type: read/write, etc. */
364shortl_whence;/* type of l_start */
365};
366
367#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
368/*
369 * advisory file read data type -
370 * information passed by user to system
371 */
372
373
374struct radvisory {
375 off_t ra_offset;
376 int ra_count;
377};
378
379
380/*
381 * detached code signatures data type -
382 * information passed by user to system used by F_ADDSIGS and F_ADDFILESIGS.
383 * F_ADDFILESIGS is a shortcut for files that contain their own signature and
384 * doesn't require mapping of the file in order to load the signature.
385 */
386typedef struct fsignatures {
387off_tfs_file_start;
388void*fs_blob_start;
389size_tfs_blob_size;
390} fsignatures_t;
391
392/* lock operations for flock(2) */
393#defineLOCK_SH0x01/* shared file lock */
394#defineLOCK_EX0x02/* exclusive file lock */
395#defineLOCK_NB0x04/* don't block when locking */
396#defineLOCK_UN0x08/* unlock file */
397
398/* fstore_t type used by F_DEALLOCATE and F_PREALLOCATE commands */
399
400typedef struct fstore {
401unsigned int fst_flags;/* IN: flags word */
402int fst_posmode;/* IN: indicates use of offset field */
403off_tfst_offset;/* IN: start of the region */
404off_tfst_length;/* IN: size of the region */
405off_t fst_bytesalloc;/* OUT: number of bytes allocated */
406} fstore_t;
407
408/* fbootstraptransfer_t used by F_READBOOTSTRAP and F_WRITEBOOTSTRAP commands */
409
410typedef struct fbootstraptransfer {
411 off_t fbt_offset; /* IN: offset to start read/write */
412 size_t fbt_length; /* IN: number of bytes to transfer */
413 void *fbt_buffer; /* IN: buffer to be read/written */
414} fbootstraptransfer_t;
415
416
417/*
418 * For F_LOG2PHYS this information is passed back to user
419 * Currently only devoffset is returned - that is the VOP_BMAP
420 * result - the disk device address corresponding to the
421 * current file offset (likely set with an lseek).
422 *
423 * The flags could hold an indication of whether the # of
424 * contiguous bytes reflects the true extent length on disk,
425 * or is an advisory value that indicates there is at least that
426 * many bytes contiguous. For some filesystems it might be too
427 * inefficient to provide anything beyond the advisory value.
428 * Flags and contiguous bytes return values are not yet implemented.
429 * For them the fcntl will nedd to switch from using BMAP to CMAP
430 * and a per filesystem type flag will be needed to interpret the
431 * contiguous bytes count result from CMAP.
432 *
433 * F_LOG2PHYS_EXT is a variant of F_LOG2PHYS that uses a passed in
434 * file offset and length instead of the current file offset.
435 * F_LOG2PHYS_EXT operates on the same structure as F_LOG2PHYS, but
436 * treats it as an in/out.
437 */
438#pragma pack(4)
439
440struct log2phys {
441unsigned intl2p_flags; /* unused so far */
442off_tl2p_contigbytes; /* F_LOG2PHYS: unused so far */
443 /* F_LOG2PHYS_EXT: IN: number of bytes to be queried */
444 /* OUT: number of contiguous bytes at this position */
445off_tl2p_devoffset; /* F_LOG2PHYS: OUT: bytes into device */
446 /* F_LOG2PHYS_EXT: IN: bytes into file */
447 /* OUT: bytes into device */
448};
449
450#pragma pack()
451
452#defineO_POPUP 0x80000000 /* force window to popup on open */
453#defineO_ALERT 0x20000000/* small, clean popup window */
454
455
456#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
457
458
459#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
460#ifndef _FILESEC_T
461struct _filesec;
462typedef struct _filesec*filesec_t;
463#define _FILESEC_T
464#endif
465typedef enum {
466FILESEC_OWNER = 1,
467FILESEC_GROUP = 2,
468FILESEC_UUID = 3,
469FILESEC_MODE = 4,
470FILESEC_ACL = 5,
471FILESEC_GRPUUID = 6,
472
473/* XXX these are private to the implementation */
474FILESEC_ACL_RAW = 100,
475FILESEC_ACL_ALLOCSIZE = 101
476} filesec_property_t;
477
478/* XXX backwards compatibility */
479#define FILESEC_GUID FILESEC_UUID
480#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
481
482__BEGIN_DECLS
483
484#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
485#define _FILESEC_UNSET_PROPERTY((void *)0)
486#define _FILESEC_REMOVE_ACL((void *)1)
487#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
488__END_DECLS
489
490#endif /* !_SYS_FCNTL_H_ */
491

Archive Download this file

Revision: 2154