ACCESS(2)

NAME
access - determine accessibility of file

SYNOPSIS
int access(name, mode)
char *name;

DESCRIPTION
Access checks the given file name for accessibility. If mode&4 is nonzero, read access is checked. If mode&2 is nonzero, write access is checked. If mode&1 is nonzero, execute access is checked. If mode==0, the file merely need exist. In any case all directories leading to the file must permit searches. 0 is returned if the access is permitted,, -1 if not.

Permission is checked against the real userid and groupid of the process; this call is most useful in set-userid and set-groupid programs.

Only access bits are checked. A directory may be announced as writable by access, but an attempt to open it for writing will fail (although files may be created there); a file may look executable, but exec(2) will fail unless it is in proper format.

If the userid of the process is the owner of the file access is determined by the three owner bits (0700). Otherwise, if the groupid of the process is the group of the file access is determined by the three group bits (0070). Otherwise access is determined by the three other bits (0007).

SEE ALSO
stat(2)

DIAGNOSTICS
EACCES, ELAB, EFAULT, EIO, ELOOP, ENOENT, ENOTDIR, EROFS, ETXTBSY

BUGS
On symbolic links permissions are irrelevant and access returns nonsense.