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

rmdir

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Purges (removes) a directory.

Syntax

   #include <unistd.h>

   int rmdir (const char *pathname);

Parameters

pathname

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

Return Values

0

Success.

-1

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

Description

The rmdir() function purges (removes) the directory specified by pathname. The directory is removed only if it is an empty directory (containing only the dot and dot dot directory entries).

If the link count of the directory becomes zero, and no process has the directory open, the directory is purged from the system and is no longer accessible.

If one or more processes have the directory open when the last link is removed, the dot and dot dot entries are removed before rmdir() returns and no new entries can be created; however, the directory is not purged until all references to the directory have been closed.

Upon successful completion, rmdir() marks for update the st_ctime and st_mtime time fields of the parent directory.

Implementation Considerations

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

The rmdir() function cannot remove the dot and dot dot directory entries, the root directory, MPE/iX accounts, or MPE/iX groups.

Errors

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

EACCESCAUSEThe calling process either does not have search permission to a component of the pathname or does not have write permission to the parent directory.
 ACTIONMake sure that the calling process has search permission to all components of the pathname and write permission to the parent directory.
EFAULTCAUSEThe system detected a NULL or bad address in attempting to use the pathname parameter, or the pathname was not terminated by a null character.
 ACTIONMake sure that the pointer is correctly initialized.
EIMPLCAUSEAn attempt was made to remove the dot or dot dot directory entries, the root directory, an MPE/iX account, or an MPE/iX group; or the pathname began with two slash characters (//).
 ACTIONRemove MPE/iX accounts and MPE/iX groups using MPE/iX CI commands. The root directory can never be removed. Do not begin pathnames with two slash characters (//).
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.

 ACTIONMake sure that both the component's length and the full pathname length do not exceed the {NAME_MAX} or {PATH_MAX} limits.
ENOENTCAUSEThe specified directory does not exist, or pathname points to an empty string.
 ACTIONSpecify a valid pathname.
ENOTDIRCAUSEA component of the pathname is not a directory.
 ACTIONSpecify a valid pathname.
ENOTEMPTYCAUSEThe directory specified by pathname cannot be removed because it is not empty.
 ACTIONMake sure that the directory is an empty directory.
ESYSERRCAUSEAn operating system error has occurred that does not map directly to any of the above errors.
 ACTIONExamine the MPE/iX error stack for the type of system error.

See Also

mkdir(), unlink(), POSIX.1 (Section 5.5.2)

Feedback to webmaster