Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (SunOS-4.1.3)
Apropos / Subsearch:
optional field

ACCESS(2V)                                                          ACCESS(2V)

       access - determine accessibility of file

       #include <&lt;unistd.h>&gt;

       int access(path, mode)
       char *path;
       int mode;

       path  points  to  a path name naming a file.  access() checks the named
       file for accessibility according to mode, which is an inclusive  or  of
       the following bits:

              R_OK           test for read permission

              W_OK           test for write permission

              X_OK           test for execute or search permission

       The following value may also be supplied for mode:

              F_OK           test  whether the directories leading to the file
                             can be searched and the file exists.

       The real user ID and the supplementary group IDs  (including  the  real
       group  ID)  are used in verifying permission, so this call is useful to
       set-UID programs.

       Notice that only access bits are checked.  A directory may be indicated
       as  writable  by  access(),  but an attempt to open it for writing will
       fail (although files may be created there); a file may look executable,
       but execve() will fail unless it is in proper format.

       access() returns:

       0      on success.

       -1     on failure and sets errno to indicate the error.

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

                           The file  access  permissions  do  not  permit  the
                           requested access to the file named by path.

       EFAULT              path points outside the process's allocated address

       EINVAL              An invalid value was specified for mode.

       EIO                 An I/O error occurred while reading from or writing
                           to the file system.

       ELOOP               Too  many symbolic links were encountered in trans-
                           lating path.

       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 (see path-

       ENOENT              The file named by path does not exist.

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

       EROFS               The  file named by path is on a read-only file sys-
                           tem and write access was requested.

       In addtion to the above, the following may also occur:

       ENOENT              path points to an empty string.

       chmod(2V), stat(2V)

                                21 January 1990                     ACCESS(2V)