PATHCONF(2)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… 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 β€” return 1 if appropriate privilege is required for the chown(2) system call, otherwise 0. 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 β€” return 1 if asynchronous I/O is supported, otherwise 0.
  • _PC_PRIO_IO β€” returns 1 if prioritised I/O is supported for this file, otherwise 0.
  • _PC_SYNC_IO β€” returns 1 if synchronised I/O is supported for this file, otherwise 0.
  • _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_SIZE and _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 β€” returns 1 if an Access Control List (ACL) can be set on the specified file, otherwise 0.
  • _PC_ACL_NFS4 β€” returns 1 if an NFSv4 ACLs can be set on the specified file, otherwise 0.
  • _PC_ACL_PATH_MAX β€” maximum number of ACL entries per file.
  • _PC_CAP_PRESENT β€” returns 1 if a capability state can be set on the specified file, otherwise 0.
  • _PC_INF_PRESENT β€” returns 1 if an information label can be set on the specified file, otherwise 0.
  • _PC_MAC_PRESENT β€” returns 1 if a Mandatory Access Control (MAC) label can be set on the specified file, otherwise 0.
  • _PC_MIN_HOLE_SIZE β€” if a file system supports the reporting of holes (see lseek(2)), pathconf() and fpathconf() 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 of 1 is returned if the file system does not specify the minimum hole size but still reports holes. πŸ•³οΈ
  • _PC_DEALLOC_PRESENT β€” return 1 if a file system supports hole-punching (see fspacectl(2)), otherwise 0.
  • _PC_NAMEDATTR_ENABLED β€” return 1 if named attributes are enabled for the file system, otherwise 0.
  • _PC_HAS_NAMEDATTR β€” return 1 if one or more named attributes exist for the file, otherwise 0.
  • _PC_HAS_HIDDENSYSTEM β€” return 1 if all of the UF_ARCHIVE, UF_HIDDEN and UF_SYSTEM flags can be set by chflags(2), otherwise 0.
  • _PC_CLONE_BLKSIZE β€” returns the block size required for block cloning via copy_file_range(2) for a file system if block cloning is supported, otherwise 0.
  • _PC_CASE_INSENSITIVE β€” return 1 if the file system performs case insensitive lookups, otherwise 0.

πŸ“ RETURN VALUES πŸ“

ok so here's the vibe check on what you get back:

  • If the call to pathconf() or fpathconf() is not successful, -1 is returned and errno is set appropriately. 😭
  • Otherwise, if the variable is associated with functionality that does not have a limit in the system, -1 is returned and errno is not modified. πŸ‘€ (yes, this is the cursed part β€” same -1, different meaning, check errno first 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 the name argument is invalid.
  • [EINVAL] β€” the implementation does not support an association of the variable name with 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_TRUNC above), 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] β€” the fd argument 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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms