ReactOS  0.4.13-dev-100-gc8611ae
fcntl.h
Go to the documentation of this file.
1 /* @(#)fcntl.h 1.19 11/10/19 Copyright 1996-2011 J. Schilling */
2 /*
3  * Generic header for users of open(), creat() and chmod()
4  *
5  * Copyright (c) 1996-2011 J. Schilling
6  */
7 /*
8  * The contents of this file are subject to the terms of the
9  * Common Development and Distribution License, Version 1.0 only
10  * (the "License"). You may not use this file except in compliance
11  * with the License.
12  *
13  * See the file CDDL.Schily.txt in this distribution for details.
14  * A copy of the CDDL is also available via the Internet at
15  * http://www.opensource.org/licenses/cddl1.txt
16  *
17  * When distributing Covered Code, include this CDDL HEADER in each
18  * file and include the License file CDDL.Schily.txt from this distribution.
19  */
20 
21 #ifndef _SCHILY_FCNTL_H
22 #define _SCHILY_FCNTL_H
23 
24 #ifndef _SCHILY_MCONFIG_H
25 #include <schily/mconfig.h>
26 #endif
27 
28 #ifndef _SCHILY_TYPES_H
29 #include <schily/types.h> /* Needed for fcntl.h */
30 #endif
31 
32 #ifndef _SCHILY_STAT_H
33 #include <schily/stat.h> /* For 3rd arg of open() and chmod() */
34 #endif
35 
36 #ifdef HAVE_SYS_FILE_H
37 /*
38  * Historical systems with flock() only need sys/file.h
39  */
40 # ifndef _INCL_SYS_FILE_H
41 # include <sys/file.h>
42 # define _INCL_SYS_FILE_H
43 # endif
44 #endif
45 #ifdef HAVE_FCNTL_H
46 # ifndef _INCL_FCNTL_H
47 # include <fcntl.h>
48 # define _INCL_FCNTL_H
49 #endif
50 #endif
51 
52 /*
53  * Do not define more than O_RDONLY / O_WRONLY / O_RDWR / O_BINARY
54  * The values may differ.
55  *
56  * O_BINARY is defined here to allow all applications to compile on a non DOS
57  * environment without repeating this definition.
58  * O_SEARCH, O_DIRECTORY and NOFOLLOW are defined here to allow to compile on
59  * older platforms.
60  * open(name, O_SEARCH) is like UNOS open(name, "") (open neither for read nor
61  * for write). This allows to call fstat() and to get an fd for openat(fd, ...)
62  */
63 #ifndef O_RDONLY
64 # define O_RDONLY 0
65 #endif
66 #ifndef O_WRONLY
67 # define O_WRONLY 1
68 #endif
69 #ifndef O_RDWR
70 # define O_RDWR 2
71 #endif
72 #ifndef O_BINARY /* Only present on DOS or similar */
73 # define O_BINARY 0
74 #endif
75 #ifndef O_NDELAY /* This is undefined on BeOS :-( */
76 # define O_NDELAY 0
77 #endif
78 #ifndef O_EXEC /* Open for exec only (non-directory) */
79 # define O_EXEC O_RDONLY
80 #endif
81 #ifndef O_SEARCH /* Open for search only. */
82 # define O_SEARCH O_RDONLY
83 #endif
84 #ifndef O_DIRECTORY /* Fail if not a directory */
85 # define O_DIRECTORY 0
86 #endif
87 #ifndef O_NOFOLLOW /* Fail if a symlink */
88 # define O_NOFOLLOW 0
89 #endif
90 
91 #ifndef O_ACCMODE
92 #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR|O_EXEC|O_SEARCH)
93 #endif
94 
95 #ifdef O_NOATIME /* Allow #ifdef O_NOATIME */
96 #define _O_NOATIME O_NOATIME
97 #else
98 #define _O_NOATIME 0
99 #endif
100 
101 #ifndef FD_CLOEXEC
102 #define FD_CLOEXEC 1 /* close on exec flag */
103 #endif
104 
105 /*
106  * The following definitions are used for emulating the *at() functions.
107  * We use higher numbers for our definitions, to allow to add emulations
108  * for missing functions without causing a clash with system definitions.
109  */
110 #ifndef HAVE_OPENAT
111 #ifndef AT_FDCWD
112 #define AT_FDCWD 0xffd19553 /* *at() to working dir */
113 #endif
114 #endif
115 #ifndef HAVE_FSTATAT
116 #ifndef AT_SYMLINK_NOFOLLOW
117 #define AT_SYMLINK_NOFOLLOW 0x10000 /* emulate lstat() */
118 #endif
119 #endif
120 #ifndef HAVE_UNLINKAT
121 #ifndef AT_REMOVEDIR
122 #define AT_REMOVEDIR 0x20000 /* emulate rmdir() */
123 #endif
124 #endif
125 #ifndef HAVE_FACCESSAT
126 #ifndef AT_EACCESS
127 #define AT_EACCESS 0x40000 /* EUID access() */
128 #endif
129 #endif
130 #ifndef HAVE_LINKAT
131 #ifndef AT_SYMLINK_FOLLOW
132 #define AT_SYMLINK_FOLLOW 0x80000 /* follow symlinks before link() */
133 #endif
134 #endif
135 
136 #endif /* _SCHILY_FCNTL_H */