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

chdir

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Changes the current working directory.

Syntax

   #include <unistd.h>

   int chdir (const char *pathname);

Parameters

pathname

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

Return Values

0

Success.

-1

An error occurred. The current working directory is not changed, and errnois set to indicate the error condition.

Description

The chdir() function causes the directory specified by pathname to be the current working directory of the calling process. The current working directory is the directory used by a process in resolving pathnames not beginning with a slash character (/).

If chdir() fails, the current working directory remains unchanged and a -1 is returned.

Implementation Considerations

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

The chdir() function does not affect the logon MPE/iX group or MPE/iX account against which CPU and connect time are accumulated, nor does chdir() alter the set of accessible files.

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.
 ACTION Make sure that the calling process has search permission to all components of the pathname.
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 The pathname begins with two slash characters (//).
 ACTION 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.

 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 The specified directory does not exist or pathname points to an empty string.
 ACTION Specify an existing directory name.
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

getcwd(), POSIX.1 (Section 5.2.1)

Feedback to webmaster