Back to index

glibc  2.9
Functions
fdopendir.c File Reference
#include <dirent.h>
#include <errno.h>
#include <hurd.h>
#include <hurd/fd.h>
#include <fcntl.h>

Go to the source code of this file.

Functions

DIR * _hurd_fd_opendir (struct hurd_fd *d)
DIR * __fdopendir (int fd)

Function Documentation

DIR* __fdopendir ( int  fd)

Definition at line 30 of file fdopendir.c.

{
  struct hurd_fd *d = _hurd_fd_get (fd);

  if (d == NULL)
    {
      errno = EBADF;
      return NULL;
    }

  /* Ensure that it's a directory.  */
  error_t err = HURD_FD_PORT_USE
    (d, ({
       file_t dir = __file_name_lookup_under (port, "/",
                                          O_DIRECTORY | O_NOTRANS, 0);;
       if (dir != MACH_PORT_NULL)
         __mach_port_deallocate (__mach_task_self (), dir);
       dir != MACH_PORT_NULL ? 0 : errno;
      }));

  if (err)
    {
      errno = err;
      return NULL;
    }

  return _hurd_fd_opendir (d);
}

Here is the call graph for this function:

DIR* _hurd_fd_opendir ( struct hurd_fd d)

Definition at line 39 of file opendir.c.

{
  DIR *dirp;

  if (d == NULL)
    {
      errno = EBADF;
      return NULL;
    }

  dirp = (DIR *) malloc (sizeof (DIR));
  if (dirp == NULL)
    return NULL;

  /* Set the descriptor to close on exec. */
  __spin_lock (&d->port.lock);
  d->flags |= FD_CLOEXEC;
  __spin_unlock (&d->port.lock);

  dirp->__fd = d;
  dirp->__data = dirp->__ptr = NULL;
  dirp->__entry_data = dirp->__entry_ptr = 0;
  dirp->__allocation = 0;
  dirp->__size = 0;

  __libc_lock_init (dirp->__lock);

  return dirp;
}

Here is the call graph for this function:

Here is the caller graph for this function: