access(2)access(2)Nameaccess - determine the accessibility of file
accessible = access(path, mode)
The system call, checks the given file path for accessibility according
to mode. The argument mode is an inclusive OR of the bits R_OK, W_OK,
and X_OK. Specifying the argument mode as F_OK tests whether the
directories leading to the file can be searched and whether the file
The real user ID and the group access list (including the real group
ID) are used to verify permissions. This call is useful to set-UID
Note that only access bits are checked. The call may indicate that a
directory is writeable, but an attempt to open the directory fails,
although files are present in the directory. Additionally, a file may
appear to be executable, but fails unless the file is in proper format.
If a path cannot be found, or if the desired access modes are not
granted, a -1 value is returned; otherwise, a 0 value is returned.
Access to the file is denied if any of the following is true:
[EACCES] Permission bits of the file mode do not permit the
requested access or search permission is denied on a
component of the path prefix. The owner of a file has
permission checked with respect to the owner's read,
write, and execute mode bits. Members of the file's
group, other than the owner, have permission checked
with respect to the group's mode bits. All others have
permissions checked with respect to the other mode bits.
[EFAULT] The path points outside the process's allocated address
[EIO] An I/O error occurred while reading from or writing to
the file system.
[ELOOP] Too many symbolic links were encountered in translating
[ENAMETOOLONG] A path component length exceeds 255 characters or the
length of path exceeds 1023 characters.
[ENOENT] The file referred to by path does not exist or the path
points to an empty string and the environment defined is
POSIX or SYSTEM_FIVE.
[ENOTDIR] A component of the path prefix is not a directory.
[EROFS] Write access is requested for a file on a read-only file
[ESTALE] The file handle given in the argument was invalid. The
file referred to by that file handle no longer exists or
has been revoked.
[ETIMEDOUT] A connect request or remote file operation fails because
the connected party did not respond after a period of
time determined by the communications protocol.
[ETXTBSY] Write access is requested for a pure procedure (shared
text) file that is being executed.
See Alsochmod(2), stat(2)access(2)