1MKDIR(2) Linux Programmer's Manual MKDIR(2)
2
3
4
6 mkdir, mkdirat - create a directory
7
9 #include <sys/stat.h>
10 #include <sys/types.h>
11
12 int mkdir(const char *pathname, mode_t mode);
13
14 #include <fcntl.h> /* Definition of AT_* constants */
15 #include <sys/stat.h>
16
17 int mkdirat(int dirfd, const char *pathname, mode_t mode);
18
19 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
20
21 mkdirat():
22 Since glibc 2.10:
23 _POSIX_C_SOURCE >= 200809L
24 Before glibc 2.10:
25 _ATFILE_SOURCE
26
28 mkdir() attempts to create a directory named pathname.
29
30 The argument mode specifies the mode for the new directory (see in‐
31 ode(7)). It is modified by the process's umask in the usual way: in
32 the absence of a default ACL, the mode of the created directory is
33 (mode & ~umask & 0777). Whether other mode bits are honored for the
34 created directory depends on the operating system. For Linux, see
35 NOTES below.
36
37 The newly created directory will be owned by the effective user ID of
38 the process. If the directory containing the file has the set-group-ID
39 bit set, or if the filesystem is mounted with BSD group semantics
40 (mount -o bsdgroups or, synonymously mount -o grpid), the new directory
41 will inherit the group ownership from its parent; otherwise it will be
42 owned by the effective group ID of the process.
43
44 If the parent directory has the set-group-ID bit set, then so will the
45 newly created directory.
46
47 mkdirat()
48 The mkdirat() system call operates in exactly the same way as mkdir(),
49 except for the differences described here.
50
51 If the pathname given in pathname is relative, then it is interpreted
52 relative to the directory referred to by the file descriptor dirfd
53 (rather than relative to the current working directory of the calling
54 process, as is done by mkdir() for a relative pathname).
55
56 If pathname is relative and dirfd is the special value AT_FDCWD, then
57 pathname is interpreted relative to the current working directory of
58 the calling process (like mkdir()).
59
60 If pathname is absolute, then dirfd is ignored.
61
62 See openat(2) for an explanation of the need for mkdirat().
63
65 mkdir() and mkdirat() return zero on success, or -1 if an error oc‐
66 curred (in which case, errno is set appropriately).
67
69 EACCES The parent directory does not allow write permission to the
70 process, or one of the directories in pathname did not allow
71 search permission. (See also path_resolution(7).)
72
73 EDQUOT The user's quota of disk blocks or inodes on the filesystem has
74 been exha