Initial revision

This commit is contained in:
ceriel
1987-01-27 15:57:55 +00:00
parent ee89196671
commit e49bbfbe1f
112 changed files with 4068 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
#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;
base = loc & ~(DIRBLKSIZ - 1);
offset = loc & (DIRBLKSIZ - 1);
if (dirp->dd_loc != 0 && offset != 0 &&
(curloc & ~(DIRBLKSIZ-1)) == base) {
dirp->dd_loc = offset;
return;
}
(void) lseek(dirp->dd_fd, base, 0);
dirp->dd_loc = 0;
dirp->dd_size = 0;
if (offset == 0)
(void) readdir(dirp);
else {
while (dirp->dd_loc < offset) {
if (readdir(dirp) == (struct direct *) 0)
return;
}
}
}