summaryrefslogtreecommitdiff
path: root/sys/dev/ic/ami.c
diff options
context:
space:
mode:
authorMarco Peereboom <marco@cvs.openbsd.org>2005-08-17 06:07:32 +0000
committerMarco Peereboom <marco@cvs.openbsd.org>2005-08-17 06:07:32 +0000
commitc9319a24a0ba5c104f74922ef24bc9bedd111afa (patch)
tree048a72e8386e0f96620044c53460fc7f717ac233 /sys/dev/ic/ami.c
parentfbfedd559c464bbd62f4211e75f2185da90b7f08 (diff)
Add support for unused disks.
Fix SCSI string madness (by deraadt). Add some debug statements in bioctl.
Diffstat (limited to 'sys/dev/ic/ami.c')
-rw-r--r--sys/dev/ic/ami.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/sys/dev/ic/ami.c b/sys/dev/ic/ami.c
index 8adfe551b44..bcdc1646cad 100644
--- a/sys/dev/ic/ami.c
+++ b/sys/dev/ic/ami.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ami.c,v 1.59 2005/08/16 01:12:46 marco Exp $ */
+/* $OpenBSD: ami.c,v 1.60 2005/08/17 06:07:31 marco Exp $ */
/*
* Copyright (c) 2001 Michael Shalayeff
@@ -2000,6 +2000,8 @@ ami_ioctl_inq(sc, bi)
int i, s, t;
int off;
int error = 0;
+ struct scsi_inquiry_data inqbuf;
+ u_int8_t ch, tg;
p = malloc(sizeof *p, M_DEVBUF, M_NOWAIT);
if (!p) {
@@ -2040,9 +2042,10 @@ ami_ioctl_inq(sc, bi)
}
}
- /* count global hotspares as volumes */
+ //printf("before bi->bi_novol: %d bi->bi_nodisk %d\n", bi->bi_novol, bi->bi_nodisk);
for(i = 0; i < ((sc->sc_flags & AMI_QUARTZ) ?
- AMI_BIG_MAX_PDRIVES : AMI_MAX_PDRIVES); i++)
+ AMI_BIG_MAX_PDRIVES : AMI_MAX_PDRIVES); i++) {
+ /* count global hotspares as volumes */
if (p->apd[i].adp_ostatus == AMI_PD_HOTSPARE
&& p->apd[i].adp_type == 0) {
bi->bi_novol++;
@@ -2051,7 +2054,25 @@ ami_ioctl_inq(sc, bi)
plist[i] = 1;
bi->bi_nodisk++;
}
+
+ }
+
+ /* count unused disks as a volume too */
+ if (p->apd[i].adp_size) {
+ ch = (i & 0xf0) >> 4;
+ tg = i & 0x0f;
+
+ if (!ami_drv_inq(sc, ch, tg, 0, &inqbuf)) {
+ if (!plist[i]) {
+ /* if it isnt claimed its unused */
+ bi->bi_novol++;
+
+ plist[i] = 1;
+ bi->bi_nodisk++;
+ }
+ }
}
+ }
bail2:
free(plist, M_DEVBUF);
@@ -2106,7 +2127,16 @@ ami_global_hsdisk(sc, bd, p)
u_int8_t ch, tg;
for(i = 0; i < ((sc->sc_flags & AMI_QUARTZ) ?
- AMI_BIG_MAX_PDRIVES : AMI_MAX_PDRIVES); i++)
+ AMI_BIG_MAX_PDRIVES : AMI_MAX_PDRIVES); i++) {
+ /*
+ printf("%02x: type: %u status: %u tag: %u sneg: %u size: %u\n",
+ i,
+ p->apd[i].adp_type,
+ p->apd[i].adp_ostatus,
+ p->apd[i].adp_tagdepth,
+ p->apd[i].adp_sneg,
+ p->apd[i].adp_size);
+ */
if (p->apd[i].adp_ostatus == AMI_PD_HOTSPARE
&& p->apd[i].adp_type == 0) {
if (ld == bd->bd_volid) {
@@ -2119,7 +2149,7 @@ ami_global_hsdisk(sc, bd, p)
if (!ami_drv_inq(sc, ch, tg, 0, &inqbuf))
strlcpy(bd->bd_vendor, inqbuf.vendor,
- sizeof(bd->bd_vendor));
+ sizeof(bd->bd_vendor) -3);
if (!ami_drv_inq(sc, ch, tg, 0x80, &vpdbuf))
strlcpy(bd->bd_serial, vpdbuf.serial,
@@ -2139,6 +2169,7 @@ ami_global_hsdisk(sc, bd, p)
}
ld++;
}
+ }
return (EINVAL);
}
@@ -2304,7 +2335,7 @@ ami_ioctl_disk(sc, bd)
if (!ami_drv_inq(sc, ch, tg, 0, &inqbuf))
strlcpy(bd->bd_vendor, inqbuf.vendor,
- sizeof(bd->bd_vendor));
+ sizeof(bd->bd_vendor) -3);
if (!ami_drv_inq(sc, ch, tg, 0x80, &vpdbuf))
strlcpy(bd->bd_serial, vpdbuf.serial,