1FPATHCONF(3P) POSIX Programmer's Manual FPATHCONF(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
11
13 fpathconf, pathconf — get configurable pathname variables
14
16 #include <unistd.h>
17
18 long fpathconf(int fildes, int name);
19 long pathconf(const char *path, int name);
20
22 The fpathconf() and pathconf() functions shall determine the current
23 value of a configurable limit or option (variable) that is associated
24 with a file or directory.
25
26 For pathconf(), the path argument points to the pathname of a file or
27 directory.
28
29 For fpathconf(), the fildes argument is an open file descriptor.
30
31 The name argument represents the variable to be queried relative to
32 that file or directory. Implementations shall support all of the vari‐
33 ables listed in the following table and may support others. The vari‐
34 ables in the following table come from <limits.h> or <unistd.h> and the
35 symbolic constants, defined in <unistd.h>, are the corresponding values
36 used for name.
37
38 ┌────────────────────────────┬──────────────────────────┬──────────────┐
39 │ Variable │ Value of name │ Requirements │
40 ├────────────────────────────┼──────────────────────────┼──────────────┤
41 │{FILESIZEBITS} │ _PC_FILESIZEBITS │ 4,7 │
42 │{LINK_MAX} │ _PC_LINK_MAX │ 1 │
43 │{MAX_CANON} │ _PC_MAX_CANON │ 2 │
44 │{MAX_INPUT} │ _PC_MAX_INPUT │ 2 │
45 │{NAME_MAX} │ _PC_NAME_MAX │ 3,4 │
46 │{PATH_MAX} │ _PC_PATH_MAX │ 4,5 │
47 │{PIPE_BUF} │ _PC_PIPE_BUF │ 6 │
48 │{POSIX2_SYMLINKS} │ _PC_2_SYMLINKS │ 4 │
49 │{POSIX_ALLOC_SIZE_MIN} │ _PC_ALLOC_SIZE_MIN │ 10 │
50 │{POSIX_REC_INCR_XFER_SIZE} │ _PC_REC_INCR_XFER_SIZE │ 10 │
51 │{POSIX_REC_MAX_XFER_SIZE} │ _PC_REC_MAX_XFER_SIZE │ 10 │
52 │{POSIX_REC_MIN_XFER_SIZE} │ _PC_REC_MIN_XFER_SIZE │ 10 │
53 │{POSIX_REC_XFER_ALIGN} │ _PC_REC_XFER_ALIGN │ 10 │
54 │{SYMLINK_MAX} │ _PC_SYMLINK_MAX │ 4,9 │
55 │_POSIX_CHOWN_RESTRICTED │ _PC_CHOWN_RESTRICTED │ 7 │
56 │_POSIX_NO_TRUNC │ _PC_NO_TRUNC │ 3,4 │
57 │_POSIX_VDISABLE │ _PC_VDISABLE │ 2 │
58 │_POSIX_ASYNC_IO │ _PC_ASYNC_IO │ 8 │
59 │_POSIX_PRIO_IO │ _PC_PRIO_IO │ 8 │
60 │_POSIX_SYNC_IO │ _PC_SYNC_IO │ 8 │
61 │_POSIX_TIMESTAMP_RESOLUTION │ _PC_TIMESTAMP_RESOLUTION │ 1 │
62 └────────────────────────────┴──────────────────────────┴──────────────┘
63 Requirements
64 1. If path or fildes refers to a directory, the value returned shall
65 apply to the directory itself.
66
67 2. If path or fildes does not refer to a terminal file, it is unspeci‐
68 fied whether an implementation supports an association of the vari‐
69 able name with the specified file.
70
71 3. If path or fildes refers to a directory, the value returned shall
72 apply to filenames within the directory.
73
74 4. If path or fildes does not refer to a directory, it is unspecified
75 whether an implementation supports an association of the variable
76 name with the specified file.
77
78 5. If path or fildes refers to a directory, the value returned shall
79 be the maximum length of a relative pathname that would not cross
80 any mount points when the specified directory is the working direc‐
81 tory.
82
83 6. If path refers to a FIFO, or fildes refers to a pipe or FIFO, the
84 value returned shall apply to the referenced object. If path or
85 fildes refers to a directory, the value returned shall apply to any
86 FIFO that exists or can be created within the directory. If path or
87 fildes refers to any other type of file, it is unspecified whether
88 an implementation supports an association of the variable name with
89 the specified file.
90
91 7. If path or fildes refers to a directory, the value returned shall
92 apply to any files, other than directories, that exist or can be
93 created within the directory.
94
95 8. If path or fildes refers to a directory, it is unspecified whether
96 an implementation supports an association of the variable name with
97 the specified file.
98
99 9. If path or fildes refers to a directory, the value returned shall
100 be the maximum length of the string that a symbolic link in that
101 directory can contain.
102
103 10. If path or fildes des does not refer to a regular file, it is
104 unspecified whether an implementation supports an association of
105 the variable name with the specified file. If an implementation
106 supports such an association for other than a regular file, the
107 value returned is unspecified.
108
110 If name is an invalid value, both pathconf() and fpathconf() shall
111 return −1 and set errno to indicate the error.
112
113 If the variable corresponding to name is described in <limits.h> as a
114 maximum or minimum value and the variable has no limit for the path or
115 file descriptor, both pathconf() and fpathconf() shall return −1 with‐
116 out changing errno. Note that indefinite limits do not imply infinite
117 limits; see <limits.h>.
118
119 If the implementation needs to use path to determine the value of name
120 and the implementation does not support the association of name with
121 the file specified by path, or if the process did not have appropriate
122 privileges to query the file specified by path, or path does not exist,
123 pathconf() shall return −1 and set errno to indicate the error.
124
125 If the implementation needs to use fildes to determine the value of
126 name and the implementation does not support the association of name
127 with the file specified by fildes, or if fildes is an invalid file
128 descriptor, fpathconf() shall return −1 and set errno to indicate the
129 error.
130
131 Otherwise, pathconf() or fpathconf() shall return the current variable
132 value for the file or directory without changing errno. The value
133 returned shall not be more restrictive than the corresponding value
134 available to the application when it was compiled with the implementa‐
135 tion's <limits.h> or <unistd.h>.
136
137 If the variable corresponding to name is dependent on an unsupported
138 option, the results are unspecified.
139
141 The pathconf() function shall fail if:
142
143 EINVAL The value of name is not valid.
144
145 ELOOP A loop exists in symbolic links encountered during resolution of
146 the path argument.
147
148 EOVERFLOW
149 The value of name is _PC_TIMESTAMP_RESOLUTION and the resolution
150 is larger than {LONG_MAX}.
151
152 The pathconf() function may fail if:
153
154 EACCES Search permission is denied for a component of the path prefix.
155
156 EINVAL The implementation does not support an association of the vari‐
157 able name with the specified file.
158
159 ELOOP More than {SYMLOOP_MAX} symbolic links were encountered during
160 resolution of the path argument.
161
162 ENAMETOOLONG
163 The length of a component of a pathname is longer than
164 {NAME_MAX}.
165
166 ENAMETOOLONG
167 The length of a pathname exceeds {PATH_MAX}, or pathname resolu‐
168 tion of a symbolic link produced an intermediate result with a
169 length that exceeds {PATH_MAX}.
170
171 ENOENT A component of path does not name an existing file or path is an
172 empty string.
173
174 ENOTDIR
175 A component of the path prefix names an existing file that is
176 neither a directory nor a symbolic link to a directory, or the
177 path argument contains at least one non-<slash> character and
178 ends with one or more trailing <slash> characters and the last
179 pathname component names an existing file that is neither a
180 directory nor a symbolic link to a directory.
181
182 The fpathconf() function shall fail if:
183
184 EINVAL The value of name is not valid.
185
186 EOVERFLOW
187 The value of name is _PC_TIMESTAMP_RESOLUTION and the resolution
188 is larger than {LONG_MAX}.
189
190 The fpathconf() function may fail if:
191
192 EBADF The fildes argument is not a valid file descriptor.
193
194 EINVAL The implementation does not support an association of the vari‐
195 able name with the specified file.
196
197 The following sections are informative.
198
200 None.
201
203 Application developers should check whether an option, such as
204 _POSIX_ADVISORY_INFO, is supported prior to obtaining and using values
205 for related variables such as {POSIX_ALLOC_SIZE_MIN}.
206
208 The pathconf() function was proposed immediately after the sysconf()
209 function when it was realized that some configurable values may differ
210 across file system, directory, or device boundaries.
211
212 For example, {NAME_MAX} frequently changes between System V and BSD-
213 based file systems; System V uses a maximum of 14, BSD 255. On an
214 implementation that provides both types of file systems, an application
215 would be forced to limit all pathname components to 14 bytes, as this
216 would be the value specified in <limits.h> on such a system.
217
218 Therefore, various useful values can be queried on any pathname or file
219 descriptor, assuming that appropriate privileges are in place.
220
221 The value returned for the variable {PATH_MAX} indicates the longest
222 relative pathname that could be given if the specified directory is the
223 current working directory of the process. A process may not always be
224 able to generate a name that long and use it if a subdirectory in the
225 pathname crosses into a more restrictive file system. Note that imple‐
226 mentations are allowed to accept pathnames longer than {PATH_MAX} bytes
227 long, but are not allowed to return pathnames longer than this unless
228 the user specifies a larger buffer using a function that provides a
229 buffer size argument.
230
231 The value returned for the variable _POSIX_CHOWN_RESTRICTED also
232 applies to directories that do not have file systems mounted on them.
233 The value may change when crossing a mount point, so applications that
234 need to know should check for each directory. (An even easier check is
235 to try the chown() function and look for an error in case it happens.)
236
237 Unlike the values returned by sysconf(), the pathname-oriented vari‐
238 ables are potentially more volatile and are not guaranteed to remain
239 constant throughout the lifetime of the process. For example, in
240 between two calls to pathconf(), the file system in question may have
241 been unmounted and remounted with different characteristics.
242
243 Also note that most of the errors are optional. If one of the variables
244 always has the same value on an implementation, the implementation need
245 not look at path or fildes to return that value and is, therefore, not
246 required to detect any of the errors except the meaning of [EINVAL]
247 that indicates that the value of name is not valid for that variable.
248
249 If the value of any of the limits is unspecified (logically infinite),
250 they will not be defined in <limits.h> and the pathconf() and fpath‐
251 conf() functions return −1 without changing errno. This can be distin‐
252 guished from the case of giving an unrecognized name argument because
253 errno is set to [EINVAL] in this case.
254
255 Since −1 is a valid return value for the pathconf() and fpathconf()
256 functions, applications should set errno to zero before calling them
257 and check errno only if the return value is −1.
258
259 For the case of {SYMLINK_MAX}, since both pathconf() and open() follow
260 symbolic links, there is no way that path or fildes could refer to a
261 symbolic link.
262
263 It was the intention of IEEE Std 1003.1d‐1999 that the following vari‐
264 ables:
265
266 {POSIX_ALLOC_SIZE_MIN} {POSIX_REC_INCR_XFER_SIZE}
267 {POSIX_REC_MAX_XFER_SIZE} {POSIX_REC_MIN_XFER_SIZE}
268 {POSIX_REC_XFER_ALIGN}
269
270 only applied to regular files, but Note 10 also permits implementation
271 of the advisory semantics on other file types unique to an implementa‐
272 tion (for example, a character special device).
273
274 The [EOVERFLOW] error for _PC_TIMESTAMP_RESOLUTION cannot occur on
275 POSIX-compliant file systems because POSIX requires a timestamp resolu‐
276 tion no larger than one second. Even on 32-bit systems, this can be
277 represented without overflow.
278
280 None.
281
283 chown(), confstr(), sysconf()
284
285 The Base Definitions volume of POSIX.1‐2008, <limits.h>, <unistd.h>
286
287 The Shell and Utilities volume of POSIX.1‐2008, getconf
288
290 Portions of this text are reprinted and reproduced in electronic form
291 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
292 -- Portable Operating System Interface (POSIX), The Open Group Base
293 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
294 cal and Electronics Engineers, Inc and The Open Group. (This is
295 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
296 event of any discrepancy between this version and the original IEEE and
297 The Open Group Standard, the original IEEE and The Open Group Standard
298 is the referee document. The original Standard can be obtained online
299 at http://www.unix.org/online.html .
300
301 Any typographical or formatting errors that appear in this page are
302 most likely to have been introduced during the conversion of the source
303 files to man page format. To report such errors, see https://www.ker‐
304 nel.org/doc/man-pages/reporting_bugs.html .
305
306
307
308IEEE/The Open Group 2013 FPATHCONF(3P)