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