## mkdir

#### OS/161 Reference Manual

### Name

mkdir - create directory

### Library

Standard C Library (libc, -lc)

### Synopsis

`#include <sys/stat.h>`
`int`
`mkdir(const char *`pathname`, mode_t` mode`);`

### Description

`mkdir` creates a directory named name, where name is the last filename component in pathname. All the directories named in the prefix portion of pathname must exist and must in fact be directories, not ordinary files. The name name must not already exist. The new directory must be created atomically.

The mode argument gives the file permissions to use and can be ignored in OS/161.

### Return Values

On success, `mkdir` returns 0. On error, -1 is returned, and errno is set according to the error encountered.

### Errors

The following error codes should be returned under the conditions given. Other error codes may be returned for other cases not mentioned here.

| ENODEV | The device prefix of pathname did not exist.
ENOTDIR | A non-final component of pathname was not a directory.
ENOENT | A non-final component of pathname did not exist.
EEXIST | An object by the name pathname already exists.
ENOSPC | The filesystem the directory was to be created on is full.
EIO | A hard I/O error occurred.
EFAULT | pathname was an invalid pointer.
EINVAL | mode was invalid.