UbixOS V2  2.0
fcntl.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2002-2018 The UbixOS Project.
3  * All rights reserved.
4  *
5  * This was developed by Christopher W. Olsen for the UbixOS Project.
6  *
7  * Redistribution and use in source and binary forms, with or without modification, are permitted
8  * provided that the following conditions are met:
9  *
10  * 1) Redistributions of source code must retain the above copyright notice, this list of
11  * conditions, the following disclaimer and the list of authors.
12  * 2) Redistributions in binary form must reproduce the above copyright notice, this list of
13  * conditions, the following disclaimer and the list of authors in the documentation and/or
14  * other materials provided with the distribution.
15  * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to
16  * endorse or promote products derived from this software without specific prior written
17  * permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
20  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _SYS_FCNTL_H_
30 #define _SYS_FCNTL_H_
31 
32 #define AT_FDCWD -100
33 
34 /* command values */
35 #define F_DUPFD 0 /* duplicate file descriptor */
36 #define F_GETFD 1 /* get file descriptor flags */
37 #define F_SETFD 2 /* set file descriptor flags */
38 #define F_GETFL 3 /* get file status flags */
39 #define F_SETFL 4 /* set file status flags */
40 #define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */
41 #define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */
42 #define F_GETLK 7 /* get record locking information */
43 #define F_SETLK 8 /* set record locking information */
44 #define F_SETLKW 9 /* F_SETLK; wait if blocked */
45 
46 /* Flag Values */
47 #define FREAD 0x0001
48 #define FWRITE 0x0002
49 #define O_NONBLOCK 0x0004 /* no delay */
50 #define O_APPEND 0x0008 /* set append mode */
51 #define O_SHLOCK 0x0010 /* open with shared file lock */
52 #define O_EXLOCK 0x0020 /* open with exclusive file lock */
53 #define O_ASYNC 0x0040 /* signal pgrp when data ready */
54 #define O_FSYNC 0x0080 /* synchronous writes */
55 #define O_SYNC 0x0080 /* POSIX synonym for O_FSYNC */
56 #define O_NOFOLLOW 0x0100 /* don't follow symlinks */
57 #define O_CREAT 0x0200 /* create if nonexistent */
58 #define O_TRUNC 0x0400 /* truncate to zero length */
59 #define O_EXCL 0x0800 /* error if already exists */
60 #define O_DIRECT 0x00010000
61 #define O_RDONLY 0x0000 /* open for reading only */
62 #define O_WRONLY 0x0001 /* open for writing only */
63 #define O_RDWR 0x0002 /* open for reading and writing */
64 #define O_ACCMODE 0x0003 /* mask for above modes */
65 
66 #define FHASLOCK 0x4000 /* descriptor holds advisory lock */
67 
68 /* F MAPPERS */
69 #define FAPPEND O_APPEND /* kernel/compat */
70 #define FASYNC O_ASYNC /* kernel/compat */
71 #define FFSYNC O_FSYNC /* kernel */
72 #define FNONBLOCK O_NONBLOCK /* kernel */
73 #define FNDELAY O_NONBLOCK /* compat */
74 #define O_NDELAY O_NONBLOCK /* compat */
75 #define FPOSIXSHM O_NOFOLLOW
76 
77 #define O_DIRECTORY 0x00020000 /* Fail if not directory */
78 #define O_EXEC 0x00040000 /* Open for execute only */
79 
80 #define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FPOSIXSHM|O_DIRECT)
81 
82 /*
83  #define FFLAGS(oflags) ((oflags) + 1)
84  #define OFLAGS(fflags) ((fflags) - 1)
85  */
86 
87 /* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */
88 #define FFLAGS(oflags) ((oflags) & O_EXEC ? (oflags) : (oflags) + 1)
89 #define OFLAGS(fflags) ((fflags) & O_EXEC ? (fflags) : (fflags) - 1)
90 
91 #define FEXEC O_EXEC
92 
93 #define FMASK (FREAD|FWRITE|FAPPEND|FASYNC|FFSYNC|FNONBLOCK|O_DIRECT|FEXEC)
94 
95 #endif /* !_SYS_FCNTL_H_ */