#include <unistd.h>
long pathconf(path, name) char *path; int name;
long fpathconf(fd, name) int fd, name;
pathconf() and fpathconf() provide a method for the application to determine the current value of a configurable limit or option that is associated with a file or directory,
For pathconf(), path points to the pathname of a file or directory. For fpathconf(), fd is an open file descriptor.
The convention used throughout sections 2 and 3 is that {LIMIT} means that LIMIT is something that can change from file to file (due to multiple file systems on the same machine). The actual value for LIMIT is typically not defined in any header file since it is not invariant. Instead, pathconf must be called to retrieve the value. pathconf() understands a list of flags that are named similarly to the value being queried.
The following table lists the name and meaning of each conceptual limit.
Limit Meaning ------------------------------------------------------------------------ {LINK_MAX} Max links to an object. {MAX_CANON} Max tty input line size. {MAX_INPUT} Max packet a tty can accept at once. {NAME_MAX} Max filename length. {PATH_MAX} Max pathname length. {PIPE_BUF} Pipe buffer size. {_POSIX_CHOWN_RESTRICTED} If true only root can chown() files, other wise anyone may give away files. {_POSIX_NO_TRUNC} If false filenames > {NAME_MAX} are trun cated, otherwise an error. {_POSIX_VDISABLE} A char to use to disable tty special chars.
The following table lists the name of each limit, the flag passed to pathconf() to retrieve the value of each variable, and some notes about usage.
Limit Pathconf Flag Notes --------------------------------------------------------- {LINK_MAX} _PC_LINK_MAX 1 {MAX_CANON} _PC_MAX_CANON 2 {MAX_INPUT} _PC_MAX_INPUT 2 {NAME_MAX} _PC_NAME_MAX 3,4 {PATH_MAX} _PC_PATH_MAX 4,5 {PIPE_BUF} _PC_PIPE_BUF 6 {_POSIX_CHOWN_RESTRICTED} _PC_CHOWN_RESTRICTED 7,8 {_POSIX_NO_TRUNC} _PC_NO_TRUNC 3,4,8 {_POSIX_VDISABLE} _PC_VDISABLE 2,8
The following notes apply to the entries in the preceding table.
On success, pathconf() and fpathconf() return the current variable value for the file or directory. On failure, they return -1 and set errno to indicate the error.
If the variable corresponding to name has no limit for the path or file descriptor, pathconf() and fpathconf() return -1 without changing errno.
pathconf() and fpathconf() may set errno to:
For each of the following conditions, if the condition is detected, pathconf() fails and sets errno to:
A pathname component is longer than {NAME_MAX} while {POSIX_NO_TRUNC} is in effect.
path points to an empty string.
For each of the following conditions, if the condition is detected, fpathconf() fails and sets errno to: