]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man0p/fcntl.h.0p
Import of man-pages 1.70
[thirdparty/man-pages.git] / man0p / fcntl.h.0p
1 .\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
2 .TH "<fcntl.h>" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
3 .\" <fcntl.h>
4 .SH NAME
5 fcntl.h \- file control options
6 .SH SYNOPSIS
7 .LP
8 \fB#include <fcntl.h>\fP
9 .SH DESCRIPTION
10 .LP
11 The \fI<fcntl.h>\fP header shall define the following requests and
12 arguments for use by the functions \fIfcntl\fP() and \fIopen\fP().
13 .LP
14 Values for \fIcmd\fP used by \fIfcntl\fP() (the following values are
15 unique) are as
16 follows:
17 .TP 7
18 F_DUPFD
19 Duplicate file descriptor.
20 .TP 7
21 F_GETFD
22 Get file descriptor flags.
23 .TP 7
24 F_SETFD
25 Set file descriptor flags.
26 .TP 7
27 F_GETFL
28 Get file status flags and file access modes.
29 .TP 7
30 F_SETFL
31 Set file status flags.
32 .TP 7
33 F_GETLK
34 Get record locking information.
35 .TP 7
36 F_SETLK
37 Set record locking information.
38 .TP 7
39 F_SETLKW
40 Set record locking information; wait if blocked.
41 .TP 7
42 F_GETOWN
43 Get process or process group ID to receive SIGURG signals.
44 .TP 7
45 F_SETOWN
46 Set process or process group ID to receive SIGURG signals.
47 .sp
48 .LP
49 File descriptor flags used for \fIfcntl\fP() are as follows:
50 .TP 7
51 FD_CLOEXEC
52 Close the file descriptor upon execution of an \fIexec\fP family function.
53 .sp
54 .LP
55 Values for \fIl_type\fP used for record locking with \fIfcntl\fP()
56 (the following values
57 are unique) are as follows:
58 .TP 7
59 F_RDLCK
60 Shared or read lock.
61 .TP 7
62 F_UNLCK
63 Unlock.
64 .TP 7
65 F_WRLCK
66 Exclusive or write lock.
67 .sp
68 .LP
69 The values used for \fIl_whence\fP, SEEK_SET, SEEK_CUR, and SEEK_END
70 shall be defined as described in \fI<unistd.h>\fP .
71 .LP
72 The following values are file creation flags and are used in the \fIoflag\fP
73 value to \fIopen\fP(). They shall be bitwise-distinct.
74 .TP 7
75 O_CREAT
76 Create file if it does not exist.
77 .TP 7
78 O_EXCL
79 Exclusive use flag.
80 .TP 7
81 O_NOCTTY
82 Do not assign controlling terminal.
83 .TP 7
84 O_TRUNC
85 Truncate flag.
86 .sp
87 .LP
88 File status flags used for \fIopen\fP() and \fIfcntl\fP() are as follows:
89 .TP 7
90 O_APPEND
91 Set append mode.
92 .TP 7
93 O_DSYNC
94 Write according to synchronized I/O data integrity completion.
95 .TP 7
96 O_NONBLOCK
97 Non-blocking mode.
98 .TP 7
99 O_RSYNC
100 Synchronized read I/O operations.
101 .TP 7
102 O_SYNC
103 Write according to synchronized I/O file integrity completion.
104 .sp
105 .LP
106 Mask for use with file access modes is as follows:
107 .TP 7
108 O_ACCMODE
109 Mask for file access modes.
110 .sp
111 .LP
112 File access modes used for \fIopen\fP() and \fIfcntl\fP() are as follows:
113 .TP 7
114 O_RDONLY
115 Open for reading only.
116 .TP 7
117 O_RDWR
118 Open for reading and writing.
119 .TP 7
120 O_WRONLY
121 Open for writing only.
122 .sp
123 .LP
124 The symbolic names for file modes for use as values of \fBmode_t\fP
125 shall be defined as described in \fI<sys/stat.h>\fP .
126 .LP
127 Values for \fIadvice\fP used by \fIposix_fadvise\fP() are as follows:
128 .TP 7
129 POSIX_FADV_NORMAL
130 .sp
131 The application has no advice to give on its behavior with respect
132 to the specified data. It is the default characteristic if no
133 advice is given for an open file.
134 .TP 7
135 POSIX_FADV_SEQUENTIAL
136 .sp
137 The application expects to access the specified data sequentially
138 from lower offsets to higher offsets.
139 .TP 7
140 POSIX_FADV_RANDOM
141 .sp
142 The application expects to access the specified data in a random order.
143 .TP 7
144 POSIX_FADV_WILLNEED
145 .sp
146 The application expects to access the specified data in the near future.
147 .TP 7
148 POSIX_FADV_DONTNEED
149 .sp
150 The application expects that it will not access the specified data
151 in the near future.
152 .TP 7
153 POSIX_FADV_NOREUSE
154 .sp
155 The application expects to access the specified data once and then
156 not reuse it thereafter.
157 .sp
158 .LP
159 The structure \fBflock\fP describes a file lock. It shall include
160 the following members:
161 .sp
162 .RS
163 .nf
164
165 \fBshort l_type \fP Type of lock; F_RDLCK, F_WRLCK, F_UNLCK. \fB
166 short l_whence\fP Flag for starting offset. \fB
167 off_t l_start \fP Relative offset in bytes. \fB
168 off_t l_len \fP Size; if 0 then until EOF. \fB
169 pid_t l_pid \fP Process ID of the process holding the lock; returned with F_GETLK. \fB
170 \fP
171 .fi
172 .RE
173 .LP
174 The \fBmode_t\fP, \fBoff_t\fP, and \fBpid_t\fP types shall be defined
175 as described in \fI<sys/types.h>\fP .
176 .LP
177 The following shall be declared as functions and may also be defined
178 as macros. Function prototypes shall be provided.
179 .sp
180 .RS
181 .nf
182
183 \fBint creat(const char *, mode_t);
184 int fcntl(int, int, ...);
185 int open(const char *, int, ...);
186
187 int posix_fadvise(int, off_t, size_t, int);
188 int posix_fallocate(int, off_t, size_t);
189
190 \fP
191 .fi
192 .RE
193 .LP
194 Inclusion of the \fI<fcntl.h>\fP header may also make visible all
195 symbols from \fI<sys/stat.h>\fP and \fI<unistd.h>\fP.
196 .LP
197 \fIThe following sections are informative.\fP
198 .SH APPLICATION USAGE
199 .LP
200 None.
201 .SH RATIONALE
202 .LP
203 None.
204 .SH FUTURE DIRECTIONS
205 .LP
206 None.
207 .SH SEE ALSO
208 .LP
209 \fI<sys/stat.h>\fP , \fI<sys/types.h>\fP , \fI<unistd.h>\fP , the
210 System Interfaces volume of IEEE\ Std\ 1003.1-2001, \fIcreat\fP(),
211 \fIexec\fP, \fIfcntl\fP(), \fIopen\fP(), \fIposix_fadvise\fP(), \fIposix_fallocate\fP(),
212 \fIposix_madvise\fP()
213 .SH COPYRIGHT
214 Portions of this text are reprinted and reproduced in electronic form
215 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
216 -- Portable Operating System Interface (POSIX), The Open Group Base
217 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
218 Electrical and Electronics Engineers, Inc and The Open Group. In the
219 event of any discrepancy between this version and the original IEEE and
220 The Open Group Standard, the original IEEE and The Open Group Standard
221 is the referee document. The original Standard can be obtained online at
222 http://www.opengroup.org/unix/online.html .