Back to index

glibc  2.9
Defines | Functions
getwd.c File Reference
#include <errno.h>
#include <limits.h>
#include <string.h>
#include <unistd.h>

Go to the source code of this file.


#define PATH_MAX   1024


char * getwd (char *buf)

Define Documentation

#define PATH_MAX   1024

Function Documentation

char* getwd ( char *  buf)

Definition at line 27 of file getwd.c.

#ifndef PATH_MAX
#define PATH_MAX 1024
  char tmpbuf[PATH_MAX];

  if (buf == NULL)
      __set_errno (EINVAL);
      return NULL;

  if (__getcwd (tmpbuf, PATH_MAX) == NULL)
      /* We use 1024 here since it should really be enough and because
        this is a safe value.  */
      __strerror_r (errno, buf, 1024);
      return NULL;

  /* This is completely unsafe.  Nobody can say how big the user
     provided buffer is.  Perhaps the application and the libc
     disagree about the value of PATH_MAX.  */
  return strcpy (buf, tmpbuf);

Here is the call graph for this function: