seekdir.c 493 B

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