Changeset 685
- Timestamp:
- Sep 11, 2003, 3:14:29 AM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/include/sys/fcntl.h
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r684 r685 1 /* sys/fcntl.h (emx+gcc) */ 2 3 #ifndef _SYS_FCNTL_H 4 #define _SYS_FCNTL_H 5 6 #if defined (__cplusplus) 7 extern "C" { 8 #endif 9 10 /* Don't forget to update /emx/src/dos/termio.inc when changing this! */ 11 12 #if !defined (O_RDONLY) 13 #define O_ACCMODE 0x03 /* mask */ 14 #define O_RDONLY 0x00 15 #define O_WRONLY 0x01 16 #define O_RDWR 0x02 17 #define O_NONBLOCK 0x04 18 #define O_APPEND 0x08 19 #define O_TEXT 0x10 20 1 /*- 2 * Copyright (c) 1983, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the University of 21 * California, Berkeley and its contributors. 22 * 4. Neither the name of the University nor the names of its contributors 23 * may be used to endorse or promote products derived from this software 24 * without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)fcntl.h 8.3 (Berkeley) 1/21/94 39 * $FreeBSD: src/sys/sys/fcntl.h,v 1.14 2002/09/17 22:22:50 mike Exp $ 40 */ 41 42 /** @file 43 * FreeBSD 5.1 + EMX 44 * 45 * @changed bird: EMX isms. 46 * @changed bird: Removed (non KERNEL) stuff we don't implement and added 47 * EMX specific stuff. 48 * @todo Consider implementing the flags and commands we don't currently 49 * include. 50 */ 51 52 #ifndef _SYS_FCNTL_H_ 53 #define _SYS_FCNTL_H_ 54 #define _SYS_FCNTL_H /* bird: EMX */ 55 56 /* 57 * This file includes the definitions for open and fcntl 58 * described by POSIX for <fcntl.h>; it also includes 59 * related kernel definitions. 60 */ 61 62 #include <sys/cdefs.h> 63 #include <sys/_types.h> 64 65 #if !defined(_MODE_T_DECLARED) && !defined(_MODE_T) /* bird: EMX */ 66 typedef __mode_t mode_t; 67 #define _MODE_T_DECLARED 68 #define _MODE_T /* bird: EMX */ 69 #endif 70 71 #if !defined(_OFF_T_DECLARED) && !defined(_OFF_T) /* bird: EMX */ 72 typedef __off_t off_t; 73 #define _OFF_T_DECLARED 74 #define _OFF_T /* bird: EMX */ 75 #endif 76 77 #if !defined(_PID_T_DECLARED) && !defined(_PID_T) /* bird: EMX */ 78 typedef __pid_t pid_t; 79 #define _PID_T_DECLARED 80 #define _PID_T /* bird: EMX */ 81 #endif 82 83 /* 84 * File status flags: these are used by open(2), fcntl(2). 85 * They are also used (indirectly) in the kernel file structure f_flags, 86 * which is a superset of the open/fcntl flags. Open flags and f_flags 87 * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags). 88 * Open/fcntl flags begin with O_; kernel-internal flags begin with F. 89 */ 90 /* open-only flags */ 91 #define O_RDONLY 0x0000 /* open for reading only */ 92 #define O_WRONLY 0x0001 /* open for writing only */ 93 #define O_RDWR 0x0002 /* open for reading and writing */ 94 #define O_ACCMODE 0x0003 /* mask for above modes */ 95 96 /* 97 * Kernel encoding of open mode; separate read and write bits that are 98 * independently testable: 1 greater than the above. 99 * 100 * XXX 101 * FREAD and FWRITE are excluded from the #ifdef _KERNEL so that TIOCFLUSH, 102 * which was documented to use FREAD/FWRITE, continues to work. 103 */ 104 #if __BSD_VISIBLE 105 #ifndef FREAD /* bird: safety */ 106 #define FREAD 0x0001 107 #define FWRITE 0x0002 108 #endif 109 #endif /* bird: safety */ 110 #define O_NONBLOCK 0x0004 /* no delay */ 111 #define O_APPEND 0x0008 /* set append mode */ 112 #if __BSD_VISIBLE 113 #if 0 /* bird: not implemented - start */ 114 #define O_SHLOCK 0x0010 /* open with shared file lock */ 115 #define O_EXLOCK 0x0020 /* open with exclusive file lock */ 116 #define O_ASYNC 0x0040 /* signal pgrp when data ready */ 117 #endif /* bird: not implemented - end */ 118 #define O_FSYNC 0x0080 /* synchronous writes */ 119 #endif 120 /* bird: EMX used 0x2000 for O_SYNC. */ 121 #define O_SYNC 0x0080 /* POSIX synonym for O_FSYNC */ 122 #if 0 /* bird: not implemented - start */ 123 #if __BSD_VISIBLE 124 #define O_NOFOLLOW 0x0100 /* don't follow symlinks */ 125 #endif 126 #endif /* bird: not implemented - end */ 127 #define O_CREAT 0x0200 /* create if nonexistent */ 128 #define O_TRUNC 0x0400 /* truncate to zero length */ 129 #define O_EXCL 0x0800 /* error if already exists */ 130 #ifdef _KERNEL 131 /* FMARK/FDEFER kept in f_gcflags */ 132 #define FMARK 0x1 /* mark during gc() */ 133 #define FDEFER 0x2 /* defer for next gc pass */ 134 #define FHASLOCK 0x4000 /* descriptor holds advisory lock */ 135 #endif 136 137 /* Defined by POSIX 1003.1; BSD default, but must be distinct from O_RDONLY. */ 138 /* bird: EMX used 0x4000 for O_NOCTTY. */ 139 #define O_NOCTTY 0x8000 /* don't assign controlling terminal */ 140 141 #if 0 /* bird: not implemented - start */ 142 #if __BSD_VISIBLE 143 /* Attempt to bypass buffer cache */ 144 #define O_DIRECT 0x00010000 145 #endif 146 #endif /* bird: not implemented - end */ 147 148 /* 149 * XXX missing O_DSYNC, O_RSYNC. 150 */ 151 152 #ifdef _KERNEL 153 /* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */ 154 #define FFLAGS(oflags) ((oflags) + 1) 155 #define OFLAGS(fflags) ((fflags) - 1) 156 157 /* bits to save after open */ 158 #define FMASK (FREAD|FWRITE|FAPPEND|FASYNC|FFSYNC|FNONBLOCK|O_DIRECT) 159 /* bits settable by fcntl(F_SETFL, ...) */ 160 #define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FPOSIXSHM|O_DIRECT) 161 #endif 162 163 /* 164 * The O_* flags used to have only F* names, which were used in the kernel 165 * and by fcntl. We retain the F* names for the kernel f_flag field 166 * and for backward compatibility for fcntl. These flags are deprecated. 167 */ 168 #if __BSD_VISIBLE 169 #define FAPPEND O_APPEND /* kernel/compat */ 170 #if 0 /* bird: not implemented - start */ 171 #define FASYNC O_ASYNC /* kernel/compat */ 172 #endif /* bird: not implemented - end */ 173 #define FFSYNC O_FSYNC /* kernel */ 174 #define FNONBLOCK O_NONBLOCK /* kernel */ 175 #define FNDELAY O_NONBLOCK /* compat */ 176 #define O_NDELAY O_NONBLOCK /* compat */ 177 #endif 178 179 #if 0 /* bird: not implemented - start */ 180 /* 181 * We are out of bits in f_flag (which is a short). However, 182 * the flag bits not set in FMASK are only meaningful in the 183 * initial open syscall. Those bits can thus be given a 184 * different meaning for fcntl(2). 185 */ 186 #if __BSD_VISIBLE 187 188 /* 189 * Set by shm_open(3) to get automatic MAP_ASYNC behavior 190 * for POSIX shared memory objects (which are otherwise 191 * implemented as plain files). 192 */ 193 #define FPOSIXSHM O_NOFOLLOW 194 #endif 195 #endif /* bird: not implemented - end */ 196 197 /* 198 * Constants used for fcntl(2) 199 */ 200 201 /* command values */ 202 /* bird: EMX used 5 for F_DUPFD. */ 203 #define F_DUPFD 0 /* duplicate file descriptor */ 204 /* bird: EMX used 3 for F_GETFD. */ 205 #define F_GETFD 1 /* get file descriptor flags */ 206 /* bird: EMX used 4 for F_SETFD. */ 207 #define F_SETFD 2 /* set file descriptor flags */ 208 /* bird: EMX used 1 for F_GETFL. */ 209 #define F_GETFL 3 /* get file status flags */ 210 /* bird: EMX used 2 for F_SETFL. */ 211 #define F_SETFL 4 /* set file status flags */ 212 #if 0 /* bird: not implemented - start */ 213 #if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112 214 #define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */ 215 #define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */ 216 #endif 217 #endif /* bird: not implemented - end */ 218 #define F_GETLK 7 /* get record locking information */ 219 #define F_SETLK 8 /* set record locking information */ 220 #define F_SETLKW 9 /* F_SETLK; wait if blocked */ 221 222 223 /* file descriptor flags (F_GETFD, F_SETFD) */ 224 #define FD_CLOEXEC 1 /* close-on-exec flag */ 225 226 /* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */ 227 #define F_RDLCK 1 /* shared or read lock */ 228 #define F_UNLCK 2 /* unlock */ 229 #define F_WRLCK 3 /* exclusive or write lock */ 230 #ifdef _KERNEL 231 #define F_WAIT 0x010 /* Wait until lock is granted */ 232 #define F_FLOCK 0x020 /* Use flock(2) semantics for lock */ 233 #define F_POSIX 0x040 /* Use POSIX semantics for lock */ 234 #endif 235 236 /* 237 * Advisory file segment locking data type - 238 * information passed to system by user 239 */ 240 struct flock { 241 off_t l_start; /* starting offset */ 242 off_t l_len; /* len = 0 means until end of file */ 243 pid_t l_pid; /* lock owner */ 244 short l_type; /* lock type: read/write, etc. */ 245 short l_whence; /* type of l_start */ 246 }; 247 248 249 #if __BSD_VISIBLE 250 /* lock operations for flock(2) */ 251 #define LOCK_SH 0x01 /* shared file lock */ 252 #define LOCK_EX 0x02 /* exclusive file lock */ 253 #define LOCK_NB 0x04 /* don't block when locking */ 254 #define LOCK_UN 0x08 /* unlock file */ 255 #endif 256 257 /* 258 * XXX missing posix_fadvise() and posix_fallocate(), and POSIX_FADV_* macros. 259 */ 260 261 #ifndef _KERNEL 262 __BEGIN_DECLS 263 int open(const char *, int, ...); 264 int creat(const char *, mode_t); 265 int fcntl(int, int, ...); 266 #if __BSD_VISIBLE 267 int flock(int, int); 268 #endif 269 __END_DECLS 270 #endif 271 272 /* bird: EMX stuff - start */ 273 #if !defined (O_TEXT) 274 /* Open flags. 275 As stated in the FreeBSD part, there is supposidly a limited number of bits 276 available. We'll try keep in suitable for 16bit just in case (don't care to 277 check what we use right now). 278 When we've disabled a few BSD flags and leave out KERNEL stuff the following 279 bits are available: 280 0x0010, 0x0020, 0x0040, 0x0100, 0x1000, 0x4000*, 0x2000 281 */ 282 #define O_TEXT 0x0010 21 283 #define O_BINARY 0x0100 22 #define O_CREAT 0x0200 23 #define O_TRUNC 0x0400 24 #define O_EXCL 0x0800 25 #define O_SYNC 0x2000 26 #define O_NOCTTY 0x4000 27 #define O_SIZE 0x8000 28 284 #define O_SIZE 0x0020 /* EMX used 0x8000 for O_SIZE. */ 29 285 #if !defined (_POSIX_SOURCE) 30 #define O_NDELAY O_NONBLOCK 31 #define O_NOINHERIT 0x1000 32 #endif 33 34 #endif 35 36 #if !defined (F_OK) 37 #define F_OK 0 38 #define X_OK 1 39 #define W_OK 2 40 #define R_OK 4 41 #endif 42 43 #if !defined (F_GETFL) 44 #define F_GETFL 1 45 #define F_SETFL 2 46 #define F_GETFD 3 47 #define F_SETFD 4 48 #define F_DUPFD 5 49 #define F_GETOSFD 6 /* RSXNT */ 50 #endif 51 52 #if !defined (FD_CLOEXEC) 53 #define FD_CLOEXEC 0x01 54 #endif 55 56 int creat (__const__ char *, int); 57 int fcntl (int, int, ...); 58 int open (__const__ char *, int, ...); 59 60 #if !defined (_POSIX_SOURCE) 61 62 #if !defined (LOCK_SH) 63 #define LOCK_SH 0x01 64 #define LOCK_EX 0x02 65 #define LOCK_NB 0x04 66 #define LOCK_UN 0x08 67 #endif 68 69 int flock (int, int); 70 71 #endif 72 286 #define O_NOINHERIT 0x1000 /* EMX used 0x1000 for O_NOINHERIT. */ 287 #endif 288 #endif 289 290 /* fcntl command */ 291 /* bird: EMX specifics - start */ 292 #define F_GETOSFD 20 /* RSXNT */ /* F_GETOSFD used to be 6 */ 293 /* bird: EMX specifics - end */ 294 295 296 #if !defined (F_OK) /* bird: Really defined in unistd.h, but Linux and EMX does it here too. */ 297 /* access function */ 298 #define F_OK 0 /* test for existence of file */ 299 #define X_OK 0x01 /* test for execute or search permission */ 300 #define W_OK 0x02 /* test for write permission */ 301 #define R_OK 0x04 /* test for read permission */ 302 #endif 73 303 74 304 #if !defined (_POSIX_SOURCE) || defined (_WITH_UNDERSCORE) 75 305 __BEGIN_DECLS 76 306 int _creat (__const__ char *, int); 77 307 int _fcntl (int, int, ...); 78 308 int _flock (int, int); 79 309 int _open (__const__ char *, int, ...); 80 81 #endif 82 83 84 #if defined (__cplusplus) 85 } 86 #endif 87 88 #endif /* not _SYS_FCNTL_H */ 310 __END_DECLS 311 #endif 312 /* bird: EMX stuff - end */ 313 314 #endif /* !_SYS_FCNTL_H_ */ -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.