mkdir
Purpose
Creates a directory.
Syntax
int mkdir (path, mode)
char *path;
int mode;
Description
The mkdir system call creates a new directory. The path
parameter names the new directory. If Distributed Ser-
vices is installed on your system, this path can cross
into another node. In this case, the new directory is
created at that node.
To execute the mkdir system call, a process must have
search permission to get to the parent directory of path
and write permission in the parent directory.
The mode parameter is the mask for the read, write, and
execute (rwx) flags for owner, group, and others. The
low-order 9 bits in mode are modified by the file mode
creation mask of the process. All bits set in the cre-
ation mask are cleared. (For more information about the
creation mask, see "umask.")
Return Value
Upon successful completion, the mkdir system call returns
a value of 0. If the mkdir system call fails, a value of
-1 is returned, and errno is set to indicate the error.
Diagnostics
The mkdir system call fails and the directory is not
created if one or more of the following are true:
ENOTDIR A component of the path is not a directory.
ENOENT A component of the path does not exist.
EACCES Creating the requested directory requires
writing in a directory with a mode that denies
write permission.
EACCES Search permission is denied for a component of
the path.
EROFS The named file resides on a read-only file
system.
EEXIST The named file already exists.
EFAULT The path parameter points outside of the proc-
ess's allocated address space.
EIO An I/O error occurred while writing to the
file system.
ESTALE The process's root or current directory is
located in a virtual file system that has been
unmounted.
If Distributed Services is installed on your system,
mkdir can also fail if one or more of the following are
true:
EDIST The server has blocked new inbound
requests.
EDIST Outbound requests are currently blocked.
EDIST The server has a release level of Distrib-
uted Services that cannot communicate with
this node.
EAGAIN The server is too busy to accept the
request.
ESTALE The file descriptor for a remote file has
become obsolete.
EPERM The translate tables of the server did not
contain any entry for either the effective
user ID or effective group ID of the
calling process.
ENODEV The named file is a remote file located on
a device that has been unmounted at the
server.
ENOMEM Either this node or the server does not
have enough memory available to service the
request.
ENOCONNECT An attempt to establish a new network con-
nection with a remote node failed.
EBADCONNECT An attempt to use an existing network con-
nection with a remote node failed.
Related Information
In this book: "chmod," "mknod," "rename," "rmdir,"
and "umask."