Commit | Line | Data |
---|---|---|
c9017fa0 KB |
1 | /*- |
2 | * Copyright (c) 1983, 1990 The Regents of the University of California. | |
3 | * All rights reserved. | |
bb0cfa24 | 4 | * |
c9017fa0 KB |
5 | * %sccs.include.redist.c% |
6 | * | |
0f9e0ffb | 7 | * @(#)fcntl.h 5.7 (Berkeley) %G% |
bb0cfa24 | 8 | */ |
c9d055bc | 9 | |
c9017fa0 KB |
10 | #ifndef F_DUPFD |
11 | ||
12 | /* command values for fcntl(2) */ | |
13 | #define F_DUPFD 0 /* duplicate file descriptor */ | |
14 | #define F_GETFD 1 /* get file descriptor flags */ | |
15 | #define F_SETFD 2 /* set file descriptor flags */ | |
16 | #define F_GETFL 3 /* get file status flags */ | |
17 | #define F_SETFL 4 /* set file status flags */ | |
18 | #ifndef _POSIX_SOURCE | |
19 | #define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */ | |
20 | #define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */ | |
21 | #endif | |
22 | #define F_GETLK 7 /* get record locking information */ | |
23 | #define F_SETLK 8 /* set record locking information */ | |
24 | #define F_SETLKW 9 /* F_SETLK; wait if blocked */ | |
25 | ||
26 | /* file descriptor flags (F_GETFD, F_SETFD) */ | |
27 | #define FD_CLOEXEC 1 /* close-on-exec flag */ | |
28 | ||
29 | /* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */ | |
30 | #define F_RDLCK 1 /* shared or read lock */ | |
31 | #define F_UNLCK 2 /* unlock */ | |
32 | #define F_WRLCK 3 /* exclusive or write lock */ | |
33 | ||
34 | #ifndef _POSIX_SOURCE | |
35 | /* lock operations for flock(2) */ | |
36 | #define LOCK_SH 0x01 /* shared file lock */ | |
37 | #define LOCK_EX 0x02 /* exclusive file lock */ | |
38 | #define LOCK_NB 0x04 /* don't block when locking */ | |
39 | #define LOCK_UN 0x08 /* unlock file */ | |
ccf9310d | 40 | #endif |
f7532098 | 41 | |
c9017fa0 KB |
42 | /* file status flags */ |
43 | #define O_RDONLY 00000 /* open for reading only */ | |
44 | #define O_WRONLY 00001 /* open for writing only */ | |
45 | #define O_RDWR 00002 /* open for reading and writing */ | |
46 | #define O_NONBLOCK 00004 /* no delay */ | |
47 | #ifndef _POSIX_SOURCE | |
48 | #define O_NDELAY O_NONBLOCK | |
49 | #define FNDELAY O_NONBLOCK | |
50 | #endif | |
51 | /* 00008 /* unused */ | |
52 | #define O_APPEND 00010 /* set append mode */ | |
53 | #ifndef _POSIX_SOURCE | |
54 | #define FAPPEND O_APPEND | |
55 | #endif | |
56 | /* kernel placeholders */ | |
57 | #if !defined(_POSIX_SOURCE) && defined(KERNEL) | |
58 | #define O_MARK 00020 /* mark during gc() */ | |
59 | #define O_DEFER 00040 /* defer for next gc pass */ | |
60 | #endif | |
61 | /* 00080 /* unused */ | |
62 | #ifndef _POSIX_SOURCE | |
63 | #define O_ASYNC 00100 /* signal pgrp when data ready */ | |
64 | #define FASYNC O_ASYNC | |
65 | #define O_SHLOCK 00200 /* shared file lock present */ | |
66 | #define O_EXLOCK 00400 /* exclusive file lock present */ | |
67 | /* 00800 /* unused */ | |
68 | #endif | |
69 | #define O_CREAT 01000 /* create if nonexistant */ | |
70 | #define O_TRUNC 02000 /* truncate to zero length */ | |
71 | #define O_EXCL 04000 /* error if already exists */ | |
72 | /* 08000 /* unused */ | |
73 | ||
74 | /* defined by POSIX 1003.1; BSD default, so no bit required */ | |
75 | #define O_NOCTTY 0 /* don't assign controlling terminal */ | |
76 | ||
77 | /* mask for file access modes */ | |
78 | #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) | |
79 | ||
0f9e0ffb | 80 | #ifndef KERNEL |
3608b574 | 81 | #if __STDC__ || c_plusplus |
c3d31314 | 82 | #include <sys/types.h> |
f7532098 | 83 | extern int fcntl(int, int, int); |
c9017fa0 KB |
84 | extern int creat(const char *, mode_t); |
85 | extern int open(const char *, int, ...); | |
f7532098 KB |
86 | #else |
87 | extern int fcntl(); | |
c9017fa0 KB |
88 | extern int creat(); |
89 | extern int open(); | |
f7532098 | 90 | #endif |
0f9e0ffb | 91 | #endif |
c9017fa0 KB |
92 | |
93 | #endif /* !F_DUPFD */ |