ref: e090c472980fc8a9d9dfc07e2165e80cd56e82bb
parent: 120c2be0bb4fb25fcaf20dde3e942563e01e7b0b
author: Jacob Moody <moody@posixcafe.org>
date: Sat Feb 10 17:16:47 EST 2024
tapefs/^(v6fs 32vfs): fix read errors (thanks Lyssa) We were always returning the start of the block when doing unaligned reads. Additionally the logical to physical block translation for 32vfs was not correct for files over 512 bytes. This code was tested with the 32V dumps from TUHS.
--- a/sys/src/cmd/tapefs/32vfs.c
+++ b/sys/src/cmd/tapefs/32vfs.c
@@ -131,7 +131,7 @@
bno++;
i++;
}
- return buf;
+ return buf+off;
}
void
@@ -208,10 +208,12 @@
if (bno < VNADDR-3)
return ((long*)r->data)[bno];
if (bno < VNADDR*LNINDIR) {
- seek(tapefile, ((long *)r->data)[(bno-(VNADDR-3))/LNINDIR]*BLSIZE, 0);
+ seek(tapefile, ((long *)r->data)[(bno-(VNADDR-3))/LNINDIR+(VNADDR-3)]*BLSIZE, 0);
if (read(tapefile, (char *)indbuf, BLSIZE) != BLSIZE)
return 0;
- return ((indbuf[bno%LNINDIR][1]<<8) + indbuf[bno%LNINDIR][0]);
+
+ return ((indbuf[(bno-(VNADDR-3))%LNINDIR][2]<<16) + (indbuf[(bno-(VNADDR-3))%LNINDIR][1]<<8)
+ + indbuf[(bno-(VNADDR-3))%LNINDIR][0]);
}
return 0;
}
--- a/sys/src/cmd/tapefs/v6fs.c
+++ b/sys/src/cmd/tapefs/v6fs.c
@@ -123,7 +123,7 @@
bno++;
i++;
}
- return buf;
+ return buf+off;
}
void
--
⑨