Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod(2)

stat(2)



  access(2)                           CLIX                           access(2)



  NAME

    access - Determines accessibility of a file

  LIBRARY

    Standard C Library (libc.a)

  SYNOPSIS

    #include <unistd.h>

    int access(
      char *path ,
      int access_mode );

  PARAMETERS

    path          Points to the file pathname.

    access_mode   Specifies the type of access.  The bit pattern contained in
                  the access_mode parameter is constructed by a logical OR of
                  the following values, defined in the <unistd.h> file:

                  R_OK   Checks read permission.

                  W_OK   Checks write permission.

                  X_OK   Checks execute (search) permission.

                  F_OK   Checks to see if the file exists.

  DESCRIPTION

    The access() function checks for accessibility of the file specified by a
    pathname according to the bit pattern contained in access_mode.

    Permission to access all components of the path parameter is determined by
    using a real user ID instead of an effective user ID, and a real group ID
    instead of an effective group ID.

    The owner of a file has permission checked with respect to the owner read,
    write, and execute mode bits.  Members of the file's group other than the
    owner have permissions checked with respect to the group mode bits, and
    all others have permissions checked with respect to the other mode bits.

  EXAMPLES

    The following determines whether the file allen exists:

    # include <unistd.h>



  2/94 - Intergraph Corporation                                              1






  access(2)                           CLIX                           access(2)



    main()
    {
      if (!access("./allen", F_OK)) {
        printf( "File exists\n" );
        exit(0);
      }
      printf ( "File does not exist\n" );
    }


  RETURN VALUES

    When the requested access is permitted, this function returns a value of
    0.  When requested access is denied, this function returns a value of -1
    and sets the global variable errno to a value that identifies the error.

  ERRORS

    Access to the file specified by the path parameter is denied when one or
    more of the following is true:

    [ENOENT]
           The named file does not exist.

    [EACCES]
           Search permission is denied for a component of the path prefix, or
           permission bits of the file mode do not permit the requested
           access.

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

    [ENAMETOOLONG]
           The length of the path parameter exceeds PATH_MAX, or a pathname
           component is longer than NAME_MAX while _POSIX_NO_TRUNC is in
           effect.

    [EINVAL]
           An invalid value was specified for access_mode.

    [ENOTDIR]
           A component of the path prefix is not a directory.

    [ETXTBUSY]
           Write access is requested for a pure procedure (shared text) file
           that is being executed.

    [EFAULT]
           The path parameter points outside the allocated address space for
           the process.




  2                                              Intergraph Corporation - 2/94






  access(2)                           CLIX                           access(2)



    [EINTR]
           A signal was caught during the access() function.

    [ENOLINK]
           The path parameter points to a remote machine and the link to that
           machine is no longer active.

    [EMULTIHOP]
           Components of path require hopping to multiple remote machines.

  RELATED INFORMATION

    Functions:  chmod(2), stat(2)









































  2/94 - Intergraph Corporation                                              3




Typewritten Software • bear@typewritten.org • Edmonds, WA 98026