getcwd

OS/161 Reference Manual

Name

getcwd - get name of current working directory

Library

Standard C Library (libc, -lc)

Synopsis

#include <unistd.h>

char *
getcwd(char *buf, size_t buflen);

Description

The name of the current directory is computed and stored in buf, an area of size buflen. The resulting string is 0-terminated.

This call is a wrapper (for Unix compatibility) around the system call __getcwd.

Note, however, that the BSD extension whereby space is allocated with malloc if buf is NULL is not supported.

Return Values

On success, getcwd returns buf. On error, NULL 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 errors not mentioned here.
  
ENOENT A component of the pathname no longer exists.
EIO A hard I/O error occurred.
EFAULT buf points to an invalid address.