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 EEXIST pathname already exists (not necessarily as a directory). This
42 includes the case where pathname is a symbolic link, dangling or
43 not.
44
45 EFAULT pathname points outside your accessible address space.
46
47 ELOOP Too many symbolic links were encountered in resolving pathname.
48
49 ENAMETOOLONG
50 pathname was too long.
51
52 ENOENT A directory component in pathname does not exist or is a dan‐
53 gling symbolic link.
54
55 ENOMEM Insufficient kernel memory was available.
56
57 ENOSPC The device containing pathname has no room for the new direc‐
58 tory.
59
60 ENOSPC The new directory cannot be created because the user's disk
61 quota is exhausted.
62
63 ENOTDIR
64 A component used as a directory in pathname is not, in fact, a
65 directory.
66
67 EPERM The file system containing pathname does not support the cre‐
68 ation of directories.
69
70 EROFS pathname refers to a file on a read-only file system.
71
73 SVr4, BSD, POSIX.1-2001.
74
76 Under Linux apart from the permission bits, only the S_ISVTX mode bit
77 is honored. That is, under Linux the created directory actually gets
78 mode (mode & ~umask & 01777). See also stat(2).
79
80 There are many infelicities in the protocol underlying NFS. Some of
81 these affect mkdir().
82
84 mkdir(1), chmod(2), chown(2), mkdirat(2), mknod(2), mount(2), rmdir(2),
85 stat(2), umask(2), unlink(2), path_resolution(7)
86
88 This page is part of release 3.25 of the Linux man-pages project. A
89 description of the project, and information about reporting bugs, can
90 be found at http://www.kernel.org/doc/man-pages/.
91
92
93
94Linux 2008-05-13 MKDIR(2)