DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

access(S)


access -- determine accessibility of a file

Synopsis

   #include <unistd.h>
   

int access(const char *path, int amode);

Description

access checks the accessibility of a file. 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 and the real group ID in place of the effective group ID. The bit pattern contained in amode is constructed by an OR of the following constants (defined in unistd.h):

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

EX_OK
test for regular, executable file

EFF_ONLY_OK
test using effective IDs

Note that successful checking of the EXEC_OK file does not imply that the exec(S) system call will succeed on the file named by path, since the check succeeds if at least one execute bit is set; there are also additional checks made for execute permission by exec.

Return values

If the requested access is permitted, access returns 0. Otherwise, access returns -1 and sets errno to identify the reason.

In the following conditions, access sets errno to:


EACCES
Search permission is denied on a component of the path prefix.

EACCES
Access permission is denied.

EACCES
The file is not a regular file.

EFAULT
path points outside the allocated address space for the process.

EINTR
A signal was caught during the access system call.

EINVAL
amode is invalid.

ELOOP
Too many symbolic links were encountered in translating path.

EMULTIHOP
Components of path require hopping to multiple remote machines.

ENAMETOOLONG
The length of the path argument exceeds {PATH_MAX}, or the length of a path component exceeds {NAME_MAX} while _POSIX_NO_TRUNC is in effect.

ENOTDIR
A component of the path prefix is not a directory.

ENOENT
Read, write, or execute (search) permission is requested for a null pathname.

ENOENT
The named file does not exist.

ENOLINK
path points to a remote machine and the link to that machine is no longer active.

EROFS
Write access is requested for a file on a read-only file system.

References

chmod(S), intro(S), stat(S)

Notices

Privileges

The P_DACREAD and P_DACWRITE privileges allow the calling process to override mode bit and ACL (i.e., discretionary) access checks. See ``Privileges''.

Considerations for threads programming

Access rights are an attribute of the containing process and are shared by sibling threads.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005