dirfd.c 353 B

123456789101112131415161718192021
  1. /*
  2. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  3. *
  4. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  5. */
  6. #include <dirent.h>
  7. #include <errno.h>
  8. #include "dirstream.h"
  9. int dirfd(DIR * dir)
  10. {
  11. if (!dir || dir->dd_fd == -1) {
  12. __set_errno(EBADF);
  13. return -1;
  14. }
  15. return dir->dd_fd;
  16. }
  17. libc_hidden_def(dirfd)