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