xref: /openbsd-src/lib/libc/sys/pathconf.2 (revision 99fd087599a8791921855f21bd7e36130f39aadc)
1.\"	$OpenBSD: pathconf.2,v 1.25 2018/06/21 20:30:36 jmc Exp $
2.\"	$NetBSD: pathconf.2,v 1.2 1995/02/27 12:35:22 cgd Exp $
3.\"
4.\" Copyright (c) 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"	@(#)pathconf.2	8.1 (Berkeley) 6/4/93
32.\"
33.Dd $Mdocdate: June 21 2018 $
34.Dt PATHCONF 2
35.Os
36.Sh NAME
37.Nm pathconf ,
38.Nm fpathconf
39.Nd get configurable pathname variables
40.Sh SYNOPSIS
41.In unistd.h
42.Ft long
43.Fn pathconf "const char *path" "int name"
44.Ft long
45.Fn fpathconf "int fd" "int name"
46.Sh DESCRIPTION
47The
48.Fn pathconf
49and
50.Fn fpathconf
51functions provide a method for applications to determine the current
52value of a configurable system limit or option variable associated
53with a pathname or file descriptor.
54.Pp
55For
56.Fn pathconf ,
57the
58.Fa path
59argument is the name of a file or directory.
60For
61.Fn fpathconf ,
62the
63.Fa fd
64argument is an open file descriptor.
65The
66.Fa name
67argument specifies the system variable to be queried.
68Symbolic constants for each name value are found in the include file
69.In unistd.h .
70.Pp
71The available values are as follows:
72.Bl -tag -width "123456"
73.It Dv _PC_LINK_MAX
74The maximum file link count.
75.It Dv _PC_MAX_CANON
76The maximum number of bytes in a terminal canonical input line.
77.It Dv _PC_MAX_INPUT
78The maximum number of bytes for which space is available in
79a terminal input queue.
80.It Dv _PC_NAME_MAX
81The maximum number of bytes in a file name.
82.It Dv _PC_PATH_MAX
83The maximum number of bytes in a pathname.
84.It Dv _PC_PIPE_BUF
85The maximum number of bytes which will be written atomically to a pipe.
86.It Dv _PC_CHOWN_RESTRICTED
87Returns 1 if appropriate privileges are required for the
88.Xr chown 2
89system call, otherwise 0.
90.St -p1003.1-2001
91requires appropriate privilege in all cases, but this behavior was
92optional in prior editions of the standard.
93.It Dv _PC_NO_TRUNC
94Returns 1 if attempts to use pathname components longer than
95.Brq Dv NAME_MAX
96will result in an
97.Bq Er ENAMETOOLONG
98error; otherwise, such components will be truncated to
99.Brq Dv NAME_MAX .
100.St -p1003.1-2001
101requires the error in all cases, but this behavior was optional in prior
102editions of the standard, and some non-POSIX-compliant file systems do not
103support this behavior.
104.It Dv _PC_VDISABLE
105Returns the terminal character disabling value.
106.It Dv _PC_2_SYMLINKS
107Returns 1 if the filesystem supports the creation of symbolic links
108within the specified directory; the meaning of
109.Dv _PC_2_SYMLINKS
110is unspecified for non-directory files.
111.It Dv _PC_ALLOC_SIZE_MIN
112Minimum number of bytes of storage allocated for any portion of a file.
113.It Dv _PC_ASYNC_IO
114Returns 1 if asynchronous I/O is supported, otherwise 0.
115.It Dv _PC_FILESIZEBITS
116Number of bits needed to represent the maximum file size.
117.It Dv _PC_PRIO_IO
118Returns 1 if prioritized I/O is supported, otherwise 0.
119.It Dv _PC_REC_INCR_XFER_SIZE
120Recommended increment for file transfer sizes between _PC_REC_MIN_XFER_SIZE
121and _PC_REC_MAX_XFER_SIZE.
122.It Dv _PC_REC_MAX_XFER_SIZE
123Maximum recommended file transfer size.
124.It Dv _PC_REC_MIN_XFER_SIZE
125Minimum recommended file transfer size.
126.It Dv _PC_REC_XFER_ALIGN
127Recommended file transfer buffer alignment.
128.It Dv _PC_SYMLINK_MAX
129Maximum number of bytes in a symbolic link.
130.It Dv _PC_SYNC_IO
131Returns 1 if synchronized I/O is supported, otherwise 0.
132.It Dv _PC_TIMESTAMP_RESOLUTION
133The resolution in nanoseconds of file timestamps.
134.El
135.Sh RETURN VALUES
136If the call to
137.Fn pathconf
138or
139.Fn fpathconf
140is not successful, \-1 is returned and
141.Va errno
142is set appropriately.
143Otherwise, if the variable is associated with functionality that does
144not have a limit in the system, \-1 is returned and
145.Va errno
146is not modified.
147Otherwise, the current variable value is returned.
148.Sh ERRORS
149If any of the following conditions occur, the
150.Fn pathconf
151and
152.Fn fpathconf
153functions shall return \-1 and set
154.Va errno
155to the corresponding value.
156.Bl -tag -width Er
157.It Bq Er EINVAL
158The value of the
159.Fa name
160argument is invalid.
161.It Bq Er EINVAL
162The implementation does not support an association of the variable
163name with the associated file.
164.It Bq Er EIO
165An I/O error occurred while reading from the file system.
166.El
167.Pp
168.Fn pathconf
169will fail if:
170.Bl -tag -width Er
171.It Bq Er ENOTDIR
172A component of the path prefix is not a directory.
173.It Bq Er ENAMETOOLONG
174A component of a pathname exceeded
175.Dv NAME_MAX
176characters (but see
177.Dv _PC_NO_TRUNC
178above), or an entire pathname (including the terminating NUL)
179exceeded
180.Dv PATH_MAX
181bytes.
182.It Bq Er ENOENT
183The named file does not exist.
184.It Bq Er EACCES
185Search permission is denied for a component of the path prefix.
186.It Bq Er ELOOP
187Too many symbolic links were encountered in translating the pathname.
188.It Bq Er EFAULT
189.Fa path
190points outside the process's allocated address space.
191.El
192.Pp
193.Fn fpathconf
194will fail if:
195.Bl -tag -width Er
196.It Bq Er EBADF
197.Fa fd
198is not a valid open file descriptor.
199.El
200.Sh SEE ALSO
201.Xr sysctl 2 ,
202.Xr sysconf 3
203.Sh STANDARDS
204The
205.Fn pathconf
206and
207.Fn fpathconf
208functions conform to
209.St -p1003.1-2008 .
210.Sh HISTORY
211The
212.Fn pathconf
213and
214.Fn fpathconf
215functions first appeared in
216.Bx 4.4 .
217