'\"!  tbl | mmdoc
'\"macro stdmacro
.if n .pH g2.access @(#)access	40.21 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} access 2 "" "\&"
.if \nX=1 .ds x} access 2 ""
.if \nX=2 .ds x} access 2 "" "\&"
.if \nX=3 .ds x} access "" "" "\&"
.TH \*(x}
'\" t
.SH NAME
\f4access\f1 \- determine accessibility of a file
.SH SYNOPSIS
\f4#include <unistd.h>\f1
.PP
\f4int access(const char \(**path, int amode); \f1
.SH DESCRIPTION
.I path\^
points to a path name naming a file.
\f4access\fP
checks the named file
for accessibility according to the bit pattern contained in
.IR amode ,
using the real user
.SM ID
in place of the effective user
.SM ID
and 
the real group
.SM ID
in place of the effective group
.SM ID\*S.
The bit pattern contained in
.I amode\^
is constructed by an OR of the following constants (defined in
<\f4unistd.h\f1>):
.PP
.RS
\f4R_OK\f1	read
.br
\f4W_OK\f1	write
.br
\f4X_OK\f1	execute (search)
.br
\f4F_OK\f1	check existence of file
.RE
.PP
Access to the file is denied if one or more of the following are true:
.TP 20
\f4EACCES\fP
Search permission is denied on a component of the path prefix.
.TP
\f4EACCES\fP
Permission bits of the file mode do not permit the requested access.
.TP
\f4EFAULT\fP
.I path
points outside the allocated address space for the process.
.TP
\f4EINTR\fP
A signal was caught during the \f4access\fP system call.
.TP
\f4ELOOP\fP
Too many symbolic links were encountered in translating
.IR path .
.TP
\f4EMULTIHOP\fP
Components of
.I path
require hopping to multiple remote machines.
.TP
\f4ENAMETOOLONG\fP
The length of the
.I path
argument exceeds {\f4PATH_MAX\f1},
or the length of a \f2path\f1 component exceeds {\f4NAME_MAX\f1} 
while \f4_POSIX_NO_TRUNC\f1 is in effect.
.TP
\f4ENOTDIR\fP
A component of the path prefix is not a directory.
.TP
\f4ENOENT\fP
Read, write, or execute (search) permission is requested for a null path name.
.TP
\f4ENOENT\fP
The named file does not exist.
.TP
\f4ENOLINK\fP
\f2path\f1 points to a remote machine and the link
to that machine is no longer active.
.TP
\f4EROFS\fP
Write access is requested for a file on a read-only file system.
.SH SEE ALSO
\f4chmod\fP(2), \f4stat\fP(2)
.br
``File Access Permission'' in \f4intro\fP(2)
.SH "DIAGNOSTICS"
If the requested access is permitted, a value of 0 is returned.
Otherwise, a value of \-1 is returned and
\f4errno\fP
is set to indicate the error.
