summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2004-02-07 22:39:17 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2004-02-07 22:39:17 +0000
commita239a8feaec04ace466ba8081411370c26e42819 (patch)
treefb12d9287bfdce63df54e7616826d90f89282ef7 /sys
parent92aea805c537b999a78b6d1050189616692da82f (diff)
If scsi_probe_bus() is called with a particular lun, ensure that lun 0
information is available to make the new lun validation logic work. i.e. don't find phantom luns just because the user asks about them. Also ensure the lun value given does not exceed the maximum valid lun for a bus, rather than assuming the maximum valid lun is 7. ok tdeval@ deraadt@.
Diffstat (limited to 'sys')
-rw-r--r--sys/scsi/scsi_base.c13
-rw-r--r--sys/scsi/scsiconf.c21
2 files changed, 21 insertions, 13 deletions
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c
index 857cd0cc9ec..1c8ca024af1 100644
--- a/sys/scsi/scsi_base.c
+++ b/sys/scsi/scsi_base.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsi_base.c,v 1.50 2004/01/10 09:12:07 grange Exp $ */
+/* $OpenBSD: scsi_base.c,v 1.51 2004/02/07 22:39:15 krw Exp $ */
/* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */
/*
@@ -299,9 +299,16 @@ scsi_inquire(sc_link, inqbuf, flags)
{
struct scsi_inquiry scsi_cmd;
- bzero(&scsi_cmd, sizeof(scsi_cmd));
+ bzero(&scsi_cmd, sizeof scsi_cmd);
scsi_cmd.opcode = INQUIRY;
- scsi_cmd.length = sizeof(struct scsi_inquiry_data);
+ scsi_cmd.length = sizeof *inqbuf;
+
+ bzero(inqbuf, sizeof *inqbuf);
+
+ memset(&inqbuf->vendor, ' ', sizeof inqbuf->vendor);
+ memset(&inqbuf->product, ' ', sizeof inqbuf->product);
+ memset(&inqbuf->revision, ' ', sizeof inqbuf->revision);
+ memset(&inqbuf->extra, ' ', sizeof inqbuf->extra);
return scsi_scsi_cmd(sc_link, (struct scsi_generic *) &scsi_cmd,
sizeof(scsi_cmd), (u_char *) inqbuf,
diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c
index c6b82e83ca6..6f24b13e5cf 100644
--- a/sys/scsi/scsiconf.c
+++ b/sys/scsi/scsiconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsiconf.c,v 1.84 2004/01/30 23:07:36 tdeval Exp $ */
+/* $OpenBSD: scsiconf.c,v 1.85 2004/02/07 22:39:16 krw Exp $ */
/* $NetBSD: scsiconf.c,v 1.57 1996/05/02 01:09:01 neil Exp $ */
/*
@@ -302,14 +302,22 @@ scsi_probe_bus(bus, target, lun)
maxlun = scsi->adapter_link->luns - 1;
minlun = 0;
} else {
- if (lun < 0 || lun > 7)
+ if (lun < 0 || lun >= scsi->adapter_link->luns)
return EINVAL;
- maxlun = minlun = lun;
+ maxlun = lun;
+ if (lun == 0 || scsi->sc_link[target][0] == NULL)
+ minlun = 0;
+ else
+ minlun = lun;
}
for (target = mintarget; target <= maxtarget; target++)
if (target != scsi_addr) {
bzero(&inqbuflun0, sizeof inqbuflun0);
+ if (minlun != 0 &&
+ (scsi_inquire(scsi->sc_link[target][0], &inqbuflun0,
+ 0) != 0))
+ continue;
for (lun = minlun; lun <= maxlun; lun++)
if (scsi_probedev(scsi, &inqbuflun0, target,
lun) == EINVAL)
@@ -673,13 +681,6 @@ scsi_probedev(scsi, inqbuflun0, target, lun)
#endif /* SCSI_2_DEF */
/* Now go ask the device all about itself. */
- bzero(&inqbuf, sizeof(inqbuf));
-
- memset(&inqbuf.vendor, ' ', sizeof inqbuf.vendor);
- memset(&inqbuf.product, ' ', sizeof inqbuf.product);
- memset(&inqbuf.revision, ' ', sizeof inqbuf.revision);
- memset(&inqbuf.extra, ' ', sizeof inqbuf.extra);
-
rslt = scsi_inquire(sc_link, &inqbuf, scsi_autoconf | SCSI_SILENT);
if (lun == 0 && rslt != 0) {