summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2009-11-22 17:01:18 +0000
committerjsing <jsing@openbsd.org>2009-11-22 17:01:18 +0000
commitd9594f12795088bca80e38e8cbadecdaf4df88a0 (patch)
tree28b0d7ccfdbfdb0e1a911e800757275b43fdbed1
parentEnsure that chunks are not already in use when creating a volume. (diff)
downloadwireguard-openbsd-d9594f12795088bca80e38e8cbadecdaf4df88a0.tar.xz
wireguard-openbsd-d9594f12795088bca80e38e8cbadecdaf4df88a0.zip
Add a framework for discipline specific ioctls.
ok marco@
-rw-r--r--sys/dev/biovar.h7
-rw-r--r--sys/dev/softraid.c31
-rw-r--r--sys/dev/softraidvar.h4
3 files changed, 39 insertions, 3 deletions
diff --git a/sys/dev/biovar.h b/sys/dev/biovar.h
index 7987450e687..5730b032946 100644
--- a/sys/dev/biovar.h
+++ b/sys/dev/biovar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: biovar.h,v 1.34 2008/08/22 02:00:12 marco Exp $ */
+/* $OpenBSD: biovar.h,v 1.35 2009/11/22 17:01:18 jsing Exp $ */
/*
* Copyright (c) 2002 Niklas Hallqvist. All rights reserved.
@@ -38,6 +38,11 @@ struct bio_common {
void *bc_cookie;
};
+struct bio_device {
+ void *cookie;
+ char dev[16];
+};
+
/* convert name to a cookie */
#define BIOCLOCATE _IOWR('B', 0, struct bio_locate)
struct bio_locate {
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index c623d64abcd..ef83413e148 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.179 2009/11/22 16:56:06 jsing Exp $ */
+/* $OpenBSD: softraid.c,v 1.180 2009/11/22 17:01:18 jsing Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -103,6 +103,7 @@ int sr_ioctl_createraid(struct sr_softc *,
struct bioc_createraid *, int);
int sr_ioctl_deleteraid(struct sr_softc *,
struct bioc_deleteraid *);
+int sr_ioctl_discipline(struct sr_softc *, u_long, caddr_t);
void sr_chunks_unwind(struct sr_softc *,
struct sr_chunk_head *);
void sr_discipline_free(struct sr_discipline *);
@@ -3104,6 +3105,34 @@ bad:
return (rv);
}
+int
+sr_ioctl_discipline(struct sr_softc *sc, u_long cmd, caddr_t addr)
+{
+ struct sr_discipline *sd = NULL;
+ struct bio_device *bc = (struct bio_device *)addr;
+ int i, rv = 1;
+
+ /* Dispatch a discipline specific ioctl. */
+
+ DNPRINTF(SR_D_IOCTL, "%s: sr_ioctl_discipline %s\n", DEVNAME(sc),
+ dr->bd_dev);
+
+ for (i = 0; i < SR_MAXSCSIBUS; i++)
+ if (sc->sc_dis[i]) {
+ if (!strncmp(sc->sc_dis[i]->sd_meta->ssd_devname,
+ bc->dev,
+ sizeof(sc->sc_dis[i]->sd_meta->ssd_devname))) {
+ sd = sc->sc_dis[i];
+ break;
+ }
+ }
+
+ if (sd && sd->sd_ioctl_handler)
+ rv = sd->sd_ioctl_handler(sd, cmd, addr);
+
+ return (rv);
+}
+
void
sr_chunks_unwind(struct sr_softc *sc, struct sr_chunk_head *cl)
{
diff --git a/sys/dev/softraidvar.h b/sys/dev/softraidvar.h
index b1035c42052..b9697157464 100644
--- a/sys/dev/softraidvar.h
+++ b/sys/dev/softraidvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraidvar.h,v 1.81 2009/08/09 14:12:25 marco Exp $ */
+/* $OpenBSD: softraidvar.h,v 1.82 2009/11/22 17:01:18 jsing Exp $ */
/*
* Copyright (c) 2006 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -463,6 +463,8 @@ struct sr_discipline {
/* discipline functions */
int (*sd_alloc_resources)(struct sr_discipline *);
int (*sd_free_resources)(struct sr_discipline *);
+ int (*sd_ioctl_handler)(struct sr_discipline *,
+ u_long, caddr_t);
int (*sd_start_discipline)(struct sr_discipline *);
void (*sd_set_chunk_state)(struct sr_discipline *,
int, int);