]>
Commit | Line | Data |
---|---|---|
fea681da MK |
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 | |
d9bfdb9c | 7 | .\" Public License. It comes with NO WARRANTY. |
fea681da | 8 | .\" |
d9343c5c | 9 | .TH MKDIR 2 2003-12-09 "Linux" "Linux Programmer's Manual" |
fea681da MK |
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 | |
e511ffb6 | 21 | .BR mkdir () |
fea681da MK |
22 | attempts to create a directory named |
23 | .IR pathname . | |
24 | ||
25 | The parameter | |
26 | .I mode | |
c13182ef MK |
27 | specifies the permissions to use. |
28 | It is modified by the process's | |
fea681da MK |
29 | .I umask |
30 | in the usual way: the permissions of the created directory are | |
31 | .RI ( mode " & ~" umask " & 0777)." | |
32 | Other mode bits of the created directory depend on the operating system. | |
33 | For Linux, see below. | |
34 | ||
35 | The newly created directory will be owned by the effective user ID of the | |
c13182ef MK |
36 | process. |
37 | If the directory containing the file has the set-group-ID | |
24d01c53 | 38 | bit set, or if the file system is mounted with BSD group semantics, the |
fea681da MK |
39 | new directory will inherit the group ownership from its parent; |
40 | otherwise it will be owned by the effective group ID of the process. | |
41 | ||
c7400a2c | 42 | If the parent directory has the set-group-ID bit set then so will the |
fea681da | 43 | newly created directory. |
fea681da | 44 | .SH "RETURN VALUE" |
e511ffb6 | 45 | .BR mkdir () |
fea681da MK |
46 | returns zero on success, or \-1 if an error occurred (in which case, |
47 | .I errno | |
48 | is set appropriately). | |
49 | .SH ERRORS | |
50 | .TP | |
51 | .B EACCES | |
52 | The parent directory does not allow write permission to the process, | |
53 | or one of the directories in | |
0daa9e92 | 54 | .I pathname |
fea681da MK |
55 | did not allow search permission. |
56 | (See also | |
ad7cc990 | 57 | .BR path_resolution (7).) |
fea681da MK |
58 | .TP |
59 | .B EEXIST | |
60 | .I pathname | |
61 | already exists (not necessarily as a directory). | |
62 | This includes the case where | |
63 | .I pathname | |
64 | is a symbolic link, dangling or not. | |
65 | .TP | |
66 | .B EFAULT | |
67 | .IR pathname " points outside your accessible address space." | |
68 | .TP | |
69 | .B ELOOP | |
70 | Too many symbolic links were encountered in resolving | |
71 | .IR pathname . | |
72 | .TP | |
73 | .B ENAMETOOLONG | |
74 | .IR pathname " was too long." | |
75 | .TP | |
76 | .B ENOENT | |
77 | A directory component in | |
78 | .I pathname | |
79 | does not exist or is a dangling symbolic link. | |
80 | .TP | |
81 | .B ENOMEM | |
82 | Insufficient kernel memory was available. | |
83 | .TP | |
84 | .B ENOSPC | |
85 | The device containing | |
86 | .I pathname | |
87 | has no room for the new directory. | |
88 | .TP | |
89 | .B ENOSPC | |
90 | The new directory cannot be created because the user's disk quota is | |
91 | exhausted. | |
92 | .TP | |
93 | .B ENOTDIR | |
94 | A component used as a directory in | |
95 | .I pathname | |
96 | is not, in fact, a directory. | |
97 | .TP | |
98 | .B EPERM | |
24d01c53 | 99 | The file system containing |
0daa9e92 | 100 | .I pathname |
fea681da MK |
101 | does not support the creation of directories. |
102 | .TP | |
103 | .B EROFS | |
104 | .I pathname | |
24d01c53 | 105 | refers to a file on a read-only file system. |
fea681da | 106 | .SH "CONFORMING TO" |
97c1eac8 MK |
107 | SVr4, BSD, POSIX.1-2001. |
108 | .\" SVr4 documents additional EIO, EMULTIHOP | |
fea681da | 109 | .SH NOTES |
682edefb MK |
110 | Under Linux apart from the permission bits, only the |
111 | .B S_ISVTX | |
112 | mode bit is honored. | |
c13182ef | 113 | That is, under Linux the created directory actually gets mode |
fea681da MK |
114 | .RI ( mode " & ~" umask " & 01777)." |
115 | See also | |
116 | .BR stat (2). | |
117 | .PP | |
c13182ef MK |
118 | There are many infelicities in the protocol underlying NFS. |
119 | Some of these affect | |
e511ffb6 | 120 | .BR mkdir (). |
fea681da MK |
121 | .SH "SEE ALSO" |
122 | .BR mkdir (1), | |
123 | .BR chmod (2), | |
d2927a1b | 124 | .BR mkdirat (2), |
fea681da MK |
125 | .BR mknod (2), |
126 | .BR mount (2), | |
fea681da MK |
127 | .BR rmdir (2), |
128 | .BR stat (2), | |
129 | .BR umask (2), | |
ad7cc990 MK |
130 | .BR unlink (2), |
131 | .BR path_resolution (7) |