mkdir(2)
_________________________________________________________________
mkdir System Call
Create a directory file.
_________________________________________________________________
SYNTAX
#include <sys/types.h>
#include <sys/stat.h>
int mkdir (path, mode)
char * path;
int mode;
PARAMETERS
path Address of a pathname.
mode File mode of the new directory.
DESCRIPTION
<Path> points to a pathname naming a file. If the file does not
already exist, a directory of that name is created. The
indicated file must be on a file system device mounted read-
write. Terminal symbolic links are followed in <path>.
The directory is initialized to contain two entries: '.' and
'..', referring to itself and its parent directory. The
directory's attributes are set as follows:
* The inode number (st_ino) refers to the per-file database
allocated.
* The device number (st_dev) is set to the device code of the
containing logical disk unit.
* The represented device (st_rdev) is undefined.
* The number of links (st_nlink) is set to two. (One for the
directory's own '.' entry, and one for the entry in the
directory's parent.)
* The file size (st_size) is set to reflect the presence of
the '.' and '..' entries.
* The file mode (st_mode) is set as follows: The file type is
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
mkdir(2)
directory. The protection rights are set to the low-order 9
bits of <mode> modified by the process's file mode creation
mask; all bits set in the process's creation mask are
cleared in the directory's mode (see umask). The set-user-
id, set-group-id, and sticky bits are cleared; they have no
meaning for a directory.
* The user id (st_uid) is set to the process's effective user
id. The group id (st_gid) is set to the process's effective
group id.
* The time last accessed (st_atime), time last modified
(st_mtime), and time of last attribute change (st_ctime) are
set to the current time.
<Path> is added to the directory's parent and is made to identify
the newly created directory. The attributes of the parent
directory change as follows:
* The number of links (st_nlink) is incremented, reflecting
the '..' entry in the new directory.
* The time last modified (st_mtime) and time of last attribute
change (st_ctime) are set to the current time.
* The file size (st_size) is updated.
If the call fails, the directory is not created, and the
attributes of the parent remain unchanged.
ACCESS CONTROL
The calling process must have write permission to the parent
directory.
The process must have permission to resolve <path>.
RETURN VALUE
0 The new directory was successfully created.
-1 An error occurred. Errno is set to indicate the
error.
EXCEPTIONS
Errno may be set to one of the following error codes:
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)
mkdir(2)
EEXIST The named file exists.
EIO An I/O error occurred while writing to the file
system device.
EACCES Permission to add an entry to the parent directory
is denied.
EROFS The named file resides on a file system device
mounted read-only.
EMLINK The maximum number of links to the parent
directory would be exceeded by the directory
creation.
ENOSPC No more contiguous space for file space or inodes.
ENOENT The file the pathname resolved to does not exist.
ENOENT A non-terminal component of the pathname does not
exist.
ENOTDIR A non-terminal component of the pathname was not a
directory or symbolic link.
ENAMETOOLONG The pathname exceeds the length limit for
pathnames.
ENAMETOOLONG A component of the pathname exceeds the length
limit for filenames.
ENOMEM There are not enough system resources to resolve
the pathname or to expand a symbolic link.
ELOOP The number of symbolic links encountered during
pathname resolution exceeded MAXSYMLINKS. A
symbolic link cycle is suspected.
DG/UX 4.00 Page 3
Licensed material--property of copyright holder(s)
mkdir(2)
EPERM The pathname contains a character not in the
allowed character set.
EFAULT The pathname does not completely reside in the
process's address space or the pathname does not
terminate in the process's address space.
SEE ALSO
The related manual sections: rmdir(2),
mkdir(1), rmdir(1),
stat(5).
DG/UX 4.00 Page 4
Licensed material--property of copyright holder(s)