Mono.Unix.Native.Syscall.access Method
Checks whether the calling task has the necessary access rights to perform operations specified by mode on the file pathname. AccessMode is a mask consisting of one or more of the values R_OK, W_OK, X_OK and F_OK which respectively test if the taks can read, write, execute or test if the file exists.

Syntax

public static int access (string pathname, AccessModes mode)

See Also

Syscall.chmod
Syscall.intro
Syscall.stat

Parameters

pathname
Documentation for this section has not yet been entered.
mode
Documentation for this section has not yet been entered.

Returns

On success, zero is returned. On error, -1 is returned and Stdlib.GetLastError returns the translated error.

Usage

Access to the file is denied if:

Error Details
Errno.ENOTDIR

A component of the path prefix is not a directory.

Errno.ENAMETOOLONG

A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters.

Errno.ENOENT

The named file does not exist.

Errno.ELOOP

Too many symbolic links were encountered in translating the pathname.

Errno.EROFS

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

Errno.ETXTBSY

Write access is requested for a pure procedure (shared text) file presently being executed.

Errno.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.

Errno.EFAULT

The path argument points outside the process's allocated address space.

Errno.EIO

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

Remarks

The access() and eaccess() system calls check the accessibility of the file named by the path argument for the access permissions indicated by the mode argument. The value of mode is either the bitwise-inclusive OR of the access permissions to be checked ( AccessModes.R_OK for read permission, AccessModes.W_OK for write permission, and AccessModes.X_OK for execute/search permission), or the existence test AccessModes.F_OK .

For additional information, see the "File Access Permission" section of Syscall.intro(2) .

The eaccess() system call uses the effective user ID and the group access list to authorize the request; the access() system call uses the real user ID in place of the effective user ID, the real group ID in place of the effective group ID, and the rest of the group access list.

Even if a process's real or effective user has appropriate privileges and indicates success for AccessModes.X_OK , the file may not actually have execute permission bits set. Likewise for AccessModes.R_OK and AccessModes.W_OK .

Requirements

Namespace: Mono.Unix.Native
Assembly: Mono.Posix (in Mono.Posix.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0