summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2007-04-03 04:15:51 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2007-04-03 04:15:51 +0000
commit8695298712ca6b05d95e2878ffa7ce38f135ccef (patch)
treee176e112d37d79ca8393e7f78acd1d4a66ab19ff /sys
parentdad57cbeaa269b36143f1e82dd2e1b74cec4496b (diff)
modernise scsi_inquiry. the length field has grown and now theres pages to
query. ok krw@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ic/mpi.c3
-rw-r--r--sys/scsi/safte.c19
-rw-r--r--sys/scsi/scsi_all.h8
-rw-r--r--sys/scsi/scsi_base.c8
4 files changed, 21 insertions, 17 deletions
diff --git a/sys/dev/ic/mpi.c b/sys/dev/ic/mpi.c
index f3555d48224..acb6a24a8ef 100644
--- a/sys/dev/ic/mpi.c
+++ b/sys/dev/ic/mpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mpi.c,v 1.83 2007/03/17 10:25:39 dlg Exp $ */
+/* $OpenBSD: mpi.c,v 1.84 2007/04/03 04:15:50 dlg Exp $ */
/*
* Copyright (c) 2005, 2006 David Gwynne <dlg@openbsd.org>
@@ -588,6 +588,7 @@ mpi_inq(struct mpi_softc *sc, u_int16_t target, int physdisk)
bzero(&inq, sizeof(inq));
inq.opcode = INQUIRY;
+ _lto2b(sizeof(struct scsi_inquiry_data), inq.length);
ccb = mpi_get_ccb(sc);
if (ccb == NULL)
diff --git a/sys/scsi/safte.c b/sys/scsi/safte.c
index ce874794f35..f6385878573 100644
--- a/sys/scsi/safte.c
+++ b/sys/scsi/safte.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: safte.c,v 1.34 2007/03/22 16:55:31 deraadt Exp $ */
+/* $OpenBSD: safte.c,v 1.35 2007/04/03 04:15:50 dlg Exp $ */
/*
* Copyright (c) 2005 David Gwynne <dlg@openbsd.org>
@@ -112,7 +112,7 @@ safte_match(struct device *parent, void *match, void *aux)
struct scsi_inquiry_data inqbuf;
struct scsi_inquiry cmd;
struct safte_inq *si = (struct safte_inq *)&inqbuf.extra;
- int flags;
+ int length, flags;
if (inq == NULL)
return (0);
@@ -127,14 +127,15 @@ safte_match(struct device *parent, void *match, void *aux)
(inq->response_format & SID_ANSII) != 2)
return (0);
- memset(&cmd, 0, sizeof(cmd));
- cmd.opcode = INQUIRY;
- cmd.length = inq->additional_length + SAFTE_EXTRA_OFFSET;
- if (cmd.length < SAFTE_INQ_LEN)
+ length = inq->additional_length + SAFTE_EXTRA_OFFSET;
+ if (length < SAFTE_INQ_LEN)
return (0);
+ if (length > sizeof(inqbuf))
+ length = sizeof(inqbuf);
- if (cmd.length > sizeof(inqbuf))
- cmd.length = sizeof(inqbuf);
+ memset(&cmd, 0, sizeof(cmd));
+ cmd.opcode = INQUIRY;
+ _lto2b(length, cmd.length);
memset(&inqbuf, 0, sizeof(inqbuf));
memset(&inqbuf.extra, ' ', sizeof(inqbuf.extra));
@@ -144,7 +145,7 @@ safte_match(struct device *parent, void *match, void *aux)
flags |= SCSI_AUTOCONF;
if (scsi_scsi_cmd(sa->sa_sc_link, (struct scsi_generic *)&cmd,
- sizeof(cmd), (u_char *)&inqbuf, cmd.length, 2, 10000, NULL,
+ sizeof(cmd), (u_char *)&inqbuf, length, 2, 10000, NULL,
flags) != 0)
return (0);
diff --git a/sys/scsi/scsi_all.h b/sys/scsi/scsi_all.h
index cf2155d5256..d15ec399b5b 100644
--- a/sys/scsi/scsi_all.h
+++ b/sys/scsi/scsi_all.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsi_all.h,v 1.40 2006/11/27 23:14:22 beck Exp $ */
+/* $OpenBSD: scsi_all.h,v 1.41 2007/04/03 04:15:50 dlg Exp $ */
/* $NetBSD: scsi_all.h,v 1.10 1996/09/12 01:57:17 thorpej Exp $ */
/*
@@ -79,10 +79,10 @@ struct scsi_sense {
struct scsi_inquiry {
u_int8_t opcode;
- u_int8_t byte2;
+ u_int8_t flags;
#define SI_EVPD 0x01
- u_int8_t unused[2];
- u_int8_t length;
+ u_int8_t pagecode;
+ u_int8_t length[2];
u_int8_t control;
};
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c
index 8c8cc705e88..bcde4fb7d9e 100644
--- a/sys/scsi/scsi_base.c
+++ b/sys/scsi/scsi_base.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsi_base.c,v 1.117 2006/12/12 02:44:36 krw Exp $ */
+/* $OpenBSD: scsi_base.c,v 1.118 2007/04/03 04:15:50 dlg Exp $ */
/* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */
/*
@@ -378,6 +378,7 @@ scsi_inquire(struct scsi_link *sc_link, struct scsi_inquiry_data *inqbuf,
int flags)
{
struct scsi_inquiry scsi_cmd;
+ int length;
int error;
bzero(&scsi_cmd, sizeof(scsi_cmd));
@@ -394,9 +395,10 @@ scsi_inquire(struct scsi_link *sc_link, struct scsi_inquiry_data *inqbuf,
* Ask for only the basic 36 bytes of SCSI2 inquiry information. This
* avoids problems with devices that choke trying to supply more.
*/
- scsi_cmd.length = SID_INQUIRY_HDR + SID_SCSI2_ALEN;
+ length = SID_INQUIRY_HDR + SID_SCSI2_ALEN;
+ _lto2b(length, scsi_cmd.length);
error = scsi_scsi_cmd(sc_link, (struct scsi_generic *)&scsi_cmd,
- sizeof(scsi_cmd), (u_char *)inqbuf, scsi_cmd.length, 2, 10000, NULL,
+ sizeof(scsi_cmd), (u_char *)inqbuf, length, 2, 10000, NULL,
SCSI_DATA_IN | flags);
return (error);