Files
oldlinux-files/Minix/2.0.0/wwwman/man2/access.2.html
2024-02-19 00:21:39 -05:00

124 lines
4.1 KiB
HTML

<HTML>
<HEAD>
<TITLE>access(2)</TITLE>
</HEAD>
<BODY>
<H1>access(2)</H1>
<HR>
<PRE>
</PRE>
<H2>NAME</H2><PRE>
access - determine accessibility of file
</PRE>
<H2>SYNOPSIS</H2><PRE>
<STRONG>#include</STRONG> <STRONG>&lt;sys/types.h&gt;</STRONG>
<STRONG>#include</STRONG> <STRONG>&lt;unistd.h&gt;</STRONG>
<STRONG>#define</STRONG> <STRONG>R_OK</STRONG> <STRONG>4</STRONG> <STRONG>/*</STRONG> <STRONG>test</STRONG> <STRONG>for</STRONG> <STRONG>read</STRONG> <STRONG>permission</STRONG> <STRONG>*/</STRONG>
<STRONG>#define</STRONG> <STRONG>W_OK</STRONG> <STRONG>2</STRONG> <STRONG>/*</STRONG> <STRONG>test</STRONG> <STRONG>for</STRONG> <STRONG>write</STRONG> <STRONG>permission</STRONG> <STRONG>*/</STRONG>
<STRONG>#define</STRONG> <STRONG>X_OK</STRONG> <STRONG>1</STRONG> <STRONG>/*</STRONG> <STRONG>test</STRONG> <STRONG>for</STRONG> <STRONG>execute</STRONG> <STRONG>(search)</STRONG> <STRONG>permission</STRONG> <STRONG>*/</STRONG>
<STRONG>#define</STRONG> <STRONG>F_OK</STRONG> <STRONG>0</STRONG> <STRONG>/*</STRONG> <STRONG>test</STRONG> <STRONG>for</STRONG> <STRONG>presence</STRONG> <STRONG>of</STRONG> <STRONG>file</STRONG> <STRONG>*/</STRONG>
<STRONG>int</STRONG> <STRONG>access(const</STRONG> <STRONG>char</STRONG> <STRONG>*</STRONG><EM>path</EM><STRONG>,</STRONG> <STRONG>mode_t</STRONG> <EM>mode</EM><STRONG>)</STRONG>
</PRE>
<H2>DESCRIPTION</H2><PRE>
<STRONG>Access</STRONG> checks the given file <EM>path</EM> for accessibility according to <EM>mode</EM>,
which is an inclusive or of the bits <STRONG>R_OK</STRONG>, <STRONG>W_OK</STRONG> and <STRONG>X_OK</STRONG>. Specifying
<EM>mode</EM> as <STRONG>F_OK</STRONG> (i.e., 0) tests whether the directories leading to the file
can be searched and the file exists.
The real user ID and the group access list (including the real group ID)
are used in verifying permission, so this call is useful to set-UID
programs.
Notice that only access bits are checked. A directory may be indicated
as writable by <STRONG>access</STRONG>, but an attempt to open it for writing will fail
(although files may be created there); a file may look executable, but
<STRONG>execve</STRONG> will fail unless it is in proper format.
</PRE>
<H2>RETURN VALUE</H2><PRE>
If <EM>path</EM> cannot be found or if any of the desired access modes would not
be granted, then a -1 value is returned; otherwise a 0 value is returned.
</PRE>
<H2>ERRORS</H2><PRE>
Access to the file is denied if one or more of the following are true:
[ENOTDIR] A component of the path prefix is not a directory.
[ENAMETOOLONG] The path name exceeds PATH_MAX characters.
[ENOENT] The named file does not exist.
[EACCES] Search permission is denied for a component of the path
prefix.
[ELOOP] Too many symbolic links were encountered in translating
the pathname. (Minix-vmd)
[EROFS] Write access is requested for a file on a read-only file
system.
[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. 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 permission checked with respect
to the ``group'' mode bits, and all others have
permissions checked with respect to the ``other'' mode
bits.
[EFAULT] <EM>Path</EM> points outside the process's allocated address space.
[EIO] An I/O error occurred while reading from or writing to the
file system.
</PRE>
<H2>SEE ALSO</H2><PRE>
<STRONG><A HREF="../man2/chmod.2.html">chmod(2)</A></STRONG>, <STRONG><A HREF="../man2/stat.2.html">stat(2)</A></STRONG>.
</PRE>
</BODY>
</HTML>