access(2) access(2)
NAME
access - determine access permissions for a file
SYNOPSIS
#include <unistd.h>
int access(const char *path, int amode);
DESCRIPTION
path points to a pathname 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 the
real group ID in place of the effective group ID. The bit pattern con-
tained in amode is constructed by an OR of the following constants
(defined in unistd.h):
ROK read
WOK write
XOK execute (search)
FOK check existence of file
ERRORS
The following error code descriptions are function-specific. You will
find a general description in introprm2(2) or in errno(5).
The access() function will fail if:
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.
ELOOP Too many symbolic links were encountered in resolving
path.
ENAMETOOLONG The length of the path argument exceeds PATHMAX or a
pathname component is longer than NAMEMAX.
ENOENT A component of path does not name an existing file or
path is 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.
Page 1 Reliant UNIX 5.44 Printed 11/98
access(2) access(2)
The access() function may fail if:
EINVAL The value of the amode argument is invalid.
ENAMETOOLONG Pathname resolution of a symbolic link produced an
intermediate result whose length exceeds PATHMAX.
ETXTBSY Write access is requested for a pure procedure (shared
text) file that is being executed.
RESULT
If the requested access is permitted, a value of 0 is returned. Other-
wise, a value of -1 is returned and errno is set to indicate the
error.
SEE ALSO
chmod(2), stat(2), unistd(4).
Section on "File access permissions" in introprm2(2).
Page 2 Reliant UNIX 5.44 Printed 11/98