1RMDIR(2) Linux Programmer's Manual RMDIR(2)
2
3
4
6 rmdir - delete a directory
7
9 #include <unistd.h>
10
11 int rmdir(const char *pathname);
12
14 rmdir() deletes a directory, which must be empty.
15
17 On success, zero is returned. On error, -1 is returned, and errno is
18 set appropriately.
19
21 EACCES Write access to the directory containing pathname was not
22 allowed, or one of the directories in the path prefix of path‐
23 name did not allow search permission. (See also path_resolu‐
24 tion(7).
25
26 EBUSY pathname is currently in use by the system or some process that
27 prevents its removal. On Linux, this means pathname is cur‐
28 rently used as a mount point or is the root directory of the
29 calling process.
30
31 EFAULT pathname points outside your accessible address space.
32
33 EINVAL pathname has . as last component.
34
35 ELOOP Too many symbolic links were encountered in resolving pathname.
36
37 ENAMETOOLONG
38 pathname was too long.
39
40 ENOENT A directory component in pathname does not exist or is a dan‐
41 gling symbolic link.
42
43 ENOMEM Insufficient kernel memory was available.
44
45 ENOTDIR
46 pathname, or a component used as a directory in pathname, is
47 not, in fact, a directory.
48
49 ENOTEMPTY
50 pathname contains entries other than . and .. ; or, pathname has
51 .. as its final component. POSIX.1 also allows EEXIST for this
52 condition.
53
54 EPERM The directory containing pathname has the sticky bit (S_ISVTX)
55 set and the process's effective user ID is neither the user ID
56 of the file to be deleted nor that of the directory containing
57 it, and the process is not privileged (Linux: does not have the
58 CAP_FOWNER capability).
59
60 EPERM The filesystem containing pathname does not support the removal
61 of directories.
62
63 EROFS pathname refers to a directory on a read-only filesystem.
64
66 POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
67
69 Infelicities in the protocol underlying NFS can cause the unexpected
70 disappearance of directories which are still being used.
71
73 rm(1), rmdir(1), chdir(2), chmod(2), mkdir(2), rename(2), unlink(2),
74 unlinkat(2)
75
77 This page is part of release 4.16 of the Linux man-pages project. A
78 description of the project, information about reporting bugs, and the
79 latest version of this page, can be found at
80 https://www.kernel.org/doc/man-pages/.
81
82
83
84Linux 2015-08-08 RMDIR(2)