dirfd.c 384 B

12345678910111213141516171819202122
  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. /* libc_hidden_proto(dirfd) */
  10. int dirfd(DIR * dir)
  11. {
  12. if (!dir || dir->dd_fd == -1) {
  13. __set_errno(EBADF);
  14. return -1;
  15. }
  16. return dir->dd_fd;
  17. }
  18. libc_hidden_def(dirfd)