RMDIR(2) SysV RMDIR(2)
NAME
rmdir - remove a directory
SYNOPSIS
int rmdir (path)
const char *path;
DESCRIPTION
rmdir removes the directory named by the pathname pointed to by path.
The directory must not have any entries other than dot (.) and dot-dot
(..).
For programs compiled to expect an AES compliant environment, if the
final component of the path argument names a symbolic link, rmdir fails.
If the directory's link count becomes 0 (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 . (dot) and .. (dot-
dot) entries, if present, are removed before the rmdir function returns,
and no new entries may be created in the directory. However, the
directory is not removed until all references to the directory have been
closed.
Upon successful completion, the rmdir function marks the st_ctime and
st_mtime fields of the parent directory for update.
ERRORS
The named directory is removed unless one or more of the following are
true:
[EINVAL] The current directory may not be removed.
[EINVAL] The "." entry of a directory may not be removed.
[EEXIST] The directory contains entries other than those for "." and
"..".
[ENOTDIR] A component of the path prefix is not a directory or the
last component of the specified pathname is a symbolic
link.
[ENOENT] The named directory does not exist or is an empty string.
[EACCES] Search permission is denied for a component of the path
prefix.
[EACCES] Write permission is denied on the directory containing the
directory to be removed.
[EBUSY] The directory to be removed is the mount point for a
mounted file system.
[EROFS] The directory entry to be removed is part of a read-only
file system.
[EFAULT] path points outside the process' allocated address space.
[EIO] An I/O error occurred while accessing the file system.
[ENAMETOOLONG]
The length of the path parameter exceeds PATH_MAX, or a
pathname component is longer than NAME_MAX.
SEE ALSO
mkdir(2).
rmdir(1), rm(1), and mkdir(1) in the SysV Command Reference.
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Otherwise, a value
of -1 is returned and errno is set as indicated under "Errors."
NOTES
Under other implementations, rmdir fails if either of the following is
true:
[ENOLINK] path 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.