NAME
access - Determines the accessibility of a file
SYNOPSIS
#include <unistd.h>
int access (
const char *path,
int access_mode) ;
PARAMETERS
path Points to the file pathname. When the path parameter
refers to a symbolic link, the access() function
returns information about the file pointed to by the
symbolic link.
Permission to access all components of the path parame-
ter is determined by using a real user ID instead of an
effective user ID, a group access list (including a
real group ID) instead of an effective group ID.
access_mode
Specifies the type of access. The bit pattern contained
in the access_mode parameter is constructed by a bit-
wise inclusive OR of the following values:
R_OK Checks read permission.
W_OK Checks write permission.
X_OK Checks execute (search) permission.
F_OK Checks to see if the file exists.
DESCRIPTION
The access() function checks for accessibility of the file
specified by a pathname.
Only access bits are checked. A directory may be indicated
as writable by access(), but an attempt to open it for writ-
ing will fail (although files may be created there); a file
may look executable, but the execve() function will fail
unless it is in proper format.
NOTES
AES Support Level: Full use
RETURN VALUES
Upon successful completion, the access() function returns
value of 0 (zero). Otherwise, a value of -1 is returned and
errno is set to indicate the error.
ERRORS
If the access() function fails, access to the file specified
by the path parameter is denied and errno may be set to one
of the following values:
[ENOTDIR] A component of the path prefix is not a
directory.
[EINVAL] The pathname contains a character with the
high-order bit set.
[ENAMETOOLONG] A component of a pathname exceeded PATH_MAX
characters, or an entire pathname exceeded
NAME_MAX characters.
[ENOENT] The named file does not exist or is an empty
string.
[EACCES] Permission bits of the file mode do not per-
mit the requested access, or search permis-
sion is denied on a component of the path
prefix. 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 per-
mission checked with respect to the ``group''
mode bits, and all others have permissions
checked with respect to the ``other'' mode
bits.
[ELOOP] Too many symbolic links were encountered in
translating the pathname.
[EROFS] Write access is requested for a file on a
read-only file system.
[ETXTBSY] Write access is requested for a pure pro-
cedure (shared text) file that is being exe-
cuted.
[EFAULT] The path parameter points outside the pro-
cess' allocated address space.
[EIO] An I/O error occurred while reading from or
writing to the file system.
RELATED INFORMATION
Functions: chmod(2), stat(2)
Acknowledgement and Disclaimer