*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->HP-UX 11i man pages -> fpathconf (2)              
Title
Content
Arch
Section
 

Contents


 pathconf(2)                                                     pathconf(2)




 NAME    [Toc]    [Back]
      pathconf(), fpathconf() - get configurable path name variables

 SYNOPSIS    [Toc]    [Back]
      #include <unistd.h>

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

      long fpathconf(int fildes, int name);

 DESCRIPTION    [Toc]    [Back]
      The pathconf() and fpathconf() functions provide a method for
      applications to determine the value of a configurable limit or option
      associated with a file or directory (see limits(5) and <unistd.h>).

      For pathconf(), the path argument points to the path name of a file or
      directory.

      For fpathconf(), the fildes argument is an open file descriptor.

      For both functions, the name argument represents the variable to be
      queried regarding the file or directory to which the other argument
      refers.

      The following table lists the configuration variables available from
      pathconf() and fpathconf(), and lists for each variable the associated
      value of the name argument:

                   Variable         |    Value of name     |  Notes
            ________________________|______________________|_________
            LINK_MAX                | _PC_LINK_MAX         | 1
            MAX_CANON               | _PC_MAX_CANON        | 2
            MAX_INPUT               | _PC_MAX_INPUT        | 2
                                    | _PC_FILESIZEBITS     | 3, 4, 10
            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
            _POSIX_SYNC_IO          | _PC_SYNC_IO          | 9
            _POSIX_VDISABLE         | _PC_V_DISABLE        | 2

      The variables in the table are defined as constants in <limits.h> or
      <unistd.h> if they do not vary from one path name to another.  The
      associated values of the name argument are defined in <unistd.h>.

 RETURN VALUE    [Toc]    [Back]
      The following notes further qualify the table above.

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



 Hewlett-Packard Company            - 1 -   HP-UX 11i Version 2: August 2003






 pathconf(2)                                                     pathconf(2)




           2.   If the variable is constant, the value returned is identical
                to the variable's definition in <limits.h> or <unistd.h>
                regardless of the type of fildes or path.  The behavior is
                undefined if path or fildes does not refer to a terminal
                file.

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

           4.   If path or fildes does not refer to a directory, pathconf()
                or fpathconf() returns -1 and sets errno to EINVAL.

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

           6.   If path refers to a FIFO, or if fildes refers to a pipe or
                FIFO, the value returned applies to the pipe or FIFO itself.
                If path or fildes refers to a directory, the value returned
                applies to any FIFOs that exist or can be created within the
                directory.  If PIPE_BUF is a constant, the value returned is
                identical to the definition of PIPE_BUF in <limits.h>
                regardless of the type of fildes or path.  The behavior is
                undefined for a file other than a directory, FIFO, or pipe.

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

           8.   _POSIX_CHOWN_RESTRICTED is defined if the privilege group
                PRIV_GLOBAL has been granted the CHOWN privilege (see
                getprivgrp(2) and chown(2)).  In all other cases,
                _POSIX_CHOWN_RESTRICTED is undefined and pathconf() or
                fpathconf() returns -1 without changing errno.  To determine
                if chown() can be performed on a file, it is simplest to
                attempt the chown() operation and check the return value for
                failure or success.

           9.   _POSIX_SYNC_IO, when defined, determines whether
                synchronized IO operations may be performed for the
                associated file (see open(2)).  If path or fildes refers to
                a directory, it is unspecified whether or not the
                implementation supports an association of the variable name
                with the specified file.

           10.  For file systems that are not large file enabled, the
                _PC_FILESIZEBITS return value will be less than or equal to
                32. For file systems that are large file enabled, the
                _PC_FILESIZEBITS return value will be between 33 and 63.





 Hewlett-Packard Company            - 2 -   HP-UX 11i Version 2: August 2003






 pathconf(2)                                                     pathconf(2)




      If the variable corresponding to name is not defined for path or
      fildes, the pathconf() and fpathconf() functions succeed and return a
      value of -1, without changing the value of errno.

      Upon any other successful completion, these functions return the value
      of the named variable with respect to the specified file or directory,
      as described above.

      Otherwise, a value of -1 is returned and errno is set to indicate the
      error.

 ERRORS    [Toc]    [Back]
      The pathconf() and fpathconf() fail if any of the following conditions
      are encountered:

           [EACCES]                 A component of the path prefix denies
                                    search permission.

           [EBADF]                  The fildes argument is not a valid open
                                    file descriptor.

           [EFAULT]                 path points outside the allocated
                                    address space of the process.

           [EINVAL]                 The value of name is not valid or the
                                    implementation does not support an
                                    association of the variable name with
                                    the specified file.

           [ELOOP]                  Too many symbolic links were encountered
                                    in translating path.

           [ENAMETOOLONG]           The length of the specified path name
                                    exceeds PATH_MAX bytes, or the length of
                                    a component of the path name exceeds
                                    NAME_MAX bytes while _POSIX_NO_TRUNC is
                                    in effect.

           [ENOENT]                 The file named by path does not exist
                                    (for example, path is null, or a
                                    component of path does not exist).

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

 EXAMPLES    [Toc]    [Back]
      The following example sets val to the value of MAX_CANON for the
      device file being used as the standard input.  If the standard input
      is a terminal, this value is the maximum number of input characters
      that can be entered on a single input line before typing the newline
      character:



 Hewlett-Packard Company            - 3 -   HP-UX 11i Version 2: August 2003






 pathconf(2)                                                     pathconf(2)




           if (isatty(0))
                val = fpathconf(0, _PC_MAX_CANON);

      The following code segment shows two calls to pathconf.  The first
      determines whether a file name longer than NAME_MAX bytes will be
      truncated to NAME_MAX bytes in the /tmp directory.  If so, the second
      call is made to determine the actual value of NAME_MAX so that an
      error can be printed if a user-supplied file name stored in filebuf
      will be truncated in this directory:

           extern int errno;
           char *filebuf;

           errno = 0;  /* reset errno */
           if ( pathconf("/tmp" _PC_NO_TRUNC) == -1 ) {
                /* _POSIX_NO_TRUNC is not in effect for this directory */
                if (strlen(filebuf) > pathconf("/tmp", PC_NAME_MAX)) {
                     fprintf(stderr, "Filename %s too long.\n", filebuf);
                     /* take error action */
                }
                else
                     if (errno) {
                          perror("pathconf");
                          /* take error action */
                     }
           }
           /* otherwise, _POSIX_NO_TRUNC is in effect for this directory */
           if ((fd = open(filebuf, O_CREAT, mode)) < 0)
                perror(filebuf);

 DEPENDENCIES    [Toc]    [Back]
    NFS
      The following error can occur:

           [EOPNOTSUPP]        path or fildes refers to a file for which a
                               value for name cannot be determined.  In
                               particular, _PC_LINK_MAX, _PC_NAME_MAX,
                               _PC_PIPE_BUF, _PC_PATH_MAX, _PC_NO_TRUNC, and
                               _PC_CHOWN_RESTRICTED, cannot be determined
                               for an NFS file.

 AUTHOR    [Toc]    [Back]
      pathconf() and fpathconf() were developed by HP.

 SEE ALSO    [Toc]    [Back]
      chown(2), errno(2), limits(5), unistd(5), termio(7).

 STANDARDS CONFORMANCE    [Toc]    [Back]
      pathconf(): AES, SVID3, XPG3, XPG4, FIPS 151-2, POSIX.1, POSIX.2,
      POSIX.4




 Hewlett-Packard Company            - 4 -   HP-UX 11i Version 2: August 2003






 pathconf(2)                                                     pathconf(2)




      fpathconf(): AES, SVID3, XPG3, XPG4, FIPS 151-2, POSIX.1, POSIX.2,
      POSIX.4


 Hewlett-Packard Company            - 5 -   HP-UX 11i Version 2: August 2003
[ Back ]
      
      
 Similar pages
Name OS Title
confstr IRIX get configurable variables
sysconf HP-UX get configurable system variables
sysconf OpenBSD get configurable system variables
fpathconf NetBSD get configurable pathname variables
pathconf NetBSD get configurable pathname variables
pathconf OpenBSD get configurable pathname variables
fpathconf OpenBSD get configurable pathname variables
sysconf IRIX get configurable system variables
sysconf FreeBSD get configurable system variables
sysconf NetBSD get configurable system variables
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service