HPlogo MPE/iX Developer's Kit Reference Manual Volume I: HP 3000 MPE/iX Computer Systems > Chapter 4  POSIX/iX Library Function Descriptions

mkdir

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Creates a directory.

Syntax

   #include <sys/types.h>

   #include <sys/stat.h>

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

Parameters

pathname

A pointer to a string containing the pathname of the directory to be created. The pathname must be terminated by a null character.

mode

The access permission bits for the new directory. Access permission bits are set by ORing any combination of the following macros:

S_IRWXU

Set file owner class read, write, and execute (if a file) or search (if a directory) permission bits.

S_IRUSR

Set file owner class read permission bit.

S_IWUSR

Set file owner class write permission bit.

S_IXUSR

Set file owner class execute (if a file) or search (if a directory) permission bit.

S_IRWXG

Set file group class read, write, and execute (if a file) or search (if a directory) permission bits.

S_IRGRP

Set file group class read permission bit.

S_IWGRP

Set file group class write permission bit.

S_IXGRP

Set file group class execute (if a file) or search (if a directory) permission bit.

S_IRWXO

Set file other class read, write, and execute (if a file), or search (if a directory) permission bits.

S_IROTH

Set file other class read permission bit.

S_IWOTH

Set file other class write permission bit.

S_IXOTH

Set file other class execute (if a file) or search (if a directory) permission bit.

Unused bits of the mode parameter not associated with access permissions must contain zeros or an error occurs.

Return Values

0

Success.

-1

An error occurred. The new directory is not created, and errno is set to indicate the error condition.

Description

The mkdir() function creates a new directory file whose name is specified in the pathname parameter. The newly created directory is an empty directory containing only the directory entries dot (. ) and dot-dot (.. ).

The access permission bits of the new directory are initialized from mode and modified by the calling process's file creation mask. The directory's UID is set to the calling process's effective UID. The directory's GID is set to the parent directory's GID.

The mkdir() function marks for update the st_atime, st_ctime, and st_mtime time fields of the newly created directory. In addition, mkdir() marks for update the st_ctime and st_mtime time fields of the parent directory.

Implementation Considerations

Refer to the EFAULT, EIMPL, ENOSPC, and ESYSERR error descriptions below.

The S_ISUID and S_ISGID bits are not currently supported.

The mkdir() function requires that the calling process have

  • write permission to the parent directory

  • search permission to each directory component of the pathname

  • MPE/iX save files (SF) capability

The mkdir() function cannot create the root directory, MPE/iX accounts, or MPE/iX groups.

The mkdir() function does not support read-only file systems.

Errors

If an error occurs, errno is set to one of the following values:

EACCESCAUSE The calling process does not have search permission to a component of the pathname, or does not have write permission to the parent directory.
 ACTION Make sure that the calling process has search permission for all components of the pathname and write permission to the parent directory.
EEXISTCAUSE The directory specified in pathname already exists.
 ACTION Make sure that pathname specifies a directory that does not already exist.
EFAULTCAUSE The system detected a NULL or bad address in attempting to use the pathname parameter, or the pathname was not terminated by a null character.
 ACTION Make sure that the pointer is correctly initialized.
EIMPLCAUSE

Any of the following conditions:

  • Attempted to create a directory in an MPE/iX account.

  • The directory name exceeded 16 characters in length in the root directory, an MPE/iX account, or an MPE/iX group.

  • The pathname begins with two slash characters (//).

  • Bits of mode that are not file permission bits do not contain zeros.

 ACTION

One of the following:

  • Do not create a directory in an MPE/iX account.

  • Make sure that the directory name does not exceed 16 characters in length when in the root directory, an MPE/iX account, or an MPE/iX group.

  • Do not begin a pathname with two slash characters (//).

  • Make sure that bits of mode that are not file permission bits contain zeros.

ENAMETOOLONGCAUSE

One of the following:

  • The length of the pathname exceeds the {PATH_MAX} limit (defined in the file <limits.h>).

  • A component of the pathname is longer than {NAME_MAX} (defined in <limits.h>), and {_POSIX_NO_TRUNC} is in effect for that directory.

 ACTION Make sure that both the component's length and the full pathname length do not exceed the {NAME_MAX} or {PATH_MAX} limits.
ENOENTCAUSE A component of the pathname does not exist, or pathname points to an empty string.
 ACTION Specify a valid pathname.
ENOSPCCAUSE The directory could not be created because of a lack of disk space, or the process owner would have exceeded limits imposed by the MPE/iX accounting facility.
 ACTION Make sure that there is enough space to create the directory on the volume set, or ask your system administrator to increase your accounting limits.
ENOTDIRCAUSE A component of the pathname is not a directory.
 ACTION Specify a valid pathname.
ESYSERRCAUSE An operating system error has occurred that does not map directly to any of the above errors.
 ACTION Examine the MPE/iX error stack for the type of system error.

See Also

chmod(), stat(), umask(), <sys/stat.h>, POSIX.1 (Section 5.4.1)

Feedback to webmaster