Subversion Repositories Kolibri OS

Rev

Rev 5369 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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