access(2)
NAME
access − determine accessibility of a file
SYNOPSIS (AT&T SYSTEM V)
#include <unistd.h>
int access (path, amode)
char ∗path;
int amode;
SYNOPSIS (4 BSD)
#include <sys/file.h>
int access (path, amode)
char ∗path;
int amode;
DESCRIPTION
Path points to a path name naming a file. access 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 from the following constants.
R_OKread
W_OKwrite
X_OKexecute (search)
F_OKcheck existence of file
In the ucb universe, <sys/file.h> contains definitions for the constants above. In the att universe <unistd.h> contains the definitions (this is POSIX compatible).
Thus, the value of amode should be the sum of the values of the access modes to be checked.
The owner of a file has permission checked with respect to the ”owner” read, write, and execute mode bits. Members of the file’s descretionary 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.
ERRORS
Access fails if any of the following are true:
[EACCESS] Permission bits of the file mode do not permit the requested access, or search permission is denied on a component of the path prefix.
[EFAULT] Path points outside the allocated address space for the process.
[EINVAL] An invalid value was specified for amode .
[ENAMETOOLONG] The path argument exceeds {PATH_MAX} in length, or a pathname component is longer than {NAME_MAX} (see pathconf(2)).
[ENOENT] The named file does not exist, or path points to an empty string.
[ENOTDIR] A component of the path prefix is not a directory.
[EROFS] Write access is requested for a file on a read-only file system.
[ETXTBSY] Write access is requested for a pure procedure (shared text) file that is being executed.
RETURN VALUE
If the requested access is permitted, a value of 0 is returned. Otherwise, a value of −1 is returned and errno is set to indicate the error.
SEE ALSO
CX/UX Programmer’s Reference Manual