xref: /original-bsd/lib/libc/sys/rmdir.2 (revision 4405f301)
1.\" Copyright (c) 1983, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)rmdir.2	8.1 (Berkeley) 06/04/93
7.\"
8.Dd
9.Dt RMDIR 2
10.Os BSD 4.2
11.Sh NAME
12.Nm rmdir
13.Nd remove a directory file
14.Sh SYNOPSIS
15.Fd #include <unistd.h>
16.Ft int
17.Fn rmdir "const char *path"
18.Sh DESCRIPTION
19.Fn Rmdir
20removes a directory file
21whose name is given by
22.Fa path .
23The directory must not have any entries other
24than
25.Ql \&.
26and
27.Ql \&.. .
28.Sh RETURN VALUES
29A 0 is returned if the remove succeeds; otherwise a -1 is
30returned and an error code is stored in the global location
31.Va errno .
32.Sh ERRORS
33The named file is removed unless:
34.Bl -tag -width [ENAMETOOLONG]
35.It Bq Er ENOTDIR
36A component of the path is not a directory.
37.It Bq Er EINVAL
38The pathname contains a character with the high-order bit set.
39.It Bq Er ENAMETOOLONG
40A component of a pathname exceeded 255 characters,
41or an entire path name exceeded 1023 characters.
42.It Bq Er ENOENT
43The named directory does not exist.
44.It Bq Er ELOOP
45Too many symbolic links were encountered in translating the pathname.
46.It Bq Er ENOTEMPTY
47The named directory contains files other than
48.Ql \&.
49and
50.Ql \&..
51in it.
52.It Bq Er EACCES
53Search permission is denied for a component of the path prefix.
54.It Bq Er EACCES
55Write permission is denied on the directory containing the link
56to be removed.
57.It Bq Er EPERM
58The directory containing the directory to be removed is marked sticky,
59and neither the containing directory nor the directory to be removed
60are owned by the effective user ID.
61.It Bq Er EBUSY
62The directory to be removed is the mount point
63for a mounted file system.
64.It Bq Er EIO
65An I/O error occurred while deleting the directory entry
66or deallocating the inode.
67.It Bq Er EROFS
68The directory entry to be removed resides on a read-only file system.
69.It Bq Er EFAULT
70.Fa Path
71points outside the process's allocated address space.
72.El
73.Sh SEE ALSO
74.Xr mkdir 2 ,
75.Xr unlink 2
76.Sh HISTORY
77The
78.Nm
79function call appeared in
80.Bx 4.2 .
81