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