1 fcntl.h |
1 /* |
|
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 /** |
|
24 @file |
|
25 @publishedAll |
|
26 @released |
|
27 */ |
|
28 |
|
29 #ifndef _FCNTL_ |
|
30 #define _FCNTL_ |
|
31 |
|
32 #ifdef __cplusplus |
|
33 extern "C" { |
|
34 #endif |
|
35 |
|
36 #include <_ansi.h> |
|
37 #define _FOPEN (-1) /* from sys/file.h, kernel use only */ |
|
38 #define _FREAD 0x0001 /* read enabled */ |
|
39 #define _FWRITE 0x0002 /* write enabled */ |
|
40 #define _FNDELAY 0x0004 /* non blocking I/O (4.2 style) */ |
|
41 #define _FAPPEND 0x0008 /* append (writes guaranteed at the end) */ |
|
42 #define _FMARK 0x0010 /* internal; mark during gc() */ |
|
43 #define _FDEFER 0x0020 /* internal; defer for next gc pass */ |
|
44 #define _FASYNC 0x0040 /* signal pgrp when data ready */ |
|
45 #define _FSHLOCK 0x0080 /* BSD flock() shared lock present */ |
|
46 #define _FEXLOCK 0x0100 /* BSD flock() exclusive lock present */ |
|
47 #define _FCREAT 0x0200 /* open with file create */ |
|
48 #define _FTRUNC 0x0400 /* open with truncation */ |
|
49 #define _FEXCL 0x0800 /* error on open if file exists */ |
|
50 #define _FNBIO 0x1000 /* non blocking I/O (sys5 style) */ |
|
51 #define _FSYNC 0x2000 /* do all writes synchronously */ |
|
52 #define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */ |
|
53 #define _FNOCTTY 0x8000 /* don't assign a ctty on this open */ |
|
54 |
|
55 #define _FBUFFERED 0x10000 /* buffer at the interface to the file system */ |
|
56 |
|
57 #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) |
|
58 |
|
59 /** |
|
60 Flag values for open(2) and fcntl(2) |
|
61 The kernel adds 1 to the open modes to turn it into some |
|
62 combination of FREAD and FWRITE. |
|
63 */ |
|
64 #define O_RDONLY 0 /* +1 == FREAD */ |
|
65 #define O_WRONLY 1 /* +1 == FWRITE */ |
|
66 #define O_RDWR 2 /* +1 == FREAD|FWRITE */ |
|
67 #define O_APPEND _FAPPEND |
|
68 #define O_CREAT _FCREAT |
|
69 #define O_TRUNC _FTRUNC |
|
70 #define O_EXCL _FEXCL |
|
71 /* O_SYNC _FSYNC not posix, defined below */ |
|
72 /* O_NDELAY _FNDELAY set in include/fcntl.h */ |
|
73 /* O_NDELAY _FNBIO set in 5include/fcntl.h */ |
|
74 #define O_NONBLOCK _FNONBLOCK |
|
75 #define O_NOCTTY _FNOCTTY |
|
76 |
|
77 #define _FBINARY 0x10000 |
|
78 #define _FTEXT 0x20000 |
|
79 #define O_BINARY _FBINARY |
|
80 #define O_TEXT _FTEXT |
|
81 #define O_BUFFERED _FBUFFERED |
|
82 |
|
83 #ifndef _POSIX_SOURCE |
|
84 |
|
85 #define O_SYNC _FSYNC |
|
86 |
|
87 /** |
|
88 Flags that work for fcntl(fd, F_SETFL, FXXXX) |
|
89 */ |
|
90 #define FAPPEND _FAPPEND |
|
91 #define FSYNC _FSYNC |
|
92 #define FASYNC _FASYNC |
|
93 #define FNBIO _FNBIO |
|
94 #define FNONBIO _FNONBLOCK /* XXX fix to be NONBLOCK everywhere */ |
|
95 #define FNDELAY _FNDELAY |
|
96 |
|
97 /** |
|
98 Flags that are disallowed for fcntl's (FCNTLCANT); |
|
99 used for opens, internal state, or locking. |
|
100 */ |
|
101 #define FREAD _FREAD |
|
102 #define FWRITE _FWRITE |
|
103 #define FMARK _FMARK |
|
104 #define FDEFER _FDEFER |
|
105 #define FSHLOCK _FSHLOCK |
|
106 #define FEXLOCK _FEXLOCK |
|
107 |
|
108 /** |
|
109 The rest of the flags, used only for opens |
|
110 */ |
|
111 #define FOPEN _FOPEN |
|
112 #define FCREAT _FCREAT |
|
113 #define FTRUNC _FTRUNC |
|
114 #define FEXCL _FEXCL |
|
115 #define FNOCTTY _FNOCTTY |
|
116 #define FBUFFERED _FBUFFERED |
|
117 |
|
118 #endif /* !_POSIX_SOURCE */ |
|
119 |
|
120 /** |
|
121 XXX close on exec request; must match UF_EXCLOSE in user.h |
|
122 */ |
|
123 #define FD_CLOEXEC 1 /* posix */ |
|
124 |
|
125 /** |
|
126 fcntl(2) requests |
|
127 */ |
|
128 #define F_DUPFD 0 /* Duplicate fildes */ |
|
129 #define F_GETFD 1 /* Get fildes flags (close on exec) */ |
|
130 #define F_SETFD 2 /* Set fildes flags (close on exec) */ |
|
131 #define F_GETFL 3 /* Get file flags */ |
|
132 #define F_SETFL 4 /* Set file flags */ |
|
133 #ifndef _POSIX_SOURCE |
|
134 #define F_GETOWN 5 /* Get owner - for ASYNC */ |
|
135 #define F_SETOWN 6 /* Set owner - for ASYNC */ |
|
136 #endif /* !_POSIX_SOURCE */ |
|
137 #define F_GETLK 7 /* Get record-locking information */ |
|
138 #define F_SETLK 8 /* Set or Clear a record-lock (Non-Blocking) */ |
|
139 #define F_SETLKW 9 /* Set or Clear a record-lock (Blocking) */ |
|
140 #ifndef _POSIX_SOURCE |
|
141 #define F_RGETLK 10 /* Test a remote lock to see if it is blocked */ |
|
142 #define F_RSETLK 11 /* Set or unlock a remote lock */ |
|
143 #define F_CNVT 12 /* Convert a fhandle to an open fd */ |
|
144 #define F_RSETLKW 13 /* Set or Clear remote record-lock(Blocking) */ |
|
145 #endif /* !_POSIX_SOURCE */ |
|
146 |
|
147 /** |
|
148 fcntl(2) flags (l_type field of flock structure) |
|
149 */ |
|
150 #define F_RDLCK 1 /* read lock */ |
|
151 #define F_WRLCK 2 /* write lock */ |
|
152 #define F_UNLCK 3 /* remove lock(s) */ |
|
153 #ifndef _POSIX_SOURCE |
|
154 #define F_UNLKSYS 4 /* remove remote locks for a given system */ |
|
155 #endif /* !_POSIX_SOURCE */ |
|
156 |
|
157 /*#include <sys/stdtypes.h>*/ |
|
158 |
|
159 /** |
|
160 file segment locking set data type - information passed to system by user |
|
161 */ |
|
162 struct flock { |
|
163 short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */ |
|
164 short l_whence; /* flag to choose starting offset */ |
|
165 long l_start; /* relative offset, in bytes */ |
|
166 long l_len; /* length, in bytes; 0 means lock to EOF */ |
|
167 short l_pid; /* returned with F_GETLK */ |
|
168 short l_xxx; /* reserved for future use */ |
|
169 }; |
|
170 |
|
171 #ifndef _POSIX_SOURCE |
|
172 /** |
|
173 extended file segment locking set data type |
|
174 */ |
|
175 struct eflock { |
|
176 short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */ |
|
177 short l_whence; /* flag to choose starting offset */ |
|
178 long l_start; /* relative offset, in bytes */ |
|
179 long l_len; /* length, in bytes; 0 means lock to EOF */ |
|
180 short l_pid; /* returned with F_GETLK */ |
|
181 short l_xxx; /* reserved for future use */ |
|
182 long l_rpid; /* Remote process id wanting this lock */ |
|
183 long l_rsys; /* Remote system id wanting this lock */ |
|
184 }; |
|
185 #endif /* !_POSIX_SOURCE */ |
|
186 |
|
187 |
|
188 #include <sys/types.h> |
|
189 #include <sys/stat.h> /* sigh. for the mode bits for open/creat */ |
|
190 |
|
191 #define creat(n,m) open(n,O_WRONLY|O_CREAT|O_TRUNC,m) |
|
192 IMPORT_C int open (const char *, int, ...); |
|
193 IMPORT_C int wopen (const wchar_t *, int, ...); |
|
194 extern int fcntl (int, int, ...); |
|
195 |
|
196 #ifdef __cplusplus |
|
197 } |
|
198 #endif |
|
199 #endif /* !_FCNTL_ */ |