Annotation of 43BSD/lib/libc/gen/seekdir.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1983 Regents of the University of California.
                      3:  * All rights reserved.  The Berkeley software License Agreement
                      4:  * specifies the terms and conditions for redistribution.
                      5:  */
                      6: 
                      7: #if defined(LIBC_SCCS) && !defined(lint)
                      8: static char sccsid[] = "@(#)seekdir.c  5.2 (Berkeley) 3/9/86";
                      9: #endif LIBC_SCCS and not lint
                     10: 
                     11: #include <sys/param.h>
                     12: #include <sys/dir.h>
                     13: 
                     14: /*
                     15:  * seek to an entry in a directory.
                     16:  * Only values returned by "telldir" should be passed to seekdir.
                     17:  */
                     18: void
                     19: seekdir(dirp, loc)
                     20:        register DIR *dirp;
                     21:        long loc;
                     22: {
                     23:        long curloc, base, offset;
                     24:        struct direct *dp;
                     25:        extern long lseek();
                     26: 
                     27:        curloc = telldir(dirp);
                     28:        if (loc == curloc)
                     29:                return;
                     30:        base = loc & ~(DIRBLKSIZ - 1);
                     31:        offset = loc & (DIRBLKSIZ - 1);
                     32:        (void) lseek(dirp->dd_fd, base, 0);
                     33:        dirp->dd_loc = 0;
                     34:        while (dirp->dd_loc < offset) {
                     35:                dp = readdir(dirp);
                     36:                if (dp == NULL)
                     37:                        return;
                     38:        }
                     39: }

unix.superglobalmegacorp.com

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