rewinddir.c 568 B

12345678910111213141516171819202122232425
  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 <unistd.h>
  9. #include "dirstream.h"
  10. libc_hidden_proto(lseek)
  11. /* rewinddir() just does an lseek(fd,0,0) - see close for comments */
  12. void rewinddir(DIR * dir)
  13. {
  14. if (!dir) {
  15. __set_errno(EBADF);
  16. return;
  17. }
  18. __UCLIBC_MUTEX_LOCK(dir->dd_lock);
  19. lseek(dir->dd_fd, 0, SEEK_SET);
  20. dir->dd_nextoff = dir->dd_nextloc = dir->dd_size = 0;
  21. __UCLIBC_MUTEX_UNLOCK(dir->dd_lock);
  22. }