From d157e37f7f569362bcb8bc76d3048720185319c4 Mon Sep 17 00:00:00 2001 From: David Gwynne Date: Thu, 13 Aug 2009 19:51:50 +0000 Subject: add ioctls to allow userland to initiator a probe or detach of devices it is providing to the kernel. this uses the req api i just added, otherwise attaches and detaches would be run from the context of the process issuing the ioctls, which then will not be able to answer them since theyre busy running the attach/detach in the kernel. --- sys/dev/vscsi.c | 12 +++++++++++- sys/dev/vscsivar.h | 10 +++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/vscsi.c b/sys/dev/vscsi.c index 550d879ccd7..e062d211e2a 100644 --- a/sys/dev/vscsi.c +++ b/sys/dev/vscsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vscsi.c,v 1.2 2009/02/16 21:19:06 miod Exp $ */ +/* $OpenBSD: vscsi.c,v 1.3 2009/08/13 19:51:49 dlg Exp $ */ /* * Copyright (c) 2008 David Gwynne @@ -261,6 +261,7 @@ int vscsiioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) { struct vscsi_softc *sc = DEV2SC(dev); + struct vscsi_ioc_devevent *de = (struct vscsi_ioc_devevent *)addr; int read = 0; int err = 0; @@ -279,6 +280,15 @@ vscsiioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) err = vscsi_t2i(sc, (struct vscsi_ioc_t2i *)addr); break; + case VSCSI_REQPROBE: + err = scsi_req_probe(sc->sc_scsibus, de->target, de->lun); + break; + + case VSCSI_REQDETACH: + err = scsi_req_detach(sc->sc_scsibus, de->target, de->lun, + DETACH_FORCE); + break; + default: err = ENOTTY; break; diff --git a/sys/dev/vscsivar.h b/sys/dev/vscsivar.h index 143805e8c96..4b9069d33cb 100644 --- a/sys/dev/vscsivar.h +++ b/sys/dev/vscsivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vscsivar.h,v 1.1 2008/12/03 23:39:32 dlg Exp $ */ +/* $OpenBSD: vscsivar.h,v 1.2 2009/08/13 19:51:49 dlg Exp $ */ /* * Copyright (c) 2008 David Gwynne @@ -60,4 +60,12 @@ struct vscsi_ioc_t2i { #define VSCSI_T2I _IOW('I', 3, struct vscsi_ioc_t2i) +struct vscsi_ioc_devevent { + u_int target; + u_int lun; +}; + +#define VSCSI_REQPROBE _IOW('I', 4, struct vscsi_ioc_devevent) +#define VSCSI_REQDETACH _IOW('I', 5, struct vscsi_ioc_devevent) + #endif /* _SYS_DEV_VSCSIVAR_H */ -- cgit v1.2.3