seekdir.c 377 B

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