seekdir.c 351 B

12345678910111213141516
  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. __pthread_mutex_lock(&(dir->dd_lock));
  12. dir->dd_nextoff = lseek(dir->dd_fd, offset, SEEK_SET);
  13. dir->dd_size = dir->dd_nextloc = 0;
  14. __pthread_mutex_unlock(&(dir->dd_lock));
  15. }