8815 mega_sas: variable set but not used
[unleashed.git] / usr / src / man / man2 / mkdir.2
blob69ac44442adfdc5d943e7973ffbd6d61d927658c
1 '\" te
2 .\" Copyright (c) 2007, Sun Microsystems, Inc.  All Rights Reserved.
3 .\" Copyright 2016 Joyent, Inc.
4 .\" Copyright 1989 AT&T
5 .\" Portions Copyright (c) 2001, the Institute of Electrical and Electronics Engineers, Inc. and The Open Group. All Rights Reserved.
6 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
7 .\" http://www.opengroup.org/bookstore/.
8 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
9 .\"  This notice shall appear on any product containing this material.
10 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
11 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
12 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
13 .TH MKDIR 2 "Sep 24, 2016"
14 .SH NAME
15 mkdir, mkdirat \- make a directory
16 .SH SYNOPSIS
17 .LP
18 .nf
19 #include <sys/types.h>
20 #include <sys/stat.h>
22 \fBint\fR \fBmkdir\fR(\fBconst char *\fR\fIpath\fR, \fBmode_t\fR \fImode\fR);
23 .fi
24 .LP
25 .nf
26 \fBint\fR \fBmkdirat\fR(\fBint\fR \fIfd\fR, \fBconst char *\fR\fIpath\fR, \fBmode_t\fR \fImode\fR);
27 .fi
29 .SH DESCRIPTION
30 .LP
31 The \fBmkdir()\fR and \fBmkdirat()\fR functions create a new directory named by
32 the path name pointed to by \fIpath\fR. The mode of the new directory is
33 initialized from \fImode\fR (see \fBchmod\fR(2) for values of mode). The
34 protection part of the \fImode\fR argument is modified by the process's file
35 creation mask (see \fBumask\fR(2)).
36 .sp
37 .LP
38 The directory's owner \fBID\fR is set to the process's effective user ID. The
39 directory's group \fBID\fR is set to the process's effective group ID, or if
40 the \fBS_ISGID\fR bit is set in the parent directory, then the group \fBID\fR
41 of the directory is inherited from the parent.  The \fBS_ISGID\fR bit of the
42 new directory is inherited from the parent directory.
43 .sp
44 .LP
45 If \fIpath\fR names a symbolic link, \fBmkdir()\fR and \fBmkdirat()\fR fail and
46 set errno to \fBEEXIST\fR.
47 .sp
48 .LP
49 The newly created directory is empty with the exception of entries for itself
50 (\fB\&.\fR) and its parent directory (\fB\&..\fR).
51 .sp
52 .LP
53 The \fBmkdirat()\fR function behaves similarly to \fBmkdir()\fR; however, if
54 \fIpath\fR is a relative path, then the directory represented by \fBfd\fR is
55 used as the starting point for resolving \fIpath\fR. To use the processes
56 current working directory, \fIfd\fR may be set to the value \fBAT_FDCWD\fR.
57 .sp
58 .LP
59 Upon successful completion, \fBmkdir()\fR and \fBmkdirat()\fR mark for update
60 the \fBst_atime\fR, \fBst_ctime\fR and \fBst_mtime\fR fields of the directory.
61 Also, the \fBst_ctime\fR and \fBst_mtime\fR fields of the directory that
62 contains the new entry are marked for update.
63 .SH RETURN VALUES
64 .LP
65 Upon successful completion, \fB0\fR is returned. Otherwise, \fB\(mi1\fR is
66 returned, no directory is created, and \fBerrno\fR is set to indicate the
67 error.
68 .SH ERRORS
69 .LP
70 The \fBmkdir()\fR and \fBmkdirat()\fR functions will fail if:
71 .sp
72 .ne 2
73 .na
74 \fB\fBEACCES\fR\fR
75 .ad
76 .RS 16n
77 Either a component of the path prefix denies search permission or write
78 permission is denied on the parent directory of the directory to be created.
79 .RE
81 .sp
82 .ne 2
83 .na
84 \fB\fBEDQUOT\fR\fR
85 .ad
86 .RS 16n
87 The directory where the new file entry is being placed cannot be extended
88 because the user's quota of disk blocks on that file system has been exhausted;
89 the new directory cannot be created because the user's quota of disk blocks on
90 that file system has been exhausted; or the user's quota of inodes on the file
91 system where the file is being created has been exhausted.
92 .RE
94 .sp
95 .ne 2
96 .na
97 \fB\fBEEXIST\fR\fR
98 .ad
99 .RS 16n
100 The named file already exists.
104 .ne 2
106 \fB\fBEFAULT\fR\fR
108 .RS 16n
109 The \fIpath\fR argument points to an illegal address.
113 .ne 2
115 \fB\fBEINVAL\fR\fR
117 .RS 16n
118 An attempt was made to create an extended attribute that is a directory.
122 .ne 2
124 \fB\fBEIO\fR\fR
126 .RS 16n
127 An I/O error has occurred while accessing the file system.
131 .ne 2
133 \fB\fBEILSEQ\fR\fR
135 .RS 16n
136 The path argument includes non-UTF8 characters and the file system accepts only
137 file names where all characters are part of the UTF-8 character codeset.
141 .ne 2
143 \fB\fBELOOP\fR\fR
145 .RS 16n
146 Too many symbolic links were encountered in translating \fIpath\fR, or a loop
147 exists in symbolic links encountered during resolution of \fIpath\fR
151 .ne 2
153 \fB\fBEMLINK\fR\fR
155 .RS 16n
156 The maximum number of links to the parent directory would be exceeded.
160 .ne 2
162 \fB\fBENAMETOOLONG\fR\fR
164 .RS 16n
165 The length of the \fIpath\fR argument exceeds \fBPATH_MAX\fR, or the length of
166 a \fIpath\fR component exceeds \fBNAME_MAX\fR while \fB_POSIX_NO_TRUNC\fR is in
167 effect.
171 .ne 2
173 \fB\fBENOENT\fR\fR
175 .RS 16n
176 A component of the path prefix does not exist or is a null pathname.
180 .ne 2
182 \fB\fBENOLINK\fR\fR
184 .RS 16n
185 The \fIpath\fR argument points to a remote machine and the link to that machine
186 is no longer active.
190 .ne 2
192 \fB\fBENOSPC\fR\fR
194 .RS 16n
195 No free space is available on the device containing the directory.
199 .ne 2
201 \fB\fBENOTDIR\fR\fR
203 .RS 16n
204 A component of the path prefix is not a directory. For \fBlinkat()\fR, if
205 \fIpath\fR is a relative path and \fIfd\fR refers to a valid file descriptor
206 which is not a directory.
210 .ne 2
212 \fB\fBEROFS\fR\fR
214 .RS 16n
215 The path prefix resides on a read-only file system.
220 The \fBmkdirat()\fR function will fail if:
222 .ne 2
224 .B EBADF
226 .RS 16n
227 The path \fIpath\fR is a relative path and \fIfd\fR is not a valid open file
228 descriptor or the value \fBAT_FDCWD\fR.
233 The \fBmkdir()\fR function may fail if:
235 .ne 2
237 \fB\fBENAMETOOLONG\fR\fR
239 .RS 16n
240 As a result of encountering a symbolic link in resolution of the \fIpath\fR
241 argument, the length of the substituted pathname string exceeded
242 {\fBPATH_MAX\fR}.
245 .SH EXAMPLES
247 \fBExample 1 \fRCreate a directory.
250 The following example demonstrates how to create a directory named
251 \fB/home/cnd/mod1\fR, with read, write, and search permissions for owner and
252 group, and with read and search permissions for others.
255 .in +2
257 #include <sys/types.h>
258 #include <sys/stat.h>
259 int status;
260 \&...
261 status = mkdir("/home/cnd/mod1",
262      S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
264 .in -2
266 .SH ATTRIBUTES
268 See \fBattributes\fR(5) for descriptions of the following attributes:
273 box;
274 c | c
275 l | l .
276 ATTRIBUTE TYPE  ATTRIBUTE VALUE
278 Interface Stability     Standard
280 MT-Level        Async-Signal-Safe
283 .SH SEE ALSO
285 \fBchmod\fR(2), \fBmknod\fR(2), \fBumask\fR(2), \fBmkdirp\fR(3GEN),
286 \fBstat.h\fR(3HEAD), \fBattributes\fR(5), \fBstandards\fR(5)