|
|
1.1 root 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
10: access \- determine accessibility of file
11: .SH SYNOPSIS
12: .nf
13: .ft B
14: #include <sys/file.h>
15: .PP
16: .ft B
17: .ta 1.25i 1.6i
18: #define R_OK 4 /* test for read permission */
19: #define W_OK 2 /* test for write permission */
20: #define X_OK 1 /* test for execute (search) permission */
21: #define F_OK 0 /* test for presence of file */
22: .PP
23: .ft B
24: accessible = access(path, mode)
25: int accessible;
26: char *path;
27: int mode;
28: .ft R
29: .fi
30: .SH DESCRIPTION
31: .I Access
32: checks the given
33: file
34: .I path
35: for accessibility according to
36: .IR mode ,
37: which is an inclusive or of the bits
38: R_OK,
39: W_OK
40: and
41: X_OK.
42: Specifying
43: .I mode
44: as F_OK (i.e., 0)
45: tests whether the directories leading to the file can be
46: searched and the file exists.
47: .PP
48: The real user ID and the group access list
49: (including the real group ID) are
50: used in verifying permission, so this call
51: is useful to set-UID programs.
52: .PP
53: Notice that only access bits are checked.
54: A directory may be indicated as writable by
55: .IR access ,
56: but an attempt to open it for writing will fail
57: (although files may be created there);
58: a file may look executable, but
59: .I execve
60: will fail unless it is in proper format.
61: .SH "RETURN VALUE
62: If
63: .I path
64: cannot be found or if any of the desired access modes would
65: not be granted, then a \-1 value is returned; otherwise
66: a 0 value is returned.
67: .SH "ERRORS
68: Access to the file is denied if one or more of the following are true:
69: .TP 15
70: [ENOTDIR]
71: A component of the path prefix is not a directory.
72: .TP 15
73: [EINVAL]
74: The pathname contains a character with the high-order bit set.
75: .TP 15
76: [ENAMETOOLONG]
77: A component of a pathname exceeded 255 characters,
78: or an entire path name exceeded 1023 characters.
79: .TP 15
80: [ENOENT]
81: The named file does not exist.
82: .TP 15
83: [EACCES]
84: Search permission is denied for a component of the path prefix.
85: .TP 15
86: [ELOOP]
87: Too many symbolic links were encountered in translating the pathname.
88: .TP 15
89: [EROFS]
90: Write access is requested for a file on a read-only file system.
91: .TP 15
92: [ETXTBSY]
93: Write access is requested for a pure procedure (shared text)
94: file that is being executed.
95: .TP 15
96: [EACCES]
97: Permission bits of the file mode do not permit the requested
98: access, or search permission is denied on a component of the
99: path prefix. The owner of a file has permission checked with
100: respect to the ``owner'' read, write, and execute mode bits,
101: members of the file's group other than the owner have permission
102: checked with respect to the ``group'' mode bits, and all
103: others have permissions checked with respect to the ``other''
104: mode bits.
105: .TP 15
106: [EFAULT]
107: .I Path
108: points outside the process's allocated address space.
109: .TP 15
110: [EIO]
111: An I/O error occurred while reading from or writing to the file system.
112: .SH "SEE ALSO
113: chmod(2), stat(2)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.