1MKDIR(2) Linux Programmer's Manual MKDIR(2)
2
3
4
6 mkdir - 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
15 mkdir() attempts to create a directory named pathname.
16
17 The argument mode specifies the permissions to use. It is modified by
18 the process's umask in the usual way: the permissions of the created
19 directory are (mode & ~umask & 0777). Other mode bits of the created
20 directory depend on the operating system. For Linux, see below.
21
22 The newly created directory will be owned by the effective user ID of
23 the process. If the directory containing the file has the set-group-ID
24 bit set, or if the file system is mounted with BSD group semantics
25 (mount -o bsdgroups or, synonymously mount -o grpid), the new directory
26 will inherit the group ownership from its parent; otherwise it will be
27 owned by the effective group ID of the process.
28
29 If the parent directory has the set-group-ID bit set then so will the
30 newly created directory.
31
33 mkdir() returns zero on success, or -1 if an error occurred (in which
34 case, errno is set appropriately).
35
37 EACCES The parent directory does not allow write permission to the
38 process, or one of the directories in pathname did not allow
39 search permission. (See also path_resolution(7).)
40
41 EDQUOT The user's quota of disk blocks or inodes on the file system has
42 been exhausted.
43
44 EEXIST pathname already exists (not necessarily as a directory). This
45 includes the case where pathname is a symbolic link, dangling or
46 not.
47
48 EFAULT pathname points outside your accessible address space.
49
50 ELOOP Too many symbolic links were encountered in resolving pathname.
51
52 EMLINK The number of links to the parent directory would exceed
53 LINK_MAX.
54
55 ENAMETOOLONG
56 pathname was too long.
57
58 ENOENT A directory component in pathname does not exist or is a dan‐
59 gling symbolic link.
60
61 ENOMEM Insufficient kernel memory was available.
62
63 ENOSPC The device containing pathname has no room for the new direc‐
64 tory.
65
66 ENOSPC The new directory cannot be created because the user's disk
67 quota is exhausted.
68
69 ENOTDIR
70 A component used as a directory in pathname is not, in fact, a
71 directory.
72
73 EPERM The file system containing pathname does not support the cre‐
74 ation of directories.
75
76 EROFS pathname refers to a file on a read-only file system.
77
79 SVr4, BSD, POSIX.1-2001.
80
82 Under Linux apart from the permission bits, only the S_ISVTX mode bit
83 is honored. That is, under Linux the created directory actually gets
84 mode (mode & ~umask & 01777). See also stat(2).
85
86 There are many infelicities in the protocol underlying NFS. Some of
87 these affect mkdir().
88
90 mkdir(1), chmod(2), chown(2), mkdirat(2), mknod(2), mount(2), rmdir(2),
91 stat(2), umask(2), unlink(2), path_resolution(7)
92
94 This page is part of release 3.53 of the Linux man-pages project. A
95 description of the project, and information about reporting bugs, can
96 be found at http://www.kernel.org/doc/man-pages/.
97
98
99
100Linux 2013-01-27 MKDIR(2)