summaryrefslogtreecommitdiffstats
path: root/man-pages-posix-2003/man0p/fcntl.h.0p
blob: 3ca3b21d28a139f30b547b82ccc9663e3f6dc1a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
.TH "<fcntl.h>" 0P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" <fcntl.h> 
.SH NAME
fcntl.h \- file control options
.SH SYNOPSIS
.LP
\fB#include <fcntl.h>\fP
.SH DESCRIPTION
.LP
The \fI<fcntl.h>\fP header shall define the following requests and
arguments for use by the functions \fIfcntl\fP() and \fIopen\fP().
.LP
Values for \fIcmd\fP used by \fIfcntl\fP() (the following values are
unique) are as
follows:
.TP 7
F_DUPFD
Duplicate file descriptor.
.TP 7
F_GETFD
Get file descriptor flags.
.TP 7
F_SETFD
Set file descriptor flags.
.TP 7
F_GETFL
Get file status flags and file access modes.
.TP 7
F_SETFL
Set file status flags.
.TP 7
F_GETLK
Get record locking information.
.TP 7
F_SETLK
Set record locking information.
.TP 7
F_SETLKW
Set record locking information; wait if blocked.
.TP 7
F_GETOWN
Get process or process group ID to receive SIGURG signals.
.TP 7
F_SETOWN
Set process or process group ID to receive SIGURG signals.
.sp
.LP
File descriptor flags used for \fIfcntl\fP() are as follows:
.TP 7
FD_CLOEXEC
Close the file descriptor upon execution of an \fIexec\fP family function.
.sp
.LP
Values for \fIl_type\fP used for record locking with \fIfcntl\fP()
(the following values
are unique) are as follows:
.TP 7
F_RDLCK
Shared or read lock.
.TP 7
F_UNLCK
Unlock.
.TP 7
F_WRLCK
Exclusive or write lock.
.sp
.LP
The values used for \fIl_whence\fP, SEEK_SET, SEEK_CUR, and SEEK_END
shall be defined as described in \fI<unistd.h>\fP . 
.LP
The following values are file creation flags and are used in the \fIoflag\fP
value to \fIopen\fP(). They shall be bitwise-distinct.
.TP 7
O_CREAT
Create file if it does not exist.
.TP 7
O_EXCL
Exclusive use flag.
.TP 7
O_NOCTTY
Do not assign controlling terminal.
.TP 7
O_TRUNC
Truncate flag.
.sp
.LP
File status flags used for \fIopen\fP() and \fIfcntl\fP() are as follows:
.TP 7
O_APPEND
Set append mode.
.TP 7
O_DSYNC
Write according to synchronized I/O data integrity completion. 
.TP 7
O_NONBLOCK
Non-blocking mode.
.TP 7
O_RSYNC
Synchronized read I/O operations. 
.TP 7
O_SYNC
Write according to synchronized I/O file integrity completion.
.sp
.LP
Mask for use with file access modes is as follows:
.TP 7
O_ACCMODE
Mask for file access modes.
.sp
.LP
File access modes used for \fIopen\fP() and \fIfcntl\fP() are as follows:
.TP 7
O_RDONLY
Open for reading only.
.TP 7
O_RDWR
Open for reading and writing.
.TP 7
O_WRONLY
Open for writing only.
.sp
.LP
The symbolic names for file modes for use as values of \fBmode_t\fP
shall be defined as described in \fI<sys/stat.h>\fP . 
.LP
Values for \fIadvice\fP used by \fIposix_fadvise\fP() are as follows:
.TP 7
POSIX_FADV_NORMAL
.sp
The application has no advice to give on its behavior with respect
to the specified data. It is the default characteristic if no
advice is given for an open file.
.TP 7
POSIX_FADV_SEQUENTIAL
.sp
The application expects to access the specified data sequentially
from lower offsets to higher offsets.
.TP 7
POSIX_FADV_RANDOM
.sp
The application expects to access the specified data in a random order.
.TP 7
POSIX_FADV_WILLNEED
.sp
The application expects to access the specified data in the near future.
.TP 7
POSIX_FADV_DONTNEED
.sp
The application expects that it will not access the specified data
in the near future.
.TP 7
POSIX_FADV_NOREUSE
.sp
The application expects to access the specified data once and then
not reuse it thereafter.
.sp
.LP
The structure \fBflock\fP describes a file lock. It shall include
the following members:
.sp
.RS
.nf

\fBshort  l_type  \fP Type of lock; F_RDLCK, F_WRLCK, F_UNLCK. \fB
short  l_whence\fP Flag for starting offset. \fB
off_t  l_start \fP Relative offset in bytes. \fB
off_t  l_len   \fP Size; if 0 then until EOF. \fB
pid_t  l_pid   \fP Process ID of the process holding the lock; returned with F_GETLK. \fB
\fP
.fi
.RE
.LP
The \fBmode_t\fP, \fBoff_t\fP, and \fBpid_t\fP types shall be defined
as described in \fI<sys/types.h>\fP .
.LP
The following shall be declared as functions and may also be defined
as macros. Function prototypes shall be provided.
.sp
.RS
.nf

\fBint  creat(const char *, mode_t);
int  fcntl(int, int, ...);
int  open(const char *, int, ...);

int  posix_fadvise(int, off_t, size_t, int);
int  posix_fallocate(int, off_t, size_t);

\fP
.fi
.RE
.LP
Inclusion of the \fI<fcntl.h>\fP header may also make visible all
symbols from \fI<sys/stat.h>\fP and \fI<unistd.h>\fP.
.LP
\fIThe following sections are informative.\fP
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fI<sys/stat.h>\fP, \fI<sys/types.h>\fP, \fI<unistd.h>\fP, the
System Interfaces volume of IEEE\ Std\ 1003.1-2001, \fIcreat\fP(),
\fIexec\fP, \fIfcntl\fP(), \fIopen\fP(), \fIposix_fadvise\fP(), \fIposix_fallocate\fP(),
\fIposix_madvise\fP()
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .