1 |
27 |
unneback |
#ifndef CYGONCE_ISO_FCNTL_H
|
2 |
|
|
#define CYGONCE_ISO_FCNTL_H
|
3 |
|
|
/*========================================================================
|
4 |
|
|
//
|
5 |
|
|
// fcntl.h
|
6 |
|
|
//
|
7 |
|
|
// POSIX file control functions
|
8 |
|
|
//
|
9 |
|
|
//========================================================================
|
10 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
11 |
|
|
// -------------------------------------------
|
12 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
13 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
14 |
|
|
//
|
15 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
16 |
|
|
// the terms of the GNU General Public License as published by the Free
|
17 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
18 |
|
|
//
|
19 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
20 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
21 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
22 |
|
|
// for more details.
|
23 |
|
|
//
|
24 |
|
|
// You should have received a copy of the GNU General Public License along
|
25 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
26 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
27 |
|
|
//
|
28 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
29 |
|
|
// or inline functions from this file, or you compile this file and link it
|
30 |
|
|
// with other works to produce a work based on this file, this file does not
|
31 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
32 |
|
|
// License. However the source code for this file must still be made available
|
33 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
34 |
|
|
//
|
35 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
36 |
|
|
// this file might be covered by the GNU General Public License.
|
37 |
|
|
//
|
38 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
39 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
40 |
|
|
// -------------------------------------------
|
41 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
42 |
|
|
//========================================================================
|
43 |
|
|
//#####DESCRIPTIONBEGIN####
|
44 |
|
|
//
|
45 |
|
|
// Author(s): jlarmour
|
46 |
|
|
// Contributors:
|
47 |
|
|
// Date: 2000-05-05
|
48 |
|
|
// Purpose: This file provides the macros, types and functions
|
49 |
|
|
// for file control required by POSIX 1003.1.
|
50 |
|
|
// Description: The real contents of this file get set from the
|
51 |
|
|
// configuration (set by the implementation)
|
52 |
|
|
// Usage: #include <fcntl.h>
|
53 |
|
|
//
|
54 |
|
|
//####DESCRIPTIONEND####
|
55 |
|
|
//
|
56 |
|
|
//======================================================================
|
57 |
|
|
*/
|
58 |
|
|
|
59 |
|
|
/* CONFIGURATION */
|
60 |
|
|
|
61 |
|
|
#include <pkgconf/isoinfra.h> /* Configuration header */
|
62 |
|
|
|
63 |
|
|
/* INCLUDES */
|
64 |
|
|
|
65 |
|
|
#ifdef CYGBLD_ISO_OFLAG_HEADER
|
66 |
|
|
# include CYGBLD_ISO_OFLAG_HEADER
|
67 |
|
|
#else
|
68 |
|
|
|
69 |
|
|
/* File access modes used for open() and fnctl() */
|
70 |
|
|
#define O_RDONLY (1<<0) /* Open for reading only */
|
71 |
|
|
#define O_WRONLY (1<<1) /* Open for writing only */
|
72 |
|
|
#define O_RDWR (O_RDONLY|O_WRONLY) /* Open for reading and writing */
|
73 |
|
|
|
74 |
|
|
/* File access mode mask */
|
75 |
|
|
#define O_ACCMODE (O_RDONLY|O_RDWR|O_WRONLY)
|
76 |
|
|
|
77 |
|
|
/* open() mode flags */
|
78 |
|
|
|
79 |
|
|
#define O_CREAT (1<<3) /* Create file it it does not exist */
|
80 |
|
|
#define O_EXCL (1<<4) /* Exclusive use */
|
81 |
|
|
#define O_NOCTTY (1<<5) /* Do not assign a controlling terminal */
|
82 |
|
|
#define O_TRUNC (1<<6) /* Truncate */
|
83 |
|
|
|
84 |
|
|
/* File status flags used for open() and fcntl() */
|
85 |
|
|
#define O_APPEND (1<<7) /* Set append mode */
|
86 |
|
|
#define O_DSYNC (1<<8) /* Synchronized I/O data integrity writes */
|
87 |
|
|
#define O_NONBLOCK (1<<9) /* No delay */
|
88 |
|
|
#define O_RSYNC (1<<10) /* Synchronized read I/O */
|
89 |
|
|
#define O_SYNC (1<<11) /* Synchronized I/O file integrity writes */
|
90 |
|
|
|
91 |
|
|
#endif /* ifndef CYGBLD_ISO_OFLAG_HEADER */
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
#if CYGINT_ISO_FCNTL
|
95 |
|
|
# ifdef CYGBLD_ISO_FCNTL_HEADER
|
96 |
|
|
# include CYGBLD_ISO_FCNTL_HEADER
|
97 |
|
|
# else
|
98 |
|
|
|
99 |
|
|
/* fcntl() command values */
|
100 |
|
|
|
101 |
|
|
#define F_DUPFD (1<<0) /* Duplicate file descriptor */
|
102 |
|
|
#define F_GETFD (1<<1) /* Get file descriptor flags */
|
103 |
|
|
#define F_SETFD (1<<2) /* Set file descriptor flags */
|
104 |
|
|
#define F_GETFL (1<<3) /* Get file status flags */
|
105 |
|
|
#define F_SETFL (1<<4) /* Set file status flags */
|
106 |
|
|
#define F_GETLK (1<<5) /* Get record locking information */
|
107 |
|
|
#define F_SETLK (1<<6) /* Set record locking information */
|
108 |
|
|
#define F_SETLKW (1<<7) /* Set record locking info; wait if blocked */
|
109 |
|
|
|
110 |
|
|
/* fd flags */
|
111 |
|
|
#define FD_CLOEXEC (1<<0) /* Close fd on exec */
|
112 |
|
|
|
113 |
|
|
/* Lock types */
|
114 |
|
|
|
115 |
|
|
#define F_RDLCK (1<<0) /* Shared or read lock */
|
116 |
|
|
#define F_UNLCK (1<<1) /* Unlock */
|
117 |
|
|
#define F_WRLCK (1<<2) /* Exclusive or write lock */
|
118 |
|
|
|
119 |
|
|
#include <sys/types.h> /* off_t, pid_t */
|
120 |
|
|
|
121 |
|
|
struct flock {
|
122 |
|
|
short l_type; /* F_RDLCK, F_WRLCK, F_UNLCK */
|
123 |
|
|
short l_whence; /* Flag for starting offset */
|
124 |
|
|
off_t l_start; /* Relative offset in bytes */
|
125 |
|
|
off_t l_len; /* Size; if 0, then until EOF */
|
126 |
|
|
pid_t l_pid; /* Process ID of the process holding the lock,
|
127 |
|
|
* returned with F_GETLK. */
|
128 |
|
|
};
|
129 |
|
|
|
130 |
|
|
#ifdef __cplusplus
|
131 |
|
|
extern "C"
|
132 |
|
|
#else
|
133 |
|
|
extern
|
134 |
|
|
#endif
|
135 |
|
|
|
136 |
|
|
int
|
137 |
|
|
fcntl( int /* fildes */, int /* cmd */, ... );
|
138 |
|
|
|
139 |
|
|
# endif /* ifndef CYGBLD_ISO_FCNTL_HEADER */
|
140 |
|
|
#endif /* if CYGINT_ISO_FCNTL */
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
#if CYGINT_ISO_OPEN
|
144 |
|
|
# ifdef CYGBLD_ISO_OPEN_HEADER
|
145 |
|
|
# include CYGBLD_ISO_OPEN_HEADER
|
146 |
|
|
# else
|
147 |
|
|
|
148 |
|
|
#ifdef __cplusplus
|
149 |
|
|
extern "C" {
|
150 |
|
|
#endif
|
151 |
|
|
|
152 |
|
|
#include <sys/types.h> /* mode_t */
|
153 |
|
|
|
154 |
|
|
extern int
|
155 |
|
|
open( const char * /* path */, int /* oflag */, ... );
|
156 |
|
|
|
157 |
|
|
extern int
|
158 |
|
|
creat( const char * /* path */, mode_t /* mode */ );
|
159 |
|
|
|
160 |
|
|
#ifdef __cplusplus
|
161 |
|
|
} /* extern "C" */
|
162 |
|
|
#endif
|
163 |
|
|
|
164 |
|
|
# endif /* ifndef CYGBLD_ISO_OPEN_HEADER */
|
165 |
|
|
#endif /* if CYGINT_ISO_OPEN */
|
166 |
|
|
|
167 |
|
|
#endif /* CYGONCE_ISO_FCNTL_H multiple inclusion protection */
|
168 |
|
|
|
169 |
|
|
/* EOF fcntl.h */
|