mkdir()

create new directory 

Function


SYNOPSIS

#include <sys/types.h>

#include <sys/stat.h>

int mkdir(const char *pathname, mode_t mode);


DESCRIPTION

The mkdir() function creates a new directory with the specified path name. The file permissions of the new directory are initialized from the specified mode. The file permission bits of the mode argument are modified by the process' file creation mask. When bits in the specified mode other than the file permission bits are set, the behavior is undefined.

The directory's user ID is set to the process' effective user ID. The directory's group ID is set to the group ID of the parent directory or to the effective group ID of the process.

The newly-created directory is an empty directory.

Upon successful completion, mkdir() marks for update the st_atime, st_ctime and st_mtime fields of the directory.


PARAMETERS

pathname 

Specifies the name of the new directory. The path name can be absolute or relative. If the specified path name is relative, the directory is created based upon your current working directory.

mode 

Is a bitwise-OR field that specifies what permissions the directory has when it is created.


RETURN VALUES

If successful, mkdir() returns a value of zero. On failure, it returns a value of -1, does not create a directory, and sets errno to one of the following values:

EACCES 

Search permission is denied on a component of the path name prefix or write permission is denied on the parent directory of the directory to be created.

EEXIST 

The named file already exists.

EFAULT 

pathname is an invalid pointer.

EIO 

While accessing the file system, an I/O error occurred.

EMLINK 

The link count of the parent directory exceeds LINK_MAX.

ENAMETOOLONG 

The length of the pathname parameter exceeds PATH_MAX or a path name component is longer than NAME_MAX.

ENOENT 

A component of the path name prefix does not exist or is a null path name.

ENOSPC 

The file system does not contain enough space to hold the contents of the new directory or to extend the parent directory of he new directory.

ENOTDIR 

A component of the path name prefix is not a directory.

EROFS 

The parent directory of the directory being created resides on a read-only file system.


CONFORMANCE

POSIX.1 (1996)


MULTITHREAD SAFETY LEVEL

Async-signal-safe.


PORTING ISSUES

None.


AVAILABILITY

MKS Toolkit for Professional Developers
MKS Toolkit for Enterprise Developers
MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
chdir(), chmod(), stat(), umask()


MKS Toolkit 9.5 Documentation Build 3.