epoc32/include/stdapis/sys/fcntl.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 0 061f57f2323e
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
williamr@2
     1
/*-
williamr@2
     2
 * © Portions copyright (c) 2005 Nokia Corporation.  All rights reserved.
williamr@2
     3
 * © Portions copyright (c) 2006-2007 Symbian Software Ltd. All rights reserved.
williamr@2
     4
 * Copyright (c) 1983, 1990, 1993
williamr@2
     5
 *	The Regents of the University of California.  All rights reserved.
williamr@2
     6
 * (c) UNIX System Laboratories, Inc.
williamr@2
     7
 * All or some portions of this file are derived from material licensed
williamr@2
     8
 * to the University of California by American Telephone and Telegraph
williamr@2
     9
 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
williamr@2
    10
 * the permission of UNIX System Laboratories, Inc.
williamr@2
    11
 *
williamr@2
    12
 * Redistribution and use in source and binary forms, with or without
williamr@2
    13
 * modification, are permitted provided that the following conditions
williamr@2
    14
 * are met:
williamr@2
    15
 * 1. Redistributions of source code must retain the above copyright
williamr@2
    16
 *    notice, this list of conditions and the following disclaimer.
williamr@2
    17
 * 2. Redistributions in binary form must reproduce the above copyright
williamr@2
    18
 *    notice, this list of conditions and the following disclaimer in the
williamr@2
    19
 *    documentation and/or other materials provided with the distribution.
williamr@2
    20
 * 4. Neither the name of the University nor the names of its contributors
williamr@2
    21
 *    may be used to endorse or promote products derived from this software
williamr@2
    22
 *    without specific prior written permission.
williamr@2
    23
 *
williamr@2
    24
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
williamr@2
    25
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
williamr@2
    26
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
williamr@2
    27
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
williamr@2
    28
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
williamr@2
    29
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
williamr@2
    30
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
williamr@2
    31
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
williamr@2
    32
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
williamr@2
    33
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
williamr@2
    34
 * SUCH DAMAGE.
williamr@2
    35
 *
williamr@2
    36
 *	@(#)fcntl.h	8.3 (Berkeley) 1/21/94
williamr@2
    37
 * $FreeBSD: src/sys/sys/fcntl.h,v 1.16 2004/04/07 04:19:49 imp Exp $
williamr@2
    38
 */
williamr@2
    39
williamr@2
    40
#ifndef _SYS_FCNTL_H_
williamr@2
    41
#define	_SYS_FCNTL_H_
williamr@2
    42
williamr@2
    43
/*
williamr@2
    44
 * This file includes the definitions for open and fcntl
williamr@2
    45
 * described by POSIX for <fcntl.h>; it also includes
williamr@2
    46
 * related kernel definitions.
williamr@2
    47
 */
williamr@2
    48
williamr@2
    49
#include <sys/cdefs.h>
williamr@2
    50
#include <sys/_types.h>
williamr@2
    51
williamr@2
    52
#ifndef _MODE_T_DECLARED
williamr@2
    53
typedef	__mode_t	mode_t;
williamr@2
    54
#define	_MODE_T_DECLARED
williamr@2
    55
#endif
williamr@2
    56
williamr@2
    57
#ifndef _OFF_T_DECLARED
williamr@2
    58
typedef	__off_t		off_t;
williamr@2
    59
#define	_OFF_T_DECLARED
williamr@2
    60
#endif
williamr@2
    61
williamr@2
    62
#ifndef _PID_T_DECLARED
williamr@2
    63
typedef	__pid_t		pid_t;
williamr@2
    64
#define	_PID_T_DECLARED
williamr@2
    65
#endif
williamr@2
    66
williamr@2
    67
/*
williamr@2
    68
 * File status flags: these are used by open(2), fcntl(2).
williamr@2
    69
 * They are also used (indirectly) in the kernel file structure f_flags,
williamr@2
    70
 * which is a superset of the open/fcntl flags.  Open flags and f_flags
williamr@2
    71
 * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags).
williamr@2
    72
 * Open/fcntl flags begin with O_; kernel-internal flags begin with F.
williamr@2
    73
 */
williamr@2
    74
/* open-only flags */
williamr@2
    75
#define	O_RDONLY	0x0000		/* open for reading only */
williamr@2
    76
#define	O_WRONLY	0x0001		/* open for writing only */
williamr@2
    77
#define	O_RDWR		0x0002		/* open for reading and writing */
williamr@2
    78
#define	O_ACCMODE	0x0003		/* mask for above modes */
williamr@2
    79
williamr@2
    80
/*
williamr@2
    81
 * Kernel encoding of open mode; separate read and write bits that are
williamr@2
    82
 * independently testable: 1 greater than the above.
williamr@2
    83
 *
williamr@2
    84
 * XXX
williamr@2
    85
 * FREAD and FWRITE are excluded from the #ifdef _KERNEL so that TIOCFLUSH,
williamr@2
    86
 * which was documented to use FREAD/FWRITE, continues to work.
williamr@2
    87
 */
