Subversion Repositories Kolibri OS

Rev

Rev 4872 | Rev 4921 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4349 Serge 1
 
2
#ifdef __cplusplus
3
extern "C" {
4
#endif
5
#define	_SYS__DEFAULT_FCNTL_H_
6
#include <_ansi.h>
7
#define	_FOPEN		(-1)	/* from sys/file.h, kernel use only */
8
#define	_FREAD		0x0001	/* read enabled */
9
#define	_FWRITE		0x0002	/* write enabled */
10
#define	_FAPPEND	0x0008	/* append (writes guaranteed at the end) */
11
#define	_FMARK		0x0010	/* internal; mark during gc() */
12
#define	_FDEFER		0x0020	/* internal; defer for next gc pass */
13
#define	_FASYNC		0x0040	/* signal pgrp when data ready */
14
#define	_FSHLOCK	0x0080	/* BSD flock() shared lock present */
15
#define	_FEXLOCK	0x0100	/* BSD flock() exclusive lock present */
16
#define	_FCREAT		0x0200	/* open with file create */
17
#define	_FTRUNC		0x0400	/* open with truncation */
18
#define	_FEXCL		0x0800	/* error on open if file exists */
19
#define	_FNBIO		0x1000	/* non blocking I/O (sys5 style) */
20
#define	_FSYNC		0x2000	/* do all writes synchronously */
21
#define	_FNONBLOCK	0x4000	/* non blocking I/O (POSIX style) */
22
#define	_FNDELAY	_FNONBLOCK	/* non blocking I/O (4.2 style) */
23
#define	_FNOCTTY	0x8000	/* don't assign a ctty on this open */
24
25
 
26
27
 
28
 * Flag values for open(2) and fcntl(2)
29
 * The kernel adds 1 to the open modes to turn it into some
30
 * combination of FREAD and FWRITE.
31
 */
32
#define	O_RDONLY	0		/* +1 == FREAD */
33
#define	O_WRONLY	1		/* +1 == FWRITE */
34
#define	O_RDWR		2		/* +1 == FREAD|FWRITE */
35
#define	O_APPEND	_FAPPEND
36
#define	O_CREAT		_FCREAT
37
#define	O_TRUNC		_FTRUNC
38
#define	O_EXCL		_FEXCL
39
#define O_SYNC		_FSYNC
40
/*	O_NDELAY	_FNDELAY 	set in include/fcntl.h */
41
/*	O_NDELAY	_FNBIO 		set in include/fcntl.h */
42
#define	O_NONBLOCK	_FNONBLOCK
43
#define	O_NOCTTY	_FNOCTTY
44
45
 
46
#define _FTEXT          0x20000
47
#define _FNOINHERIT 0x40000
48
49
 
50
#define O_TEXT      _FTEXT
51
#define O_NOINHERIT _FNOINHERIT
52
53
 
54
#if defined (_WIN32) || defined (__CYGWIN__)
55
#define _FBINARY        0x10000
56
#define _FTEXT          0x20000
57
#define _FNOINHERIT	0x40000
58
59
 
60
#define O_TEXT		_FTEXT
61
#define O_NOINHERIT	_FNOINHERIT
62
/* O_CLOEXEC is the Linux equivalent to O_NOINHERIT */
63
#define O_CLOEXEC	_FNOINHERIT
64
65
 
66
#define _O_RDONLY	O_RDONLY
67
#define _O_WRONLY	O_WRONLY
68
#define _O_RDWR		O_RDWR
69
#define _O_APPEND	O_APPEND
70
#define _O_CREAT	O_CREAT
71
#define _O_TRUNC	O_TRUNC
72
#define _O_EXCL		O_EXCL
73
#define _O_TEXT		O_TEXT
74
#define _O_BINARY	O_BINARY
75
#define _O_RAW		O_BINARY
76
#define _O_NOINHERIT	O_NOINHERIT
77
#endif
78
79
 
80
81
 
82
 * Flags that work for fcntl(fd, F_SETFL, FXXXX)
83
 */
84
#define	FAPPEND		_FAPPEND
85
#define	FSYNC		_FSYNC
86
#define	FASYNC		_FASYNC
87
#define	FNBIO		_FNBIO
88
#define	FNONBIO		_FNONBLOCK	/* XXX fix to be NONBLOCK everywhere */
89
#define	FNDELAY		_FNDELAY
90
91
 
92
 * Flags that are disallowed for fcntl's (FCNTLCANT);
93
 * used for opens, internal state, or locking.
94
 */
95
#define	FREAD		_FREAD
96
#define	FWRITE		_FWRITE
97
#define	FMARK		_FMARK
98
#define	FDEFER		_FDEFER
99
#define	FSHLOCK		_FSHLOCK
100
#define	FEXLOCK		_FEXLOCK
101
102
 
103
 * The rest of the flags, used only for opens
104
 */
105
#define	FOPEN		_FOPEN
106
#define	FCREAT		_FCREAT
107
#define	FTRUNC		_FTRUNC
108
#define	FEXCL		_FEXCL
109
#define	FNOCTTY		_FNOCTTY
110
111
 
112
113
 
114
#define	FD_CLOEXEC	1	/* posix */
115
116
 
117
#define	F_DUPFD		0	/* Duplicate fildes */
118
#define	F_GETFD		1	/* Get fildes flags (close on exec) */
119
#define	F_SETFD		2	/* Set fildes flags (close on exec) */
120
#define	F_GETFL		3	/* Get file flags */
121
#define	F_SETFL		4	/* Set file flags */
122
#ifndef	_POSIX_SOURCE
123
#define	F_GETOWN 	5	/* Get owner - for ASYNC */
124
#define	F_SETOWN 	6	/* Set owner - for ASYNC */
125
#endif	/* !_POSIX_SOURCE */
126
#define	F_GETLK  	7	/* Get record-locking information */
127
#define	F_SETLK  	8	/* Set or Clear a record-lock (Non-Blocking) */
128
#define	F_SETLKW 	9	/* Set or Clear a record-lock (Blocking) */
129
#ifndef	_POSIX_SOURCE
130
#define	F_RGETLK 	10	/* Test a remote lock to see if it is blocked */
131
#define	F_RSETLK 	11	/* Set or unlock a remote lock */
132
#define	F_CNVT 		12	/* Convert a fhandle to an open fd */
133
#define	F_RSETLKW 	13	/* Set or Clear remote record-lock(Blocking) */
134
#endif	/* !_POSIX_SOURCE */
135
#ifdef __CYGWIN__
136
#define	F_DUPFD_CLOEXEC	14	/* As F_DUPFD, but set close-on-exec flag */
137
#endif
138
139
 
140
#define	F_RDLCK		1	/* read lock */
141
#define	F_WRLCK		2	/* write lock */
142
#define	F_UNLCK		3	/* remove lock(s) */
143
#ifndef	_POSIX_SOURCE
144
#define	F_UNLKSYS	4	/* remove remote locks for a given system */
145
#endif	/* !_POSIX_SOURCE */
146
147
 
148
/* Special descriptor value to denote the cwd in calls to openat(2) etc. */
149
#define AT_FDCWD -2
150
151
 
152
#define AT_EACCESS              1
153
#define AT_SYMLINK_NOFOLLOW     2
154
#define AT_SYMLINK_FOLLOW       4
155
#define AT_REMOVEDIR            8
156
#endif
157
158
 
159
160
 
161
/* file segment locking set data type - information passed to system by user */
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
#endif /* __CYGWIN__ */
171
172
 
173
/* extended file segment locking set data type */
174
struct eflock {
175
	short	l_type;		/* F_RDLCK, F_WRLCK, or F_UNLCK */
176
	short	l_whence;	/* flag to choose starting offset */
177
	long	l_start;	/* relative offset, in bytes */
178
	long	l_len;		/* length, in bytes; 0 means lock to EOF */
179
	short	l_pid;		/* returned with F_GETLK */
180
	short	l_xxx;		/* reserved for future use */
181
	long	l_rpid;		/* Remote process id wanting this lock */
182
	long	l_rsys;		/* Remote system id wanting this lock */
183
};
184
#endif	/* !_POSIX_SOURCE */
185
186
 
187
 
188
#include 		/* sigh. for the mode bits for open/creat */
189
190
 
191
extern int creat _PARAMS ((const char *, mode_t));
192
extern int fcntl _PARAMS ((int, int, ...));
193
#ifdef __CYGWIN__
194
#include 
195
extern int futimesat _PARAMS ((int, const char *, const struct timeval *));
196
extern int openat _PARAMS ((int, const char *, int, ...));
197
#endif
198
199
 
200
   of newlib.  */
201
#ifdef _COMPILING_NEWLIB
202
extern int _open _PARAMS ((const char *, int, ...));
203
extern int _fcntl _PARAMS ((int, int, ...));
204
#ifdef __LARGE64_FILES
205
extern int _open64 _PARAMS ((const char *, int, ...));
206
#endif
207
#endif
208
209
 
210
}
211
#endif
212
#endif	/* !_SYS__DEFAULT_FCNTL_H_ */
213