seekdir.c 518 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. libc_hidden_proto(lseek)
  11. void seekdir(DIR * dir, long int offset)
  12. {
  13. if (!dir) {
  14. __set_errno(EBADF);
  15. return;
  16. }
  17. __UCLIBC_MUTEX_LOCK(dir->dd_lock);
  18. dir->dd_nextoff = lseek(dir->dd_fd, offset, SEEK_SET);
  19. dir->dd_size = dir->dd_nextloc = 0;
  20. __UCLIBC_MUTEX_UNLOCK(dir->dd_lock);
  21. }