mkdir(2P) INTERACTIVE UNIX System (POSIX) mkdir(2P)
NAME
mkdir - make a directory
SYNOPSIS
#include <sys/types.h>
#include <sys/stat.h>
int mkdir (path, mode)
char *path; mode_t mode;
DESCRIPTION
The routine mkdir creates a new directory with the name
path. The argument mode specifies the initial mode of the
new directory. The protection bits of the argument mode are
modified by the process file mode creation mask (see
umask(2P)). The value of the argument mode should be the
logical OR of the values of the desired permissions:
Name Description
S_IREAD Read by owner
S_IWRITE Write by owner
S_IEXEC Execute (search) by owner
S_IRGRP Read by group
S_IWGRP Write by group
S_IXGRP Execute (search) by group
S_IROTH Read by others (i.e., anyone else)
S_IWOTH Write by others
S_IXOTH Execute (search) by others
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 to the group ID of the directory in
which the directory is being created.
The newly created directory is empty with the possible
exception of entries for `` . '' and ``..''. mkdir will
fail and no directory will be created if one or more of the
following is true:
[ENOTDIR] A component of the path prefix is not a
directory.
[ENOENT] A component of the path prefix does not
exist.
Rev. 1.1 Page 1
mkdir(2P) INTERACTIVE UNIX System (POSIX) mkdir(2P)
[ENOLINK] The path variable points to a remote machine
and the link to that machine is no longer
active.
[EMULTIHOP] Components of path require hopping to multi-
ple remote machines.
[EACCES] Either a component of the path prefix denies
search permission, or write permission is
denied on the parent directory of the direc-
tory to be created.
[ENOENT] The path is longer than the maximum allowed.
[EEXIST] The named file already exists.
[EROFS] The path prefix resides on a read-only file
system.
[EFAULT] path points outside the allocated address
space of the process.
[EMLINK] The maximum number of links to the parent
directory would be exceeded.
[EIO] An I/O error has occurred while accessing the
file system.
[ENAMETOOLONG] The length of the path argument exceeds
{PATH_MAX}, or a path name component is
longer than {NAME_MAX} while
{_POSIX_NO_TRUNC} is in effect.
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Oth-
erwise, a value of -1 is returned, and errno is set to indi-
cate the error.
Rev. 1.1 Page 2