Back to index

glibc  2.9
Functions
hurdchdir.c File Reference
#include <errno.h>
#include <unistd.h>
#include <hurd.h>
#include <hurd/port.h>
#include <hurd/fd.h>
#include <fcntl.h>
#include <string.h>

Go to the source code of this file.

Functions

int _hurd_change_directory_port_from_name (struct hurd_port *portcell, const char *name)

Function Documentation

int _hurd_change_directory_port_from_name ( struct hurd_port portcell,
const char *  name 
)

Definition at line 29 of file hurdchdir.c.

{
  size_t len;
  const char *lookup;
  file_t dir;

  /* Append trailing "/." to directory name to force ENOTDIR if it's not a
     directory and EACCES if we don't have search permission.  */
  len = strlen (name);
  if (len >= 2 && name[len - 2] == '/' && name[len - 1] == '.')
    lookup = name;
  else
    {
      char *n = alloca (len + 3);
      memcpy (n, name, len);
      n[len] = '/';
      n[len + 1] = '.';
      n[len + 2] = '\0';
      lookup = n;
    }

  dir = __file_name_lookup (lookup, 0, 0);
  if (dir == MACH_PORT_NULL)
    return -1;

  _hurd_port_set (portcell, dir);
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function: