2 #include "../port/lib.h"
7 #include "../port/error.h"
9 typedef union Hblock Hblock;
26 char linkname[NAMSIZ];
30 static int getdir(Hblock *hb, Dir *sp);
31 static int checksum(Hblock *hb);
34 tarlookup(uchar *addr, char *file, int *dlen)
40 while(getdir(hp, &dir) != 0) {
41 if(strcmp(file, hp->dbuf.name) == 0) {
43 return (uchar*)(hp+1);
45 hp += (dir.length+TBLOCK-1)/TBLOCK + 1;
51 getdir(Hblock *hp, Dir *sp)
55 if (hp->dbuf.name[0] == '\0')
57 sp->length = strtol(hp->dbuf.size, 0, 8);
58 sp->mtime = strtol(hp->dbuf.mtime, 0, 8);
59 chksum = strtol(hp->dbuf.chksum, 0, 8);
60 if (chksum != checksum(hp)) {
61 print("directory checksum error\n");
74 for (cp = hp->dummy; cp < &hp->dummy[TBLOCK]; cp++) {
75 if(cp < hp->dbuf.chksum || cp >= &hp->dbuf.chksum[sizeof(hp->dbuf.chksum)])