2 #ifndef _SYS__DEFAULT_FCNTL_H_
6 #define _SYS__DEFAULT_FCNTL_H_
9 #define _FOPEN (-1) /* from sys/file.h, kernel use only */
10 #define _FREAD 0x0001 /* read enabled */
11 #define _FWRITE 0x0002 /* write enabled */
12 #define _FAPPEND 0x0008 /* append (writes guaranteed at the end) */
13 #define _FMARK 0x0010 /* internal; mark during gc() */
14 #define _FDEFER 0x0020 /* internal; defer for next gc pass */
15 #define _FASYNC 0x0040 /* signal pgrp when data ready */
16 #define _FSHLOCK 0x0080 /* BSD flock() shared lock present */
17 #define _FEXLOCK 0x0100 /* BSD flock() exclusive lock present */
18 #define _FCREAT 0x0200 /* open with file create */
19 #define _FTRUNC 0x0400 /* open with truncation */
20 #define _FEXCL 0x0800 /* error on open if file exists */
21 #define _FNBIO 0x1000 /* non blocking I/O (sys5 style) */
22 #define _FSYNC 0x2000 /* do all writes synchronously */
23 #define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */
24 #define _FNDELAY _FNONBLOCK /* non blocking I/O (4.2 style) */
25 #define _FNOCTTY 0x8000 /* don't assign a ctty on this open */
26 #if defined (__CYGWIN__)
27 #define _FBINARY 0x10000
28 #define _FTEXT 0x20000
30 #define _FNOINHERIT 0x40000
31 #define _FDIRECT 0x80000
32 #define _FNOFOLLOW 0x100000
33 #define _FDIRECTORY 0x200000
34 #define _FEXECSRCH 0x400000
35 #if defined (__CYGWIN__)
36 #define _FTMPFILE 0x800000
37 #define _FNOATIME 0x1000000
38 #define _FPATH 0x2000000
41 #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
44 * Flag values for open(2) and fcntl(2)
45 * The kernel adds 1 to the open modes to turn it into some
46 * combination of FREAD and FWRITE.
48 #define O_RDONLY 0 /* +1 == FREAD */
49 #define O_WRONLY 1 /* +1 == FWRITE */
50 #define O_RDWR 2 /* +1 == FREAD|FWRITE */
51 #define O_APPEND _FAPPEND
52 #define O_CREAT _FCREAT
53 #define O_TRUNC _FTRUNC
56 /* O_NDELAY _FNDELAY set in include/fcntl.h */
57 /* O_NDELAY _FNBIO set in include/fcntl.h */
58 #define O_NONBLOCK _FNONBLOCK
59 #define O_NOCTTY _FNOCTTY
61 /* POSIX-1.2008 specific flags */
62 #if __POSIX_VISIBLE >= 200809
63 #define O_CLOEXEC _FNOINHERIT
64 #define O_NOFOLLOW _FNOFOLLOW
65 #define O_DIRECTORY _FDIRECTORY
66 #define O_EXEC _FEXECSRCH
67 #define O_SEARCH _FEXECSRCH
71 #define O_DIRECT _FDIRECT
74 #define O_DSYNC _FSYNC
75 #define O_RSYNC _FSYNC
77 #if defined (__CYGWIN__)
78 #define O_BINARY _FBINARY
81 /* Linux-specific flags */
83 #define O_TMPFILE _FTMPFILE
84 #define O_NOATIME _FNOATIME
92 * Flags that work for fcntl(fd, F_SETFL, FXXXX)
94 #define FAPPEND _FAPPEND
96 #define FASYNC _FASYNC
98 #define FNONBIO _FNONBLOCK /* XXX fix to be NONBLOCK everywhere */
99 #define FNDELAY _FNDELAY
102 * Flags that are disallowed for fcntl's (FCNTLCANT);
103 * used for opens, internal state, or locking.
106 #define FWRITE _FWRITE
108 #define FDEFER _FDEFER
109 #define FSHLOCK _FSHLOCK
110 #define FEXLOCK _FEXLOCK
113 * The rest of the flags, used only for opens
116 #define FCREAT _FCREAT
117 #define FTRUNC _FTRUNC
119 #define FNOCTTY _FNOCTTY
121 #endif /* __MISC_VISIBLE */
124 #define FNONBLOCK _FNONBLOCK
125 #endif /* __BSD_VISIBLE */
127 /* XXX close on exec request; must match UF_EXCLOSE in user.h */
128 #define FD_CLOEXEC 1 /* posix */
130 /* fcntl(2) requests */
131 #define F_DUPFD 0 /* Duplicate fildes */
132 #define F_GETFD 1 /* Get fildes flags (close on exec) */
133 #define F_SETFD 2 /* Set fildes flags (close on exec) */
134 #define F_GETFL 3 /* Get file flags */
135 #define F_SETFL 4 /* Set file flags */
136 #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112
137 #define F_GETOWN 5 /* Get owner - for ASYNC */
138 #define F_SETOWN 6 /* Set owner - for ASYNC */
139 #endif /* __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 */
140 #define F_GETLK 7 /* Get record-locking information */
141 #define F_SETLK 8 /* Set or Clear a record-lock (Non-Blocking) */
142 #define F_SETLKW 9 /* Set or Clear a record-lock (Blocking) */
144 #define F_RGETLK 10 /* Test a remote lock to see if it is blocked */
145 #define F_RSETLK 11 /* Set or unlock a remote lock */
146 #define F_CNVT 12 /* Convert a fhandle to an open fd */
147 #define F_RSETLKW 13 /* Set or Clear remote record-lock(Blocking) */
148 #endif /* __MISC_VISIBLE */
149 #if __POSIX_VISIBLE >= 200809
150 #define F_DUPFD_CLOEXEC 14 /* As F_DUPFD, but set close-on-exec flag */
153 /* fcntl(2) flags (l_type field of flock structure) */
154 #define F_RDLCK 1 /* read lock */
155 #define F_WRLCK 2 /* write lock */
156 #define F_UNLCK 3 /* remove lock(s) */
158 #define F_UNLKSYS 4 /* remove remote locks for a given system */
159 #endif /* __MISC_VISIBLE */
161 #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809
162 /* Special descriptor value to denote the cwd in calls to openat(2) etc. */
165 /* Flag values for faccessat2) et al. */
166 #define AT_EACCESS 0x0001
167 #define AT_SYMLINK_NOFOLLOW 0x0002
168 #define AT_SYMLINK_FOLLOW 0x0004
169 #define AT_REMOVEDIR 0x0008
171 #define AT_EMPTY_PATH 0x0010
172 #define _AT_NULL_PATHNAME_ALLOWED 0x4000 /* Internal flag used by futimesat */
177 /* lock operations for flock(2) */
178 #define LOCK_SH 0x01 /* shared file lock */
179 #define LOCK_EX 0x02 /* exclusive file lock */
180 #define LOCK_NB 0x04 /* don't block when locking */
181 #define LOCK_UN 0x08 /* unlock file */
184 /*#include <sys/stdtypes.h>*/
187 /* file segment locking set data type - information passed to system by user */
189 short l_type
; /* F_RDLCK, F_WRLCK, or F_UNLCK */
190 short l_whence
; /* flag to choose starting offset */
191 long l_start
; /* relative offset, in bytes */
192 long l_len
; /* length, in bytes; 0 means lock to EOF */
193 short l_pid
; /* returned with F_GETLK */
194 short l_xxx
; /* reserved for future use */
196 #endif /* __CYGWIN__ */
199 /* extended file segment locking set data type */
201 short l_type
; /* F_RDLCK, F_WRLCK, or F_UNLCK */
202 short l_whence
; /* flag to choose starting offset */
203 long l_start
; /* relative offset, in bytes */
204 long l_len
; /* length, in bytes; 0 means lock to EOF */
205 short l_pid
; /* returned with F_GETLK */
206 short l_xxx
; /* reserved for future use */
207 long l_rpid
; /* Remote process id wanting this lock */
208 long l_rsys
; /* Remote system id wanting this lock */
210 #endif /* __MISC_VISIBLE */
212 #include <sys/types.h>
213 #include <sys/stat.h> /* sigh. for the mode bits for open/creat */
215 extern int open (const char *, int, ...);
217 extern int openat (int, const char *, int, ...);
219 extern int creat (const char *, mode_t
);
220 extern int fcntl (int, int, ...);
222 extern int flock (int, int);
225 #include <sys/time.h>
226 extern int futimesat (int, const char *, const struct timeval
[2]);
229 /* Provide _<systemcall> prototypes for functions provided by some versions
232 extern int _open (const char *, int, ...);
233 extern int _fcntl (int, int, ...);
234 #ifdef __LARGE64_FILES
235 extern int _open64 (const char *, int, ...);
242 #endif /* !_SYS__DEFAULT_FCNTL_H_ */