HPlogo MPE/iX Developer's Kit Reference Manual Volume I: HP 3000 MPE/iX Computer Systems > Chapter 4  POSIX/iX Library Function Descriptions

access

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Check file accessibility

Syntax

   #include <unistd.h>

   int access (const char *path, init amode );

Parameters

path

The pathname of a file.

amode

One of the following file access permissions.

The bitwise inclusive OR of the following access permission constants to be checked:

Access Permissions

Descriptions

R_OK

Test for read permission.

W_OK

Test for write permission.

X_OK

Test for execute or search permission.

Or the existence test (F_OK)

Other values of the amode argument are ignored.

Description

The access permissions of the filenamed path is checked by the access() function. The path argument for file access permissions is indicated by amode based on the real (not effective) user ID (UID) and group ID (GID).

The amode value is the bitwise inclusive OR of the access permissions or the existence test checking if the file exists or not.

The three access permissions are checked individually, if they need to be checked at all. If the process has appropriate privileges, execute file permission will be granted.

Implementation Considerations

None.

Errors

If an error occurs, errno is set to one of the following values:

E2BIGCAUSEThe number of bytes used by the new process image's argument list and environment list combined is greater than the limit of {ARG_MAX} (defined in <limits.h>).
 ACTIONReduce the size of the argument list or environment list or both.
EACCESCAUSE

One of the following:

  • The calling process does not have search permission to a component of the pathname.

  • The calling process does not have execute permission to the file.

 ACTION

One of the following:

  • Make sure that the calling process has search permission to all components of the pathname.

  • Make sure that the calling process has execute permission to the file.

EFAULTCAUSEThe system detected a NULL or bad address in attempting to use the pathname parameter, or the pathname was not terminated by a null character.
 ACTIONMake sure that the pointer is correctly initialized.
EIMPLCAUSEThe pathname did not resolve to a valid MPE/iX file, group, and account, or the pathname begins with two slashes.
 ACTIONSpecify a valid pathname as described in the pathname parameter description.
ENAMETOOLONGCAUSE

One of the following:

  • The length of the pathname exceeds the {PATH_MAX} limit (defined in the file <limits.h>).

  • A component of the pathname is longer than {NAME_MAX} (defined in <limits.h>), and {_POSIX_NO_TRUNC} is in effect for that directory.

 ACTIONMake sure that both the component's length and the full pathname length do not exceed the {NAME_MAX} or {PATH_MAX} limits.
ENOENTCAUSEa component of the pathname for the executable file does not exist, or pathname points to an empty string.
 ACTIONSpecify a valid pathname.
ENOEXECCAUSEThe program file does not have the NMPRG file code.
 ACTIONMake sure that the program file has the NMPRG file code.
ENOMEMCAUSEThe new process image requires more memory than the system allows.
ACTIONNo action required. The new process image cannot be created. 
ENOTDIRCAUSEA component of the pathname is not a directory.
 ACTIONSpecify a valid pathname.
EPERMCAUSE

One of the following:

  • The calling process does not have the MPE/iX process handling (PH) capability.

  • The calling process has outstanding switches to CM code, has set critical mode, has outstanding NOWAITIO, or is holding an operating system internal resource, or the calling process is in a Procedure Exit handler.

 ACTION

One of the following:

  • Link the program file with the MPE/iX PH capability.

  • Do not execute execl() when the calling process has outstanding switches to CM code, has set critical mode, has outstanding NOWAITIO, or is holding an operating system internal resource, or in a Procedure Exit handler.

See Also

chmod(), stat(), <unistd.h>

Feedback to webmaster