1994-06-24 14:02:31 +00:00
|
|
|
/* $Id$ */
|
1987-01-27 15:57:55 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/dir.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* seek to an entry in a directory.
|
|
|
|
* Only values returned by "telldir" should be passed to seekdir.
|
|
|
|
*/
|
|
|
|
seekdir(dirp, loc)
|
|
|
|
register DIR *dirp;
|
|
|
|
long loc;
|
|
|
|
{
|
|
|
|
long curloc, base, offset;
|
|
|
|
extern long telldir();
|
|
|
|
extern struct direct *readdir();
|
|
|
|
|
|
|
|
curloc = telldir(dirp);
|
|
|
|
if (loc == curloc)
|
|
|
|
return;
|
1987-02-24 13:10:59 +00:00
|
|
|
offset = loc % dirp->dd_bsize;
|
|
|
|
base = loc - offset;
|
1987-03-27 15:11:06 +00:00
|
|
|
if (dirp->dd_loc != -1 &&
|
1987-02-24 13:10:59 +00:00
|
|
|
(curloc - (curloc % dirp->dd_bsize)) == base) {
|
1987-01-27 15:57:55 +00:00
|
|
|
dirp->dd_loc = offset;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
(void) lseek(dirp->dd_fd, base, 0);
|
1987-03-27 15:11:06 +00:00
|
|
|
dirp->dd_loc = -1;
|
1987-01-27 15:57:55 +00:00
|
|
|
dirp->dd_size = 0;
|
1987-02-24 13:10:59 +00:00
|
|
|
while (dirp->dd_loc < offset) {
|
|
|
|
if (readdir(dirp) == (struct direct *) 0)
|
|
|
|
return;
|
1987-01-27 15:57:55 +00:00
|
|
|
}
|
|
|
|
}
|