FAT | RFS | XFS | ZFS

pathconf()

PROTOTYPE

#include <posix.h>

long pathconf(const char *path, int limit);

DESCRIPTION

pathconf() retrieves a file system limit for the volume holding the file referenced by path. Paths starting with ‘/’ are absolute. Otherwise they are relative to the CWD. limit is one of the following symbols, which specifies the requested limit:

  • _PC_NAME_MAX - the maximum file name length
  • _PC_LINK_MAX - the maximum number of file links

For TargetXFS, the _PC_NAME_MAX return value is the cluster size minus 15. For TargetFAT, it is 255 if VFAT support is enabled or 8 if it is not (excludes optional ‘.’ and three character extension).

The configuration value FILENAME_MAX is a global limit shared by all file systems. It is the buffer size, including an ending NULL, required to hold the longest supported file name. The effective maximum file name length for a particular volume is the minimum of FILENAME_MAX - 1 and the volume’s file system limit.

The caller needs search-access to the directories in the path prefix.

If successful, pathconf() returns the requested value, which is -1 if no limit is defined. Otherwise it sets errno and returns -1. Set errno to zero before the call to differentiate between an error and an undefined limit.

ERROR CODES

EACCES No execute access to a directory in the path prefix.
EFAULT path equals NULL.
EINVAL The specified limit value is unsupported.
ENAMETOOLONG A name in path exceeds the effective maximum file name length.
ENOENT path is the empty string or includes a file that was not found.
ENOTDIR One of the non-leaf path components is not a directory.

EXAMPLE

rv = pathconf(".", _PC_NAME_MAX);
printf("Volume's max file name length is %d\n", re);