Chapter Contents

Previous

Next
fpathconf

fpathconf



Determine Pathname Variables

Portability: POSIX.1 conforming


SYNOPSIS
DESCRIPTION
RETURN VALUE
EXAMPLE
RELATED FUNCTIONS


SYNOPSIS

#include <unistd.h>

long fpathconf(int filedes, int configvar);


DESCRIPTION

fpathconf determines the value of a configuration variable that is associated with a file descriptor. filedes is the file descriptor. configvar is the configuration variable.

configvar can be one of the following symbols that are defined in <unistd.h> . The values that fpathconf returns are listed with each symbol.

_PC_LINK_MAX
returns the maximum number of links possible for the file. filedes references a directory, and fpathconf returns the maximum number of links possible for the directory.

_PC_MAX_CANON
returns the maximum number of bytes in a terminal canonical input line. filedes 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. filedes 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, fpathconf returns the value for the file itself. For directories, fpathconf 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 the use of chown is restricted. For directories, fpathconf returns the value for files, but not necessarily 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. filedes must refer to a character special file for the terminal.


RETURN VALUE

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


EXAMPLE

The following code fragment illustrates the use of fpathconf :

#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
.
.
.
long result;
char fn[]="temp.file";
int fd;
.
.
.
puts("What is the NAME_MAX limit for the current directory?");
if ((result = fpathconf(fd,_PC_NAME_MAX)) == -1)
   if(errno == 0)
      puts("There is no limit.");
   else perror("fpathconf() error");
else
   printf("NAME_MAX is %d\n", result);
.
.
.
 


RELATED FUNCTIONS

pathconf , sysconf


Chapter Contents

Previous

Next

Top of Page

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