MKDIR(2) SysV MKDIR(2)
NAME
mkdir - make a directory
SYNOPSIS
#include <sys/stat.h>
#include <sys/types.h>
int mkdir (path, mode)
const char *path;
mode_t mode;
DESCRIPTION
The routine mkdir creates a new directory with the name path. The mode of
the new directory is initialized from the mode. The protection part of
the mode argument is modified by the process' mode mask (see umask(2)).
If the final component of the path argument refers to a symbolic link,
the link is traversed and pathname resolution continues.
The directory's owner ID is set to the process' effective user ID. If
the node is configured in a FIPS compliant mode of operation, the
directory's group ID is set to that of the parent directory in which it
is created. Otherwise, the group ID is set to the process' effective
group ID.
Upon successful completion, the mkdir() function marks the st_atime,
st_ctime, and st_mtime fields of the directory for update, and marks the
st_ctime and st_mtime fields of the new directory's parent directory for
update.
ERRORS
mkdir will fail and no directory will be created if one or more of the
following are true:
[ENOTDIR] A component of the path prefix is not a directory.
[ENOENT] A component of the path argument does not exist or points
to an empty string.
[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.
[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.
[EIO] An I/O error has occurred while accessing the file system.
[EMLINK] The link count of the parent directory would exceed
LINK_MAX.
[ENAMETOOLONG]
The length of the path argument exceeds PATH_MAX or a
pathname component is longer than NAME_MAX.
[ENOTDIR] A component of the path prefix is not a directory.
[ENOSPC] The file system does not contain enough space to hold the
contents of the new directory or to extend the parent
directory of the new directory.
[EDQUOT] The directory in which the entry for the new directory is
being placed cannot be extended because the user's quota of
disk blocks on the file system containing the directory has
been exhausted.
[EDQUOT] The new directory cannot be created because the user's
quota of disk blocks on the file system that will contain
the directory has been exhausted.
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Otherwise, a value
of -1 is returned and errno is set as indicated under "Errors."
NOTES
Under other implementations, mkdir fails if any of the following are
true:
[ENOLINK] path points to a remote machine and the link to that
machine is no longer active.
[EMULTIHOP] Components of path require hopping to multiple remote
machines.
SEE ALSO
chmod(2), umask(2), <sys/stat.h>, <sys/types.h>.