[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1


access, accessx, or faccessx Subroutine

Purpose

Determines the accessibility of a file.

Library

Standard C Library (libc.a)

Syntax

#include <unistd.h>


int access ( PathName, Mode)
char *PathName;
int Mode;


int accessx (PathName, Mode, Who)
char *PathName;
int Mode, Who;


int faccessx ( FileDescriptor, Mode, Who)
int FileDescriptor;
int Mode, Who;

Description

The access, accessx, and faccessx subroutines determine the accessibility of a file system object. The accessx and faccessx subroutines allow the specification of a class of users or processes for whom access is to be checked.

The caller must have search permission for all components of the PathName parameter.

Parameters


PathName Specifies the path name of the file. If the PathName parameter refers to a symbolic link, the access subroutine returns information about the file pointed to by the symbolic link.
FileDescriptor Specifies the file descriptor of an open file.
Mode Specifies the access modes to be checked. This parameter is a bit mask containing 0 or more of the following values, which are defined in the sys/access.h file:

R_OK
Check read permission.

W_OK
Check write permission.

X_OK
Check execute or search permission.

F_OK
Check the existence of a file.

If none of these values are specified, the existence of a file is checked.

Who Specifies the class of users for whom access is to be checked. This parameter must be one of the following values, which are defined in the sys/access.h file:

ACC_SELF
Determines if access is permitted for the current process. The effective user and group IDs, the concurrent group set and the privilege of the current process are used for the calculation.

ACC_INVOKER
Determines if access is permitted for the invoker of the current process. The real user and group IDs, the concurrent group set, and the privilege of the invoker are used for the calculation.

Note: The expression access (PathName, Mode) is equivalent to accessx (PathName, Mode, ACC_INVOKER).

ACC_OTHERS
Determines if the specified access is permitted for any user other than the object owner. The Mode parameter must contain only one of the valid modes. Privilege is not considered in the calculation.

ACC_ALL
Determines if the specified access is permitted for all users. The Mode parameter must contain only one of the valid modes. Privilege is not considered in the calculation .

Return Values

If the requested access is permitted, the access, accessx, and faccessx subroutines return a value of 0. If the requested access is not permitted or the function call fails, a value of -1 is returned and the errno global variable is set to indicate the error.

Error Codes

The access and accessx subroutines fail if one or more of the following are true:

EACCES Search permission is denied on a component of the PathName prefix.
EFAULT The PathName parameter points to a location outside the allocated address space of the process.
ELOOP Too many symbolic links were encountered in translating the PathName parameter.
ENOENT A component of the PathName does not exist or the process has the disallow truncation attribute set.
ENOTDIR A component of the PathName is not a directory.
ESTALE The process root or current directory is located in a virtual file system that has been unmounted.
ENOENT The named file does not exist.
ENOENT The PathName parameter was null.
ENOENT A symbolic link was named, but the file to which it refers does not exist.
ENAMETOOLONG A component of the PathName parameter exceeded 255 characters or the entire PathName parameter exceeded 1023 characters.

The faccessx subroutine fails if the following is true:

EBADF The value of the FileDescriptor parameter is not valid.

The access, accessx, and faccessx subroutines fail if one or more of the following is true:

EIO An I/O error occurred during the operation.
EACCES The file protection does not allow the requested access.
EROFS Write access is requested for a file on a read-only file system.

If Network File System (NFS) is installed on your system, the accessx and faccessx subroutines can also fail if the following is true:

ETIMEDOUT The connection timed out.
ETXTBSY Write access is requested for a shared text file that is being executed.
EINVAL The value of the Mode argument is invalid.

Implementation Specifics

These subroutines are part of Base Operating System (BOS) Runtime.

Related Information

The acl_get (acl_get or acl_fget Subroutine) subroutine, chacl (chacl or fchacl Subroutine) subroutine, statx subroutine, statacl subroutine.

The aclget command, aclput command, chmod command, chown command.

Files, Directories, and File Systems for Programmers in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]