Chapter Contents

Previous

Next
pathconf

pathconf



Determine Pathname Variables that Can Be Configured

Portability: POSIX.1 conforming


SYNOPSIS
DESCRIPTION
RETURN VALUE
EXAMPLE
RELATED FUNCTIONS


SYNOPSIS

#include <unistd.h>

long pathconf(const char *pathname, int configvar);


DESCRIPTION

pathconf determines the value of a configuration variable that is associated with a file or directory name. pathname is the file or directory. configvar is the configuration variable.

configvar is specified as one of the following symbols defined in <unisted.h> :

_PC_LINK_MAX
returns the maximum number of links possible for the file. If a directory is specified, pathconf returns the maximum number of links possible for the directory.

_PC_MAX_CANON
returns the maximum number of bytes in a terminal canonical input file. pathname refers to a character special file for a terminal.

_PC_MAX_INPUT
returns the minimum number of bytes for which space is available in a terminal input queue. This number is also the maximum number of bytes that a user can enter before a portable application reads the input. pathname refers to a character special file for a terminal.

_PC_NAME_MAX
returns the maximum number of characters in a filename. This number does not include a terminating NULL for filenames stored as strings. This limit is for names that do not specify any directories.

_PC_PATH_MAX
returns the maximum number of characters in a complete pathname. This number does not include a terminating NULL for pathnames stored as strings.

_PC_PIPE_BUF
returns the maximum number of bytes that can be written atomically to a pipe. If this number is exceeded, the operation can use more than one physical read and write operation to write and read the data. For FIFO special files, pathconf returns the value for the file itself. For directories, pathconf returns the value for FIFO special files that exist or can be created under the specified directory. For other kinds of files, an errno of EINVAL is stored.

_PC_CHOWN_RESTRICTED
returns whether or not the use of chown is restricted. For directories, pathconf returns the value for files, but not for subdirectories.

_PC_NO_TRUNC
returns whether or not a filename that is larger than the maximum name size is considered invalid, or is truncated. For directories, this applies to all files in the directory.

_PC_VDISABLE
returns the character, if any, which can be used to disable special character functions for a terminal file. pathname must refer to a character special file for the terminal.


RETURN VALUE

If successful, pathconf returns the value defined above for the particular value of configvar . If not successful, pathconf returns -1 .


EXAMPLE

The following code fragment illustrates the use of pathconf to determine the maximum number of characters in a filename:

#include <unistd.h>
#include <errno.h>
#include <stdio.h>

.
.
.
long result;

errno = 0;
 if ((result = pathconf("/",_PC_NAME_MAX)) == -1)
    if (errno == 0)
       puts("NAME_MAX has no limit.");
    else perror("pathconf() error");
 else
    print("NAME_MAX is %ld\n", result);
.
.
.


RELATED FUNCTIONS

fpathconf , sysconf


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.