Back to index

glibc  2.9
closedir.c File Reference
#include <errno.h>
#include <stddef.h>
#include <stdlib.h>
#include <dirent.h>
#include <unistd.h>
#include <hurd.h>
#include <hurd/fd.h>
#include "dirstream.h"

Go to the source code of this file.


int __closedir (DIR *dirp)

Function Documentation

int __closedir ( DIR *  dirp)

Definition at line 31 of file closedir.c.

  error_t err;

  if (dirp == NULL)
      errno = EINVAL;
      return -1;

  __libc_lock_lock (dirp->__lock);
  err = __vm_deallocate (__mach_task_self (),
                      (vm_address_t) dirp->__data, dirp->__allocation);
  dirp->__data = NULL;
  err = _hurd_fd_close (dirp->__fd);

  if (err)
      /* Unlock the DIR.  A failing closedir can be repeated (and may fail
        again, but shouldn't deadlock).  */
      __libc_lock_unlock (dirp->__lock);
      return __hurd_fail (err);

  /* Clean up the lock and free the structure.  */
  __libc_lock_fini (dirp->__lock);
  free (dirp);

  return 0;

Here is the call graph for this function: