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