Annotation of researchv10no/cmd/asd/seekdir.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.