1FPATHCONF(P)               POSIX Programmer's Manual              FPATHCONF(P)
2
3
4

NAME

6       fpathconf, pathconf - get configurable pathname variables
7

SYNOPSIS

9       #include <unistd.h>
10
11       long fpathconf(int fildes, int name);
12       long pathconf(const char *path, int name);
13
14

DESCRIPTION

16       The  fpathconf()  and  pathconf() functions shall determine the current
17       value of a configurable limit or option (variable) that  is  associated
18       with a file or directory.
19
20       For  pathconf(),  the path argument points to the pathname of a file or
21       directory.
22
23       For fpathconf(), the fildes argument is an open file descriptor.
24
25       The name argument represents the variable to  be  queried  relative  to
26       that  file or directory. Implementations shall support all of the vari‐
27       ables listed in the following table and may support others.  The  vari‐
28       ables in the following table come from <limits.h> or <unistd.h> and the
29       symbolic constants, defined in <unistd.h>, are the corresponding values
30       used for name.
31
32          Variable                    Value of name           Requirements
33          {FILESIZEBITS}              _PC_FILESIZEBITS        3,4
34          {LINK_MAX}                  _PC_LINK_MAX            1
35          {MAX_CANON}                 _PC_MAX_CANON           2
36          {MAX_INPUT}                 _PC_MAX_INPUT           2
37          {NAME_MAX}                  _PC_NAME_MAX            3,4
38          {PATH_MAX}                  _PC_PATH_MAX            4,5
39          {PIPE_BUF}                  _PC_PIPE_BUF            6
40          {POSIX_ALLOC_SIZE_MIN}      _PC_ALLOC_SIZE_MIN
41          {POSIX_REC_INCR_XFER_SIZE}  _PC_REC_INCR_XFER_SIZE
42          {POSIX_REC_MAX_XFER_SIZE}   _PC_REC_MAX_XFER_SIZE
43          {POSIX_REC_MIN_XFER_SIZE}   _PC_REC_MIN_XFER_SIZE
44          {POSIX_REC_XFER_ALIGN}      _PC_REC_XFER_ALIGN
45          {SYMLINK_MAX}               _PC_SYMLINK_MAX         4,9
46          _POSIX_CHOWN_RESTRICTED     _PC_CHOWN_RESTRICTED    7
47          _POSIX_NO_TRUNC             _PC_NO_TRUNC            3,4
48          _POSIX_VDISABLE             _PC_VDISABLE            2
49          _POSIX_ASYNC_IO             _PC_ASYNC_IO            8
50          _POSIX_PRIO_IO              _PC_PRIO_IO             8
51          _POSIX_SYNC_IO              _PC_SYNC_IO             8
52
53   Requirements
54        1. If  path  or fildes refers to a directory, the value returned shall
55           apply to the directory itself.
56
57        2. If path or fildes does not refer to a terminal file, it is unspeci‐
58           fied whether an implementation supports an association of the vari‐
59           able name with the specified file.
60
61        3. If path or fildes refers to a directory, the value  returned  shall
62           apply to filenames within the directory.
63
64        4. If  path or fildes does not refer to a directory, it is unspecified
65           whether an implementation supports an association of  the  variable
66           name with the specified file.
67
68        5. If  path  or fildes refers to a directory, the value returned shall
69           be the maximum length of a relative  pathname  when  the  specified
70           directory is the working directory.
71
72        6. If  path  refers to a FIFO, or fildes refers to a pipe or FIFO, the
73           value returned shall apply to the referenced  object.  If  path  or
74           fildes refers to a directory, the value returned shall apply to any
75           FIFO that exists or can be created within the directory. If path or
76           fildes  refers to any other type of file, it is unspecified whether
77           an implementation supports an association of the variable name with
78           the specified file.
79
80        7. If  path  or fildes refers to a directory, the value returned shall
81           apply to any files, other than directories, that exist  or  can  be
82           created within the directory.
83
84        8. If  path or fildes refers to a directory, it is unspecified whether
85           an implementation supports an association of the variable name with
86           the specified file.
87
88        9. If  path  or fildes refers to a directory, the value returned shall
89           be the maximum length of the string that a symbolic  link  in  that
90           directory can contain.
91

RETURN VALUE

93       If  name  is  an  invalid  value, both pathconf() and fpathconf() shall
94       return -1 and set errno to indicate the error.
95
96       If the variable corresponding to name has no limit for the path or file
97       descriptor,  both  pathconf()  and  fpathconf() shall return -1 without
98       changing errno. If the implementation needs to use  path  to  determine
99       the  value of name and the implementation does not support the associa‐
100       tion of name with the file specified by path, or if the process did not
101       have  appropriate  privileges  to  query the file specified by path, or
102       path does not exist, pathconf() shall return -1 and set errno to  indi‐
103       cate the error.
104
105       If  the  implementation  needs  to use fildes to determine the value of
106       name and the implementation does not support the  association  of  name
107       with  the  file  specified  by  fildes, or if fildes is an invalid file
108       descriptor, fpathconf() shall return -1 and set errno to  indicate  the
109       error.
110
111       Otherwise,  pathconf() or fpathconf() shall return the current variable
112       value for the file or  directory  without  changing  errno.  The  value
113       returned  shall  not  be  more restrictive than the corresponding value
114       available to the application when it was compiled with the  implementa‐
115       tion's <limits.h> or <unistd.h>.
116

