| manpages.info - online man pages | ![]() |
|||
|
access (2) Table of Contents
Nameaccess - check access permissions of a file or pathname
Synopsis#include <unistd.h>
int
DescriptionThe access() function checks the accessibility of the file named by path for the access permissions indicated by mode. The value of mode is the bitwise inclusive OR of the access permissions to be checked (R_OK for read permission, W_OK for write permission and X_OK for execute/search permission) or the existence test, F_OK. All components of the pathname path are checked for access permissions (including F_OK).
The real user ID is used in place of the effective user ID and the real group access list (including the real group ID) are used in place of the effective ID for verifying permission.
Even if a process has appropriate privileges and indicates success for X_OK, the file may not actually have execute permission bits set. Likewise for R_OK and W_OK.
Return ValuesIf 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.
ErrorsAccess to the file is denied if:
See Also
StandardsThe access() function conforms to ISO/IEC 9945-1:1990 (``POSIX.1'').
CaveatAccess() is a potential security hole and should never be used.
|