mkdir(2) mkdir(2) NAME mkdir - make a directory C SYNOPSIS #include <sys/types.h> #include <sys/stat.h> int mkdir (const char *path, mode_t mode); DESCRIPTION mkdir creates a new directory with the name path. The mode of the new directory is initialized from mode (see chmod(2) for values of mode]. The protection part of mode is modified by the process's mode mask (see umask(2)). The S_ISGID, S_ISUID, and S_ISVTX bits are silently deleted from mode. 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 or the group ID of the directory in which the directory is being created. This is determined as follows: If the underlying filesystem was mounted with the BSD file creation semantics flag (see fstab(4)) or the S_ISGID bit is set (see chmod(2)) on the parent directory, then the group ID of the new is set to the group ID of the parent directory, otherwise it is set to the effective group ID of the calling process. The newly created directory is empty with the possible exception of entries for itself (.) and its parent directory (..). Upon successful completion, mkdir marks 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 are marked for update. mkdir will fail and no directory will be created if one or more of the following are true: [ENOTDIR] A component of the path prefix is not a directory. [ENOENT] A component of the path prefix does not exist. [ENAMETOOLONG] The length of the path argument exceeds {PATH_MAX}, or a pathname component is longer than {NAME_MAX}. [EACCES] Either a component of the path prefix denies search permission or write permission is denied on the parent directory of the directory to be created. [EEXIST] The named file already exists. [EROFS] The path prefix resides on a read-only filesystem. [EFAULT] Path points outside the allocated address space of the process. [ELOOP] Too many symbolic links were encountered in translating path. [EMLINK] The maximum number of links to the parent directory would exceed {LINK_MAX}. [ENOSPC] The directory in which the entry for the new directory is being placed cannot be extended because there is no space left on the filesystem containing the directory or the new directory cannot be created because there is no space left on the filesystem that will contain the directory or there are no free inodes on the filesystem on which the directory is being created. [EDQUOT] The directory in which the entry for the new directory is being placed cannot be extended either because the user's quota of disk blocks on the filesystem containing the directory has been exhausted or the new directory cannot be created because the user's quota of disk blocks on the filesystem that will contain the directory has been exhausted or the user's quota of inodes on the filesystem on which the directory is being created has been exhausted. [EIO] An I/O error has occurred while accessing the filesystem. SEE ALSO 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. Page 2