Annotation of 42BSD/lib/libc/gen/seekdir.c, revision 1.1

1.1     ! root        1: #ifndef lint
        !             2: static char sccsid[] = "@(#)seekdir.c  4.10 (Berkeley) 7/1/83";
        !             3: #endif
        !             4: 
        !             5: #include <sys/param.h>
        !             6: #include <sys/dir.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:        extern long lseek();
        !            20: 
        !            21:        curloc = telldir(dirp);
        !            22:        if (loc == curloc)
        !            23:                return;
        !            24:        base = loc & ~(DIRBLKSIZ - 1);
        !            25:        offset = loc & (DIRBLKSIZ - 1);
        !            26:        (void) lseek(dirp->dd_fd, base, 0);
        !            27:        dirp->dd_loc = 0;
        !            28:        while (dirp->dd_loc < offset) {
        !            29:                dp = readdir(dirp);
        !            30:                if (dp == NULL)
        !            31:                        return;
        !            32:        }
        !            33: }

unix.superglobalmegacorp.com

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