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