diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2006-11-27 18:32:34 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2006-11-27 18:32:34 +0000 |
commit | 7c51ad67b81086e88fd2d0cd99479d5edd6f0595 (patch) | |
tree | b9108950e72e6e8a8ec19e8fb5f38eaedd234388 /sys | |
parent | bea421002c064742dd575ed94896af3b3394adae (diff) |
add bio code to do hotplug of devices on the scsibus.
thumbs up deraadt@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/scsi/scsiconf.c | 38 | ||||
-rw-r--r-- | sys/sys/scsiio.h | 11 |
2 files changed, 46 insertions, 3 deletions
diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c index 18864714b94..71547f25fbb 100644 --- a/sys/scsi/scsiconf.c +++ b/sys/scsi/scsiconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.c,v 1.120 2006/11/27 13:33:15 dlg Exp $ */ +/* $OpenBSD: scsiconf.c,v 1.121 2006/11/27 18:32:33 dlg Exp $ */ /* $NetBSD: scsiconf.c,v 1.57 1996/05/02 01:09:01 neil Exp $ */ /* @@ -59,6 +59,8 @@ #include <scsi/scsiconf.h> #if NBIO > 0 +#include <sys/ioctl.h> +#include <sys/scsiio.h> #include <dev/biovar.h> #endif @@ -233,7 +235,39 @@ scsibussubmatch(struct device *parent, void *match, void *aux) int scsibus_bioctl(struct device *dev, u_long cmd, caddr_t addr) { - return (ENOTTY); + struct scsibus_softc *sc = (struct scsibus_softc *)dev; + struct sbioc_device *sdev; + + switch (cmd) { + case SBIOCPROBE: + sdev = (struct sbioc_device *)addr; + + if (sdev->sd_target == -1 && sdev->sd_lun == -1) + return (scsi_probe_bus(sc)); + + /* specific lun and wildcard target is bad */ + if (sdev->sd_target == -1) + return (EINVAL); + + if (sdev->sd_lun == -1) + return (scsi_probe_target(sc, sdev->sd_target)); + + return (scsi_probe_lun(sc, sdev->sd_target, sdev->sd_lun)); + + case SBIOCDETACH: + sdev = (struct sbioc_device *)addr; + + if (sdev->sd_target == -1) + return (EINVAL); + + if (sdev->sd_lun == -1) + return (scsi_detach_target(sc, sdev->sd_target, 0)); + + return (scsi_detach_lun(sc, sdev->sd_target, sdev->sd_lun, 0)); + + default: + return (ENOTTY); + } } #endif diff --git a/sys/sys/scsiio.h b/sys/sys/scsiio.h index 5d245518c03..553184bf338 100644 --- a/sys/sys/scsiio.h +++ b/sys/sys/scsiio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiio.h,v 1.7 2006/07/23 02:50:20 dlg Exp $ */ +/* $OpenBSD: scsiio.h,v 1.8 2006/11/27 18:32:33 dlg Exp $ */ /* $NetBSD: scsiio.h,v 1.3 1994/06/29 06:45:09 cgd Exp $ */ #ifndef _SYS_SCSIIO_H_ @@ -67,4 +67,13 @@ struct scsi_addr { #define SCIOCRESET _IO('Q', 7) /* reset the device */ #define SCIOCIDENTIFY _IOR('Q', 9, struct scsi_addr) +struct sbioc_device { + void *sd_cookie; + int sd_target; + int sd_lun; +}; + +#define SBIOCPROBE _IOWR('Q', 127, struct sbioc_device) +#define SBIOCDETACH _IOWR('Q', 128, struct sbioc_device) + #endif /* _SYS_SCSIIO_H_ */ |