'\"macro stdmacro
.if n .pH g2.rmdir @(#)rmdir	40.19 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} rmdir 2 "" "" "\&"
.if \nX=1 .ds x} rmdir 2 "" ""
.if \nX=2 .ds x} rmdir 2 "" "" "\&"
.if \nX=3 .ds x} rmdir 2 "" "" "\&"
.TH \*(x}
.SH NAME
\f4rmdir\f1 \- remove a directory
.SH SYNOPSIS
\f4#include <unistd.h>\f1
.PP
\f4int rmdir(const char \(**path);\f1
.SH DESCRIPTION
\f4rmdir\fP
removes the directory named by the path name
pointed to by
.IR path .
The directory must not have any entries other
than ``\f4.\fP'' and ``\f4..\fP''.
.PP
If the directory's link count becomes zero and no process has the directory
open, the space occupied by the directory is freed and the directory is no
longer accessible. If one or more processes have the directory open when the
last link is removed, the ``\f4.\fP'' and ``\f4..\fP'' entries, if present,
are removed before \f4rmdir\fP returns and no new entries may be created in
the directory, but the directory is not removed until all references to the
directory have been closed.
.PP
If \f2path\fP is a symbolic link, it is not followed.
.PP
Upon successful completion \f4rmdir\fP marks for update the \f4st_ctime\fP
and \f4st_mtime\fP fields of the parent directory.
.PP
The named directory is removed unless one or more of the following are true:
.TP 20
\f4EACCES\fP
Search permission is denied for a component of the path prefix.
.TP
\f4EACCES\fP
Write permission is denied on the directory containing the directory
to be removed.
.TP
\f4EACCES\fP
The parent directory has the sticky bit set and
is not owned by the user;
the directory is not owned by the user and
is not writable by the user; the user is not a super-user.
.TP
\f4EBUSY\fP
The directory to be removed is the mount point for a mounted file system.
.TP 20
\f4EEXIST\fP
The directory contains entries other than those for ``\f4.\fP'' and ``\f4..\fP''.
.TP
\f4EFAULT\fP
.I path\^
points outside the process's allocated address space.
.TP 20
\f4EINVAL\fP
The directory to be removed is the current directory.
.TP 20
\f4EINVAL\fP
The directory to be removed is the ``\f4.\fP'' entry of a directory.
.TP
\f4EIO\fP
An I/O error occurred while accessing the
file system.
.TP
\f4ELOOP\fP
Too many symbolic links were encountered in translating \f2path\f1.
.TP
\f4EMULTIHOP\fP
Components of \f2path\f1 require hopping to
multiple remote machines
and the file system does not allow it.
.TP
\f4ENAMETOOLONG\fP
The length of the \f2path\f1 argument exceeds {\f4PATH_MAX\f1}, or the
length of a \f2path\f1 component exceeds {\f4NAME_MAX\f1} while
\f4_POSIX_NO_TRUNC\f1 is in effect.
.TP
\f4ENOTDIR\fP
A component of the path prefix is not a directory.
.TP
\f4ENOENT\fP
The named directory does not exist or is the null pathname.
.TP
\f4EROFS\fP
The directory entry to be removed is part of a
read-only file system.
.TP
\f4ENOLINK\fP
\f2path\f1 points to a remote machine, and the link
to that machine is no longer active.
.SH "DIAGNOSTICS"
Upon successful completion, a value of 0 is returned.
Otherwise, a value of \-1 is returned and
\f4errno\fP
is set to indicate the error.
.SH "SEE ALSO"
\f4mkdir\fP(2).
.sp .2
\f4rmdir\fP(1), \f4rm\fP(1), and \f4mkdir\fP(1)
in the
\f2User's Reference Manual\f1.
