1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/openenvcore/include/sys/fcntl.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,272 @@
1.4 +/*-
1.5 + *
1.6 + * Copyright (c) 1983, 1990, 1993
1.7 + * The Regents of the University of California. All rights reserved.
1.8 + * (c) UNIX System Laboratories, Inc.
1.9 + * All or some portions of this file are derived from material licensed
1.10 + * to the University of California by American Telephone and Telegraph
1.11 + * Co. or Unix System Laboratories, Inc. and are reproduced herein with
1.12 + * the permission of UNIX System Laboratories, Inc.
1.13 + *
1.14 + * Redistribution and use in source and binary forms, with or without
1.15 + * modification, are permitted provided that the following conditions
1.16 + * are met:
1.17 + * 1. Redistributions of source code must retain the above copyright
1.18 + * notice, this list of conditions and the following disclaimer.
1.19 + * 2. Redistributions in binary form must reproduce the above copyright
1.20 + * notice, this list of conditions and the following disclaimer in the
1.21 + * documentation and/or other materials provided with the distribution.
1.22 + * 4. Neither the name of the University nor the names of its contributors
1.23 + * may be used to endorse or promote products derived from this software
1.24 + * without specific prior written permission.
1.25 + *
1.26 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1.27 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1.28 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1.29 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1.30 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1.31 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1.32 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1.33 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1.34 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1.35 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1.36 + * SUCH DAMAGE.
1.37 + * * © * Portions Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
1.38 + *
1.39 + * @(#)fcntl.h 8.3 (Berkeley) 1/21/94
1.40 + * $FreeBSD: src/sys/sys/fcntl.h,v 1.16 2004/04/07 04:19:49 imp Exp $
1.41 + */
1.42 +
1.43 +#ifndef _SYS_FCNTL_H_
1.44 +#define _SYS_FCNTL_H_
1.45 +
1.46 +/*
1.47 + * This file includes the definitions for open and fcntl
1.48 + * described by POSIX for <fcntl.h>; it also includes
1.49 + * related kernel definitions.
1.50 + */
1.51 +
1.52 +#include <sys/cdefs.h>
1.53 +#include <sys/_types.h>
1.54 +
1.55 +#ifndef _MODE_T_DECLARED
1.56 +typedef __mode_t mode_t;
1.57 +#define _MODE_T_DECLARED
1.58 +#endif
1.59 +
1.60 +#ifndef _OFF_T_DECLARED
1.61 +typedef __off_t off_t;
1.62 +
1.63 +#if defined(SYMBIAN_OE_LARGE_FILE_SUPPORT) && !defined(SYMBIAN_OE_NO_LFS)
1.64 +typedef __off_t off64_t;
1.65 +#endif /* SYMBIAN_OE_LARGE_FILE_SUPPORT && !SYMBIAN_OE_NO_LFS */
1.66 +
1.67 +#define _OFF_T_DECLARED
1.68 +#endif
1.69 +
1.70 +#ifndef _PID_T_DECLARED
1.71 +typedef __pid_t pid_t;
1.72 +#define _PID_T_DECLARED
1.73 +#endif
1.74 +
1.75 +/*
1.76 + * File status flags: these are used by open(2), fcntl(2).
1.77 + * They are also used (indirectly) in the kernel file structure f_flags,
1.78 + * which is a superset of the open/fcntl flags. Open flags and f_flags
1.79 + * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags).
1.80 + * Open/fcntl flags begin with O_; kernel-internal flags begin with F.
1.81 + */
1.82 +/* open-only flags */
1.83 +#define O_RDONLY 0x0000 /* open for reading only */
1.84 +#define O_WRONLY 0x0001 /* open for writing only */
1.85 +#define O_RDWR 0x0002 /* open for reading and writing */
1.86 +#define O_ACCMODE 0x0003 /* mask for above modes */
1.87 +
1.88 +#if defined(SYMBIAN_OE_LARGE_FILE_SUPPORT) && !defined(SYMBIAN_OE_NO_LFS)
1.89 +#define O_LARGEFILE 0x0004
1.90 +#endif /* SYMBIAN_OE_LARGE_FILE_SUPPORT && !SYMBIAN_OE_NO_LFS */
1.91 +
1.92 +/*
1.93 + * Kernel encoding of open mode; separate read and write bits that are
1.94 + * independently testable: 1 greater than the above.
1.95 + *
1.96 + * XXX
1.97 + * FREAD and FWRITE are excluded from the #ifdef _KERNEL so that TIOCFLUSH,
1.98 + * which was documented to use FREAD/FWRITE, continues to work.
1.99 + */
1.100 +#if __BSD_VISIBLE
1.101 +#define FREAD 0x0001
1.102 +#define FWRITE 0x0002
1.103 +#endif
1.104 +#define O_NONBLOCK 0x0004 /* no delay */
1.105 +#define O_APPEND 0x0008 /* set append mode */
1.106 +#if __BSD_VISIBLE
1.107 +#define O_SHLOCK 0x0010 /* open with shared file lock */
1.108 +#define O_EXLOCK 0x0020 /* open with exclusive file lock */
1.109 +#define O_ASYNC 0x0040 /* signal pgrp when data ready */
1.110 +#define O_FSYNC 0x0080 /* synchronous writes */
1.111 +#endif
1.112 +#define O_SYNC 0x0080 /* POSIX synonym for O_FSYNC */
1.113 +#if __BSD_VISIBLE
1.114 +#define O_NOFOLLOW 0x0100 /* don't follow symlinks */
1.115 +#endif
1.116 +#define O_CREAT 0x0200 /* create if nonexistent */
1.117 +#define O_TRUNC 0x0400 /* truncate to zero length */
1.118 +#define O_EXCL 0x0800 /* error if already exists */
1.119 +#ifdef _KERNEL
1.120 +#define FHASLOCK 0x4000 /* descriptor holds advisory lock */
1.121 +#endif
1.122 +
1.123 +/* Defined by POSIX 1003.1; BSD default, but must be distinct from O_RDONLY. */
1.124 +#define O_NOCTTY 0x8000 /* don't assign controlling terminal */
1.125 +
1.126 +#if __BSD_VISIBLE
1.127 +/* Attempt to bypass buffer cache */
1.128 +#define O_DIRECT 0x00010000
1.129 +#endif
1.130 +
1.131 +//Copied from MRT1.0 fcntl.h header
1.132 +#define _FBUFFERED 0x10000 /* buffer at the interface to the file system */
1.133 +#define _FBINARY 0x10000
1.134 +#define _FTEXT 0x20000
1.135 +#define O_BINARY _FBINARY
1.136 +#define O_TEXT _FTEXT
1.137 +#define O_BUFFERED _FBUFFERED
1.138 +
1.139 +/*
1.140 + * XXX missing O_DSYNC, O_RSYNC.
1.141 + */
1.142 +
1.143 +#ifdef _KERNEL
1.144 +/* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */
1.145 +#define FFLAGS(oflags) ((oflags) + 1)
1.146 +#define OFLAGS(fflags) ((fflags) - 1)
1.147 +
1.148 +/* bits to save after open */
1.149 +#define FMASK (FREAD|FWRITE|FAPPEND|FASYNC|FFSYNC|FNONBLOCK|O_DIRECT)
1.150 +/* bits settable by fcntl(F_SETFL, ...) */
1.151 +#define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FPOSIXSHM|O_DIRECT)
1.152 +#endif
1.153 +
1.154 +/*
1.155 + * The O_* flags used to have only F* names, which were used in the kernel
1.156 + * and by fcntl. We retain the F* names for the kernel f_flag field
1.157 + * and for backward compatibility for fcntl. These flags are deprecated.
1.158 + */
1.159 +#if __BSD_VISIBLE
1.160 +#define FAPPEND O_APPEND /* kernel/compat */
1.161 +#define FASYNC O_ASYNC /* kernel/compat */
1.162 +#define FFSYNC O_FSYNC /* kernel */
1.163 +#define FNONBLOCK O_NONBLOCK /* kernel */
1.164 +#define FNDELAY O_NONBLOCK /* compat */
1.165 +#define O_NDELAY O_NONBLOCK /* compat */
1.166 +#endif
1.167 +
1.168 +/*
1.169 + * We are out of bits in f_flag (which is a short). However,
1.170 + * the flag bits not set in FMASK are only meaningful in the
1.171 + * initial open syscall. Those bits can thus be given a
1.172 + * different meaning for fcntl(2).
1.173 + */
1.174 +#if __BSD_VISIBLE
1.175 +
1.176 +/*
1.177 + * Set by shm_open(3) to get automatic MAP_ASYNC behavior
1.178 + * for POSIX shared memory objects (which are otherwise
1.179 + * implemented as plain files).
1.180 + */
1.181 +#define FPOSIXSHM O_NOFOLLOW
1.182 +#endif
1.183 +
1.184 +/*SYMBIAN Flag for tmpfile removal*/
1.185 +#ifdef __SYMBIAN32__
1.186 +#define O_TMPFILE 0x10000000 /* flag for cleanup of tmpfiles*/
1.187 +#endif //__SYMBIAN32__
1.188 +/*SYMBIAN Flag for shm_open()*/
1.189 +#ifdef __SYMBIAN32__
1.190 +#define O_SHMFLG 0x01000000 /* flag for shm_open()*/
1.191 +#endif //__SYMBIAN32__
1.192 +/*
1.193 + * Constants used for fcntl(2)
1.194 + */
1.195 +
1.196 +/* command values */
1.197 +#define F_DUPFD 0 /* duplicate file descriptor */
1.198 +#define F_GETFD 1 /* get file descriptor flags */
1.199 +#define F_SETFD 2 /* set file descriptor flags */
1.200 +#define F_GETFL 3 /* get file status flags */
1.201 +#define F_SETFL 4 /* set file status flags */
1.202 +#if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
1.203 +#define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */
1.204 +#define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */
1.205 +#endif
1.206 +#define F_GETLK 7 /* get record locking information */
1.207 +#define F_SETLK 8 /* set record locking information */
1.208 +#define F_SETLKW 9 /* F_SETLK; wait if blocked */
1.209 +
1.210 +#if defined(SYMBIAN_OE_LARGE_FILE_SUPPORT) && !defined(SYMBIAN_OE_NO_LFS)
1.211 +#define F_GETLK64 F_GETLK
1.212 +#define F_SETLK64 F_SETLK
1.213 +#define F_SETLKW64 F_SETLKW
1.214 +#endif /* SYMBIAN_OE_LARGE_FILE_SUPPORT && !SYMBIAN_OE_NO_LFS */
1.215 +
1.216 +/* file descriptor flags (F_GETFD, F_SETFD) */
1.217 +#define FD_CLOEXEC 1 /* close-on-exec flag */
1.218 +
1.219 +/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
1.220 +#define F_RDLCK 1 /* shared or read lock */
1.221 +#define F_UNLCK 2 /* unlock */
1.222 +#define F_WRLCK 3 /* exclusive or write lock */
1.223 +#ifdef _KERNEL
1.224 +#define F_WAIT 0x010 /* Wait until lock is granted */
1.225 +#define F_FLOCK 0x020 /* Use flock(2) semantics for lock */
1.226 +#define F_POSIX 0x040 /* Use POSIX semantics for lock */
1.227 +#endif
1.228 +
1.229 +/*
1.230 + * Advisory file segment locking data type -
1.231 + * information passed to system by user
1.232 + */
1.233 +struct flock {
1.234 + off_t l_start; /* starting offset */
1.235 + off_t l_len; /* len = 0 means until end of file */
1.236 + pid_t l_pid; /* lock owner */
1.237 + short l_type; /* lock type: read/write, etc. */
1.238 + short l_whence; /* type of l_start */
1.239 +};
1.240 +
1.241 +#if defined(SYMBIAN_OE_LARGE_FILE_SUPPORT) && !defined(SYMBIAN_OE_NO_LFS)
1.242 +#define flock64 flock
1.243 +#endif /* SYMBIAN_OE_LARGE_FILE_SUPPORT && !SYMBIAN_OE_NO_LFS */
1.244 +
1.245 +
1.246 +#if __BSD_VISIBLE
1.247 +/* lock operations for flock(2) */
1.248 +#define LOCK_SH 0x01 /* shared file lock */
1.249 +#define LOCK_EX 0x02 /* exclusive file lock */
1.250 +#define LOCK_NB 0x04 /* don't block when locking */
1.251 +#define LOCK_UN 0x08 /* unlock file */
1.252 +#endif
1.253 +
1.254 +/*
1.255 + * XXX missing posix_fadvise() and posix_fallocate(), and POSIX_FADV_* macros.
1.256 + */
1.257 +
1.258 +#ifndef _KERNEL
1.259 +__BEGIN_DECLS
1.260 +IMPORT_C int open(const char *, int, ...);
1.261 +IMPORT_C int creat(const char *, mode_t);
1.262 +IMPORT_C int fcntl(int, int, ...);
1.263 +
1.264 +#if defined(SYMBIAN_OE_LARGE_FILE_SUPPORT) && !defined(SYMBIAN_OE_NO_LFS)
1.265 +#define open64 open
1.266 +#define creat64 creat
1.267 +#endif /* SYMBIAN_OE_LARGE_FILE_SUPPORT && !SYMBIAN_OE_NO_LFS */
1.268 +
1.269 +#if __BSD_VISIBLE
1.270 +int flock(int, int);
1.271 +#endif
1.272 +__END_DECLS
1.273 +#endif
1.274 +
1.275 +#endif /* !_SYS_FCNTL_H_ */