williamr@2
    88
#if __BSD_VISIBLE
williamr@2
    89
#define	FREAD		0x0001
williamr@2
    90
#define	FWRITE		0x0002
williamr@2
    91
#endif
williamr@2
    92
#define	O_NONBLOCK	0x0004		/* no delay */
williamr@2
    93
#define	O_APPEND	0x0008		/* set append mode */
williamr@2
    94
#if __BSD_VISIBLE
williamr@2
    95
#define	O_SHLOCK	0x0010		/* open with shared file lock */
williamr@2
    96
#define	O_EXLOCK	0x0020		/* open with exclusive file lock */
williamr@2
    97
#define	O_ASYNC		0x0040		/* signal pgrp when data ready */
williamr@2
    98
#define	O_FSYNC		0x0080		/* synchronous writes */
williamr@2
    99
#endif
williamr@2
   100
#define	O_SYNC		0x0080		/* POSIX synonym for O_FSYNC */
williamr@2
   101
#if __BSD_VISIBLE
williamr@2
   102
#define	O_NOFOLLOW	0x0100		/* don't follow symlinks */
williamr@2
   103
#endif
williamr@2
   104
#define	O_CREAT		0x0200		/* create if nonexistent */
williamr@2
   105
#define	O_TRUNC		0x0400		/* truncate to zero length */
williamr@2
   106
#define	O_EXCL		0x0800		/* error if already exists */
williamr@2
   107
#ifdef _KERNEL
williamr@2
   108
#define	FHASLOCK	0x4000		/* descriptor holds advisory lock */
williamr@2
   109
#endif
williamr@2
   110
williamr@2
   111
/* Defined by POSIX 1003.1; BSD default, but must be distinct from O_RDONLY. */
williamr@2
   112
#define	O_NOCTTY	0x8000		/* don't assign controlling terminal */
williamr@2
   113
williamr@2
   114
#if __BSD_VISIBLE
williamr@2
   115
/* Attempt to bypass buffer cache */
williamr@2
   116
#define O_DIRECT	0x00010000
williamr@2
   117
#endif
williamr@2
   118
williamr@2
   119
//Copied from MRT1.0 fcntl.h header
williamr@2
   120
#define _FBUFFERED  0x10000 /* buffer at the interface to the file system */
williamr@2
   121
#define _FBINARY        0x10000
williamr@2
   122
#define _FTEXT          0x20000
williamr@2
   123
#define O_BINARY	_FBINARY
williamr@2
   124
#define O_TEXT		_FTEXT
williamr@2
   125
#define O_BUFFERED  _FBUFFERED
williamr@2
   126
williamr@2
   127
/*
williamr@2
   128
 * XXX missing O_DSYNC, O_RSYNC.
williamr@2
   129
 */
williamr@2
   130
williamr@2
   131
#ifdef _KERNEL
williamr@2
   132
/* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */
williamr@2
   133
#define	FFLAGS(oflags)	((oflags) + 1)
williamr@2
   134
#define	OFLAGS(fflags)	((fflags) - 1)
williamr@2
   135
williamr@2
   136
/* bits to save after open */
williamr@2
   137
#define	FMASK		(FREAD|FWRITE|FAPPEND|FASYNC|FFSYNC|FNONBLOCK|O_DIRECT)
williamr@2
   138
/* bits settable by fcntl(F_SETFL, ...) */
williamr@2
   139
#define	FCNTLFLAGS	(FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FPOSIXSHM|O_DIRECT)
williamr@2
   140
#endif
williamr@2
   141
williamr@2
   142
/*
williamr@2
   143
 * The O_* flags used to have only F* names, which were used in the kernel
williamr@2
   144
 * and by fcntl.  We retain the F* names for the kernel f_flag field
williamr@2
   145
 * and for backward compatibility for fcntl.  These flags are deprecated.
williamr@2
   146
 */
williamr@2
   147
#if __BSD_VISIBLE
williamr@2
   148
#define	FAPPEND		O_APPEND	/* kernel/compat */
williamr@2
   149
#define	FASYNC		O_ASYNC		/* kernel/compat */
williamr@2
   150
#define	FFSYNC		O_FSYNC		/* kernel */
williamr@2
   151
#define	FNONBLOCK	O_NONBLOCK	/* kernel */
williamr@2
   152
#define	FNDELAY		O_NONBLOCK	/* compat */
williamr@2
   153
#define	O_NDELAY	O_NONBLOCK	/* compat */
williamr@2
   154
#endif
williamr@2
   155
williamr@2
   156
/*
williamr@2
   157
 * We are out of bits in f_flag (which is a short).  However,
williamr@2
   158
 * the flag bits not set in FMASK are only meaningful in the
williamr@2
   159
 * initial open syscall.  Those bits can thus be given a
williamr@2
   160
 * different meaning for fcntl(2).
williamr@2
   161
 */
