os/ossrv/genericopenlibs/cstdlib/LINCSYS/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
* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description:
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
sl@0
    20
/**
sl@0
    21
 @file
sl@0
    22
 @publishedAll
sl@0
    23
 @released
sl@0
    24
*/
sl@0
    25
sl@0
    26
#ifndef	_FCNTL_
sl@0
    27
#define	_FCNTL_
sl@0
    28
sl@0
    29
#ifdef __cplusplus
sl@0
    30
extern "C" {
sl@0
    31
#endif
sl@0
    32
sl@0
    33
#include <_ansi.h>
sl@0
    34
#define	_FOPEN		(-1)	/* from sys/file.h, kernel use only */
sl@0
    35
#define	_FREAD		0x0001	/* read enabled */
sl@0
    36
#define	_FWRITE		0x0002	/* write enabled */
sl@0
    37
#define	_FNDELAY	0x0004	/* non blocking I/O (4.2 style) */
sl@0
    38
#define	_FAPPEND	0x0008	/* append (writes guaranteed at the end) */
sl@0
    39
#define	_FMARK		0x0010	/* internal; mark during gc() */
sl@0
    40
#define	_FDEFER		0x0020	/* internal; defer for next gc pass */
sl@0
    41
#define	_FASYNC		0x0040	/* signal pgrp when data ready */
sl@0
    42
#define	_FSHLOCK	0x0080	/* BSD flock() shared lock present */
sl@0
    43
#define	_FEXLOCK	0x0100	/* BSD flock() exclusive lock present */
sl@0
    44
#define	_FCREAT		0x0200	/* open with file create */
sl@0
    45
#define	_FTRUNC		0x0400	/* open with truncation */
sl@0
    46
#define	_FEXCL		0x0800	/* error on open if file exists */
sl@0
    47
#define	_FNBIO		0x1000	/* non blocking I/O (sys5 style) */
sl@0
    48
#define	_FSYNC		0x2000	/* do all writes synchronously */
sl@0
    49
#define	_FNONBLOCK	0x4000	/* non blocking I/O (POSIX style) */
sl@0
    50
#define	_FNOCTTY	0x8000	/* don't assign a ctty on this open */
sl@0
    51
sl@0
    52
#define _FBUFFERED  0x10000 /* buffer at the interface to the file system */
sl@0
    53
sl@0
    54
#define	O_ACCMODE	(O_RDONLY|O_WRONLY|O_RDWR)
sl@0
    55
sl@0
    56
/**
sl@0
    57
Flag values for open(2) and fcntl(2)
sl@0
    58
The kernel adds 1 to the open modes to turn it into some
sl@0
    59
combination of FREAD and FWRITE.
sl@0
    60
*/
sl@0
    61
#define	O_RDONLY	0		/* +1 == FREAD */
sl@0
    62
#define	O_WRONLY	1		/* +1 == FWRITE */
sl@0
    63
#define	O_RDWR		2		/* +1 == FREAD|FWRITE */
sl@0
    64
#define	O_APPEND	_FAPPEND
sl@0
    65
#define	O_CREAT		_FCREAT
sl@0
    66
#define	O_TRUNC		_FTRUNC
sl@0
    67
#define	O_EXCL		_FEXCL
sl@0
    68
/*	O_SYNC		_FSYNC		not posix, defined below */
sl@0
    69
/*	O_NDELAY	_FNDELAY 	set in include/fcntl.h */
sl@0
    70
/*	O_NDELAY	_FNBIO 		set in 5include/fcntl.h */
sl@0
    71
#define	O_NONBLOCK	_FNONBLOCK
sl@0
    72
#define	O_NOCTTY	_FNOCTTY
sl@0
    73
sl@0
    74
#define _FBINARY        0x10000
sl@0
    75
#define _FTEXT          0x20000
sl@0
    76
#define O_BINARY	_FBINARY
sl@0
    77
#define O_TEXT		_FTEXT
sl@0
    78
#define O_BUFFERED  _FBUFFERED
sl@0
    79
sl@0
    80
#ifndef	_POSIX_SOURCE
sl@0
    81
sl@0
    82
#define	O_SYNC		_FSYNC
sl@0
    83
sl@0
    84
/**
sl@0
    85
Flags that work for fcntl(fd, F_SETFL, FXXXX)
sl@0
    86
*/
sl@0
    87
#define	FAPPEND		_FAPPEND
sl@0
    88
#define	FSYNC		_FSYNC
sl@0
    89
#define	FASYNC		_FASYNC
sl@0
    90
#define	FNBIO		_FNBIO
sl@0
    91
#define	FNONBIO		_FNONBLOCK	/* XXX fix to be NONBLOCK everywhere */
sl@0
    92
#define	FNDELAY		_FNDELAY
sl@0
    93
sl@0
    94
/**
sl@0
    95
Flags that are disallowed for fcntl's (FCNTLCANT);
sl@0
    96
used for opens, internal state, or locking.
sl@0
    97
*/
sl@0
    98
#define	FREAD		_FREAD
sl@0
    99
#define	FWRITE		_FWRITE
sl@0
   100
#define	FMARK		_FMARK
sl@0
   101
#define	FDEFER		_FDEFER
sl@0
   102
#define	FSHLOCK		_FSHLOCK
sl@0
   103
#define	FEXLOCK		_FEXLOCK
sl@0
   104
sl@0
   105
/**
sl@0
   106
The rest of the flags, used only for opens
sl@0
   107
*/
sl@0
   108
#define	FOPEN		_FOPEN
sl@0
   109
#define	FCREAT		_FCREAT
sl@0
   110
#define	FTRUNC		_FTRUNC
sl@0
   111
#define	FEXCL		_FEXCL
sl@0
   112
#define	FNOCTTY		_FNOCTTY
sl@0
   113
#define FBUFFERED   _FBUFFERED
sl@0
   114
sl@0
   115
#endif	/* !_POSIX_SOURCE */
sl@0
   116
sl@0
   117
/**
sl@0
   118
XXX close on exec request; must match UF_EXCLOSE in user.h 
sl@0
   119
*/
sl@0
   120
#define	FD_CLOEXEC	1	/* posix */
sl@0
   121
sl@0
   122
/** 
sl@0
   123
fcntl(2) requests 
sl@0
   124
*/
sl@0
   125
#define	F_DUPFD		0	/* Duplicate fildes */
sl@0
   126
#define	F_GETFD		1	/* Get fildes flags (close on exec) */
sl@0
   127
#define	F_SETFD		2	/* Set fildes flags (close on exec) */
sl@0
   128
#define	F_GETFL		3	/* Get file flags */
sl@0
   129
#define	F_SETFL		4	/* Set file flags */
sl@0
   130
#ifndef	_POSIX_SOURCE
sl@0
   131
#define	F_GETOWN 	5	/* Get owner - for ASYNC */
sl@0
   132
#define	F_SETOWN 	6	/* Set owner - for ASYNC */
sl@0
   133
#endif	/* !_POSIX_SOURCE */
sl@0
   134
#define	F_GETLK  	7	/* Get record-locking information */
sl@0
   135
#define	F_SETLK  	8	/* Set or Clear a record-lock (Non-Blocking) */
sl@0
   136
#define	F_SETLKW 	9	/* Set or Clear a record-lock (Blocking) */
sl@0
   137
#ifndef	_POSIX_SOURCE
sl@0
   138
#define	F_RGETLK 	10	/* Test a remote lock to see if it is blocked */
sl@0
   139
#define	F_RSETLK 	11	/* Set or unlock a remote lock */
sl@0
   140
#define	F_CNVT 		12	/* Convert a fhandle to an open fd */
sl@0
   141
#define	F_RSETLKW 	13	/* Set or Clear remote record-lock(Blocking) */
sl@0
   142
#endif	/* !_POSIX_SOURCE */
sl@0
   143
sl@0
   144
/** 
sl@0
   145
fcntl(2) flags (l_type field of flock structure) 
sl@0
   146
*/
sl@0
   147
#define	F_RDLCK		1	/* read lock */
sl@0
   148
#define	F_WRLCK		2	/* write lock */
sl@0
   149
#define	F_UNLCK		3	/* remove lock(s) */
sl@0
   150
#ifndef	_POSIX_SOURCE
sl@0
   151
#define	F_UNLKSYS	4	/* remove remote locks for a given system */
sl@0
   152
#endif	/* !_POSIX_SOURCE */
sl@0
   153
sl@0
   154
/*#include <sys/stdtypes.h>*/
sl@0
   155
sl@0
   156
/** 
sl@0
   157
file segment locking set data type - information passed to system by user 
sl@0
   158
*/
sl@0
   159
struct flock {
sl@0
   160
	short	l_type;		/* F_RDLCK, F_WRLCK, or F_UNLCK */
sl@0
   161
	short	l_whence;	/* flag to choose starting offset */
sl@0
   162
	long	l_start;	/* relative offset, in bytes */
sl@0
   163
	long	l_len;		/* length, in bytes; 0 means lock to EOF */
sl@0
   164
	short	l_pid;		/* returned with F_GETLK */
sl@0
   165
	short	l_xxx;		/* reserved for future use */
sl@0
   166
};
sl@0
   167
sl@0
   168
#ifndef	_POSIX_SOURCE
sl@0
   169
/** 
sl@0
   170
extended file segment locking set data type 
sl@0
   171
*/
sl@0
   172
struct eflock {
sl@0
   173
	short	l_type;		/* F_RDLCK, F_WRLCK, or F_UNLCK */
sl@0
   174
	short	l_whence;	/* flag to choose starting offset */
sl@0
   175
	long	l_start;	/* relative offset, in bytes */
sl@0
   176
	long	l_len;		/* length, in bytes; 0 means lock to EOF */
sl@0
   177
	short	l_pid;		/* returned with F_GETLK */
sl@0
   178
	short	l_xxx;		/* reserved for future use */
sl@0
   179
	long	l_rpid;		/* Remote process id wanting this lock */
sl@0
   180
	long	l_rsys;		/* Remote system id wanting this lock */
sl@0
   181
};
sl@0
   182
#endif	/* !_POSIX_SOURCE */
sl@0
   183
sl@0
   184
sl@0
   185
#include <sys/types.h>
sl@0
   186
#include <sys/stat.h>		/* sigh. for the mode bits for open/creat */
sl@0
   187
sl@0
   188
#define creat(n,m)	open(n,O_WRONLY|O_CREAT|O_TRUNC,m)
sl@0
   189
IMPORT_C int open	(const char *, int, ...);
sl@0
   190
IMPORT_C int wopen	(const wchar_t *, int, ...);
sl@0
   191
extern int fcntl	(int, int, ...);
sl@0
   192
sl@0
   193
#ifdef __cplusplus
sl@0
   194
}
sl@0
   195
#endif
sl@0
   196
#endif	/* !_FCNTL_ */