mkdir() is in <sys/stat.h>
whereas rmdir() is in <unistd.h>
. Wouldn't it make more sense to have them in the same header file?
The reason is, that with mkdir(2)
you specify the permissions in the second argument:
int mkdir(const char *pathname, mode_t mode);
These mode-flags and the type mode_t
are defined in sys/stat.h
(at least indirectly by including bits/stat.h
and bits/types.h
on my system), so it seems appropriate to define mkdir() there, too. Otherwise, including unistd.h
would lead to an error, since the type mode_t
is unknown there.
In contrast, rmdir(2)
doesn't take any arguments besides the filename, so it can remain in unistd.h
, since there are no other dependencies.