sl@0: /*- sl@0: * sl@0: * Copyright (c) 1983, 1990, 1993 sl@0: * The Regents of the University of California. All rights reserved. sl@0: * (c) UNIX System Laboratories, Inc. sl@0: * All or some portions of this file are derived from material licensed sl@0: * to the University of California by American Telephone and Telegraph sl@0: * Co. or Unix System Laboratories, Inc. and are reproduced herein with sl@0: * the permission of UNIX System Laboratories, Inc. sl@0: * sl@0: * Redistribution and use in source and binary forms, with or without sl@0: * modification, are permitted provided that the following conditions sl@0: * are met: sl@0: * 1. Redistributions of source code must retain the above copyright sl@0: * notice, this list of conditions and the following disclaimer. sl@0: * 2. Redistributions in binary form must reproduce the above copyright sl@0: * notice, this list of conditions and the following disclaimer in the sl@0: * documentation and/or other materials provided with the distribution. sl@0: * 4. Neither the name of the University nor the names of its contributors sl@0: * may be used to endorse or promote products derived from this software sl@0: * without specific prior written permission. sl@0: * sl@0: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND sl@0: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE sl@0: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE sl@0: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE sl@0: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL sl@0: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS sl@0: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) sl@0: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT sl@0: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY sl@0: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF sl@0: * SUCH DAMAGE. sl@0: * * © * Portions Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. sl@0: * sl@0: * @(#)fcntl.h 8.3 (Berkeley) 1/21/94 sl@0: * $FreeBSD: src/sys/sys/fcntl.h,v 1.16 2004/04/07 04:19:49 imp Exp $ sl@0: */ sl@0: sl@0: #ifndef _SYS_FCNTL_H_ sl@0: #define _SYS_FCNTL_H_ sl@0: sl@0: /* sl@0: * This file includes the definitions for open and fcntl sl@0: * described by POSIX for ; it also includes sl@0: * related kernel definitions. sl@0: */ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: #ifndef _MODE_T_DECLARED sl@0: typedef __mode_t mode_t; sl@0: #define _MODE_T_DECLARED sl@0: #endif sl@0: sl@0: #ifndef _OFF_T_DECLARED sl@0: typedef __off_t off_t; sl@0: sl@0: #if defined(SYMBIAN_OE_LARGE_FILE_SUPPORT) && !defined(SYMBIAN_OE_NO_LFS) sl@0: typedef __off_t off64_t; sl@0: #endif /* SYMBIAN_OE_LARGE_FILE_SUPPORT && !SYMBIAN_OE_NO_LFS */ sl@0: sl@0: #define _OFF_T_DECLARED sl@0: #endif sl@0: sl@0: #ifndef _PID_T_DECLARED sl@0: typedef __pid_t pid_t; sl@0: #define _PID_T_DECLARED sl@0: #endif sl@0: sl@0: /* sl@0: * File status flags: these are used by open(2), fcntl(2). sl@0: * They are also used (indirectly) in the kernel file structure f_flags, sl@0: * which is a superset of the open/fcntl flags. Open flags and f_flags sl@0: * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags). sl@0: * Open/fcntl flags begin with O_; kernel-internal flags begin with F. sl@0: */ sl@0: /* open-only flags */ sl@0: #define O_RDONLY 0x0000 /* open for reading only */ sl@0: #define O_WRONLY 0x0001 /* open for writing only */ sl@0: #define O_RDWR 0x0002 /* open for reading and writing */ sl@0: #define O_ACCMODE 0x0003 /* mask for above modes */ sl@0: sl@0: #if defined(SYMBIAN_OE_LARGE_FILE_SUPPORT) && !defined(SYMBIAN_OE_NO_LFS) sl@0: #define O_LARGEFILE 0x0004 sl@0: #endif /* SYMBIAN_OE_LARGE_FILE_SUPPORT && !SYMBIAN_OE_NO_LFS */ sl@0: sl@0: /* sl@0: * Kernel encoding of open mode; separate read and write bits that are sl@0: * independently testable: 1 greater than the above. sl@0: * sl@0: * XXX sl@0: * FREAD and FWRITE are excluded from the #ifdef _KERNEL so that TIOCFLUSH, sl@0: * which was documented to use FREAD/FWRITE, continues to work. sl@0: */ sl@0: #if __BSD_VISIBLE sl@0: #define FREAD 0x0001 sl@0: #define FWRITE 0x0002 sl@0: #endif sl@0: #define O_NONBLOCK 0x0004 /* no delay */ sl@0: #define O_APPEND 0x0008 /* set append mode */ sl@0: #if __BSD_VISIBLE sl@0: #define O_SHLOCK 0x0010 /* open with shared file lock */ sl@0: #define O_EXLOCK 0x0020 /* open with exclusive file lock */ sl@0: #define O_ASYNC 0x0040 /* signal pgrp when data ready */ sl@0: #define O_FSYNC 0x0080 /* synchronous writes */ sl@0: #endif sl@0: #define O_SYNC 0x0080 /* POSIX synonym for O_FSYNC */ sl@0: #if __BSD_VISIBLE sl@0: #define O_NOFOLLOW 0x0100 /* don't follow symlinks */ sl@0: #endif sl@0: #define O_CREAT 0x0200 /* create if nonexistent */ sl@0: #define O_TRUNC 0x0400 /* truncate to zero length */ sl@0: #define O_EXCL 0x0800 /* error if already exists */ sl@0: #ifdef _KERNEL sl@0: #define FHASLOCK 0x4000 /* descriptor holds advisory lock */ sl@0: #endif sl@0: sl@0: /* Defined by POSIX 1003.1; BSD default, but must be distinct from O_RDONLY. */ sl@0: #define O_NOCTTY 0x8000 /* don't assign controlling terminal */ sl@0: sl@0: #if __BSD_VISIBLE sl@0: /* Attempt to bypass buffer cache */ sl@0: #define O_DIRECT 0x00010000 sl@0: #endif sl@0: sl@0: //Copied from MRT1.0 fcntl.h header sl@0: #define _FBUFFERED 0x10000 /* buffer at the interface to the file system */ sl@0: #define _FBINARY 0x10000 sl@0: #define _FTEXT 0x20000 sl@0: #define O_BINARY _FBINARY sl@0: #define O_TEXT _FTEXT sl@0: #define O_BUFFERED _FBUFFERED sl@0: sl@0: /* sl@0: * XXX missing O_DSYNC, O_RSYNC. sl@0: */ sl@0: sl@0: #ifdef _KERNEL sl@0: /* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */ sl@0: #define FFLAGS(oflags) ((oflags) + 1) sl@0: #define OFLAGS(fflags) ((fflags) - 1) sl@0: sl@0: /* bits to save after open */ sl@0: #define FMASK (FREAD|FWRITE|FAPPEND|FASYNC|FFSYNC|FNONBLOCK|O_DIRECT) sl@0: /* bits settable by fcntl(F_SETFL, ...) */ sl@0: #define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FPOSIXSHM|O_DIRECT) sl@0: #endif sl@0: sl@0: /* sl@0: * The O_* flags used to have only F* names, which were used in the kernel sl@0: * and by fcntl. We retain the F* names for the kernel f_flag field sl@0: * and for backward compatibility for fcntl. These flags are deprecated. sl@0: */ sl@0: #if __BSD_VISIBLE sl@0: #define FAPPEND O_APPEND /* kernel/compat */ sl@0: #define FASYNC O_ASYNC /* kernel/compat */ sl@0: #define FFSYNC O_FSYNC /* kernel */ sl@0: #define FNONBLOCK O_NONBLOCK /* kernel */ sl@0: #define FNDELAY O_NONBLOCK /* compat */ sl@0: #define O_NDELAY O_NONBLOCK /* compat */ sl@0: #endif sl@0: sl@0: /* sl@0: * We are out of bits in f_flag (which is a short). However, sl@0: * the flag bits not set in FMASK are only meaningful in the sl@0: * initial open syscall. Those bits can thus be given a sl@0: * different meaning for fcntl(2). sl@0: */ sl@0: #if __BSD_VISIBLE sl@0: sl@0: /* sl@0: * Set by shm_open(3) to get automatic MAP_ASYNC behavior sl@0: * for POSIX shared memory objects (which are otherwise sl@0: * implemented as plain files). sl@0: */ sl@0: #define FPOSIXSHM O_NOFOLLOW sl@0: #endif sl@0: sl@0: /*SYMBIAN Flag for tmpfile removal*/ sl@0: #ifdef __SYMBIAN32__ sl@0: #define O_TMPFILE 0x10000000 /* flag for cleanup of tmpfiles*/ sl@0: #endif //__SYMBIAN32__ sl@0: /*SYMBIAN Flag for shm_open()*/ sl@0: #ifdef __SYMBIAN32__ sl@0: #define O_SHMFLG 0x01000000 /* flag for shm_open()*/ sl@0: #endif //__SYMBIAN32__ sl@0: /* sl@0: * Constants used for fcntl(2) sl@0: */ sl@0: sl@0: /* command values */ sl@0: #define F_DUPFD 0 /* duplicate file descriptor */ sl@0: #define F_GETFD 1 /* get file descriptor flags */ sl@0: #define F_SETFD 2 /* set file descriptor flags */ sl@0: #define F_GETFL 3 /* get file status flags */ sl@0: #define F_SETFL 4 /* set file status flags */ sl@0: #if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112 sl@0: #define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */ sl@0: #define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */ sl@0: #endif sl@0: #define F_GETLK 7 /* get record locking information */ sl@0: #define F_SETLK 8 /* set record locking information */ sl@0: #define F_SETLKW 9 /* F_SETLK; wait if blocked */ sl@0: sl@0: #if defined(SYMBIAN_OE_LARGE_FILE_SUPPORT) && !defined(SYMBIAN_OE_NO_LFS) sl@0: #define F_GETLK64 F_GETLK sl@0: #define F_SETLK64 F_SETLK sl@0: #define F_SETLKW64 F_SETLKW sl@0: #endif /* SYMBIAN_OE_LARGE_FILE_SUPPORT && !SYMBIAN_OE_NO_LFS */ sl@0: sl@0: /* file descriptor flags (F_GETFD, F_SETFD) */ sl@0: #define FD_CLOEXEC 1 /* close-on-exec flag */ sl@0: sl@0: /* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */ sl@0: #define F_RDLCK 1 /* shared or read lock */ sl@0: #define F_UNLCK 2 /* unlock */ sl@0: #define F_WRLCK 3 /* exclusive or write lock */ sl@0: #ifdef _KERNEL sl@0: #define F_WAIT 0x010 /* Wait until lock is granted */ sl@0: #define F_FLOCK 0x020 /* Use flock(2) semantics for lock */ sl@0: #define F_POSIX 0x040 /* Use POSIX semantics for lock */ sl@0: #endif sl@0: sl@0: /* sl@0: * Advisory file segment locking data type - sl@0: * information passed to system by user sl@0: */ sl@0: struct flock { sl@0: off_t l_start; /* starting offset */ sl@0: off_t l_len; /* len = 0 means until end of file */ sl@0: pid_t l_pid; /* lock owner */ sl@0: short l_type; /* lock type: read/write, etc. */ sl@0: short l_whence; /* type of l_start */ sl@0: }; sl@0: sl@0: #if defined(SYMBIAN_OE_LARGE_FILE_SUPPORT) && !defined(SYMBIAN_OE_NO_LFS) sl@0: #define flock64 flock sl@0: #endif /* SYMBIAN_OE_LARGE_FILE_SUPPORT && !SYMBIAN_OE_NO_LFS */ sl@0: sl@0: sl@0: #if __BSD_VISIBLE sl@0: /* lock operations for flock(2) */ sl@0: #define LOCK_SH 0x01 /* shared file lock */ sl@0: #define LOCK_EX 0x02 /* exclusive file lock */ sl@0: #define LOCK_NB 0x04 /* don't block when locking */ sl@0: #define LOCK_UN 0x08 /* unlock file */ sl@0: #endif sl@0: sl@0: /* sl@0: * XXX missing posix_fadvise() and posix_fallocate(), and POSIX_FADV_* macros. sl@0: */ sl@0: sl@0: #ifndef _KERNEL sl@0: __BEGIN_DECLS sl@0: IMPORT_C int open(const char *, int, ...); sl@0: IMPORT_C int creat(const char *, mode_t); sl@0: IMPORT_C int fcntl(int, int, ...); sl@0: sl@0: #if defined(SYMBIAN_OE_LARGE_FILE_SUPPORT) && !defined(SYMBIAN_OE_NO_LFS) sl@0: #define open64 open sl@0: #define creat64 creat sl@0: #endif /* SYMBIAN_OE_LARGE_FILE_SUPPORT && !SYMBIAN_OE_NO_LFS */ sl@0: sl@0: #if __BSD_VISIBLE sl@0: int flock(int, int); sl@0: #endif sl@0: __END_DECLS sl@0: #endif sl@0: sl@0: #endif /* !_SYS_FCNTL_H_ */