'\"macro stdmacro
.if n .pH g2.mkdir @(#)mkdir	40.28 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} mkdir 2 "" "" "\&"
.if \nX=1 .ds x} mkdir 2 "" ""
.if \nX=2 .ds x} mkdir 2 "" "" "\&"
.if \nX=3 .ds x} mkdir 2 "" "" "\&"
.TH \*(x}
.SH NAME
\f4mkdir\f1 \- make a directory
.SH SYNOPSIS
\f4#include <sys/types.h>\f1
.br
\f4#include <sys/stat.h>\f1
.PP
\f4int mkdir(const char \(**path, mode_t mode); \f1
.SH DESCRIPTION
\f4mkdir\fP
creates a 
new directory named by the path name pointed to by
.IR path\^ .
The mode of the new
directory is 
initialized from
.IR mode\^ 
[see \f4chmod\fP(2) for values of mode].
The protection part of the
.I mode\^
argument is modified by the
process's file creation mask
[see
\f4umask\fP(2)].
.PP
The directory's owner
.SM ID
is set to 
the process's effective user
\s-1ID\s0.
The directory's group
.SM ID
is set to the 
process's effective group \s-1ID\s0, or if the \f4S_ISGID\fP bit is
set in the parent directory, then the group
.SM ID
of the directory is inherited
from the parent.  The \f4S_ISGID\fP bit of the new directory is 
inherited from the parent directory.
.PP
If \f2path\fP is a symbolic link, it is not followed.
.PP
The newly created directory is empty
with the exception
of entries for itself (\f4.\fP)
and its parent directory (\f4..\fP).
.PP
Upon successful completion, \f4mkdir\fP marks for update the \f4st_atime\fP,
\f4st_ctime\fP and \f4st_mtime\fP fields of the directory. Also, the
\f4st_ctime\fP and \f4st_mtime\fP fields of the directory that contains the
new entry are marked for update.
.PP
\f4mkdir\fP
fails and creates no directory if one or more of the following
are true:
.TP 20
\f4EACCES\fP
Either a component of the path prefix denies search permission
or write permission is denied on the parent directory of the directory
to be created.
.TP
\f4EEXIST\fP
The named file
already exists.
.TP
\f4EFAULT\fP
.I path\^
points outside the allocated address space of the process.
.TP
\f4EIO\fP
An I/O error has occurred while accessing the file system.
.TP
\f4ELOOP\fP
Too many symbolic links were encountered in translating \f2path\f1.
.TP
\f4EMLINK\fP
The maximum number of links to the parent directory would be exceeded.
.TP
\f4EMULTIHOP\fP
Components of \f2path\f1 require hopping to multiple
remote machines
and the file system type does not allow it.
.TP 20
\f4ENAMETOOLONG\fP
The length of the \f2path\f1 argument exceeds {\f4PATH_MAX\fP}, or the
length of a \f2path\f1 component exceeds {\f4NAME_MAX\fP} while
\f4_POSIX_NO_TRUNC\fP is in effect.
.TP
\f4ENOENT\fP
A component of the
path prefix
does not exist or is a null pathname.
.TP
\f4ENOLINK\fP
.I path\^
points to a remote machine and the link to that
machine is no longer active.
.TP
\f4ENOSPC\fP
No free space is available on the device containing the directory.
.TP 20
\f4ENOTDIR\fP
A component of
the
path prefix
is not a directory.
.TP
\f4EROFS\fP
The path prefix resides
on a read-only file system.
.SH DIAGNOSTICS
Upon successful completion, a value of 0 is returned.
Otherwise, a value of \-1 is returned, and 
\f4errno\fP
is set to indicate the error.
.SH SEE ALSO
\f4chmod\fP(2), \f4mknod\fP(2), \f4umask\fP(2), \f4stat\fP(5).
.Ee
