1.\" $OpenBSD: pathconf.2,v 1.26 2024/05/18 05:20:22 guenther 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: May 18 2024 $ 34.Dt PATHCONF 2 35.Os 36.Sh NAME 37.Nm pathconf , 38.Nm pathconfat , 39.Nm fpathconf 40.Nd get configurable pathname variables 41.Sh SYNOPSIS 42.In unistd.h 43.Ft long 44.Fn pathconf "const char *path" "int name" 45.Ft long 46.Fn fpathconf "int fd" "int name" 47.In fcntl.h 48.Ft long 49.Fn pathconfat "int fd" "const char *path" "int name" "int flag" 50.Sh DESCRIPTION 51The 52.Fn pathconf , 53.Fn pathconfat , 54and 55.Fn fpathconf 56functions provide a method for applications to determine the current 57value of a configurable system limit or option variable associated 58with a pathname or file descriptor. 59.Pp 60For 61.Fn pathconf , 62the 63.Fa path 64argument is the name of a file or directory. 65For 66.Fn fpathconf , 67the 68.Fa fd 69argument is an open file descriptor. 70The 71.Fa name 72argument specifies the system variable to be queried. 73Symbolic constants for each name value are found in the include file 74.In unistd.h . 75.Pp 76The available values are as follows: 77.Bl -tag -width "123456" 78.It Dv _PC_LINK_MAX 79The maximum file link count. 80.It Dv _PC_MAX_CANON 81The maximum number of bytes in a terminal canonical input line. 82.It Dv _PC_MAX_INPUT 83The maximum number of bytes for which space is available in 84a terminal input queue. 85.It Dv _PC_NAME_MAX 86The maximum number of bytes in a file name. 87.It Dv _PC_PATH_MAX 88The maximum number of bytes in a pathname. 89.It Dv _PC_PIPE_BUF 90The maximum number of bytes which will be written atomically to a pipe. 91.It Dv _PC_CHOWN_RESTRICTED 92Returns 1 if appropriate privileges are required for the 93.Xr chown 2 94system call, otherwise 0. 95.St -p1003.1-2001 96requires appropriate privilege in all cases, but this behavior was 97optional in prior editions of the standard. 98.It Dv _PC_NO_TRUNC 99Returns 1 if attempts to use pathname components longer than 100.Brq Dv NAME_MAX 101will result in an 102.Bq Er ENAMETOOLONG 103error; otherwise, such components will be truncated to 104.Brq Dv NAME_MAX . 105.St -p1003.1-2001 106requires the error in all cases, but this behavior was optional in prior 107editions of the standard, and some non-POSIX-compliant file systems do not 108support this behavior. 109.It Dv _PC_VDISABLE 110Returns the terminal character disabling value. 111.It Dv _PC_2_SYMLINKS 112Returns 1 if the filesystem supports the creation of symbolic links 113within the specified directory; the meaning of 114.Dv _PC_2_SYMLINKS 115is unspecified for non-directory files. 116.It Dv _PC_ALLOC_SIZE_MIN 117Minimum number of bytes of storage allocated for any portion of a file. 118.It Dv _PC_ASYNC_IO 119Returns 1 if asynchronous I/O is supported, otherwise 0. 120.It Dv _PC_FILESIZEBITS 121Number of bits needed to represent the maximum file size. 122.It Dv _PC_PRIO_IO 123Returns 1 if prioritized I/O is supported, otherwise 0. 124.It Dv _PC_REC_INCR_XFER_SIZE 125Recommended increment for file transfer sizes between _PC_REC_MIN_XFER_SIZE 126and _PC_REC_MAX_XFER_SIZE. 127.It Dv _PC_REC_MAX_XFER_SIZE 128Maximum recommended file transfer size. 129.It Dv _PC_REC_MIN_XFER_SIZE 130Minimum recommended file transfer size. 131.It Dv _PC_REC_XFER_ALIGN 132Recommended file transfer buffer alignment. 133.It Dv _PC_SYMLINK_MAX 134Maximum number of bytes in a symbolic link. 135.It Dv _PC_SYNC_IO 136Returns 1 if synchronized I/O is supported, otherwise 0. 137.It Dv _PC_TIMESTAMP_RESOLUTION 138The resolution in nanoseconds of file timestamps. 139.El 140.Pp 141The 142.Fn pathconfat 143function is equivalent to 144.Fn pathconf 145except in the case where 146.Fa path 147specifies a relative path. 148In this case the file to be changed is determined relative to the directory 149associated with the file descriptor 150.Fa fd 151instead of the current working directory. 152.Pp 153If 154.Fn pathconfat 155is passed the special value 156.Dv AT_FDCWD 157(defined in 158.In fcntl.h ) 159in the 160.Fa fd 161parameter, the current working directory is used. 162If 163.Fa flag 164is also zero, the behavior is identical to a call to 165.Fn pathconf . 166.Pp 167The 168.Fa flag 169argument is the bitwise OR of zero or more of the following values: 170.Pp 171.Bl -tag -width AT_SYMLINK_NOFOLLOW -offset indent -compact 172.It Dv AT_SYMLINK_NOFOLLOW 173If 174.Fa path 175names a symbolic link, then the system variable for the symbolic 176link is queried. 177.El 178.Sh RETURN VALUES 179If the call to 180.Fn pathconf , 181.Fn pathconfat , 182or 183.Fn fpathconf 184is not successful, \-1 is returned and 185.Va errno 186is set appropriately. 187Otherwise, if the variable is associated with functionality that does 188not have a limit in the system, \-1 is returned and 189.Va errno 190is not modified. 191Otherwise, the current variable value is returned. 192.Sh ERRORS 193If any of the following conditions occur, the 194.Fn pathconf , 195.Fn pathconfat , 196and 197.Fn fpathconf 198functions shall return \-1 and set 199.Va errno 200to the corresponding value. 201.Bl -tag -width Er 202.It Bq Er EINVAL 203The value of the 204.Fa name 205argument is invalid. 206.It Bq Er EINVAL 207The implementation does not support an association of the variable 208name with the associated file. 209.It Bq Er EIO 210An I/O error occurred while reading from the file system. 211.El 212.Pp 213.Fn pathconf 214and 215.Fn pathconfat 216will fail if: 217.Bl -tag -width Er 218.It Bq Er ENOTDIR 219A component of the path prefix is not a directory. 220.It Bq Er ENAMETOOLONG 221A component of a pathname exceeded 222.Dv NAME_MAX 223characters (but see 224.Dv _PC_NO_TRUNC 225above), or an entire pathname (including the terminating NUL) 226exceeded 227.Dv PATH_MAX 228bytes. 229.It Bq Er ENOENT 230The named file does not exist. 231.It Bq Er EACCES 232Search permission is denied for a component of the path prefix. 233.It Bq Er ELOOP 234Too many symbolic links were encountered in translating the pathname. 235.It Bq Er EFAULT 236.Fa path 237points outside the process's allocated address space. 238.El 239.Pp 240Additionally, the 241.Fn pathconfat 242function will fail if: 243.Bl -tag -width Er 244.It Bq Er EINVAL 245The value of the 246.Fa flag 247argument was neither zero nor 248.Dv AT_SYMLINK_NOFOLLOW . 249.It Bq Er EBADF 250The 251.Fa path 252argument specifies a relative path and the 253.Fa fd 254argument is neither 255.Dv AT_FDCWD 256nor a valid file descriptor. 257.It Bq Er ENOTDIR 258The 259.Fa path 260argument specifies a relative path and the 261.Fa fd 262argument is a valid file descriptor but it does not reference a directory. 263.It Bq Er EACCES 264The 265.Fa path 266argument specifies a relative path but search permission is denied 267for the directory which the 268.Fa fd 269file descriptor references. 270.El 271.Pp 272.Fn fpathconf 273will fail if: 274.Bl -tag -width Er 275.It Bq Er EBADF 276.Fa fd 277is not a valid open file descriptor. 278.El 279.Sh SEE ALSO 280.Xr sysctl 2 , 281.Xr sysconf 3 282.Sh STANDARDS 283The 284.Fn pathconf 285and 286.Fn fpathconf 287functions conform to 288.St -p1003.1-2008 . 289.Sh HISTORY 290The 291.Fn pathconf 292and 293.Fn fpathconf 294functions first appeared in 295.Bx 4.4 . 296The 297.Fn pathconfat 298function first appeared in 299.Ox 7.6 . 300