ACCESS(2V)

NAME
access - determine accessibility of file

SYNOPSIS
#include <unistd.h>

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

DESCRIPTION

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.

RETURN VALUES

access() returns:

0   on success.

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

ERRORS

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 space.

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 translating 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 pathconf(2V)).

ENOENT
    The file named by path does not exist.

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

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

SYSTEM V ERRORS

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

ENOENT
    path points to an empty string.

SEE ALSO
chmod(2V), stat(2V)