[Previous] [Contents] [Next]

eaccess()

Check to see if a file or directory can be accessed (extended version)

Synopsis:

#include <libgen.h>

int eaccess( const char * path,
             int mode );

Library:

libc

Description:

The eaccess() function is an extended version of access(). It checks if the file or directory specified by path exists and if it can be accessed with the file access permissions given by amode. However, unlike access(), it uses the effective user ID and effective group ID.

The value of amode is either the existence test, F_OK, or a bitwise ORing of the following access permissions to be checked, as defined in the header <unistd.h>:

R_OK
Test for read permission.
W_OK
Test for write permission.
X_OK
For a directory, test for search permission. Otherwise, test for execute permission.

Returns:

0
The file or directory exists and can be accessed with the specified mode.
-1
An error occurred (errno is set.)

Errors:

EACCES
The permissions specified by amode are denied, or search permission is denied on a component of the path prefix.
EINVAL
An invalid value was specified for amode.
ELOOP
Too many levels of symbolic links or prefixes.
ENAMETOOLONG
The length of the path string exceeds PATH_MAX, or a pathname component is longer than NAME_MAX.
ENOENT
A component of the path isn't valid.
ENOSYS
The eaccess() function isn't implemented for the filesystem specified in path.
ENOTDIR
A component of the path prefix isn't a directory.
EROFS
Write access was requested for a file residing on a read-only file system.

Classification:

Unix

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

access(), chmod(), errno, fstat(), open(), stat()


[Previous] [Contents] [Next]