PATHCONF(2)
π PATHCONF(2) β the one where we ask the filesystem "hey bestie, what's your limit?" π
ok so this is pathconf(2), a page from section 2 of the manual (system calls, iykyk) β and honestly it's giving "filesystem personality quiz". Let's get into it β¨
πΈ NAME πΈ
pathconf, lpathconf, fpathconf β get configurable pathname variables
π¦ LIBRARY π¦
Standard C Library (libc, -lc)
β¨ SYNOPSIS β¨
#include <unistd.h>
long
pathconf(const char *path, int name);
long
lpathconf(const char *path, int name);
long
fpathconf(int fd, int name);
π DESCRIPTION π
okay so the pathconf(), lpathconf() and fpathconf() system calls are literally the way your app goes "hey, what's the current value of this configurable system limit or option variable" β and the answer is tied to a pathname or a file descriptor. main character energy fr π
For pathconf() and lpathconf(), the path argument is the name of a file or directory. For fpathconf(), the fd argument is an open file descriptor. The name argument specifies the system variable you're querying. The symbolic constants for each name value live in the include file <unistd.h>. π«Ά
So the lpathconf() system call is like pathconf() β except when the named file is a symbolic link, in which case lpathconf() returns info about the link, while pathconf() returns info about the file the link references. sneaky but valid πͺ
The available values are as follows:
_PC_LINK_MAXβ the maximum file link count. π―_PC_MAX_CANONβ the maximum number of bytes in a terminal canonical input line._PC_MAX_INPUTβ the minimum maximum number of bytes for which space is available in a terminal input queue._PC_NAME_MAXβ the maximum number of bytes in a file name._PC_PATH_MAXβ the maximum number of bytes in a pathname._PC_PIPE_BUFβ the maximum number of bytes which will be written atomically to a pipe. no partial writes, we don't do that here π«_PC_CHOWN_RESTRICTEDβ return1if appropriate privilege is required for thechown(2)system call, otherwise0. IEEE Std 1003.1-2001 (βPOSIX.1β) requires appropriate privilege in all cases, but this behavior was optional in prior editions of the standard._PC_NO_TRUNCβ return greater than zero if attempts to use pathname components longer than{NAME_MAX}will result in an[ENAMETOOLONG]error; otherwise, such components will be truncated to{NAME_MAX}. IEEE Std 1003.1-2001 (βPOSIX.1β) requires the error in all cases, but this behavior was optional in prior editions of the standard, and some non-POSIX-compliant file systems do not support this behavior._PC_VDISABLEβ returns the terminal character disabling value._PC_ASYNC_IOβ return1if asynchronous I/O is supported, otherwise0._PC_PRIO_IOβ returns1if prioritised I/O is supported for this file, otherwise0._PC_SYNC_IOβ returns1if synchronised I/O is supported for this file, otherwise0._PC_ALLOC_SIZE_MINβ minimum number of bytes of storage allocated for any portion of a file._PC_FILESIZEBITSβ number of bits needed to represent the maximum file size._PC_REC_INCR_XFER_SIZEβ recommended increment for file transfer sizes between_PC_REC_MIN_XFER_SIZEand_PC_REC_MAX_XFER_SIZE._PC_REC_MAX_XFER_SIZEβ maximum recommended file transfer size._PC_REC_MIN_XFER_SIZEβ minimum recommended file transfer size._PC_REC_XFER_ALIGNβ recommended file transfer buffer alignment. line it up bestie π_PC_SYMLINK_MAXβ maximum number of bytes in a symbolic link._PC_ACL_EXTENDEDβ returns1if an Access Control List (ACL) can be set on the specified file, otherwise0._PC_ACL_NFS4β returns1if an NFSv4 ACLs can be set on the specified file, otherwise0._PC_ACL_PATH_MAXβ maximum number of ACL entries per file._PC_CAP_PRESENTβ returns1if a capability state can be set on the specified file, otherwise0._PC_INF_PRESENTβ returns1if an information label can be set on the specified file, otherwise0._PC_MAC_PRESENTβ returns1if a Mandatory Access Control (MAC) label can be set on the specified file, otherwise0._PC_MIN_HOLE_SIZEβ if a file system supports the reporting of holes (seelseek(2)),pathconf()andfpathconf()return a positive number that represents the minimum hole size returned in bytes. The offsets of holes returned will be aligned to this same value. A special value of1is returned if the file system does not specify the minimum hole size but still reports holes. π³οΈ_PC_DEALLOC_PRESENTβ return1if a file system supports hole-punching (seefspacectl(2)), otherwise0._PC_NAMEDATTR_ENABLEDβ return1if named attributes are enabled for the file system, otherwise0._PC_HAS_NAMEDATTRβ return1if one or more named attributes exist for the file, otherwise0._PC_HAS_HIDDENSYSTEMβ return1if all of theUF_ARCHIVE,UF_HIDDENandUF_SYSTEMflags can be set bychflags(2), otherwise0._PC_CLONE_BLKSIZEβ returns the block size required for block cloning viacopy_file_range(2)for a file system if block cloning is supported, otherwise0._PC_CASE_INSENSITIVEβ return1if the file system performs case insensitive lookups, otherwise0.
π RETURN VALUES π
ok so here's the vibe check on what you get back:
- If the call to
pathconf()orfpathconf()is not successful,-1is returned anderrnois set appropriately. π - Otherwise, if the variable is associated with functionality that does not have a limit in the system,
-1is returned anderrnois not modified. π (yes, this is the cursed part β same-1, different meaning, checkerrnofirst bestie) - Otherwise, the current variable value is returned. π
π ERRORS π
If any of the following conditions occur, the pathconf() and fpathconf() system calls shall return -1 and set errno to the corresponding value:
[EINVAL]β the value of thenameargument is invalid.[EINVAL]β the implementation does not support an association of the variablenamewith the associated file.
The pathconf() system call will fail if:
[ENOTDIR]β a component of the path prefix is not a directory.[ENAMETOOLONG]β a component of a pathname exceeded{NAME_MAX}characters (but see_PC_NO_TRUNCabove), or an entire path name exceeded{PATH_MAX}characters.[ENOENT]β the named file does not exist. she's not there π[EACCES]β search permission is denied for a component of the path prefix.[ELOOP]β too many symbolic links were encountered in translating the pathname.[EIO]β an I/O error occurred while reading from or writing to the file system.[EINTEGRITY]β corrupted data was detected while reading from the file system.
The fpathconf() system call will fail if:
[EBADF]β thefdargument is not a valid open file descriptor.[EIO]β an I/O error occurred while reading from or writing to the file system.[EINTEGRITY]β corrupted data was detected while reading from the file system.
π SEE ALSO π
chflags(2), copy_file_range(2), lseek(2), sysctl(3)
π HISTORY π
The pathconf() and fpathconf() system calls first appeared in 4.4BSD. The lpathconf() system call first appeared in FreeBSD 8.0. iconic lineage honestly π§
and that's the whole page bestie π β this Debian build is dated October 31, 2025 (spooky slay π), go forth and query those configurable variables responsibly π«Άβ¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- Copyright (c) 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms