1 .\" This manpage is Copyright (C) 1992 Drew Eckhardt;
2 .\" and Copyright (C) 1993 Michael Haardt
3 .\" and Copyright (C) 1993,1994 Ian Jackson
4 .\" and Copyright (C) 2006, 2014 Michael Kerrisk
6 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
7 .\" You may distribute it under the terms of the GNU General
8 .\" Public License. It comes with NO WARRANTY.
11 .TH MKDIR 2 2014-08-19 "Linux" "Linux Programmer's Manual"
13 mkdir, mkdirat \- create a directory
16 .B #include <sys/stat.h>
17 .B #include <sys/types.h>
18 .\" .B #include <unistd.h>
20 .BI "int mkdir(const char *" pathname ", mode_t " mode );
22 .BR "#include <fcntl.h> " "/* Definition of AT_* constants */"
23 .B #include <sys/stat.h>
25 .BI "int mkdirat(int " dirfd ", const char *" pathname ", mode_t " mode );
29 Feature Test Macro Requirements for glibc (see
30 .BR feature_test_macros (7)):
39 _XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
49 attempts to create a directory named
54 specifies the permissions to use.
55 It is modified by the process's
57 in the usual way: the permissions of the created directory are
58 .RI ( mode " & ~" umask " & 0777)."
59 Other mode bits of the created directory depend on the operating system.
62 The newly created directory will be owned by the effective user ID of the
64 If the directory containing the file has the set-group-ID
65 bit set, or if the filesystem is mounted with BSD group semantics
66 .RI ( "mount -o bsdgroups"
68 .IR "mount -o grpid" ),
69 the new directory will inherit the group ownership from its parent;
70 otherwise it will be owned by the effective group ID of the process.
72 If the parent directory has the set-group-ID bit set, then so will the
73 newly created directory.
79 system call operates in exactly the same way as
81 except for the differences described here.
83 If the pathname given in
85 is relative, then it is interpreted relative to the directory
86 referred to by the file descriptor
88 (rather than relative to the current working directory of
89 the calling process, as is done by
91 for a relative pathname).
101 is interpreted relative to the current working
102 directory of the calling process (like
113 for an explanation of the need for
119 return zero on success, or \-1 if an error occurred (in which case,
121 is set appropriately).
125 The parent directory does not allow write permission to the process,
126 or one of the directories in
128 did not allow search permission.
130 .BR path_resolution (7).)
133 The user's quota of disk blocks or inodes on the filesystem has been
138 already exists (not necessarily as a directory).
139 This includes the case where
141 is a symbolic link, dangling or not.
144 .IR pathname " points outside your accessible address space."
147 Too many symbolic links were encountered in resolving
151 The number of links to the parent directory would exceed
155 .IR pathname " was too long."
158 A directory component in
160 does not exist or is a dangling symbolic link.
163 Insufficient kernel memory was available.
166 The device containing
168 has no room for the new directory.
171 The new directory cannot be created because the user's disk quota is
175 A component used as a directory in
177 is not, in fact, a directory.
180 The filesystem containing
182 does not support the creation of directories.
186 refers to a file on a read-only filesystem.
188 The following additional errors can occur for
193 is not a valid file descriptor.
199 is a file descriptor referring to a file other than a directory.
202 was added to Linux in kernel 2.6.16;
203 library support was added to glibc in version 2.4.
206 SVr4, BSD, POSIX.1-2001, POSIX.1-2008.
207 .\" SVr4 documents additional EIO, EMULTIHOP
212 Under Linux, apart from the permission bits, only the
215 That is, under Linux the created directory actually gets mode
216 .RI ( mode " & ~" umask " & 01777)."
220 There are many infelicities in the protocol underlying NFS.
224 On older kernels where
226 is unavailable, the glibc wrapper function falls back to the use of
230 is a relative pathname,
231 glibc constructs a pathname based on the symbolic link in
233 that corresponds to the
246 .BR path_resolution (7)
248 This page is part of release 3.79 of the Linux
251 A description of the project,
252 information about reporting bugs,
253 and the latest version of this page,
255 \%http://www.kernel.org/doc/man\-pages/.