1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LINCSYS/FCNTL.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,196 @@
1.4 +/*
1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +/**
1.24 + @file
1.25 + @publishedAll
1.26 + @released
1.27 +*/
1.28 +
1.29 +#ifndef _FCNTL_
1.30 +#define _FCNTL_
1.31 +
1.32 +#ifdef __cplusplus
1.33 +extern "C" {
1.34 +#endif
1.35 +
1.36 +#include <_ansi.h>
1.37 +#define _FOPEN (-1) /* from sys/file.h, kernel use only */
1.38 +#define _FREAD 0x0001 /* read enabled */
1.39 +#define _FWRITE 0x0002 /* write enabled */
1.40 +#define _FNDELAY 0x0004 /* non blocking I/O (4.2 style) */
1.41 +#define _FAPPEND 0x0008 /* append (writes guaranteed at the end) */
1.42 +#define _FMARK 0x0010 /* internal; mark during gc() */
1.43 +#define _FDEFER 0x0020 /* internal; defer for next gc pass */
1.44 +#define _FASYNC 0x0040 /* signal pgrp when data ready */
1.45 +#define _FSHLOCK 0x0080 /* BSD flock() shared lock present */
1.46 +#define _FEXLOCK 0x0100 /* BSD flock() exclusive lock present */
1.47 +#define _FCREAT 0x0200 /* open with file create */
1.48 +#define _FTRUNC 0x0400 /* open with truncation */
1.49 +#define _FEXCL 0x0800 /* error on open if file exists */
1.50 +#define _FNBIO 0x1000 /* non blocking I/O (sys5 style) */
1.51 +#define _FSYNC 0x2000 /* do all writes synchronously */
1.52 +#define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */
1.53 +#define _FNOCTTY 0x8000 /* don't assign a ctty on this open */
1.54 +
1.55 +#define _FBUFFERED 0x10000 /* buffer at the interface to the file system */
1.56 +
1.57 +#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
1.58 +
1.59 +/**
1.60 +Flag values for open(2) and fcntl(2)
1.61 +The kernel adds 1 to the open modes to turn it into some
1.62 +combination of FREAD and FWRITE.
1.63 +*/
1.64 +#define O_RDONLY 0 /* +1 == FREAD */
1.65 +#define O_WRONLY 1 /* +1 == FWRITE */
1.66 +#define O_RDWR 2 /* +1 == FREAD|FWRITE */
1.67 +#define O_APPEND _FAPPEND
1.68 +#define O_CREAT _FCREAT
1.69 +#define O_TRUNC _FTRUNC
1.70 +#define O_EXCL _FEXCL
1.71 +/* O_SYNC _FSYNC not posix, defined below */
1.72 +/* O_NDELAY _FNDELAY set in include/fcntl.h */
1.73 +/* O_NDELAY _FNBIO set in 5include/fcntl.h */
1.74 +#define O_NONBLOCK _FNONBLOCK
1.75 +#define O_NOCTTY _FNOCTTY
1.76 +
1.77 +#define _FBINARY 0x10000
1.78 +#define _FTEXT 0x20000
1.79 +#define O_BINARY _FBINARY
1.80 +#define O_TEXT _FTEXT
1.81 +#define O_BUFFERED _FBUFFERED
1.82 +
1.83 +#ifndef _POSIX_SOURCE
1.84 +
1.85 +#define O_SYNC _FSYNC
1.86 +
1.87 +/**
1.88 +Flags that work for fcntl(fd, F_SETFL, FXXXX)
1.89 +*/
1.90 +#define FAPPEND _FAPPEND
1.91 +#define FSYNC _FSYNC
1.92 +#define FASYNC _FASYNC
1.93 +#define FNBIO _FNBIO
1.94 +#define FNONBIO _FNONBLOCK /* XXX fix to be NONBLOCK everywhere */
1.95 +#define FNDELAY _FNDELAY
1.96 +
1.97 +/**
1.98 +Flags that are disallowed for fcntl's (FCNTLCANT);
1.99 +used for opens, internal state, or locking.
1.100 +*/
1.101 +#define FREAD _FREAD
1.102 +#define FWRITE _FWRITE
1.103 +#define FMARK _FMARK
1.104 +#define FDEFER _FDEFER
1.105 +#define FSHLOCK _FSHLOCK
1.106 +#define FEXLOCK _FEXLOCK
1.107 +
1.108 +/**
1.109 +The rest of the flags, used only for opens
1.110 +*/
1.111 +#define FOPEN _FOPEN
1.112 +#define FCREAT _FCREAT
1.113 +#define FTRUNC _FTRUNC
1.114 +#define FEXCL _FEXCL
1.115 +#define FNOCTTY _FNOCTTY
1.116 +#define FBUFFERED _FBUFFERED
1.117 +
1.118 +#endif /* !_POSIX_SOURCE */
1.119 +
1.120 +/**
1.121 +XXX close on exec request; must match UF_EXCLOSE in user.h
1.122 +*/
1.123 +#define FD_CLOEXEC 1 /* posix */
1.124 +
1.125 +/**
1.126 +fcntl(2) requests
1.127 +*/
1.128 +#define F_DUPFD 0 /* Duplicate fildes */
1.129 +#define F_GETFD 1 /* Get fildes flags (close on exec) */
1.130 +#define F_SETFD 2 /* Set fildes flags (close on exec) */
1.131 +#define F_GETFL 3 /* Get file flags */
1.132 +#define F_SETFL 4 /* Set file flags */
1.133 +#ifndef _POSIX_SOURCE
1.134 +#define F_GETOWN 5 /* Get owner - for ASYNC */
1.135 +#define F_SETOWN 6 /* Set owner - for ASYNC */
1.136 +#endif /* !_POSIX_SOURCE */
1.137 +#define F_GETLK 7 /* Get record-locking information */
1.138 +#define F_SETLK 8 /* Set or Clear a record-lock (Non-Blocking) */
1.139 +#define F_SETLKW 9 /* Set or Clear a record-lock (Blocking) */
1.140 +#ifndef _POSIX_SOURCE
1.141 +#define F_RGETLK 10 /* Test a remote lock to see if it is blocked */
1.142 +#define F_RSETLK 11 /* Set or unlock a remote lock */
1.143 +#define F_CNVT 12 /* Convert a fhandle to an open fd */
1.144 +#define F_RSETLKW 13 /* Set or Clear remote record-lock(Blocking) */
1.145 +#endif /* !_POSIX_SOURCE */
1.146 +
1.147 +/**
1.148 +fcntl(2) flags (l_type field of flock structure)
1.149 +*/
1.150 +#define F_RDLCK 1 /* read lock */
1.151 +#define F_WRLCK 2 /* write lock */
1.152 +#define F_UNLCK 3 /* remove lock(s) */
1.153 +#ifndef _POSIX_SOURCE
1.154 +#define F_UNLKSYS 4 /* remove remote locks for a given system */
1.155 +#endif /* !_POSIX_SOURCE */
1.156 +
1.157 +/*#include <sys/stdtypes.h>*/
1.158 +
1.159 +/**
1.160 +file segment locking set data type - information passed to system by user
1.161 +*/
1.162 +struct flock {
1.163 + short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
1.164 + short l_whence; /* flag to choose starting offset */
1.165 + long l_start; /* relative offset, in bytes */
1.166 + long l_len; /* length, in bytes; 0 means lock to EOF */
1.167 + short l_pid; /* returned with F_GETLK */
1.168 + short l_xxx; /* reserved for future use */
1.169 +};
1.170 +
1.171 +#ifndef _POSIX_SOURCE
1.172 +/**
1.173 +extended file segment locking set data type
1.174 +*/
1.175 +struct eflock {
1.176 + short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
1.177 + short l_whence; /* flag to choose starting offset */
1.178 + long l_start; /* relative offset, in bytes */
1.179 + long l_len; /* length, in bytes; 0 means lock to EOF */
1.180 + short l_pid; /* returned with F_GETLK */
1.181 + short l_xxx; /* reserved for future use */
1.182 + long l_rpid; /* Remote process id wanting this lock */
1.183 + long l_rsys; /* Remote system id wanting this lock */
1.184 +};
1.185 +#endif /* !_POSIX_SOURCE */
1.186 +
1.187 +
1.188 +#include <sys/types.h>
1.189 +#include <sys/stat.h> /* sigh. for the mode bits for open/creat */
1.190 +
1.191 +#define creat(n,m) open(n,O_WRONLY|O_CREAT|O_TRUNC,m)
1.192 +IMPORT_C int open (const char *, int, ...);
1.193 +IMPORT_C int wopen (const wchar_t *, int, ...);
1.194 +extern int fcntl (int, int, ...);
1.195 +
1.196 +#ifdef __cplusplus
1.197 +}
1.198 +#endif
1.199 +#endif /* !_FCNTL_ */