ERRORS

118       The pathconf() function shall fail if:
119
120       EINVAL The value of name is not valid.
121
122       ELOOP  A loop exists in symbolic links encountered during resolution of
123              the path argument.
124
125
126       The pathconf() function may fail if:
127
128       EACCES Search permission is denied for a component of the path prefix.
129
130       EINVAL The implementation does not support an association of the  vari‐
131              able name with the specified file.
132
133       ELOOP  More  than  {SYMLOOP_MAX} symbolic links were encountered during
134              resolution of the path argument.
135
136       ENAMETOOLONG
137              The length of the path argument exceeds {PATH_MAX} or a pathname
138              component is longer than {NAME_MAX}.
139
140       ENAMETOOLONG
141              As a result of encountering a symbolic link in resolution of the
142              path argument, the length of  the  substituted  pathname  string
143              exceeded {PATH_MAX}.
144
145       ENOENT A component of path does not name an existing file or path is an
146              empty string.
147
148       ENOTDIR
149              A component of the path prefix is not a directory.
150
151
152       The fpathconf() function shall fail if:
153
154       EINVAL The value of name is not valid.
155
156
157       The fpathconf() function may fail if:
158
159       EBADF  The fildes argument is not a valid file descriptor.
160
161       EINVAL The implementation does not support an association of the  vari‐
162              able name with the specified file.
163
164
165       The following sections are informative.
166

EXAMPLES

168       None.
169

APPLICATION USAGE

171       None.
172

RATIONALE

174       The  pathconf()  function  was proposed immediately after the sysconf()
175       function when it was realized that some configurable values may  differ
176       across file system, directory, or device boundaries.
177
178       For  example,  {NAME_MAX}  frequently changes between System V and BSD-
179       based file systems; System V uses a maximum of  14,  BSD  255.   On  an
180       implementation that provides both types of file systems, an application
181       would be forced to limit all pathname components to 14 bytes,  as  this
182       would be the value specified in <limits.h> on such a system.
183
184       Therefore, various useful values can be queried on any pathname or file
185       descriptor, assuming that the appropriate permissions are in place.
186
187       The value returned for the variable {PATH_MAX}  indicates  the  longest
188       relative pathname that could be given if the specified directory is the
189       process' current working directory. A process may not always be able to
190       generate  a name that long and use it if a subdirectory in the pathname
191       crosses into a more restrictive file system.
192
193       The  value  returned  for  the  variable  _POSIX_CHOWN_RESTRICTED  also
194       applies  to  directories that do not have file systems mounted on them.
195       The value may change when crossing a mount point, so applications  that
196       need  to know should check for each directory. (An even easier check is
197       to try the chown() function and look for an error in case it happens.)
198
199       Unlike the values returned by sysconf(),  the  pathname-oriented  vari‐
200       ables  are  potentially  more volatile and are not guaranteed to remain
201       constant throughout the process' lifetime. For example, in between  two
202       calls  to  pathconf(),  the  file  system  in  question  may  have been
203       unmounted and remounted with different characteristics.
204
205       Also note that most of the errors are optional. If one of the variables
206       always has the same value on an implementation, the implementation need
207       not look at path or fildes to return that value and is, therefore,  not
208       required  to  detect  any  of the errors except the meaning of [EINVAL]
209       that indicates that the value of name is not valid for that variable.
210
211       If the value of any of the limits is unspecified (logically  infinite),
212       they  will  not  be defined in <limits.h> and the pathconf() and fpath‐
213       conf() functions return -1 without changing errno. This can be  distin‐
214       guished  from  the case of giving an unrecognized name argument because
215       errno is set to [EINVAL] in this case.
216
217       Since -1 is a valid return value for  the  pathconf()  and  fpathconf()
218       functions,  applications  should  set errno to zero before calling them
219       and check errno only if the return value is -1.
220
221       For the case of {SYMLINK_MAX}, since both pathconf() and open()  follow
222       symbolic  links,  there  is no way that path or fildes could refer to a
223       symbolic link.
224

FUTURE DIRECTIONS

226       None.
227

SEE ALSO

229       confstr()   ,   sysconf()   ,   the   Base   Definitions   volume    of
230       IEEE Std 1003.1-2001,  <limits.h>,  <unistd.h>, the Shell and Utilities
231       volume of IEEE Std 1003.1-2001
232
234       Portions of this text are reprinted and reproduced in  electronic  form
235       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
236       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
237       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
238       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
239       event of any discrepancy between this version and the original IEEE and
240       The Open Group Standard, the original IEEE and The Open Group  Standard
241       is  the  referee document. The original Standard can be obtained online
242       at http://www.opengroup.org/unix/online.html .
243
244
245
246IEEE/The Open Group                  2003                         FPATHCONF(P)
Impressum