rewinddir.c 543 B

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