201 lines
3.9 KiB
Groff
201 lines
3.9 KiB
Groff
'\"macro stdmacro
|
|
.if n .pH g2.mkdir @(#)mkdir 30.7 of 2/11/86
|
|
.TH mkdir 2
|
|
.SH NAME
|
|
mkdir \- make a directory
|
|
.Op c p a
|
|
.SH C SYNOPSIS
|
|
.nf
|
|
\f3#include <sys/types.h>\f1
|
|
\f3#include <sys/stat.h>\f1
|
|
.sp .6v
|
|
\f3int mkdir (const char \(**path, mode_t mode);\f1
|
|
.fi
|
|
.Op
|
|
.Op f
|
|
.SH FORTRAN SYNOPSIS
|
|
.nf
|
|
\f3integer *4 function mkdir (path, mode)\f1
|
|
\f3character * (*) path\f1
|
|
\f3integer *4 mode\f1
|
|
.fi
|
|
.Op
|
|
.SH DESCRIPTION
|
|
.I mkdir
|
|
creates a
|
|
new directory with
|
|
the name
|
|
.I path.
|
|
The mode of the new
|
|
directory is
|
|
initialized from
|
|
.I mode
|
|
(see
|
|
.IR chmod (2)
|
|
for values of
|
|
.IR mode ].
|
|
The protection part of
|
|
.I mode
|
|
is modified by the process's mode mask
|
|
(see
|
|
.IR umask (2)).
|
|
The \f4S_ISGID\fP, \f4S_ISUID\fP, and \f4S_ISVTX\fP bits are silently deleted
|
|
from
|
|
.IR mode .
|
|
.PP
|
|
The directory's owner
|
|
ID
|
|
is set to
|
|
the process's effective user
|
|
ID.
|
|
The directory's group
|
|
ID
|
|
is set to the
|
|
process's effective group
|
|
ID
|
|
or the group
|
|
ID
|
|
of the directory in which the directory is being created.
|
|
This is determined as follows:
|
|
.PP
|
|
If the underlying filesystem was mounted with
|
|
the
|
|
BSD
|
|
file creation semantics flag (see
|
|
.IR fstab (4))
|
|
or the
|
|
.B S_ISGID
|
|
bit is set (see
|
|
.IR chmod (2))
|
|
on the parent directory, then the group
|
|
ID
|
|
of the new is set to the group
|
|
ID
|
|
of the parent directory, otherwise it is set to the
|
|
effective group
|
|
ID
|
|
of the calling process.
|
|
.PP
|
|
The newly created directory is empty
|
|
with the possible exception
|
|
of entries for itself (.)
|
|
and its parent directory (..).
|
|
.PP
|
|
Upon successful completion,
|
|
.I mkdir
|
|
marks for update the
|
|
\f3st_atime\fP,
|
|
\f3st_ctime\fP
|
|
and
|
|
\f3st_mtime\fP
|
|
fields of the directory.
|
|
Also, the
|
|
\f3st_ctime\fP
|
|
and
|
|
\f3st_mtime\fP
|
|
fields of the directory that contains the
|
|
new entry are marked for update.
|
|
.PP
|
|
.I mkdir
|
|
will fail and no directory will be
|
|
created if one or more of the following
|
|
are true:
|
|
.TP 17
|
|
[ENOTDIR]
|
|
A component of
|
|
the
|
|
path prefix
|
|
is not a directory.
|
|
.TP
|
|
[ENOENT]
|
|
A component of the
|
|
path prefix
|
|
does not exist.
|
|
.\".TP
|
|
.\".SM
|
|
.\"[ENOLINK]
|
|
.\".I Path
|
|
.\"points to a remote machine and the link to that
|
|
.\"machine is no longer active.
|
|
.\".TP
|
|
.\".SM
|
|
.\"[EMULTIHOP]
|
|
.\"Components of \f2path\f1 require hopping to multiple
|
|
.\"remote machines.
|
|
.TP
|
|
[ENAMETOOLONG]
|
|
The length of the
|
|
.I path
|
|
argument exceeds
|
|
.IR {PATH_MAX} ,
|
|
or a pathname component is longer than
|
|
.IR {NAME_MAX} .
|
|
.TP
|
|
[EACCES]
|
|
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
|
|
[EEXIST]
|
|
The named file
|
|
already exists.
|
|
.TP
|
|
[EROFS]
|
|
The path prefix resides
|
|
on a read-only filesystem.
|
|
.TP
|
|
[EFAULT]
|
|
.I Path
|
|
points outside the allocated address space of the process.
|
|
.TP
|
|
[ELOOP]
|
|
Too many symbolic links were encountered in translating
|
|
.IR path .
|
|
.TP
|
|
[EMLINK]
|
|
The maximum number of links to the parent directory would
|
|
exceed
|
|
.IR {LINK_MAX} .
|
|
.TP
|
|
[ENOSPC]
|
|
The directory in which the entry for the new directory is being placed
|
|
cannot be extended because there is no space left on the filesystem
|
|
containing the directory or
|
|
the new directory cannot be created because
|
|
there is no space left on the filesystem
|
|
that will contain the directory or
|
|
there are no free inodes on the filesystem on which the
|
|
directory is being created.
|
|
.TP
|
|
[EDQUOT]
|
|
The directory in which the entry for the new directory
|
|
is being placed cannot be extended either because the
|
|
user's quota of disk blocks on the filesystem
|
|
containing the directory has been exhausted or
|
|
the new directory cannot be created because the user's
|
|
quota of disk blocks on the filesystem that will
|
|
contain the directory has been exhausted or
|
|
the user's quota of inodes on the filesystem on
|
|
which the directory is being created has been exhausted.
|
|
.TP
|
|
[EIO]
|
|
An I/O error has occurred while accessing the filesystem.
|
|
.SH SEE ALSO
|
|
mkdir(1),
|
|
chmod(2),
|
|
mknod(2),
|
|
umask(2),
|
|
unlink(2),
|
|
fstab(4),
|
|
stat(5)
|
|
.SH DIAGNOSTICS
|
|
Upon successful completion, a value of 0 is returned.
|
|
Otherwise, a value of -1 is returned, and
|
|
.I errno
|
|
is set to indicate the error.
|