If a transfer to or from a floppy disk crosses a 64k boundary, we have to

use a bounce buffer for the actual transfer to avoid crossing a 64k
boundary.  To do this, we malloc a buffer twice as big as we need and then
find an aligned block within that buffer to do the transfer.  The check
to see which part of the block we use used the wrong variable for part of
the condition meaning that in certain edge cases we would ask the BIOS to
cross a 64k boundary.  The BIOS request would then fail resulting in file
transfers that just magically fail in the middle without any apparent
reason.  Specifically, my tests for the splitfs boot floppies managed to
trigger this edge case.

MFC after:	1 week
X-MFC-info:	along with fixes to libstand filesystems
This commit is contained in:
John Baldwin 2004-01-21 23:22:29 +00:00
parent 94215c94fe
commit 4939882522

View File

@ -867,7 +867,7 @@ bd_read(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest)
*/
x = min(FLOPPY_BOUNCEBUF, (unsigned)blks);
bbuf = malloc(x * 2 * BIOSDISK_SECSIZE);
if (((u_int32_t)VTOP(bbuf) & 0xffff0000) == ((u_int32_t)VTOP(dest + x * BIOSDISK_SECSIZE) & 0xffff0000)) {
if (((u_int32_t)VTOP(bbuf) & 0xffff0000) == ((u_int32_t)VTOP(bbuf + x * BIOSDISK_SECSIZE) & 0xffff0000)) {
breg = bbuf;
} else {
breg = bbuf + x * BIOSDISK_SECSIZE;
@ -1000,7 +1000,7 @@ bd_write(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest)
x = min(FLOPPY_BOUNCEBUF, (unsigned)blks);
bbuf = malloc(x * 2 * BIOSDISK_SECSIZE);
if (((u_int32_t)VTOP(bbuf) & 0xffff0000) == ((u_int32_t)VTOP(dest + x * BIOSDISK_SECSIZE) & 0xffff0000)) {
if (((u_int32_t)VTOP(bbuf) & 0xffff0000) == ((u_int32_t)VTOP(bbuf + x * BIOSDISK_SECSIZE) & 0xffff0000)) {
breg = bbuf;
} else {
breg = bbuf + x * BIOSDISK_SECSIZE;