9fans archive / 1996 / 04 / 14 / prev next
From: scott@ang... scott@ang...
Subject: No subject
Date: Sun, 7 Apr 1996 00:49:30 -0500
tarfs reports checksum errors on some tarfiles (generated by gnutar, I think),
because it computes the checksum over all TBLOCK chars, but only reads the
header before doing so. The following patch seems to fix the problem.
term% diff /n/cd/sys/src/cmd/tapefs/tarfs.c .
38c38
< long blkno, isabs, chksum, linkflg;
---
> long blkno, isabs, chksum, linkflg, t;
47c47
< if (read(tapefile, (char *)&dblock.dbuf, sizeof(dblock.dbuf))<sizeof(dblock.dbuf))
---
> if (read(tapefile, (char *)&dblock, sizeof(dblock))<sizeof(dblock))
60,61c60,61
< if (chksum != checksum()){
< fprint(1, "bad checksum on %.28s\n", dblock.dbuf.name);
---
> if (chksum != (t=checksum())){
> fprint(1, "bad checksum %o != %o on %.28s\n", chksum, t, dblock.dbuf.name);
132c132
< i += *cp;
---
> i += *cp & 0xff;