|
|
1.1 ! root 1: /* Copyright (c) 1982 Regents of the University of California */ ! 2: ! 3: static char sccsid[] = "@(#)seekdir.c 4.3 2/25/82"; ! 4: ! 5: #include <sys/types.h> ! 6: #include <ndir.h> ! 7: ! 8: /* ! 9: * seek to an entry in a directory. ! 10: * Only values returned by ``telldir'' should be passed to seekdir. ! 11: */ ! 12: void ! 13: seekdir(dirp, loc) ! 14: register DIR *dirp; ! 15: long loc; ! 16: { ! 17: long curloc, base, offset; ! 18: struct direct *dp; ! 19: ! 20: curloc = telldir(dirp); ! 21: if (loc == curloc) ! 22: return; ! 23: base = loc & ~(DIRBLKSIZ - 1); ! 24: offset = loc & (DIRBLKSIZ - 1); ! 25: if (dirp->dd_loc != 0 && (curloc & ~(DIRBLKSIZ - 1)) == base) { ! 26: dirp->dd_loc = offset; ! 27: return; ! 28: } ! 29: lseek(dirp->dd_fd, base, 0); ! 30: dirp->dd_loc = 0; ! 31: while (dirp->dd_loc < offset) { ! 32: dp = readdir(dirp); ! 33: if (dp == NULL) ! 34: return; ! 35: } ! 36: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.