williamr@2
   162
#if __BSD_VISIBLE
williamr@2
   163
williamr@2
   164
/*
williamr@2
   165
 * Set by shm_open(3) to get automatic MAP_ASYNC behavior
williamr@2
   166
 * for POSIX shared memory objects (which are otherwise
williamr@2
   167
 * implemented as plain files).
williamr@2
   168
 */
williamr@2
   169
#define	FPOSIXSHM	O_NOFOLLOW
williamr@2
   170
#endif
williamr@2
   171
williamr@2
   172
/*SYMBIAN Flag for tmpfile removal*/
williamr@2
   173
#ifdef __SYMBIAN32__
williamr@2
   174
#define O_TMPFILE 	0x10000000		/* flag for cleanup of tmpfiles*/
williamr@2
   175
#endif //__SYMBIAN32__
williamr@2
   176
williamr@2
   177
/*
williamr@2
   178
 * Constants used for fcntl(2)
williamr@2
   179
 */
williamr@2
   180
williamr@2
   181
/* command values */
williamr@2
   182
#define	F_DUPFD		0		/* duplicate file descriptor */
williamr@2
   183
#define	F_GETFD		1		/* get file descriptor flags */
williamr@2
   184
#define	F_SETFD		2		/* set file descriptor flags */
williamr@2
   185
#define	F_GETFL		3		/* get file status flags */
williamr@2
   186
#define	F_SETFL		4		/* set file status flags */
williamr@2
   187
#if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
williamr@2
   188
#define	F_GETOWN	5		/* get SIGIO/SIGURG proc/pgrp */
williamr@2
   189
#define F_SETOWN	6		/* set SIGIO/SIGURG proc/pgrp */
williamr@2
   190
#endif
williamr@2
   191
#define	F_GETLK		7		/* get record locking information */
williamr@2
   192
#define	F_SETLK		8		/* set record locking information */
williamr@2
   193
#define	F_SETLKW	9		/* F_SETLK; wait if blocked */
williamr@2
   194
williamr@2
   195
/* file descriptor flags (F_GETFD, F_SETFD) */
williamr@2
   196
#define	FD_CLOEXEC	1		/* close-on-exec flag */
williamr@2
   197
williamr@2
   198
/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
williamr@2
   199
#define	F_RDLCK		1		/* shared or read lock */
williamr@2
   200
#define	F_UNLCK		2		/* unlock */
williamr@2
   201
#define	F_WRLCK		3		/* exclusive or write lock */
williamr@2
   202
#ifdef _KERNEL
williamr@2
   203
#define	F_WAIT		0x010		/* Wait until lock is granted */
williamr@2
   204
#define	F_FLOCK		0x020	 	/* Use flock(2) semantics for lock */
williamr@2
   205
#define	F_POSIX		0x040	 	/* Use POSIX semantics for lock */
williamr@2
   206
#endif
williamr@2
   207
williamr@2
   208
/*
williamr@2
   209
 * Advisory file segment locking data type -
williamr@2
   210
 * information passed to system by user
williamr@2
   211
 */
williamr@2
   212
struct flock {
williamr@2
   213
	off_t	l_start;	/* starting offset */
williamr@2
   214
	off_t	l_len;		/* len = 0 means until end of file */
williamr@2
   215
	pid_t	l_pid;		/* lock owner */
williamr@2
   216
	short	l_type;		/* lock type: read/write, etc. */
williamr@2
   217
	short	l_whence;	/* type of l_start */
williamr@2
   218
};
williamr@2
   219
williamr@2
   220
williamr@2
   221
#if __BSD_VISIBLE
williamr@2
   222
/* lock operations for flock(2) */
williamr@2
   223
#define	LOCK_SH		0x01		/* shared file lock */
williamr@2
   224
#define	LOCK_EX		0x02		/* exclusive file lock */
williamr@2
   225
#define	LOCK_NB		0x04		/* don't block when locking */
williamr@2
   226
#define	LOCK_UN		0x08		/* unlock file */
williamr@2
   227
#endif
williamr@2
   228
williamr@2
   229
/*
williamr@2
   230
 * XXX missing posix_fadvise() and posix_fallocate(), and POSIX_FADV_* macros.
williamr@2
   231
 */
williamr@2
   232
williamr@2
   233
#ifndef _KERNEL
williamr@2
   234
__BEGIN_DECLS
williamr@2
   235
IMPORT_C int	open(const char *, int, ...);
williamr@2
   236
IMPORT_C int	creat(const char *, mode_t);
williamr@2
   237
IMPORT_C int	fcntl(int, int, ...);
williamr@2
   238
#if __BSD_VISIBLE
williamr@2
   239
int	flock(int, int);
williamr@2
   240
#endif
williamr@2
   241
__END_DECLS
williamr@2
   242
#endif
williamr@2
   243
williamr@2
   244
#endif /* !_SYS_FCNTL_H_ */