ref: ee9b29550f887f125253826c7af3495ac41b39f7
parent: c80f22f74a4b7d08451a73258cbbf1b013da92d8
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Dec 23 18:10:42 EST 2018
Make the check work. Embarrassing.
--- a/sys/src/cmd/nusb/disk/disk.c
+++ b/sys/src/cmd/nusb/disk/disk.c
@@ -361,16 +361,7 @@
return 0;
}
-static int
-needunstall(void)
-{
- char buf[ERRMAX];
- rerrstr(buf, sizeof(buf));
- return strstr(buf, "medium not present") == nil;
-}
-
-
/*
* called by SR*() commands provided by scuzz's scsireq
*/
@@ -377,11 +368,15 @@
long
umsrequest(Umsc *umsc, ScsiPtr *cmd, ScsiPtr *data, int *status)
{
+ char buf[ERRMAX];
Cbw cbw;
Csw csw;
- int n, nio;
+ int n, nio, present;
Ums *ums;
+ rerrstr(buf, sizeof(buf));
+ present = strstr(buf, "medium not present") == nil;
+
ums = umsc->ums;
memcpy(cbw.signature, "USBC", 4);
@@ -427,7 +422,7 @@
else
fprint(2, "disk: data: %d bytes (nio: %d)\n", n, nio);
nio = n;
- if(n < 0 && needunstall() || (n <= 9 || data->write == 0))
+ if((n == 0 && present) || (n < 0 && data->write == 0))
unstall(dev, ums->epin, Ein);
}