BSD 3 development
[unix-history] / usr / man / man2 / access.2
CommitLineData
e6817382
BJ
1.TH ACCESS 2
2.SH NAME
3access \- determine accessibility of file
4.SH SYNOPSIS
5.B access(name, mode)
6.br
7.B char *name;
8.SH DESCRIPTION
9.I Access
10checks the given
11file
12.I name
13for accessibility according to
14.I mode,
15which is 4 (read), 2 (write) or 1 (execute) or a combination thereof.
16Specifying mode 0
17tests whether the directories leading to the file can be
18searched and the file exists.
19.PP
20An appropriate error indication is returned if
21.I name
22cannot be found or if any
23of the desired access modes would not be granted.
24On disallowed accesses
25\-1 is returned and the error code is in
26.IR errno .
270 is returned from successful tests.
28.PP
29The user and group IDs with respect to which permission is checked
30are the real UID and GID of the process, so this call is
31useful to set-UID programs.
32.PP
33Notice that it is only access bits that are checked.
34A directory may be announced as writable by
35.I access,
36but an attempt to open it for writing will fail
37(although files may be created there);
38a file may look executable, but
39.I exec
40will fail unless it is in proper format.
41.PP
42.SH SEE ALSO
43stat(2)
44.SH "ASSEMBLER (PDP-11)"
45(access = 33.)
46.br
47.B sys access; name; mode