summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2019-09-15 15:00:30 +0000
committerkrw <krw@openbsd.org>2019-09-15 15:00:30 +0000
commit4ab68d81de1b5fb36470555ea0e67927ea5f5e52 (patch)
treed17e37c25ec7a25c24f1f95ba849be79e86eda28
parentAdd ttyC4 to lost of devices to change when logging in on ttyC0 (and in (diff)
downloadwireguard-openbsd-4ab68d81de1b5fb36470555ea0e67927ea5f5e52.tar.xz
wireguard-openbsd-4ab68d81de1b5fb36470555ea0e67927ea5f5e52.zip
With the recent fixes to SCSI version detection we reproduced a
problem encountered by FreeBSD and Linux when they started to try issuing READ CAPACITY 16 commands to 'newer' devices. i.e. some USB devices return bad data instead of an error when they can't handle the command. Reproduce the FreeBSD solution (r233746 by mav@) by issuing READ CAPACITY 16 commands only to devices that claim to be REALLY new (a.k.a. newer than SPC-2, a.k.a. newer than SCSI-3), or which indicate they really are bigger than can be reported via READ CAPACITY 10. Should fix some USB devices claiming to have 71,776,119,061,217,281 or 33,601,071,049,867,265 sectors.
-rw-r--r--sys/scsi/sd.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index 92e22c1b1ba..b867ef92df5 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd.c,v 1.280 2019/09/14 13:30:48 krw Exp $ */
+/* $OpenBSD: sd.c,v 1.281 2019/09/15 15:00:30 krw Exp $ */
/* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */
/*-
@@ -1537,13 +1537,13 @@ sd_size(struct sd_softc *sc, int flags)
return (ENXIO);
/*
- * post-SPC (i.e. post-SCSI-3)) devices can start with 16 byte
- * read capacity commands. Older devices start with then 10 byte
+ * post-SPC2 (i.e. post-SCSI-3) devices can start with 16 byte
+ * read capacity commands. Older devices start with the 10 byte
* version and move up to the 16 byte version if the device
* says it has more sectors than can be reported via the 10 byte
* read capacity.
*/
- if (SID_ANSII_REV(&sc->sc_link->inqdata) >= SCSI_REV_SPC) {
+ if (SID_ANSII_REV(&sc->sc_link->inqdata) > SCSI_REV_SPC2) {
rv = sd_read_cap_16(sc, flags);
if (rv != 0)
rv = sd_read_cap_10(sc, flags);