1ACCESS(2)                     System Calls Manual                    ACCESS(2)
2
3
4

NAME

6       access - determine accessibility of file
7

SYNOPSIS

9       #include <sys/file.h>
10
11       #define R_OK    4/* test for read permission */
12       #define W_OK    2/* test for write permission */
13       #define X_OK    1/* test for execute (search) permission */
14       #define F_OK    0/* test for presence of file */
15
16       accessible = access(path, mode)
17       int accessible;
18       char *path;
19       int mode;
20

DESCRIPTION

22       Access  checks the given file path for accessibility according to mode,
23       which is an inclusive or of the bits R_OK, W_OK and  X_OK.   Specifying
24       mode  as  F_OK  (i.e.,  0) tests whether the directories leading to the
25       file can be searched and the file exists.
26
27       The real user ID and the group access list (including  the  real  group
28       ID) are used in verifying permission, so this call is useful to set-UID
29       programs.
30
31       Notice that only access bits are checked.  A directory may be indicated
32       as  writable by access, but an attempt to open it for writing will fail
33       (although files may be created there); a file may look executable,  but
34       execve will fail unless it is in proper format.
35

RETURN VALUE

37       If path cannot be found or if any of the desired access modes would not
38       be granted, then a -1  value  is  returned;  otherwise  a  0  value  is
39       returned.
40

ERRORS

42       Access to the file is denied if one or more of the following are true:
43
44       [ENOTDIR]      A component of the path prefix is not a directory.
45
46       [EINVAL]       The  pathname  contains  a character with the high-order
47                      bit set.
48
49       [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an
50                      entire path name exceeded 1023 characters.
51
52       [ENOENT]       The named file does not exist.
53
54       [EACCES]       Search  permission is denied for a component of the path
55                      prefix.
56
57       [ELOOP]        Too many symbolic links were encountered in  translating
58                      the pathname.
59
60       [EROFS]        Write access is requested for a file on a read-only file
61                      system.
62
63       [ETXTBSY]      Write access is requested for a pure  procedure  (shared
64                      text) file that is being executed.
65
66       [EACCES]       Permission  bits  of  the  file  mode  do not permit the
67                      requested access, or search permission is  denied  on  a
68                      component  of  the path prefix.  The owner of a file has
69                      permission checked with respect to the  ``owner''  read,
70                      write,  and  execute  mode  bits,  members of the file's
71                      group other than the owner have permission checked  with
72                      respect  to the ``group'' mode bits, and all others have
73                      permissions checked with respect to the  ``other''  mode
74                      bits.
75
76       [EFAULT]       Path  points  outside  the  process's  allocated address
77                      space.
78
79       [EIO]          An I/O error occurred while reading from or  writing  to
80                      the file system.
81

SEE ALSO

83       chmod(2), stat(2)
84
85
86
874th Berkeley Distribution        May 22, 1986                        ACCESS(2)
Impressum