Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod(2)

stat(2)

ACCESS(2)  —  SYSTEM CALLS

NAME

access − determine accessibility of file

SYNOPSIS

#include <sys/file.h>

access(path, mode)
char ∗path;
int mode;

DESCRIPTION

path points to a path name naming a file.  access() checks the named file for accessibility according to mode, which is an inclusive or of the bits R_OK (test for read permission), W_OK (test for write permission) and s-1X_OK (test for execute or search permission).  Specifying mode as F_OK (that is, 0) tests whether the directories leading to the file can be searched and the file exists. 

The real user ID and the group access list (including the real group ID) are used in verifying permission, so this call is useful to set-UID programs. 

The owner of a file has permission checked with respect to the owner read, write, and execute mode bits, members of the file’s group other than the owner have permission checked with respect to the group mode bits, and all others have permissions checked with respect to the other mode bits. 

Notice that only access bits are checked.  A directory may be indicated as writable by access, but an attempt to open it for writing will fail (although files may be created there); a file may look executable, but execve() will fail unless it is in proper format. 

RETURN VALUE

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

ERRORS

access() to the file is denied if one or more of the following are true:

ENOTDIR A component of the path prefix of path is not a directory. 

ENAMETOOLONG The length of a component of path exceeds 255 characters, or the length of path exceeds 1023 characters. 

ENOENT The file named by path does not exist. 

EACCES Search permission is denied for a component of the path prefix of path.

ELOOP Too many symbolic links were encountered in translating path.

EROFS The file named by path is on a read-only file system and write access was requested. 

EACCES Permission bits of the file mode do not permit the requested access to the file named by path.

EFAULT path points outside the process’s allocated address space. 

EIO An I/O error occurred while reading from or writing to the file system. 

SEE ALSO

chmod(2), stat(2)

Sun Release 4.0  —  Last change: 22 March 1989

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026