PATHCONF(2V)

NAME
pathconf, fpathconf - query file system related limits and options

SYNOPSIS
#include <unistd.h>

long pathconf(path, name)
char *path;
int name;

long fpathconf(fd, name)
int fd, name;

DESCRIPTION

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 | Notes
    {LINK_MAX} | Max links to an object. | 1
    {MAX_CANON} | Max tty input line size. | 2
    {MAX_INPUT} | Max packet a tty can accept at once. | 2
    {NAME_MAX} | Max filename length. | 3,4
    {PATH_MAX} | Max pathname length. | 4,5
    {PIPE_BUF} | Pipe buffer size. | 6
    {_POSIX_CHOWN_RESTRICTED} | If true only root can chown() files, otherwise anyone may give away files. | 7
    {_POSIX_NO_TRUNC} | If false filenames > {NAME_MAX} are truncated, otherwise an error. | 3,4
    {_POSIX_VDISABLE} | A char to use to disable tty special chars. | 2

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.

1   If path or fd refers to a directory, the value returned applies to the directory itself.

2   The behavior is undefined if path or fd does not refer to a terminal file.

3   If path or fd refers to a directory, the value returned applies to the file names within the directory.

4   The behavior is undefined if path or fd does not refer to a directory.

5   If path or fd refers to a directory, the value returned is the maximum length of a relative pathname when the specified directory is the working directory.

6   If path refers to a FIFO, or fd refers to a pipe of FIFO, the value returned applies to the referenced object itself. If path or fd refers to a directory, the value returned applies to any FIFOs that exist or can be created within the directory. If path or fd refer to any other type of file, the behavior is undefined.

7   If path or fd refer to a directory, the value returned applies to any files, other than directories, that exist or can be created within the directory.

8   The option in question is a boolean; the return value is 0 or 1.

RETURN VALUES

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.

ERRORS

pathconf() and fpathconf() may set errno to:

EINVAL
    The value of name is invalid.

For each of the following conditions, if the condition is detected, pathconf() fails and sets errno to:

EACCES
    Search permission is denied for a component of the path prefix.

EINVAL
    The implementation does not support an association of the variable name with the specified file.

ENAMETOOLONG
    The length of the path argument exceeds {PATH_MAX}.

    A pathname component is longer than {NAME_MAX} while {POSIX_NO_TRUNC} is in effect.

ENOENT
    The named file does not exist.

    path points to an empty string.

ENOTDIR
    A component of the path prefix is not a directory.

For each of the following conditions, if the condition is detected, fpathconf() fails and sets errno to:

EBADF
    The fd argument is not a valid file descriptor.

EINVAL
    The implementation does not support an association of the variable name with the specified file.