rmdir(2)
NAME
rmdir − remove a directory file
SYNOPSIS
int rmdir(const char *path);
DESCRIPTION
rmdir() removes a directory file whose name is given by path. The directory must be empty (except for files . and ..) before it can be removed.
RETURN VALUE
rmdir() returns 0 if the directory removal succeeds; otherwise, it returns −1 and sets errno to indicate the error.
ERRORS
rmdir() fails and the directory is not removed if any of the following conditions are encountered:
[EACCES] A component of the path prefix denies search permission.
[EACCES] Write permission is denied on the directory containing the link to be removed.
[EBUSY] The directory to be removed is the mount point for a mounted file system.
[EEXIST] The named directory is not empty. It contains files other than . and ...
[EFAULT] path points outside the process’s allocated address space. The reliable detection of this error is implementation dependent.
[EINVAL] The path is ..
[ELOOP] Too many symbolic links were encountered in translating the path name.
[ENAMETOOLONG] The length of the specified path name exceeds PATH_MAX bytes, or the length of a component of the path name exceeds NAME_MAX bytes while _POSIX_NO_TRUNC is in effect.
[ENOENT] The named file does not exist.
[ENOTDIR] A component of the path is not a directory.
[EPERM] The directory containing the directory to be removed has the sticky bit set and neither the containing directory nor the directory to be removed are owned by the effective user ID.
[EROFS] The directory entry to be removed resides on a read-only file system.
AUTHOR
rmdir() was developed by the University of California, Berkeley.
SEE ALSO
STANDARDS CONFORMANCE
rmdir(): AES, SVID2, XPG3, XPG4, FIPS 151-2, POSIX.1
Hewlett-Packard Company — HP-UX Release 9.0: August 1992