seekdir.c 422 B

123456789101112131415161718192021
  1. #include <dirent.h>
  2. #include <errno.h>
  3. #include <unistd.h>
  4. #include "dirstream.h"
  5. void seekdir(DIR * dir, long int offset)
  6. {
  7. if (!dir) {
  8. __set_errno(EBADF);
  9. return;
  10. }
  11. #ifdef __UCLIBC_HAS_THREADS__
  12. pthread_mutex_lock(&(dir->dd_lock));
  13. #endif
  14. dir->dd_nextoff = lseek(dir->dd_fd, offset, SEEK_SET);
  15. dir->dd_size = dir->dd_nextloc = 0;
  16. #ifdef __UCLIBC_HAS_THREADS__
  17. pthread_mutex_unlock(&(dir->dd_lock));
  18. #endif
  19. }