1 /* 2 Copyright (C) 2001, 2004, 2005 Axis Communications AB. 3 All rights reserved. 4 5 Redistribution and use in source and binary forms, with or without 6 modification, are permitted provided that the following conditions 7 are met: 8 9 1. Redistributions of source code must retain the above copyright 10 notice, this list of conditions and the following disclaimer. 11 12 2. Neither the name of Axis Communications nor the names of its 13 contributors may be used to endorse or promote products derived 14 from this software without specific prior written permission. 15 16 THIS SOFTWARE IS PROVIDED BY AXIS COMMUNICATIONS AND ITS CONTRIBUTORS 17 AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AXIS 20 COMMUNICATIONS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 POSSIBILITY OF SUCH DAMAGE. 28 */ 29 /* This file is to be kept in sync with newlib/libc/include/sys/fcntl.h, 30 on which it is based, except values used or returned by syscalls must 31 be those of the Linux/CRIS kernel. */ 32 33 #ifndef _FCNTL_ 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 #define _FCNTL_ 38 #include <_ansi.h> 39 #define _FOPEN (-1) /* from sys/file.h, kernel use only */ 40 #define _FREAD 0x0001 /* read enabled */ 41 #define _FWRITE 0x0002 /* write enabled */ 42 #define _FNDELAY 0x0800 /* non blocking I/O (4.2 style) */ 43 #define _FAPPEND 0x0400 /* append (writes guaranteed at the end) */ 44 #define _FMARK 0x0010 /* internal; mark during gc() */ 45 #define _FDEFER 0x0020 /* internal; defer for next gc pass */ 46 #define _FASYNC 0x2000 /* signal pgrp when data ready */ 47 #define _FCREAT 0x0040 /* open with file create */ 48 #define _FTRUNC 0x0200 /* open with truncation */ 49 #define _FEXCL 0x0080 /* error on open if file exists */ 50 #define _FNBIO _FNONBLOCK /* non blocking I/O (sys5 style) */ 51 #define _FSYNC 0x1000 /* do all writes synchronously */ 52 #define _FNONBLOCK 0x0800 /* non blocking I/O (POSIX style) */ 53 #define _FNOCTTY 0x0100 /* don't assign a ctty on this open */ 54 55 #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) 56 57 /* 58 * Flag values for open(2) and fcntl(2) 59 * The kernel adds 1 to the open modes to turn it into some 60 * combination of FREAD and FWRITE. 61 */ 62 #define O_RDONLY 0 /* +1 == FREAD */ 63 #define O_WRONLY 1 /* +1 == FWRITE */ 64 #define O_RDWR 2 /* +1 == FREAD|FWRITE */ 65 #define O_APPEND _FAPPEND 66 #define O_CREAT _FCREAT 67 #define O_TRUNC _FTRUNC 68 #define O_EXCL _FEXCL 69 /* O_SYNC _FSYNC not posix, defined below */ 70 /* O_NDELAY _FNDELAY set in include/fcntl.h */ 71 /* O_NDELAY _FNBIO set in 5include/fcntl.h */ 72 #define O_NONBLOCK _FNONBLOCK 73 #define O_NOCTTY _FNOCTTY 74 75 #ifndef _POSIX_SOURCE 76 77 #define O_SYNC _FSYNC 78 79 /* 80 * Flags that work for fcntl(fd, F_SETFL, FXXXX) 81 */ 82 #define FAPPEND _FAPPEND 83 #define FSYNC _FSYNC 84 #define FASYNC _FASYNC 85 #define FNBIO _FNBIO 86 #define FNONBIO _FNONBLOCK /* XXX fix to be NONBLOCK everywhere */ 87 #define FNDELAY _FNDELAY 88 89 /* 90 * Flags that are disallowed for fcntl's (FCNTLCANT); 91 * used for opens, internal state, or locking. 92 */ 93 #define FREAD _FREAD 94 #define FWRITE _FWRITE 95 #define FMARK _FMARK 96 #define FDEFER _FDEFER 97 #define FSHLOCK _FSHLOCK 98 #define FEXLOCK _FEXLOCK 99 100 /* 101 * The rest of the flags, used only for opens 102 */ 103 #define FOPEN _FOPEN 104 #define FCREAT _FCREAT 105 #define FTRUNC _FTRUNC 106 #define FEXCL _FEXCL 107 #define FNOCTTY _FNOCTTY 108 109 #endif /* !_POSIX_SOURCE */ 110 111 /* XXX close on exec request; must match UF_EXCLOSE in user.h */ 112 #define FD_CLOEXEC 1 /* posix */ 113 114 /* fcntl(2) requests */ 115 #define F_DUPFD 0 /* dup */ 116 #define F_GETFD 1 /* get f_flags */ 117 #define F_SETFD 2 /* set f_flags */ 118 #define F_GETFL 3 /* more flags (cloexec) */ 119 #define F_SETFL 4 120 #define F_GETLK 5 121 #define F_SETLK 6 122 #define F_SETLKW 7 123 124 #define F_SETOWN 8 /* for sockets. */ 125 #define F_GETOWN 9 /* for sockets. */ 126 127 /* for F_[GET|SET]FL */ 128 #define FD_CLOEXEC 1 /* actually anything with low bit set goes */ 129 130 /* for posix fcntl() and lockf() */ 131 #define F_RDLCK 0 132 #define F_WRLCK 1 133 #define F_UNLCK 2 134 135 /* for old implementation of bsd flock () */ 136 #define F_EXLCK 4 /* or 3 */ 137 #define F_SHLCK 8 /* or 4 */ 138 139 /* operations for bsd flock(), also used by the kernel implementation */ 140 #define LOCK_SH 1 /* shared lock */ 141 #define LOCK_EX 2 /* exclusive lock */ 142 #define LOCK_NB 4 /* or'd with one of the above to prevent 143 blocking */ 144 #define LOCK_UN 8 /* remove lock */ 145 146 /* file segment locking set data type - information passed to system by user */ 147 struct flock { 148 short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */ 149 short l_whence; /* flag to choose starting offset */ 150 long l_start; /* relative offset, in bytes */ 151 long l_len; /* length, in bytes; 0 means lock to EOF */ 152 short l_pid; /* returned with F_GETLK */ 153 short l_xxx; /* reserved for future use */ 154 }; 155 156 #ifndef _POSIX_SOURCE 157 /* extended file segment locking set data type */ 158 struct eflock { 159 short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */ 160 short l_whence; /* flag to choose starting offset */ 161 long l_start; /* relative offset, in bytes */ 162 long l_len; /* length, in bytes; 0 means lock to EOF */ 163 short l_pid; /* returned with F_GETLK */ 164 short l_xxx; /* reserved for future use */ 165 long l_rpid; /* Remote process id wanting this lock */ 166 long l_rsys; /* Remote system id wanting this lock */ 167 }; 168 #endif /* !_POSIX_SOURCE */ 169 170 171 #include <sys/types.h> 172 #include <sys/stat.h> /* sigh. for the mode bits for open/creat */ 173 174 extern int open (const char *, int, ...); 175 extern int creat (const char *, mode_t); 176 extern int fcntl (int, int, ...); 177 178 /* Provide _<systemcall> prototypes for functions provided by some versions 179 of newlib. */ 180 #ifdef _LIBC 181 extern int _open (const char *, int, ...); 182 extern int _fcntl (int, int, ...); 183 #ifdef __LARGE64_FILES 184 extern int _open64 (const char *, int, ...); 185 #endif 186 #endif 187 188 #ifdef __cplusplus 189 } 190 #endif 191 #endif /* !_FCNTL_ */ 192