mkdir(S) 6 January 1993 mkdir(S) Name mkdir - make a directory Syntax cc . . . -lc #include <sys/types.h> #include <sys/stat.h> int mkdir (path, mode) char *path; mode_t mode; Description The routine mkdir creates a new directory with the name path. The argu- ment mode specifies the initial mode of the new directory. The protec- tion bits of the argument mode are modified by the process file mode creation mask (see umask(S)). The value of the argument mode should be the logical OR of the values of the desired permissions: Name Description ________________________________________________ SIEXEC Execute (search) by owner SIREAD Read by owner SIRGRP Read by group SIROTH Read by others (that is, anyone else) SIWGRP Write by group SIWOTH Write by others SIWRITE Write by owner SIXGRP Execute (search) by group SIXOTH Execute (search) by others The directory's owner ID is set to the process's effective user ID. The directory's group ID is set to the process's effective group ID. The newly created directory is empty with the possible exception of entries for ``.'' and ``..'' . mkdir fails and no directory is created if one or more of the following is true: [EACCES] Either a component of the path prefix denies search per- mission, or write permission is denied on the parent directory of the directory to be created. [EEXIST] The named file already exists. [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 maximum number of links to the parent directory would be exceeded. [EMULTIHOP] Components of path require hopping to multiple remote ma- chines. [ENOENT] 1. A component of the path prefix does not exist. 2. The path is longer than the maximum allowed. [ENOLINK] path points to a remote machine and the link to that ma- chine is no longer active. [ENOTDIR] A component of the path prefix is not a directory. [EROFS] The path prefix resides on a read-only file system. Diagnostics Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned, and errno is set to indicate the error. Standards conformance mkdir is conformant with: X/Open Portability Guide, Issue 3, 1989; IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C Language] (ISO/IEC 9945-1); and NIST FIPS 151-1.