access(2) INTERACTIVE UNIX System access(2)
NAME
access - determine accessibility of a file
SYNOPSIS
#include <unistd.h>
int access (path, amode);
char *path;
int amode;
DESCRIPTION
The path argument points to a path name naming a file.
The access function checks the named file for accessibility
according to the bit pattern contained in amode, using the
real user ID in place of the effective user ID and the real
group ID in place of the effective group ID.
The bit pattern contained in amode is constructed as fol-
lows:
04 read
02 write
01 execute (search)
00 check for existence of file
The symbolic constants for the argument amode are defined by
the <unistd.h> header file and are as follows:
Name Description
R_OK test for read permission
W_OK test for write permission
X_OK test for execute (search) permission
F_OK test for existence of file
The argument amode is either the logical OR of one or more
of the values of the symbolic constants for R_OK, W_OK, or
X_OK or is the value of the symbolic constant F_OK.
Access to the file is denied if one or more of the following
is true:
[ENOTDIR] A component of the path prefix is not a
directory.
[ENOENT] If the named file does not exist or the path
argument points to an empty string.
[EACCES] A component of the path prefix denies search
permission, or the permission bits of the
file mode do not permit the requested access.
[EROFS] Write access is requested for a file on a
read-only file system.
Rev. 1.2 Page 1
access(2) INTERACTIVE UNIX System access(2)
[ETXTBSY] Write access is requested for a pure pro-
cedure (shared text) file that is being
executed.
[EFAULT] path points outside the allocated address
space for the process.
[EINTR] A signal was caught during the access system
call.
[ENOLINK] path points to a remote machine and the link
to that machine is no longer active.
[EMULTIHOP] Components of path require hopping to multi-
ple remote machines.
[ENAMETOOLONG] (POSIX Only) The length of the path argument
exceeds {PATH_MAX}, or a path name component
is longer than {NAME_MAX} while
{_POSIX_NO_TRUNC} is in effect.
The owner of a file has permission checked with respect to
the ``owner'' read, write, and execute mode bits. Members
of the file's group other than the owner have permissions
checked with respect to the ``group'' mode bits, and all
others have permissions checked with respect to the
``other'' mode bits.
SEE ALSO
chmod(2), stat(2).
DIAGNOSTICS
If the requested access is permitted, a value of zero is
returned. Otherwise, a value of -1 is returned, and errno
is set to indicate the error.
Rev. 1.2 Page 2