| MKDIR(2) | System Calls Manual | MKDIR(2) |
mkdir, mkdirat
— make a directory file
Standard C Library (libc, -lc)
#include
<sys/stat.h>
int
mkdir(const
char *path, mode_t
mode);
#include
<sys/stat.h>
#include <fcntl.h>
int
mkdirat(int
fd, const char
*path, mode_t
mode);
The directory path is created with the
access permissions specified by mode and restricted by
the umask(2) of the calling
process. On NetBSD all other mode bits
(S_ISUID, S_ISGID,
S_ISTXT) are ignored. This is implementation
defined; for example on Linux S_ISTXT is
honored.
mkdirat()
works the same way as
mkdir()
except if path is relative. In that case, it is looked
up from a directory whose file descriptor was passed as
fd. Search permission is required this directory.
fd can be set to AT_FDCWD in
order to specify the current directory.
The directory's owner ID is set to the process's effective user ID. The directory's group ID is set to that of the parent directory in which it is created.
The mkdir() and
mkdirat() functions return the value 0 if
successful; otherwise the value -1 is returned and the global
variable errno is set to indicate the error.
Both mkdir() and
mkdirat() will fail and no directory will be created
if:
EACCES]EDQUOT]EEXIST]EFAULT]EIO]ELOOP]ENAMETOOLONG]NAME_MAX}
characters, or an entire path name exceeded
{PATH_MAX} characters.ENOENT]ENOSPC]ENOTDIR]EROFS]In addition, mkdirat() will fail if:
The mkdir() function conforms to
IEEE Std 1003.1-1990 (“POSIX.1”).
mkdirat() conforms to IEEE Std
1003.1-2008 (“POSIX.1”).
The mkdir() function appeared in
Version 1 AT&T UNIX.
| February 4, 2020 | NetBSD 11.0 |