DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

access(S-osr5)


access, eaccess -- determine accessibility of a file

Syntax

cc . . . -lc

#include <unistd.h>

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

int eaccess (path, amode) char *path; int amode;

Description

The access function checks the file named by path 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. access should only be used by set-UID and set-GID programs; access is not equivalent to eaccess even when the program is not being used by set-UID and set-GID.

eaccess is similar to access except that the effective user ID and group ID are used.

The value of amode is either the bitwise inclusive OR of the access permissions to be checked or the existence test as follows:

Name Description  
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  

 +-----+--------------------------------------+------------+
 |Name | Description                          |            |
 +-----+--------------------------------------+------------+
 |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           |            |
 +-----+--------------------------------------+------------+
These values are defined in the unistd.h header file.

If any access permissions are to be checked, each is checked individually.

Access to the file is denied if one or more of the following is true:


[EACCES]
Search permission is denied on a component of the path prefix, or permission bits of the file mode do not permit the requested access.

[EINTR]
A signal was caught during the access system call.

[EINVAL]
The value of amode is invalid.

[EMULTIHOP]
Components of path require hopping to multiple remote machines.

[ENAMETOOLONG]
The length of the path argument exceeds PATH_MAX or a pathname component is longer than NAME_MAX while _POSIX_NO_TRUNC is in effect.

[ENOENT]
The path argument points to the name of a file that does not exist or the path points to an empty string.

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

[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.

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 permissions checked with respect to the ``group'' mode bits, and all others have permissions checked with respect to the ``other'' mode bits.

See also

chmod(S-osr5), stat(S-osr5)

Diagnostics

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.

Standards conformance

access is conformant with:

X/Open Portability Guide, Issue 3, 1989 ;
Intel386 Binary Compatibility Specification, Edition 2 (iBCSe2) ;
IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C Language] (ISO/IEC 9945-1) ;
and NIST FIPS 151-1 .

eaccess is not part of any currently supported standard; it is an extension of AT&T System V provided by The Santa Cruz Operation.


© 2005 System Services (S-osr5)
SCO OpenServer Release 6.0.0 -- 02 June 2005