1*8269e767SBrooks Davis.\" Copyright (c) 1983, 1991, 1993 2*8269e767SBrooks Davis.\" The Regents of the University of California. All rights reserved. 3*8269e767SBrooks Davis.\" 4*8269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without 5*8269e767SBrooks Davis.\" modification, are permitted provided that the following conditions 6*8269e767SBrooks Davis.\" are met: 7*8269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright 8*8269e767SBrooks Davis.\" notice, this list of conditions and the following disclaimer. 9*8269e767SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright 10*8269e767SBrooks Davis.\" notice, this list of conditions and the following disclaimer in the 11*8269e767SBrooks Davis.\" documentation and/or other materials provided with the distribution. 12*8269e767SBrooks Davis.\" 3. Neither the name of the University nor the names of its contributors 13*8269e767SBrooks Davis.\" may be used to endorse or promote products derived from this software 14*8269e767SBrooks Davis.\" without specific prior written permission. 15*8269e767SBrooks Davis.\" 16*8269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17*8269e767SBrooks Davis.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18*8269e767SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19*8269e767SBrooks Davis.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20*8269e767SBrooks Davis.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21*8269e767SBrooks Davis.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22*8269e767SBrooks Davis.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23*8269e767SBrooks Davis.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24*8269e767SBrooks Davis.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25*8269e767SBrooks Davis.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26*8269e767SBrooks Davis.\" SUCH DAMAGE. 27*8269e767SBrooks Davis.\" 28*8269e767SBrooks Davis.Dd March 30, 2020 29*8269e767SBrooks Davis.Dt MKDIR 2 30*8269e767SBrooks Davis.Os 31*8269e767SBrooks Davis.Sh NAME 32*8269e767SBrooks Davis.Nm mkdir , 33*8269e767SBrooks Davis.Nm mkdirat 34*8269e767SBrooks Davis.Nd make a directory file 35*8269e767SBrooks Davis.Sh LIBRARY 36*8269e767SBrooks Davis.Lb libc 37*8269e767SBrooks Davis.Sh SYNOPSIS 38*8269e767SBrooks Davis.In sys/stat.h 39*8269e767SBrooks Davis.Ft int 40*8269e767SBrooks Davis.Fn mkdir "const char *path" "mode_t mode" 41*8269e767SBrooks Davis.Ft int 42*8269e767SBrooks Davis.Fn mkdirat "int fd" "const char *path" "mode_t mode" 43*8269e767SBrooks Davis.Sh DESCRIPTION 44*8269e767SBrooks DavisThe directory 45*8269e767SBrooks Davis.Fa path 46*8269e767SBrooks Davisis created with the access permissions specified by 47*8269e767SBrooks Davis.Fa mode 48*8269e767SBrooks Davisand restricted by the 49*8269e767SBrooks Davis.Xr umask 2 50*8269e767SBrooks Davisof the calling process. 51*8269e767SBrooks Davis.Pp 52*8269e767SBrooks DavisThe directory's owner ID is set to the process's effective user ID. 53*8269e767SBrooks DavisThe directory's group ID is set to that of the parent directory in 54*8269e767SBrooks Daviswhich it is created. 55*8269e767SBrooks Davis.Pp 56*8269e767SBrooks DavisThe 57*8269e767SBrooks Davis.Fn mkdirat 58*8269e767SBrooks Davissystem call is equivalent to 59*8269e767SBrooks Davis.Fn mkdir 60*8269e767SBrooks Davisexcept in the case where 61*8269e767SBrooks Davis.Fa path 62*8269e767SBrooks Davisspecifies a relative path. 63*8269e767SBrooks DavisIn this case the newly created directory is created relative to the 64*8269e767SBrooks Davisdirectory associated with the file descriptor 65*8269e767SBrooks Davis.Fa fd 66*8269e767SBrooks Davisinstead of the current working directory. 67*8269e767SBrooks DavisIf 68*8269e767SBrooks Davis.Fn mkdirat 69*8269e767SBrooks Davisis passed the special value 70*8269e767SBrooks Davis.Dv AT_FDCWD 71*8269e767SBrooks Davisin the 72*8269e767SBrooks Davis.Fa fd 73*8269e767SBrooks Davisparameter, the current working directory is used and the behavior is 74*8269e767SBrooks Davisidentical to a call to 75*8269e767SBrooks Davis.Fn mkdir . 76*8269e767SBrooks Davis.Sh RETURN VALUES 77*8269e767SBrooks Davis.Rv -std mkdir 78*8269e767SBrooks Davis.Sh ERRORS 79*8269e767SBrooks DavisThe 80*8269e767SBrooks Davis.Fn mkdir 81*8269e767SBrooks Davissystem call 82*8269e767SBrooks Daviswill fail and no directory will be created if: 83*8269e767SBrooks Davis.Bl -tag -width Er 84*8269e767SBrooks Davis.It Bq Er ENOTDIR 85*8269e767SBrooks DavisA component of the path prefix is not a directory. 86*8269e767SBrooks Davis.It Bq Er ENAMETOOLONG 87*8269e767SBrooks DavisA component of a pathname exceeded 255 characters, 88*8269e767SBrooks Davisor an entire path name exceeded 1023 characters. 89*8269e767SBrooks Davis.It Bq Er ENOENT 90*8269e767SBrooks DavisA component of the path prefix does not exist. 91*8269e767SBrooks Davis.It Bq Er EACCES 92*8269e767SBrooks DavisSearch permission is denied for a component of the path prefix, 93*8269e767SBrooks Davisor write permission is denied 94*8269e767SBrooks Davison the parent directory of the directory to be created. 95*8269e767SBrooks Davis.It Bq Er ELOOP 96*8269e767SBrooks DavisToo many symbolic links were encountered in translating the pathname. 97*8269e767SBrooks Davis.It Bq Er EPERM 98*8269e767SBrooks DavisThe parent directory of the directory to be created has its immutable flag set, 99*8269e767SBrooks Davissee the 100*8269e767SBrooks Davis.Xr chflags 2 101*8269e767SBrooks Davismanual page for more information. 102*8269e767SBrooks Davis.It Bq Er EROFS 103*8269e767SBrooks DavisThe named directory would reside on a read-only file system. 104*8269e767SBrooks Davis.It Bq Er EMLINK 105*8269e767SBrooks DavisThe new directory cannot be created because the parent directory contains 106*8269e767SBrooks Davistoo many subdirectories. 107*8269e767SBrooks Davis.It Bq Er EEXIST 108*8269e767SBrooks DavisThe named file exists. 109*8269e767SBrooks Davis.It Bq Er ENOSPC 110*8269e767SBrooks DavisThe new directory cannot be created because there is no space left 111*8269e767SBrooks Davison the file system that will contain the directory. 112*8269e767SBrooks Davis.It Bq Er ENOSPC 113*8269e767SBrooks DavisThere are no free inodes on the file system on which the 114*8269e767SBrooks Davisdirectory is being created. 115*8269e767SBrooks Davis.It Bq Er EDQUOT 116*8269e767SBrooks DavisThe new directory cannot be created because the user's 117*8269e767SBrooks Davisquota of disk blocks on the file system that will 118*8269e767SBrooks Daviscontain the directory has been exhausted. 119*8269e767SBrooks Davis.It Bq Er EDQUOT 120*8269e767SBrooks DavisThe user's quota of inodes on the file system on 121*8269e767SBrooks Daviswhich the directory is being created has been exhausted. 122*8269e767SBrooks Davis.It Bq Er EIO 123*8269e767SBrooks DavisAn I/O error occurred while making the directory entry or allocating the inode. 124*8269e767SBrooks Davis.It Bq Er EIO 125*8269e767SBrooks DavisAn I/O error occurred while reading from or writing to the file system. 126*8269e767SBrooks Davis.It Bq Er EINTEGRITY 127*8269e767SBrooks DavisCorrupted data was detected while reading from the file system. 128*8269e767SBrooks Davis.It Bq Er EFAULT 129*8269e767SBrooks DavisThe 130*8269e767SBrooks Davis.Fa path 131*8269e767SBrooks Davisargument 132*8269e767SBrooks Davispoints outside the process's allocated address space. 133*8269e767SBrooks Davis.El 134*8269e767SBrooks Davis.Pp 135*8269e767SBrooks DavisIn addition to the errors returned by the 136*8269e767SBrooks Davis.Fn mkdir , 137*8269e767SBrooks Davisthe 138*8269e767SBrooks Davis.Fn mkdirat 139*8269e767SBrooks Davismay fail if: 140*8269e767SBrooks Davis.Bl -tag -width Er 141*8269e767SBrooks Davis.It Bq Er EBADF 142*8269e767SBrooks DavisThe 143*8269e767SBrooks Davis.Fa path 144*8269e767SBrooks Davisargument does not specify an absolute path and the 145*8269e767SBrooks Davis.Fa fd 146*8269e767SBrooks Davisargument is neither 147*8269e767SBrooks Davis.Dv AT_FDCWD 148*8269e767SBrooks Davisnor a valid file descriptor open for searching. 149*8269e767SBrooks Davis.It Bq Er ENOTDIR 150*8269e767SBrooks DavisThe 151*8269e767SBrooks Davis.Fa path 152*8269e767SBrooks Davisargument is not an absolute path and 153*8269e767SBrooks Davis.Fa fd 154*8269e767SBrooks Davisis neither 155*8269e767SBrooks Davis.Dv AT_FDCWD 156*8269e767SBrooks Davisnor a file descriptor associated with a directory. 157*8269e767SBrooks Davis.El 158*8269e767SBrooks Davis.Sh SEE ALSO 159*8269e767SBrooks Davis.Xr chflags 2 , 160*8269e767SBrooks Davis.Xr chmod 2 , 161*8269e767SBrooks Davis.Xr stat 2 , 162*8269e767SBrooks Davis.Xr umask 2 163*8269e767SBrooks Davis.Sh STANDARDS 164*8269e767SBrooks DavisThe 165*8269e767SBrooks Davis.Fn mkdir 166*8269e767SBrooks Davissystem call is expected to conform to 167*8269e767SBrooks Davis.St -p1003.1-90 . 168*8269e767SBrooks DavisThe 169*8269e767SBrooks Davis.Fn mkdirat 170*8269e767SBrooks Davissystem call follows The Open Group Extended API Set 2 specification. 171*8269e767SBrooks Davis.Sh HISTORY 172*8269e767SBrooks DavisThe 173*8269e767SBrooks Davis.Fn mkdirat 174*8269e767SBrooks Davissystem call appeared in 175*8269e767SBrooks Davis.Fx 8.0 . 176*8269e767SBrooks DavisThe 177*8269e767SBrooks Davis.Fn mkdir 178*8269e767SBrooks Davissystem call appeared in 179*8269e767SBrooks Davis.At v1 . 180