source: trunk/minix/man/man2/access.2@ 15

Last change on this file since 15 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 2.7 KB
Line 
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
5.\" @(#)access.2 6.5 (Berkeley) 5/22/86
6.\"
7.TH ACCESS 2 "May 22, 1986"
8.UC 4
9.SH NAME
10access \- determine accessibility of file
11.SH SYNOPSIS
12.ft B
13.nf
14#include <sys/types.h>
15#include <unistd.h>
16.PP
17.ft B
18.ta 1.25i 1.6i
19.nf
20#define R_OK 4 /* test for read permission */
21#define W_OK 2 /* test for write permission */
22#define X_OK 1 /* test for execute (search) permission */
23#define F_OK 0 /* test for presence of file */
24.PP
25.ft B
26.nf
27int access(const char *\fIpath\fP, mode_t \fImode\fP)
28.ft R
29.fi
30.SH DESCRIPTION
31.B Access
32checks the given
33file
34.I path
35for accessibility according to
36.IR mode ,
37which is an inclusive or of the bits
38.BR R_OK ,
39.BR W_OK
40and
41.BR X_OK .
42Specifying
43.I mode
44as
45.B F_OK
46(i.e., 0)
47tests whether the directories leading to the file can be
48searched and the file exists.
49.PP
50The real user ID and the group access list
51(including the real group ID) are
52used in verifying permission, so this call
53is useful to set-UID programs.
54.PP
55Notice that only access bits are checked.
56A directory may be indicated as writable by
57.BR access ,
58but an attempt to open it for writing will fail
59(although files may be created there);
60a file may look executable, but
61.B execve
62will fail unless it is in proper format.
63.SH "RETURN VALUE
64If
65.I path
66cannot be found or if any of the desired access modes would
67not be granted, then a \-1 value is returned; otherwise
68a 0 value is returned.
69.SH "ERRORS
70Access to the file is denied if one or more of the following are true:
71.TP 15
72[ENOTDIR]
73A component of the path prefix is not a directory.
74.TP 15
75[ENAMETOOLONG]
76The path name exceeds PATH_MAX characters.
77.TP 15
78[ENOENT]
79The named file does not exist.
80.TP 15
81[EACCES]
82Search permission is denied for a component of the path prefix.
83.TP 15
84[ELOOP]
85Too many symbolic links were encountered in translating the pathname.
86(Minix-vmd)
87.TP 15
88[EROFS]
89Write access is requested for a file on a read-only file system.
90.TP 15
91[EACCES]
92Permission bits of the file mode do not permit the requested
93access, or search permission is denied on a component of the
94path prefix. The owner of a file has permission checked with
95respect to the ``owner'' read, write, and execute mode bits,
96members of the file's group other than the owner have permission
97checked with respect to the ``group'' mode bits, and all
98others have permissions checked with respect to the ``other''
99mode bits.
100.TP 15
101[EFAULT]
102.I Path
103points outside the process's allocated address space.
104.TP 15
105[EIO]
106An I/O error occurred while reading from or writing to the file system.
107.SH "SEE ALSO
108.BR chmod (2),
109.BR stat (2).
Note: See TracBrowser for help on using the repository browser.