ref: 32077be8e30da961d61a7ad57f302bdae45f7de5
parent: 71c1961cceb6e9fc886398278c8191b85b2eb952
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Jan 6 22:23:33 EST 2026
nusb/disk: ignore file offset for raw status reads (thanks terin stock) > The sd(3) manual explains the process for executing arbitrary SCSI > commands on a storage device using the device's "raw" file: (1) write > the command, (2) read/write data associated with the command, and (3) > read the status of the command. > For USB Mass Storage disks, nusb/disk used lib9fs's readbuf function to > copy the status back to the caller. However, this function takes into > account the current file offset. As a result, the caller could recieve > either a partial status or no status, depending on the file offset. Patch applied, but with modification to maintain: req->ofcall.count <= req->ifcall.ocount
--- a/sys/src/cmd/nusb/disk/disk.c
+++ b/sys/src/cmd/nusb/disk/disk.c
@@ -772,8 +772,11 @@
break;
case Pstatus:
n = snprint(buf, sizeof buf, "%11.0ud ", lun->status);
- readbuf(req, buf, n);
+ if(n < count)
+ count = n;
lun->phase = Pcmd;
+ req->ofcall.count = count;
+ memmove(data, buf, count);
respond(req, nil);
break;
}
--
⑨