xref: /freebsd/lib/libsys/pathconf.2 (revision ac64cd191c3f49efe900b8e90657f51578503265)
18269e767SBrooks Davis.\" Copyright (c) 1993
28269e767SBrooks Davis.\"	The Regents of the University of California.  All rights reserved.
38269e767SBrooks Davis.\"
48269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without
58269e767SBrooks Davis.\" modification, are permitted provided that the following conditions
68269e767SBrooks Davis.\" are met:
78269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright
88269e767SBrooks Davis.\"    notice, this list of conditions and the following disclaimer.
98269e767SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright
108269e767SBrooks Davis.\"    notice, this list of conditions and the following disclaimer in the
118269e767SBrooks Davis.\"    documentation and/or other materials provided with the distribution.
128269e767SBrooks Davis.\" 3. Neither the name of the University nor the names of its contributors
138269e767SBrooks Davis.\"    may be used to endorse or promote products derived from this software
148269e767SBrooks Davis.\"    without specific prior written permission.
158269e767SBrooks Davis.\"
168269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
178269e767SBrooks Davis.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
188269e767SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
198269e767SBrooks Davis.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
208269e767SBrooks Davis.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
218269e767SBrooks Davis.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
228269e767SBrooks Davis.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
238269e767SBrooks Davis.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
248269e767SBrooks Davis.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
258269e767SBrooks Davis.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
268269e767SBrooks Davis.\" SUCH DAMAGE.
278269e767SBrooks Davis.\"
28*ac64cd19SRick Macklem.Dd July 5, 2025
298269e767SBrooks Davis.Dt PATHCONF 2
308269e767SBrooks Davis.Os
318269e767SBrooks Davis.Sh NAME
328269e767SBrooks Davis.Nm pathconf ,
338269e767SBrooks Davis.Nm lpathconf ,
348269e767SBrooks Davis.Nm fpathconf
358269e767SBrooks Davis.Nd get configurable pathname variables
368269e767SBrooks Davis.Sh LIBRARY
378269e767SBrooks Davis.Lb libc
388269e767SBrooks Davis.Sh SYNOPSIS
398269e767SBrooks Davis.In unistd.h
408269e767SBrooks Davis.Ft long
418269e767SBrooks Davis.Fn pathconf "const char *path" "int name"
428269e767SBrooks Davis.Ft long
438269e767SBrooks Davis.Fn lpathconf "const char *path" "int name"
448269e767SBrooks Davis.Ft long
458269e767SBrooks Davis.Fn fpathconf "int fd" "int name"
468269e767SBrooks Davis.Sh DESCRIPTION
478269e767SBrooks DavisThe
488269e767SBrooks Davis.Fn pathconf ,
498269e767SBrooks Davis.Fn lpathconf
508269e767SBrooks Davisand
518269e767SBrooks Davis.Fn fpathconf
528269e767SBrooks Davissystem calls provide a method for applications to determine the current
538269e767SBrooks Davisvalue of a configurable system limit or option variable associated
548269e767SBrooks Daviswith a pathname or file descriptor.
558269e767SBrooks Davis.Pp
568269e767SBrooks DavisFor
578269e767SBrooks Davis.Fn pathconf
588269e767SBrooks Davisand
598269e767SBrooks Davis.Fn lpathconf ,
608269e767SBrooks Davisthe
618269e767SBrooks Davis.Fa path
628269e767SBrooks Davisargument is the name of a file or directory.
638269e767SBrooks DavisFor
648269e767SBrooks Davis.Fn fpathconf ,
658269e767SBrooks Davisthe
668269e767SBrooks Davis.Fa fd
678269e767SBrooks Davisargument is an open file descriptor.
688269e767SBrooks DavisThe
698269e767SBrooks Davis.Fa name
708269e767SBrooks Davisargument specifies the system variable to be queried.
718269e767SBrooks DavisSymbolic constants for each name value are found in the include file
728269e767SBrooks Davis.Li <unistd.h> .
738269e767SBrooks Davis.Pp
748269e767SBrooks DavisThe
758269e767SBrooks Davis.Fn lpathconf
768269e767SBrooks Davissystem call is like
778269e767SBrooks Davis.Fn pathconf
788269e767SBrooks Davisexcept in the case where the named file is a symbolic link,
798269e767SBrooks Davisin which case
808269e767SBrooks Davis.Fn lpathconf
818269e767SBrooks Davisreturns information about the link,
828269e767SBrooks Daviswhile
838269e767SBrooks Davis.Fn pathconf
848269e767SBrooks Davisreturns information about the file the link references.
858269e767SBrooks Davis.Pp
868269e767SBrooks DavisThe available values are as follows:
878269e767SBrooks Davis.Bl -tag -width 6n
888269e767SBrooks Davis.It Li _PC_LINK_MAX
898269e767SBrooks DavisThe maximum file link count.
908269e767SBrooks Davis.It Li _PC_MAX_CANON
918269e767SBrooks DavisThe maximum number of bytes in terminal canonical input line.
928269e767SBrooks Davis.It Li _PC_MAX_INPUT
938269e767SBrooks DavisThe minimum maximum number of bytes for which space is available in
948269e767SBrooks Davisa terminal input queue.
958269e767SBrooks Davis.It Li _PC_NAME_MAX
968269e767SBrooks DavisThe maximum number of bytes in a file name.
978269e767SBrooks Davis.It Li _PC_PATH_MAX
988269e767SBrooks DavisThe maximum number of bytes in a pathname.
998269e767SBrooks Davis.It Li _PC_PIPE_BUF
1008269e767SBrooks DavisThe maximum number of bytes which will be written atomically to a pipe.
1018269e767SBrooks Davis.It Li _PC_CHOWN_RESTRICTED
1028269e767SBrooks DavisReturn 1 if appropriate privilege is required for the
1038269e767SBrooks Davis.Xr chown 2
1048269e767SBrooks Davissystem call, otherwise 0.
1058269e767SBrooks Davis.St -p1003.1-2001
1068269e767SBrooks Davisrequires appropriate privilege in all cases, but this behavior was optional
1078269e767SBrooks Davisin prior editions of the standard.
1088269e767SBrooks Davis.It Li _PC_NO_TRUNC
1098269e767SBrooks DavisReturn greater than zero if attempts to use pathname components longer than
1108269e767SBrooks Davis.Brq Dv NAME_MAX
1118269e767SBrooks Daviswill result in an
1128269e767SBrooks Davis.Bq Er ENAMETOOLONG
1138269e767SBrooks Daviserror; otherwise, such components will be truncated to
1148269e767SBrooks Davis.Brq Dv NAME_MAX .
1158269e767SBrooks Davis.St -p1003.1-2001
1168269e767SBrooks Davisrequires the error in all cases, but this behavior was optional in prior
1178269e767SBrooks Daviseditions of the standard, and some
1188269e767SBrooks Davis.No non- Ns Tn POSIX Ns -compliant
1198269e767SBrooks Davisfile systems do not support this behavior.
1208269e767SBrooks Davis.It Li _PC_VDISABLE
1218269e767SBrooks DavisReturns the terminal character disabling value.
1228269e767SBrooks Davis.It Li _PC_ASYNC_IO
1238269e767SBrooks DavisReturn 1 if asynchronous I/O is supported, otherwise 0.
1248269e767SBrooks Davis.It Li _PC_PRIO_IO
1258269e767SBrooks DavisReturns 1 if prioritised I/O is supported for this file,
1268269e767SBrooks Davisotherwise 0.
1278269e767SBrooks Davis.It Li _PC_SYNC_IO
1288269e767SBrooks DavisReturns 1 if synchronised I/O is supported for this file, otherwise 0.
1298269e767SBrooks Davis.It Li _PC_ALLOC_SIZE_MIN
1308269e767SBrooks DavisMinimum number of bytes of storage allocated for any portion of a file.
1318269e767SBrooks Davis.It Li _PC_FILESIZEBITS
1328269e767SBrooks DavisNumber of bits needed to represent the maximum file size.
1338269e767SBrooks Davis.It Li _PC_REC_INCR_XFER_SIZE
1348269e767SBrooks DavisRecommended increment for file transfer sizes between
1358269e767SBrooks Davis.Dv _PC_REC_MIN_XFER_SIZE
1368269e767SBrooks Davisand
1378269e767SBrooks Davis.Dv _PC_REC_MAX_XFER_SIZE .
1388269e767SBrooks Davis.It Li _PC_REC_MAX_XFER_SIZE
1398269e767SBrooks DavisMaximum recommended file transfer size.
1408269e767SBrooks Davis.It Li _PC_REC_MIN_XFER_SIZE
1418269e767SBrooks DavisMinimum recommended file transfer size.
1428269e767SBrooks Davis.It Li _PC_REC_XFER_ALIGN
1438269e767SBrooks DavisRecommended file transfer buffer alignment.
1448269e767SBrooks Davis.It Li _PC_SYMLINK_MAX
1458269e767SBrooks DavisMaximum number of bytes in a symbolic link.
1468269e767SBrooks Davis.It Li _PC_ACL_EXTENDED
1478269e767SBrooks DavisReturns 1 if an Access Control List (ACL) can be set on the specified
1488269e767SBrooks Davisfile, otherwise 0.
1498269e767SBrooks Davis.It Li _PC_ACL_NFS4
1508269e767SBrooks DavisReturns 1 if an NFSv4 ACLs can be set on the specified
1518269e767SBrooks Davisfile, otherwise 0.
1528269e767SBrooks Davis.It Li _PC_ACL_PATH_MAX
1538269e767SBrooks DavisMaximum number of ACL entries per file.
1548269e767SBrooks Davis.It Li _PC_CAP_PRESENT
1558269e767SBrooks DavisReturns 1 if a capability state can be set on the specified file,
1568269e767SBrooks Davisotherwise 0.
1578269e767SBrooks Davis.It Li _PC_INF_PRESENT
1588269e767SBrooks DavisReturns 1 if an information label can be set on the specified file,
1598269e767SBrooks Davisotherwise 0.
1608269e767SBrooks Davis.It Li _PC_MAC_PRESENT
1618269e767SBrooks DavisReturns 1 if a Mandatory Access Control (MAC) label can be set on the
1628269e767SBrooks Davisspecified file, otherwise 0.
1638269e767SBrooks Davis.It Li _PC_MIN_HOLE_SIZE
1648269e767SBrooks DavisIf a file system supports the reporting of holes (see
1658269e767SBrooks Davis.Xr lseek 2 ) ,
1668269e767SBrooks Davis.Fn pathconf
1678269e767SBrooks Davisand
1688269e767SBrooks Davis.Fn fpathconf
1698269e767SBrooks Davisreturn a positive number that represents the minimum hole size returned in
1708269e767SBrooks Davisbytes.
1718269e767SBrooks DavisThe offsets of holes returned will be aligned to this same value.
1728269e767SBrooks DavisA special value of 1 is returned if the file system does not specify the minimum
1738269e767SBrooks Davishole size but still reports holes.
1748269e767SBrooks Davis.It Li _PC_DEALLOC_PRESENT
1758269e767SBrooks DavisReturn 1 if a file system supports hole-punching (see
1768269e767SBrooks Davis.Xr fspacectl 2 ) ,
1778269e767SBrooks Davisotherwise 0.
17833e22c4fSRick Macklem.It Li _PC_NAMEDATTR_ENABLED
17933e22c4fSRick MacklemReturn 1 if named attributes are enabled for the file system, otherwise 0.
18038eb41a3SRick Macklem.It Li _PC_HAS_NAMEDATTR
18138eb41a3SRick MacklemReturn 1 if one or more named attributes exist for the file, otherwise 0.
182*ac64cd19SRick Macklem.It Li _PC_HAS_HIDDENSYSTEM
183*ac64cd19SRick MacklemReturn 1 if both
184*ac64cd19SRick Macklem.Dv UF_HIDDEN
185*ac64cd19SRick Macklemand
186*ac64cd19SRick Macklem.Dv UF_SYSTEM
187*ac64cd19SRick Macklemflags can be set by
188*ac64cd19SRick Macklem.Xr chflags 2 ,
189*ac64cd19SRick Macklemotherwise 0.
1908269e767SBrooks Davis.El
1918269e767SBrooks Davis.Sh RETURN VALUES
1928269e767SBrooks DavisIf the call to
1938269e767SBrooks Davis.Fn pathconf
1948269e767SBrooks Davisor
1958269e767SBrooks Davis.Fn fpathconf
1968269e767SBrooks Davisis not successful, \-1 is returned and
1978269e767SBrooks Davis.Va errno
1988269e767SBrooks Davisis set appropriately.
1998269e767SBrooks DavisOtherwise, if the variable is associated with functionality that does
2008269e767SBrooks Davisnot have a limit in the system, \-1 is returned and
2018269e767SBrooks Davis.Va errno
2028269e767SBrooks Davisis not modified.
2038269e767SBrooks DavisOtherwise, the current variable value is returned.
2048269e767SBrooks Davis.Sh ERRORS
2058269e767SBrooks DavisIf any of the following conditions occur, the
2068269e767SBrooks Davis.Fn pathconf
2078269e767SBrooks Davisand
2088269e767SBrooks Davis.Fn fpathconf
2098269e767SBrooks Davissystem calls shall return -1 and set
2108269e767SBrooks Davis.Va errno
2118269e767SBrooks Davisto the corresponding value.
2128269e767SBrooks Davis.Bl -tag -width Er
2138269e767SBrooks Davis.It Bq Er EINVAL
2148269e767SBrooks DavisThe value of the
2158269e767SBrooks Davis.Fa name
2168269e767SBrooks Davisargument is invalid.
2178269e767SBrooks Davis.It Bq Er EINVAL
2188269e767SBrooks DavisThe implementation does not support an association of the variable
2198269e767SBrooks Davisname with the associated file.
2208269e767SBrooks Davis.El
2218269e767SBrooks Davis.Pp
2228269e767SBrooks DavisThe
2238269e767SBrooks Davis.Fn pathconf
2248269e767SBrooks Davissystem call
2258269e767SBrooks Daviswill fail if:
2268269e767SBrooks Davis.Bl -tag -width Er
2278269e767SBrooks Davis.It Bq Er ENOTDIR
2288269e767SBrooks DavisA component of the path prefix is not a directory.
2298269e767SBrooks Davis.It Bq Er ENAMETOOLONG
2308269e767SBrooks DavisA component of a pathname exceeded
2318269e767SBrooks Davis.Brq Dv NAME_MAX
2328269e767SBrooks Davischaracters (but see
2338269e767SBrooks Davis.Dv _PC_NO_TRUNC
2348269e767SBrooks Davisabove),
2358269e767SBrooks Davisor an entire path name exceeded
2368269e767SBrooks Davis.Brq Dv PATH_MAX
2378269e767SBrooks Davischaracters.
2388269e767SBrooks Davis.It Bq Er ENOENT
2398269e767SBrooks DavisThe named file does not exist.
2408269e767SBrooks Davis.It Bq Er EACCES
2418269e767SBrooks DavisSearch permission is denied for a component of the path prefix.
2428269e767SBrooks Davis.It Bq Er ELOOP
2438269e767SBrooks DavisToo many symbolic links were encountered in translating the pathname.
2448269e767SBrooks Davis.It Bq Er EIO
2458269e767SBrooks DavisAn I/O error occurred while reading from or writing to the file system.
2468269e767SBrooks Davis.It Bq Er EINTEGRITY
2478269e767SBrooks DavisCorrupted data was detected while reading from the file system.
2488269e767SBrooks Davis.El
2498269e767SBrooks Davis.Pp
2508269e767SBrooks DavisThe
2518269e767SBrooks Davis.Fn fpathconf
2528269e767SBrooks Davissystem call
2538269e767SBrooks Daviswill fail if:
2548269e767SBrooks Davis.Bl -tag -width Er
2558269e767SBrooks Davis.It Bq Er EBADF
2568269e767SBrooks DavisThe
2578269e767SBrooks Davis.Fa fd
2588269e767SBrooks Davisargument
2598269e767SBrooks Davisis not a valid open file descriptor.
2608269e767SBrooks Davis.It Bq Er EIO
2618269e767SBrooks DavisAn I/O error occurred while reading from or writing to the file system.
2628269e767SBrooks Davis.It Bq Er EINTEGRITY
2638269e767SBrooks DavisCorrupted data was detected while reading from the file system.
2648269e767SBrooks Davis.El
2658269e767SBrooks Davis.Sh SEE ALSO
266*ac64cd19SRick Macklem.Xr chflags 2 ,
2678269e767SBrooks Davis.Xr lseek 2 ,
2688269e767SBrooks Davis.Xr sysctl 3
2698269e767SBrooks Davis.Sh HISTORY
2708269e767SBrooks DavisThe
2718269e767SBrooks Davis.Fn pathconf
2728269e767SBrooks Davisand
2738269e767SBrooks Davis.Fn fpathconf
2748269e767SBrooks Davissystem calls first appeared in
2758269e767SBrooks Davis.Bx 4.4 .
2768269e767SBrooks DavisThe
2778269e767SBrooks Davis.Fn lpathconf
2788269e767SBrooks Davissystem call first appeared in
2798269e767SBrooks Davis.Fx 8.0 .
280