1rmdir(2) System Calls rmdir(2)
2
3
4
6 rmdir - remove a directory
7
9 #include <unistd.h>
10
11 int rmdir(const char *path);
12
13
15 The rmdir() function removes the directory named by the path name
16 pointed to by path. The directory must not have any entries other than
17 "." and "..".
18
19
20 If the directory's link count becomes zero and no process has the
21 directory open, the space occupied by the directory is freed and the
22 directory is no longer accessible. If one or more processes have the
23 directory open when the last link is removed, the "." and ".." entries,
24 if present, are removed before rmdir() returns and no new entries may
25 be created in the directory, but the directory is not removed until all
26 references to the directory have been closed.
27
28
29 Upon successful completion rmdir() marks for update the st_ctime and
30 st_mtime fields of the parent directory.
31
33 Upon successful completion, 0 is returned. Otherwise, −1 is returned,
34 errno is set to indicate the error, and the named directory is not
35 changed.
36
38 The rmdir() function will fail if:
39
40 EACCES Search permission is denied for a component of the path
41 prefix and {PRIV_FILE_DAC_SEARCH} is not asserted in
42 the effective set of the calling process
43
44 Write permission is denied on the directory containing
45 the directory to be removed and {PRIV_FILE_DAC_WRITE}
46 is not asserted.
47
48 The parent directory has the S_ISVTX variable set, is
49 not owned by the user, and {PRIV_FILE_OWNER} is not
50 asserted.
51
52 The directory is not owned by the user and is not
53 writable by the user.
54
55
56 EBUSY The directory to be removed is the mount point for a
57 mounted file system.
58
59
60 EEXIST The directory contains entries other than those for "."
61 and "..".
62
63
64 EFAULT The path argument points to an illegal address.
65
66
67 EINVAL The directory to be removed is the current directory,
68 or the final component of path is ".".
69
70
71 EILSEQ The path argument includes non-UTF8 characters and the
72 file system accepts only file names where all charac‐
73 ters are part of the UTF-8 character codeset.
74
75
76 EIO An I/O error occurred while accessing the file system.
77
78
79 ELOOP Too many symbolic links were encountered in translating
80 path.
81
82
83 ENAMETOOLONG The length of the path argument exceeds PATH_MAX, or
84 the length of a path component exceeds NAME_MAX while
85 _POSIX_NO_TRUNC is in effect.
86
87
88 ENOENT The named directory does not exist or is the null path‐
89 name.
90
91
92 ENOLINK The path argument points to a remote machine, and the
93 connection to that machine is no longer active.
94
95
96 ENOTDIR A component of the path prefix is not a directory.
97
98
99 EROFS The directory entry to be removed is part of a read-
100 only file system.
101
102
104 See attributes(5) for descriptions of the following attributes:
105
106
107
108
109 ┌─────────────────────────────┬─────────────────────────────┐
110 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
111 ├─────────────────────────────┼─────────────────────────────┤
112 │Interface Stability │Standard │
113 ├─────────────────────────────┼─────────────────────────────┤
114 │MT-Level │Async-Signal-Safe │
115 └─────────────────────────────┴─────────────────────────────┘
116
118 mkdir(1), rm(1), mkdir(2), attributes(5), privileges(5), standards(5)
119
120
121
122SunOS 5.11 18 May 2007 rmdir(2)