diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2020-09-05 14:21:53 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2020-09-05 14:21:53 +0000 |
commit | 311bd9a43d7daa17e91adc18df0e999c606882a0 (patch) | |
tree | 1bb6cae6b9a80c5242a41912d47b5c84ea929c7c /sys/scsi | |
parent | 2378367b6b423b06926486b2392031f32dbd3525 (diff) |
Rename SID_INQUIRY_HDR (a.k.a. 5) to more explicit SID_SCSI2_HDRLEN and use it
to replace various uses of '5' when calculating the amount of data in the
INQUIRY response. Matches up more naturally with SID_SCSI2_ALEN.
Also use to fix SCSIDEBUG display of INQUIRY responses to show correct count of
bytes received/available.
Diffstat (limited to 'sys/scsi')
-rw-r--r-- | sys/scsi/mpath_hds.c | 6 | ||||
-rw-r--r-- | sys/scsi/scsi_all.h | 6 | ||||
-rw-r--r-- | sys/scsi/scsi_base.c | 15 |
3 files changed, 14 insertions, 13 deletions
diff --git a/sys/scsi/mpath_hds.c b/sys/scsi/mpath_hds.c index 3662beb26ec..6e64c807153 100644 --- a/sys/scsi/mpath_hds.c +++ b/sys/scsi/mpath_hds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpath_hds.c,v 1.23 2020/06/30 18:43:37 krw Exp $ */ +/* $OpenBSD: mpath_hds.c,v 1.24 2020/09/05 14:21:52 krw Exp $ */ /* * Copyright (c) 2011 David Gwynne <dlg@openbsd.org> @@ -261,7 +261,7 @@ hds_inquiry(struct scsi_link *link, int *mode) { struct scsi_xfer *xs; u_int8_t *buf; - size_t len = link->inqdata.additional_length + 5; + size_t len = SID_SCSI2_HDRLEN + link->inqdata.additional_length; int error; if (len < HDS_INQ_TYPE_OFFSET + sizeof(int)) @@ -296,7 +296,7 @@ hds_info(struct hds_softc *sc) struct scsi_link *link = sc->sc_path.p_link; struct scsi_xfer *xs; u_int8_t *buf; - size_t len = link->inqdata.additional_length + 5; + size_t len = SID_SCSI2_HDRLEN + link->inqdata.additional_length; char ldev[9], ctrl, port; int error; diff --git a/sys/scsi/scsi_all.h b/sys/scsi/scsi_all.h index a0b013ae3ae..a537de82a7a 100644 --- a/sys/scsi/scsi_all.h +++ b/sys/scsi/scsi_all.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_all.h,v 1.62 2020/09/02 23:41:01 krw Exp $ */ +/* $OpenBSD: scsi_all.h,v 1.63 2020/09/05 14:21:52 krw Exp $ */ /* $NetBSD: scsi_all.h,v 1.10 1996/09/12 01:57:17 thorpej Exp $ */ /* @@ -252,8 +252,8 @@ struct scsi_inquiry_data { #define SID_TrmIOP 0x40 /* obsolete */ #define SID_AENC 0x80 /* obsolete */ u_int8_t additional_length; -#define SID_INQUIRY_HDR 5 /* Bytes up to & including additional_length */ -#define SID_SCSI2_ALEN 31 /* Additional bytes of basic SCSI2 info */ +#define SID_SCSI2_HDRLEN 5 /* Bytes up to & including additional_length */ +#define SID_SCSI2_ALEN 31 /* Additional bytes of basic SCSI2 info */ u_int8_t spc3_flags; #define SPC3_SID_PROTECT 0x01 /* 0 == Type 0, 1 == Type 1, 2 or 3 */ #define SPC3_SID_RESERVED 0x06 diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c index f582d5fb07c..00402e42be7 100644 --- a/sys/scsi/scsi_base.c +++ b/sys/scsi/scsi_base.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_base.c,v 1.273 2020/09/01 12:17:53 krw Exp $ */ +/* $OpenBSD: scsi_base.c,v 1.274 2020/09/05 14:21:52 krw Exp $ */ /* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */ /* @@ -849,7 +849,7 @@ scsi_inquire(struct scsi_link *link, struct scsi_inquiry_data *inqbuf, * information. This avoids problems with devices that choke trying to * supply more. */ - bytes = 36; + bytes = SID_SCSI2_HDRLEN + SID_SCSI2_ALEN; #ifdef SCSIDEBUG again: @@ -872,13 +872,14 @@ again: #ifdef SCSIDEBUG sc_print_addr(link); - if (bytes > inqbuf->additional_length + 4) - bytes = inqbuf->additional_length + 4; + if (bytes > SID_SCSI2_HDRLEN + inqbuf->additional_length) + bytes = SID_SCSI2_HDRLEN + inqbuf->additional_length; printf("got %zu of %u bytes of inquiry data:\n", - bytes, inqbuf->additional_length + 4); + bytes, SID_SCSI2_HDRLEN + inqbuf->additional_length); scsi_show_mem((u_char *)inqbuf, bytes); - if (bytes == 36 && bytes < inqbuf->additional_length + 4) { - bytes = inqbuf->additional_length + 4; + if (bytes == SID_SCSI2_HDRLEN + SID_SCSI2_ALEN && bytes < + SID_SCSI2_HDRLEN + inqbuf->additional_length) { + bytes = SID_SCSI2_HDRLEN + inqbuf->additional_length; if (bytes > sizeof(*inqbuf)) bytes = sizeof(*inqbuf); goto again; |