Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ (2) — Plan9 3rd Edition

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

stat(2)

ACCESS(2)

NAME

access − determine accessibility of file

SYNOPSIS

­#include <u.h>
­#include <libc.h>

int access(char ∗name, int mode)

DESCRIPTION

­Access evaluates the given file ­name for accessibility.  If mode&4 is nonzero, read permission is expected; if mode&2, write permission; if mode&1, execute permission.  If mode==0, the file merely need exist.  In any case all directories leading to the file must permit searches.  Zero is returned if the desired access is permitted, −1 if not. 

Only access bits are checked.  A file may look executable, but exec(2) will fail unless it is in proper format.

The include file defines AEXIST=0, AEXEC=1, AWRITE=2, and AREAD=4. 

SOURCE

­/sys/src/libc/9sys/access.c

SEE ALSO

stat(2)

DIAGNOSTICS

Sets errstr.

BUGS

Since file permissions are checked by the server and group information is not known to the client, ­access must open the file to check permissions.  (It calls stat(2) to check simple existence.) Besides giving misleading information about the writability of directories, this is as expensive as the open that ­access is often intended to avoid. 

Plan 9  —  March 27, 2001

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