Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

access(2) [v7 man page]

ACCESS(2)							System Calls Manual							 ACCESS(2)

NAME
access - determine accessibility of file SYNOPSIS
access(name, mode) char *name; DESCRIPTION
Access checks the given file name for accessibility according to mode, which is 4 (read), 2 (write) or 1 (execute) or a combination thereof. Specifying mode 0 tests whether the directories leading to the file can be searched and the file exists. An appropriate error indication is returned if name cannot be found or if any of the desired access modes would not be granted. On disal- lowed accesses -1 is returned and the error code is in errno. 0 is returned from successful tests. The user and group IDs with respect to which permission is checked are the real UID and GID of the process, so this call is useful to set- UID programs. Notice that it is only access bits that are checked. A directory may be announced 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 exec will fail unless it is in proper format. SEE ALSO
stat(2) ASSEMBLER
(access = 33.) sys access; name; mode ACCESS(2)

Check Out this Related Man Page

access(2)							System Calls Manual							 access(2)

Name
       access - determine the accessibility of file

Syntax
       #include <unistd.h>
       accessible = access(path, mode)
       int accessible;
       char *path;
       int mode;

Description
       The  system  call,  checks the given file path for accessibility according to mode.  The argument mode is an inclusive OR of the bits R_OK,
       W_OK, and X_OK.	Specifying the argument mode as F_OK tests whether the directories leading to the file can be  searched  and  whether  the
       file exists.

       The  real  user	ID and the group access list (including the real group ID) are used to verify permissions.  This call is useful to set-UID
       programs.

       Note that only access bits are checked.	The call may indicate that a directory is writeable, but an attempt to open the  directory  fails,
       although files are present in the directory.  Additionally, a file may appear to be executable, but fails unless the file is in proper for-
       mat.

       If a path cannot be found, or if the desired access modes are not granted, a -1 value is returned; otherwise, a 0 value is returned.

Diagnostics
       Access to the file is denied if any of the following is true:

       [EACCES]       Permission bits of the file mode do not permit the requested access or search permission is denied on  a	component  of  the
		      path  prefix.   The  owner  of a file has permission checked with respect to the owner's read, write, and execute mode bits.
		      Members of the file's group, other than the owner, have permission checked with respect to the group's mode bits.  All  oth-
		      ers have permissions checked with respect to the other mode bits.

       [EFAULT]       The path points outside the process's allocated address space.

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

       [ELOOP]	      Too many symbolic links were encountered in translating the pathname.

       [ENAMETOOLONG] A path component length exceeds 255 characters or the length of path exceeds 1023 characters.

       [ENOENT]       The  file  referred  to by path does not exist or the path points to an empty string and the environment defined is POSIX or
		      SYSTEM_FIVE.

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

       [EROFS]	      Write access is requested for a file on a read-only file system.

       [ESTALE]       The file handle given in the argument was invalid.  The file referred to by that file handle no longer exists  or  has  been
		      revoked.

       [ETIMEDOUT]    A  connect  request or remote file operation fails because the connected party did not respond after a period of time deter-
		      mined by the communications protocol.

       [ETXTBSY]      Write access is requested for a pure procedure (shared text) file that is being executed.

See Also
       chmod(2), stat(2)

																	 access(2)
Man Page