Creates a directory.
#include <stat.h> int mkdir (const char *dir_spec, mode_t mode); (ISO POSIX-1) int mkdir (const char *dir_spec, mode_t mode, . . . ); (DEC C Extension)
DBA0:[BAY.WINDOWS] /* OpenVMS */ /dba0/bay/windows /* UNIX style */
This specification cannot contain a node name, file name, file extension, file version, or a wildcard character. The same restriction applies to the UNIX style directory specifications. For more information about the restrictions on UNIX style specifications, see Chapter 1.
The file protection of the new directory is derived from the mode argument, the process's file protection mask (see the umask function), and the parent-directory default protections.
In a manner consistent with the OpenVMS behavior for creating directories, mkdir never applies delete access to the directory. An application that needs to set delete access should use an explicit call to chmod to set write permission.
See the Description section of this function for more information about how the file protection is set for the newly created directory.
If this argument is 0, the DEC C RTL does not place a limit on the maximum number of file versions.
If this argument is not specified, the DEC C RTL gives the created directory the default version limit of the parent directory.
This optional argument is specific to the DEC C RTL and is not portable.
unsigned short r_v_number
The volume (device) on which to place the created directory
if the device is part of a volume set. If this argument is not
specified, the DEC C RTL arbitrarily
places the created directory within the volume set. This optional
argument is specific to the DEC C RTL
and is not portable.
If you do not specify any optional arguments, the DEC C RTL gives the directory your UIC and the default version limit of the parent directory, and arbitrarily places the directory within the volume set. You cannot get the default behavior for the uic or max_versions arguments if you specify any arguments after them.
The file protection supplied by the mode argument is modified by the process's file protection mask in such a way that the file protection for the new directory is set to the bitwise AND of the mode argument and the complement of the file protection mask.
Default file protections are supplied to the new directory from the parent-directory such that if a protection value bit in the new directory is zero, then the value of this bit is inherited from the parent-directory. However, bits in the parent directory's file protection that indicate delete access do not cause corresponding bits to be set in the new directory's file protection.
0 | Indicates success. |
-1 | Indicates failure. |
umask (0002); /* turn world write access off */ mkdir ("sys$disk:[.parentdir.childdir]", 0222); /* turn write access on */ Parent directory file protection: System:RWD, Owner:RWD, Group:R, World:RThe file protection derived from the combination of the mode argument and the file protection mask set by umask is (0222) & ~(0002), which is 0220. When the parent directory defaults are applied to this protection, the protection for the new directory becomes:
File protection: System:RWD, Owner:RWD, Group:RWD, World:R
umask (0000); mkdir ("sys$disk:[.parentdir.childdir]", 0444); /* turn read access on */ Parent directory file protection: System:RWD, Owner:RWD, Group:RWD, World:RWDThe file protection derived from the combination of the mode argument and the file protection mask set by umask is (0444) & ~(0000) which is 0444. When the parent directory defaults are applied to this protection, the protection for the new directory is:
File protection: System:RW, Owner:RW, Group:RW, World:RW
Note that delete access is not inherited.