-
Notifications
You must be signed in to change notification settings - Fork 1
/
fcntl.h
237 lines (190 loc) · 7.14 KB
/
fcntl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#ifndef FCNTL_H
#define FCNTL_H
#include <windows.h>
#if !defined(_MSC_VER)
#include <sys/types.h>
#endif
/* FCNTL ops */
#define F_LINUX_SPECIFIC_BASE 1024
#define F_DUPFD 0 /* dup */
#define F_GETFD 1 /* get close_on_exec */
#define F_SETFD 2 /* set/clear close_on_exec */
#define F_GETFL 3 /* get file->f_flags */
#define F_SETFL 4 /* set file->f_flags */
#ifndef F_GETLK
#define F_GETLK 5
#define F_SETLK 6
#define F_SETLKW 7
#endif
//#ifndef F_SETOWN
//#define F_SETOWN 8 /* for sockets. */
//#define F_GETOWN 9 /* for sockets. */
//#endif
//#ifndef F_SETSIG
//#define F_SETSIG 10 /* for sockets. */
//#define F_GETSIG 11 /* for sockets. */
//#endif
#ifndef F_GETLK64
#define F_GETLK64 12 /* using 'struct flock64' */
#define F_SETLK64 13
#define F_SETLKW64 14
#endif
//#ifndef F_SETOWN_EX
//#define F_SETOWN_EX 15
//#define F_GETOWN_EX 16
//#endif
/*
* Open File Description Locks
*
* Usually record locks held by a process are released on *any* close and are
* not inherited across a fork().
*
* These cmd values will set locks that conflict with process-associated
* record locks, but are "owned" by the open file description, not the
* process. This means that they are inherited across fork() like BSD (flock)
* locks, and they are only released automatically when the last reference to
* the the open file against which they were acquired is put.
*/
#define F_OFD_GETLK 36
#define F_OFD_SETLK 37
#define F_OFD_SETLKW 38
//#define F_SETLEASE (F_LINUX_SPECIFIC_BASE + 0)
//#define F_GETLEASE (F_LINUX_SPECIFIC_BASE + 1)
/*
* Request nofications on a directory.
* See below for events that may be notified.
*/
//#define F_NOTIFY (F_LINUX_SPECIFIC_BASE + 2)
#define F_DUPFD_CLOEXEC (F_LINUX_SPECIFIC_BASE + 6)
/*
* Set and get of pipe page size array
*/
//#define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7)
//#define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8)
/*
* Set/Get seals
*/
//#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
//#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
/*
* Set/Get write life time hints. {GET,SET}_RW_HINT operate on the
* underlying inode, while {GET,SET}_FILE_RW_HINT operate only on
* the specific file.
*/
//#define F_GET_RW_HINT (F_LINUX_SPECIFIC_BASE + 11)
//#define F_SET_RW_HINT (F_LINUX_SPECIFIC_BASE + 12)
//#define F_GET_FILE_RW_HINT (F_LINUX_SPECIFIC_BASE + 13)
//#define F_SET_FILE_RW_HINT (F_LINUX_SPECIFIC_BASE + 14)
/* FCNTL enum constants. */
//#define F_OWNER_TID 0
//#define F_OWNER_PID 1
//#define F_OWNER_PGRP 2
//struct f_owner_ex {
// int type;
// __kernel_pid_t pid;
//};
/* for F_[GET|SET]FL */
#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
/* for posix fcntl() and lockf() */
#ifndef F_RDLCK
#define F_RDLCK 0
#define F_WRLCK 1
#define F_UNLCK 2
#endif
/* for old implementation of bsd flock () */
#ifndef F_EXLCK
#define F_EXLCK 4 /* or 3 */
#define F_SHLCK 8 /* or 4 */
#endif
/*
* Types of seals
*/
//#define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */
//#define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */
//#define F_SEAL_GROW 0x0004 /* prevent file from growing */
//#define F_SEAL_WRITE 0x0008 /* prevent writes */
//#define F_SEAL_FUTURE_WRITE 0x0010 /* prevent future writes while mapped */
/* (1U << 31) is reserved for signed error codes */
/*
* Valid hint values for F_{GET,SET}_RW_HINT. 0 is "not set", or can be
* used to clear any hints previously set.
*/
//#define RWH_WRITE_LIFE_NOT_SET 0
//#define RWH_WRITE_LIFE_NONE 1
//#define RWH_WRITE_LIFE_SHORT 2
//#define RWH_WRITE_LIFE_MEDIUM 3
//#define RWH_WRITE_LIFE_LONG 4
//#define RWH_WRITE_LIFE_EXTREME 5
/*
* The originally introduced spelling is remained from the first
* versions of the patch set that introduced the feature, see commit
* v4.13-rc1~212^2~51.
*/
//#define RWF_WRITE_LIFE_NOT_SET RWH_WRITE_LIFE_NOT_SET
/*
* Types of directory notifications that may be requested.
*/
//#define DN_ACCESS 0x00000001 /* File accessed */
//#define DN_MODIFY 0x00000002 /* File modified */
//#define DN_CREATE 0x00000004 /* File created */
//#define DN_DELETE 0x00000008 /* File removed */
//#define DN_RENAME 0x00000010 /* File renamed */
//#define DN_ATTRIB 0x00000020 /* File changed attibutes */
//#define DN_MULTISHOT 0x80000000 /* Don't remove notifier */
#define _O_RDONLY 0x0000 /* open for reading only */
#define _O_WRONLY 0x0001 /* open for writing only */
#define _O_RDWR 0x0002 /* open for reading and writing */
#define _O_APPEND 0x0008 /* writes done at eof */
#define _O_CREAT 0x0100 /* create and open file */
#define _O_TRUNC 0x0200 /* open and truncate */
#define _O_EXCL 0x0400 /* open only if file doesn't already exist */
/* O_TEXT files have <cr><lf> sequences translated to <lf> on read()'s,
** and <lf> sequences translated to <cr><lf> on write()'s
*/
#define _O_TEXT 0x4000 /* file mode is text (translated) */
#define _O_BINARY 0x8000 /* file mode is binary (untranslated) */
/* macro to translate the C 2.0 name used to force binary mode for files */
#define _O_RAW _O_BINARY
/* Open handle inherit bit */
#define _O_NOINHERIT 0x0080 /* child process doesn't inherit file */
/* Temporary file bit - file is deleted when last handle is closed */
#define _O_TEMPORARY 0x0040 /* temporary file bit */
/* temporary access hint */
#define _O_SHORT_LIVED 0x1000 /* temporary storage file, try not to flush */
/* sequential/random access hints */
#define _O_SEQUENTIAL 0x0020 /* file access is primarily sequential */
#define _O_RANDOM 0x0010 /* file access is primarily random */
#if !defined _O_CLOEXEC && defined _O_NOINHERIT
/* Mingw spells it 'O_NOINHERIT'. */
# define _O_CLOEXEC _O_NOINHERIT
#endif
#define _O_ASYNC 0x2000
int fcntl(int fd, int cmd, ... /* arg */ );
typedef struct _QWORD _QWORD;
struct _QWORD {
DWORD ddLower;
DWORD ddUpper;
}; /* _QWORD */
#if defined(_MSC_VER)
typedef unsigned int pid_t; /* process ID of requesting task */
#endif
typedef LONG off_t;
struct flock
{
short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
off_t l_start; /* Offset where the lock begins. */
off_t l_len; /* Size of the locked area; zero means until EOF. */
pid_t l_pid; /* Process holding the lock. */
};
struct flock64
{
short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
_QWORD l_start; /* Offset where the lock begins. */
_QWORD l_len; /* Size of the locked area; zero means until EOF. */
DWORD l_pid; /* Process holding the lock. */
};
typedef struct flock flock;
typedef struct flock64 flock64;
#endif