The mkdir() function shall create a new directory with name path.
The file permission bits of the new directory shall be initialized from
mode. These file permission bits of the mode argument shall be
modified by the process' file creation mask.
When bits in mode other than the file permission bits are set, the
meaning of these additional bits is implementation-defined.
The directory's user ID shall be set to the process' effective user ID. The
directory's group ID shall be set to the group ID of the parent directory or
to the effective group ID of the process. Implementations shall provide a way
to initialize the directory's group ID to the group ID of the parent
directory. Implementations may, but need not, provide an
implementation-defined way to initialize the directory's group ID to the
effective group ID of the calling process.
The newly created directory shall be an empty directory.
If path names a symbolic link, mkdir() shall fail and set
errno to [EEXIST].
Upon successful completion, mkdir() shall mark for update the
st_atime, st_ctime, and st_mtime fields of the directory.
Also, the st_ctime and st_mtime fields of the directory that
contains the new entry shall be marked for update.
The mkdir() function originated in 4.2 BSD and was added to System V in
4.3 BSD detects [ENAMETOOLONG].
The POSIX.1-1990 standard required that the group ID of a newly created
directory be set to the group ID of its parent directory or to the effective
group ID of the creating process. FIPS 151-2 required that implementations
provide a way to have the group ID be set to the group ID of the containing
directory, but did not prohibit implementations also supporting a way to set
the group ID to the effective group ID of the creating process. Conforming
applications should not assume which group ID will be used. If it matters, an
application can use chown() to set the group ID after the directory is
created, or determine under what conditions the implementation will set the
desired group ID.
Portions of this text are reprinted and reproduced in electronic form from IEEE
Std 1003.1, 2003 Edition, Standard for Information Technology -- Portable
Operating System Interface (POSIX), The Open Group Base Specifications Issue
6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics
Engineers, Inc and The Open Group. In the event of any discrepancy between
this version and the original IEEE and The Open Group Standard, the original
IEEE and The Open Group Standard is the referee document. The original
Standard can be obtained online at http://www.opengroup.org/unix/online.html