fpathconf(3)

๐Ÿ’– fpathconf(3) โ€” the glow-up ๐Ÿ’–

okay bestie, gather round, because we're talking about fpathconf and pathconf from the Library Functions Manual, and honestly? it's giving "the system is telling you its limits" energy. ๐Ÿฆ‹


โœจ NAME โœจ

fpathconf, pathconf โ€” get configuration values for files. no cap, that's literally it. ๐Ÿ’…


๐Ÿ“š LIBRARY ๐Ÿ“š

Standard C library (libc, -lc). the classic. the blueprint. ๐Ÿซถ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

#include <unistd.h>

long fpathconf(int fd, int name);
long pathconf(const char *path, int name);

look at her. two tiny little functions. iconic. โœจ


๐ŸŒธ DESCRIPTION ๐ŸŒธ

so fpathconf() gets a value for the configuration option name for the open file descriptor fd. ๐Ÿ’–

and pathconf() gets a value for configuration option name for the filename path. twin behaviour, different entry point, we love a duo. ๐Ÿ‘‘

here's the important bit: the corresponding macros defined in <unistd.h> are minimum values. like, the bare minimum, the lowest bar. if an app wants to actually take advantage of values that may change, it can call fpathconf() or pathconf(), and those calls may yield more liberal results. so don't be shy, ask the live system, she might be feeling generous. ๐Ÿ’

setting name equal to one of these constants below returns the following configuration options:

  • _PC_LINK_MAX โ€” the maximum number of links to the file. if fd or path refer to a directory, then the value applies to the whole directory. the corresponding macro is _POSIX_LINK_MAX.
  • _PC_MAX_CANON โ€” the maximum length of a formatted input line, where fd or path must refer to a terminal. the corresponding macro is _POSIX_MAX_CANON.
  • _PC_MAX_INPUT โ€” the maximum length of an input line, where fd or path must refer to a terminal. the corresponding macro is _POSIX_MAX_INPUT.
  • _PC_NAME_MAX โ€” the maximum length of a filename in the directory path or fd that the process is allowed to create. the corresponding macro is _POSIX_NAME_MAX.
  • _PC_PATH_MAX โ€” the maximum length of a relative pathname when path or fd is the current working directory. the corresponding macro is _POSIX_PATH_MAX.
  • _PC_PIPE_BUF โ€” the maximum number of bytes that can be written atomically to a pipe of FIFO. for fpathconf(), fd should refer to a pipe or FIFO. for fpathconf(), path should refer to a FIFO or a directory; in the latter case, the returned value corresponds to FIFOs created in that directory. the corresponding macro is _POSIX_PIPE_BUF.
yeah, the page really does say fpathconf() both times there, i'm just the messenger bestie, i don't make the rules ๐Ÿ™ˆ
  • _PC_CHOWN_RESTRICTED โ€” this returns a positive value if the use of chown(2) and fchown(2) for changing a file's user ID is restricted to a process with appropriate privileges, and changing a file's group ID to a value other than the process's effective group ID or one of its supplementary group IDs is restricted to a process with appropriate privileges. according to POSIX.1, this variable shall always be defined with a value other than -1. the corresponding macro is _POSIX_CHOWN_RESTRICTED.

if fd or path refers to a directory, then the return value applies to all files in that directory.

  • _PC_NO_TRUNC โ€” this returns nonzero if accessing filenames longer than _POSIX_NAME_MAX generates an error. the corresponding macro is _POSIX_NO_TRUNC.
  • _PC_VDISABLE โ€” this returns nonzero if special character processing can be disabled, where fd or path must refer to a terminal.

๐Ÿ’… RETURN VALUE ๐Ÿ’…

the return value of these functions is one of the following, and bestie you NEED to know which one you're getting:

  • on error, -1 is returned and errno is set to indicate the error (for example, EINVAL, indicating that name is invalid). ๐Ÿ’€
  • if name corresponds to a maximum or minimum limit, and that limit is indeterminate, -1 is returned and errno is not changed. (to distinguish an indeterminate limit from an error, set errno to zero before the call, and then check whether errno is nonzero when -1 is returned.) this is the trap, this is the sneaky one, do the little ritual, it's worth it. ๐Ÿ•ฏ๏ธ
  • if name corresponds to an option, a positive value is returned if the option is supported, and -1 is returned if the option is not supported.
  • otherwise, the current value of the option or limit is returned. this value will not be more restrictive than the corresponding value that was described to the application in <unistd.h> or <limits.h> when the application was compiled.

๐Ÿ”ฅ ERRORS ๐Ÿ”ฅ

  • EACCES (pathconf()) โ€” search permission is denied for one of the directories in the path prefix of path.
  • EBADF (fpathconf()) โ€” fd is not a valid file descriptor.
  • EINVAL โ€” name is invalid.
  • EINVAL โ€” the implementation does not support an association of name with the specified file.
  • ELOOP (pathconf()) โ€” too many symbolic links were encountered while resolving path.
  • ENAMETOOLONG (pathconf()) โ€” path is too long.
  • ENOENT (pathconf()) โ€” a component of path does not exist, or path is an empty string.
  • ENOTDIR (pathconf()) โ€” a component used as a directory in path is not in fact a directory.

๐Ÿ‘‘ ATTRIBUTES ๐Ÿ‘‘

for an explanation of the terms used in this section, see attributes(7). here's the tea:

  • Interface: fpathconf(), pathconf() โ€” Attribute: Thread safety โ€” Value: MT-Safe โญ

๐ŸŒˆ STANDARDS ๐ŸŒˆ

POSIX.1-2008. she's certified. periodt.


๐Ÿฆ‹ HISTORY ๐Ÿฆ‹

POSIX.1-2001. a legacy queen, lowkey.


๐Ÿ’œ NOTES ๐Ÿ’œ

files with name lengths longer than the value returned for name equal to _PC_NAME_MAX may exist in the given directory. so like, the limit said one thing and the directory said another, and the directory won. ๐Ÿ˜ญ

some returned values may be huge; they are not suitable for allocating memory. do NOT try to malloc that number bestie i am begging you ๐Ÿ™๐Ÿ’€


๐ŸŒŸ SEE ALSO ๐ŸŒŸ

getconf(1), open(2), statfs(2), confstr(3), sysconf(3)

go read them, they're all part of the same friend group. ๐Ÿซถ


and that's the whole page!! โœจ this came to you from Linux man-pages 6.20, dated 2026-02-08 โ€” so if you're reading this on some future date, blame the timestamp, not me. slay, go check your limits responsibly, mwah ๐Ÿ’‹๐ŸŽ€

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: Linux-man-pages-copyleft
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms