rewinddir.c 427 B

12345678910111213141516171819
  1. #include <dirent.h>
  2. #include <errno.h>
  3. #include <unistd.h>
  4. #include "dirstream.h"
  5. libc_hidden_proto(lseek)
  6. /* rewinddir() just does an lseek(fd,0,0) - see close for comments */
  7. void rewinddir(DIR * dir)
  8. {
  9. if (!dir) {
  10. __set_errno(EBADF);
  11. return;
  12. }
  13. __pthread_mutex_lock(&(dir->dd_lock));
  14. lseek(dir->dd_fd, 0, SEEK_SET);
  15. dir->dd_nextoff = dir->dd_nextloc = dir->dd_size = 0;
  16. __pthread_mutex_unlock(&(dir->dd_lock));
  17. }