8 * File system for tar tapes (read-only)
12 #define NBLOCK 40 /* maximum blocksize */
13 #define DBLOCK 20 /* default blocksize */
28 char linkname[TNAMSIZ];
38 long blkno, isabs, chksum, linkflg;
41 tapefile = open(name, OREAD);
43 error("Can't open argument file");
46 seek(tapefile, TBLOCK*blkno, 0);
47 if (read(tapefile, dblock.dummy, sizeof(dblock.dummy))<sizeof(dblock.dummy))
49 if (dblock.dbuf.name[0]=='\0')
52 f.mode = strtoul(dblock.dbuf.mode, 0, 8);
53 f.uid = strtoul(dblock.dbuf.uid, 0, 8);
54 f.gid = strtoul(dblock.dbuf.gid, 0, 8);
55 if((uchar)dblock.dbuf.size[0] == 0x80)
56 f.size = b8byte(dblock.dbuf.size+3);
58 f.size = strtoull(dblock.dbuf.size, 0, 8);
59 f.mdate = strtoul(dblock.dbuf.mtime, 0, 8);
60 chksum = strtoul(dblock.dbuf.chksum, 0, 8);
61 /* the mode test is ugly but sometimes necessary */
62 if (dblock.dbuf.linkflag == '5'
63 || (f.mode&0170000) == 040000
64 || strrchr(dblock.dbuf.name, '\0')[-1] == '/'){
69 linkflg = dblock.dbuf.linkflag=='s' || dblock.dbuf.linkflag=='1';
70 isabs = dblock.dbuf.name[0]=='/';
71 if (chksum != checksum()){
72 fprint(1, "bad checksum on %.28s\n", dblock.dbuf.name);
76 /*fprint(2, "link %s->%s skipped\n", dblock.dbuf.name,
77 dblock.dbuf.linkname);*/
82 f.name = dblock.dbuf.name+isabs;
84 fprint(1, "null name skipped\n");
87 blkno += 1 + (f.size+TBLOCK-1)/TBLOCK;
104 doread(Ram *r, vlong off, long cnt)
106 seek(tapefile, TBLOCK*r->addr+off, 0);
107 if (cnt>sizeof(dblock.tbuf))
108 error("read too big");
109 read(tapefile, dblock.tbuf, cnt);
120 dowrite(Ram *r, char *buf, long off, long cnt)
122 USED(r); USED(buf); USED(off); USED(cnt);
138 for (cp = dblock.dbuf.chksum; cp < &dblock.dbuf.chksum[sizeof(dblock.dbuf.chksum)]; cp++)
141 for (cp = dblock.dummy; cp < &dblock.dummy[TBLOCK]; cp++)