2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
34 #define _FOPEN (-1) /* from sys/file.h, kernel use only */
35 #define _FREAD 0x0001 /* read enabled */
36 #define _FWRITE 0x0002 /* write enabled */
37 #define _FNDELAY 0x0004 /* non blocking I/O (4.2 style) */
38 #define _FAPPEND 0x0008 /* append (writes guaranteed at the end) */
39 #define _FMARK 0x0010 /* internal; mark during gc() */
40 #define _FDEFER 0x0020 /* internal; defer for next gc pass */
41 #define _FASYNC 0x0040 /* signal pgrp when data ready */
42 #define _FSHLOCK 0x0080 /* BSD flock() shared lock present */
43 #define _FEXLOCK 0x0100 /* BSD flock() exclusive lock present */
44 #define _FCREAT 0x0200 /* open with file create */
45 #define _FTRUNC 0x0400 /* open with truncation */
46 #define _FEXCL 0x0800 /* error on open if file exists */
47 #define _FNBIO 0x1000 /* non blocking I/O (sys5 style) */
48 #define _FSYNC 0x2000 /* do all writes synchronously */
49 #define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */
50 #define _FNOCTTY 0x8000 /* don't assign a ctty on this open */
52 #define _FBUFFERED 0x10000 /* buffer at the interface to the file system */
54 #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
57 Flag values for open(2) and fcntl(2)
58 The kernel adds 1 to the open modes to turn it into some
59 combination of FREAD and FWRITE.
61 #define O_RDONLY 0 /* +1 == FREAD */
62 #define O_WRONLY 1 /* +1 == FWRITE */
63 #define O_RDWR 2 /* +1 == FREAD|FWRITE */
64 #define O_APPEND _FAPPEND
65 #define O_CREAT _FCREAT
66 #define O_TRUNC _FTRUNC
68 /* O_SYNC _FSYNC not posix, defined below */
69 /* O_NDELAY _FNDELAY set in include/fcntl.h */
70 /* O_NDELAY _FNBIO set in 5include/fcntl.h */
71 #define O_NONBLOCK _FNONBLOCK
72 #define O_NOCTTY _FNOCTTY
74 #define _FBINARY 0x10000
75 #define _FTEXT 0x20000
76 #define O_BINARY _FBINARY
78 #define O_BUFFERED _FBUFFERED
85 Flags that work for fcntl(fd, F_SETFL, FXXXX)
87 #define FAPPEND _FAPPEND
89 #define FASYNC _FASYNC
91 #define FNONBIO _FNONBLOCK /* XXX fix to be NONBLOCK everywhere */
92 #define FNDELAY _FNDELAY
95 Flags that are disallowed for fcntl's (FCNTLCANT);
96 used for opens, internal state, or locking.
99 #define FWRITE _FWRITE
101 #define FDEFER _FDEFER
102 #define FSHLOCK _FSHLOCK
103 #define FEXLOCK _FEXLOCK
106 The rest of the flags, used only for opens
109 #define FCREAT _FCREAT
110 #define FTRUNC _FTRUNC
112 #define FNOCTTY _FNOCTTY
113 #define FBUFFERED _FBUFFERED
115 #endif /* !_POSIX_SOURCE */
118 XXX close on exec request; must match UF_EXCLOSE in user.h
120 #define FD_CLOEXEC 1 /* posix */
125 #define F_DUPFD 0 /* Duplicate fildes */
126 #define F_GETFD 1 /* Get fildes flags (close on exec) */
127 #define F_SETFD 2 /* Set fildes flags (close on exec) */
128 #define F_GETFL 3 /* Get file flags */
129 #define F_SETFL 4 /* Set file flags */
130 #ifndef _POSIX_SOURCE
131 #define F_GETOWN 5 /* Get owner - for ASYNC */
132 #define F_SETOWN 6 /* Set owner - for ASYNC */
133 #endif /* !_POSIX_SOURCE */
134 #define F_GETLK 7 /* Get record-locking information */
135 #define F_SETLK 8 /* Set or Clear a record-lock (Non-Blocking) */
136 #define F_SETLKW 9 /* Set or Clear a record-lock (Blocking) */
137 #ifndef _POSIX_SOURCE
138 #define F_RGETLK 10 /* Test a remote lock to see if it is blocked */
139 #define F_RSETLK 11 /* Set or unlock a remote lock */
140 #define F_CNVT 12 /* Convert a fhandle to an open fd */
141 #define F_RSETLKW 13 /* Set or Clear remote record-lock(Blocking) */
142 #endif /* !_POSIX_SOURCE */
145 fcntl(2) flags (l_type field of flock structure)
147 #define F_RDLCK 1 /* read lock */
148 #define F_WRLCK 2 /* write lock */
149 #define F_UNLCK 3 /* remove lock(s) */
150 #ifndef _POSIX_SOURCE
151 #define F_UNLKSYS 4 /* remove remote locks for a given system */
152 #endif /* !_POSIX_SOURCE */
154 /*#include <sys/stdtypes.h>*/
157 file segment locking set data type - information passed to system by user
160 short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
161 short l_whence; /* flag to choose starting offset */
162 long l_start; /* relative offset, in bytes */
163 long l_len; /* length, in bytes; 0 means lock to EOF */
164 short l_pid; /* returned with F_GETLK */
165 short l_xxx; /* reserved for future use */
168 #ifndef _POSIX_SOURCE
170 extended file segment locking set data type
173 short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
174 short l_whence; /* flag to choose starting offset */
175 long l_start; /* relative offset, in bytes */
176 long l_len; /* length, in bytes; 0 means lock to EOF */
177 short l_pid; /* returned with F_GETLK */
178 short l_xxx; /* reserved for future use */
179 long l_rpid; /* Remote process id wanting this lock */
180 long l_rsys; /* Remote system id wanting this lock */
182 #endif /* !_POSIX_SOURCE */
185 #include <sys/types.h>
186 #include <sys/stat.h> /* sigh. for the mode bits for open/creat */
188 #define creat(n,m) open(n,O_WRONLY|O_CREAT|O_TRUNC,m)
189 IMPORT_C int open (const char *, int, ...);
190 IMPORT_C int wopen (const wchar_t *, int, ...);
191 extern int fcntl (int, int, ...);
196 #endif /* !_FCNTL_ */