namespaces.7: ffix
[man-pages.git] / man2 / rmdir.2
blob33b95be74620f1ca94085106d450153f94e1cb88
1 .\" This manpage is Copyright (C) 1992 Drew Eckhardt;
2 .\"             and Copyright (C) 1993 Michael Haardt, Ian Jackson.
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
27 .\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
28 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
29 .\"
30 .TH RMDIR 2 2021-03-22 "Linux" "Linux Programmer's Manual"
31 .SH NAME
32 rmdir \- delete a directory
33 .SH SYNOPSIS
34 .nf
35 .B #include <unistd.h>
36 .PP
37 .BI "int rmdir(const char *" pathname );
38 .fi
39 .SH DESCRIPTION
40 .BR rmdir ()
41 deletes a directory, which must be empty.
42 .SH RETURN VALUE
43 On success, zero is returned.
44 On error, \-1 is returned, and
45 .I errno
46 is set to indicate the error.
47 .SH ERRORS
48 .TP
49 .B EACCES
50 Write access to the directory containing
51 .I pathname
52 was not allowed, or one of the directories in the path prefix of
53 .I pathname
54 did not allow search permission.
55 (See also
56 .BR path_resolution (7).)
57 .TP
58 .B EBUSY
59 .I pathname
60 is currently in use by the system or some process that prevents its
61 removal.
62 On Linux, this means
63 .I pathname
64 is currently used as a mount point
65 or is the root directory of the calling process.
66 .TP
67 .B EFAULT
68 .IR pathname " points outside your accessible address space."
69 .TP
70 .B EINVAL
71 .I pathname
72 has
73 .I .
74 as last component.
75 .TP
76 .B ELOOP
77 Too many symbolic links were encountered in resolving
78 .IR pathname .
79 .TP
80 .B ENAMETOOLONG
81 .IR pathname " was too long."
82 .TP
83 .B ENOENT
84 A directory component in
85 .I pathname
86 does not exist or is a dangling symbolic link.
87 .TP
88 .B ENOMEM
89 Insufficient kernel memory was available.
90 .TP
91 .B ENOTDIR
92 .IR pathname ,
93 or a component used as a directory in
94 .IR pathname ,
95 is not, in fact, a directory.
96 .TP
97 .B ENOTEMPTY
98 .I pathname
99 contains entries other than
100 .IR . " and " .. " ;"
102 .I pathname
104 .I ..
105 as its final component.
106 POSIX.1 also allows
107 .\" POSIX.1-2001, POSIX.1-2008
108 .B EEXIST
109 for this condition.
111 .B EPERM
112 The directory containing
113 .I pathname
114 has the sticky bit
115 .RB ( S_ISVTX )
116 set and the process's effective user ID is neither the user ID
117 of the file to be deleted nor that of the directory containing it,
118 and the process is not privileged (Linux: does not have the
119 .B CAP_FOWNER
120 capability).
122 .B EPERM
123 The filesystem containing
124 .I pathname
125 does not support the removal of directories.
127 .B EROFS
128 .I pathname
129 refers to a directory on a read-only filesystem.
130 .SH CONFORMING TO
131 POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
132 .SH BUGS
133 Infelicities in the protocol underlying NFS can cause the unexpected
134 disappearance of directories which are still being used.
135 .SH SEE ALSO
136 .BR rm (1),
137 .BR rmdir (1),
138 .BR chdir (2),
139 .BR chmod (2),
140 .BR mkdir (2),
141 .BR rename (2),
142 .BR unlink (2),
143 .BR unlinkat (2)