]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/mkdir.2
ffix
[thirdparty/man-pages.git] / man2 / mkdir.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" This manpage is Copyright (C) 1992 Drew Eckhardt;
4 .\" 1993 Michael Haardt
5 .\" 1993,1994 Ian Jackson.
6 .\" You may distribute it under the terms of the GNU General
7 .\" Public Licence. It comes with NO WARRANTY.
8 .\"
9 .TH MKDIR 2 2003-12-09 "Linux 2.4" "Linux Programmer's Manual"
10 .SH NAME
11 mkdir \- create a directory
12 .SH SYNOPSIS
13 .nf
14 .B #include <sys/stat.h>
15 .B #include <sys/types.h>
16 .\" .B #include <unistd.h>
17 .sp
18 .BI "int mkdir(const char *" pathname ", mode_t " mode );
19 .fi
20 .SH DESCRIPTION
21 .BR mkdir ()
22 attempts to create a directory named
23 .IR pathname .
24
25 The parameter
26 .I mode
27 specifies the permissions to use. It is modified by the process's
28 .I umask
29 in the usual way: the permissions of the created directory are
30 .RI ( mode " & ~" umask " & 0777)."
31 Other mode bits of the created directory depend on the operating system.
32 For Linux, see below.
33
34 The newly created directory will be owned by the effective user ID of the
35 process. If the directory containing the file has the set-group-ID
36 bit set, or if the filesystem is mounted with BSD group semantics, the
37 new directory will inherit the group ownership from its parent;
38 otherwise it will be owned by the effective group ID of the process.
39
40 If the parent directory has the set-group-ID bit set then so will the
41 newly created directory.
42 .SH "RETURN VALUE"
43 .BR mkdir ()
44 returns zero on success, or \-1 if an error occurred (in which case,
45 .I errno
46 is set appropriately).
47 .SH ERRORS
48 .TP
49 .B EACCES
50 The parent directory does not allow write permission to the process,
51 or one of the directories in
52 .IR pathname
53 did not allow search permission.
54 (See also
55 .BR path_resolution (2).)
56 .TP
57 .B EEXIST
58 .I pathname
59 already exists (not necessarily as a directory).
60 This includes the case where
61 .I pathname
62 is a symbolic link, dangling or not.
63 .TP
64 .B EFAULT
65 .IR pathname " points outside your accessible address space."
66 .TP
67 .B ELOOP
68 Too many symbolic links were encountered in resolving
69 .IR pathname .
70 .TP
71 .B ENAMETOOLONG
72 .IR pathname " was too long."
73 .TP
74 .B ENOENT
75 A directory component in
76 .I pathname
77 does not exist or is a dangling symbolic link.
78 .TP
79 .B ENOMEM
80 Insufficient kernel memory was available.
81 .TP
82 .B ENOSPC
83 The device containing
84 .I pathname
85 has no room for the new directory.
86 .TP
87 .B ENOSPC
88 The new directory cannot be created because the user's disk quota is
89 exhausted.
90 .TP
91 .B ENOTDIR
92 A component used as a directory in
93 .I pathname
94 is not, in fact, a directory.
95 .TP
96 .B EPERM
97 The filesystem containing
98 .IR pathname
99 does not support the creation of directories.
100 .TP
101 .B EROFS
102 .I pathname
103 refers to a file on a read-only filesystem.
104 .SH "CONFORMING TO"
105 SVr4, BSD, POSIX.1-2001.
106 .\" SVr4 documents additional EIO, EMULTIHOP
107 .SH NOTES
108 Under Linux apart from the permission bits, only the S_ISVTX mode bit
109 is honored. That is, under Linux the created directory actually gets mode
110 .RI ( mode " & ~" umask " & 01777)."
111 See also
112 .BR stat (2).
113 .PP
114 There are many infelicities in the protocol underlying NFS. Some
115 of these affect
116 .BR mkdir ().
117 .SH "SEE ALSO"
118 .BR mkdir (1),
119 .BR chmod (2),
120 .BR mkdirat (2),
121 .BR mknod (2),
122 .BR mount (2),
123 .BR path_resolution (2),
124 .BR rmdir (2),
125 .BR stat (2),
126 .BR umask (2),
127 .BR unlink (2)