ref: f9230151dd405278cd78ec0e32ba166cc418ab9a
parent: 671d8daa0f2d7f067b8ab3d547adbd718da93fe9
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