OSDN Git Service

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