xref: /freebsd/lib/libsys/rmdir.2 (revision 5f757f3f)
1.\" Copyright (c) 1983, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd March 30, 2020
29.Dt RMDIR 2
30.Os
31.Sh NAME
32.Nm rmdir
33.Nd remove a directory file
34.Sh LIBRARY
35.Lb libc
36.Sh SYNOPSIS
37.In unistd.h
38.Ft int
39.Fn rmdir "const char *path"
40.Sh DESCRIPTION
41The
42.Fn rmdir
43system call
44removes a directory file
45whose name is given by
46.Fa path .
47The directory must not have any entries other
48than
49.Ql .\&
50and
51.Ql \&.. .
52.Sh RETURN VALUES
53.Rv -std rmdir
54.Sh ERRORS
55The named file is removed unless:
56.Bl -tag -width Er
57.It Bq Er ENOTDIR
58A component of the path is not a directory.
59.It Bq Er ENAMETOOLONG
60A component of a pathname exceeded 255 characters,
61or an entire path name exceeded 1023 characters.
62.It Bq Er ENOENT
63The named directory does not exist.
64.It Bq Er ELOOP
65Too many symbolic links were encountered in translating the pathname.
66.It Bq Er ENOTEMPTY
67The named directory contains files other than
68.Ql .\&
69and
70.Ql ..\&
71in it.
72.It Bq Er EACCES
73Search permission is denied for a component of the path prefix.
74.It Bq Er EACCES
75Write permission is denied on the directory containing the link
76to be removed.
77.It Bq Er EPERM
78The directory to be removed has its immutable, undeletable or append-only flag
79set, see the
80.Xr chflags 2
81manual page for more information.
82.It Bq Er EPERM
83The parent directory of the directory to be removed has its immutable or
84append-only flag set.
85.It Bq Er EPERM
86The directory containing the directory to be removed is marked sticky,
87and neither the containing directory nor the directory to be removed
88are owned by the effective user ID.
89.It Bq Er EINVAL
90The last component of the path is
91.Ql .\&
92or
93.Ql .. .
94.It Bq Er EBUSY
95The directory to be removed is the mount point
96for a mounted file system.
97.It Bq Er EIO
98An I/O error occurred while deleting the directory entry
99or deallocating the inode.
100.It Bq Er EINTEGRITY
101Corrupted data was detected while reading from the file system.
102.It Bq Er EROFS
103The directory entry to be removed resides on a read-only file system.
104.It Bq Er EFAULT
105The
106.Fa path
107argument
108points outside the process's allocated address space.
109.El
110.Sh SEE ALSO
111.Xr mkdir 2 ,
112.Xr unlink 2
113.Sh HISTORY
114The
115.Fn rmdir
116system call appeared in
117.Bx 4.2 .
118