diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2009-11-23 16:34:00 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2009-11-23 16:34:00 +0000 |
commit | c58f71a9d88cb9ff90fce3e2d85ad187973565ec (patch) | |
tree | 8f7008c34a54338a4cf3c06b303a890179a80f96 | |
parent | ecb04f492b9be2bc502a476317e1bb7eead1a01e (diff) |
Improve discipline specific ioctl framework and attach to softraid ioctl.
ok marco@
-rw-r--r-- | sys/dev/biovar.h | 17 | ||||
-rw-r--r-- | sys/dev/softraid.c | 17 | ||||
-rw-r--r-- | sys/dev/softraidvar.h | 4 |
3 files changed, 24 insertions, 14 deletions
diff --git a/sys/dev/biovar.h b/sys/dev/biovar.h index 5730b032946..8051c913316 100644 --- a/sys/dev/biovar.h +++ b/sys/dev/biovar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: biovar.h,v 1.35 2009/11/22 17:01:18 jsing Exp $ */ +/* $OpenBSD: biovar.h,v 1.36 2009/11/23 16:33:59 jsing Exp $ */ /* * Copyright (c) 2002 Niklas Hallqvist. All rights reserved. @@ -38,11 +38,6 @@ 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 { @@ -207,6 +202,15 @@ struct bioc_deleteraid { char bd_dev[16]; /* device */ }; +#define BIOCDISCIPLINE _IOWR('B', 40, struct bioc_discipline) +struct bioc_discipline { + void *bd_cookie; + char bd_dev[16]; + u_int32_t bd_cmd; + u_int32_t bd_size; + void *bd_data; +}; + /* kernel and userspace defines */ #define BIOC_INQ 0x0001 #define BIOC_DISK 0x0002 @@ -216,6 +220,7 @@ struct bioc_deleteraid { #define BIOC_SETSTATE 0x0020 #define BIOC_CREATERAID 0x0040 #define BIOC_DELETERAID 0x0080 +#define BIOC_DISCIPLINE 0x0100 /* user space defines */ #define BIOC_DEVLIST 0x10000 diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c index ef83413e148..d6c269a9bc7 100644 --- a/sys/dev/softraid.c +++ b/sys/dev/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.180 2009/11/22 17:01:18 jsing Exp $ */ +/* $OpenBSD: softraid.c,v 1.181 2009/11/23 16:33:59 jsing Exp $ */ /* * Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org> @@ -103,7 +103,8 @@ 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); +int sr_ioctl_discipline(struct sr_softc *, + struct bioc_discipline *); void sr_chunks_unwind(struct sr_softc *, struct sr_chunk_head *); void sr_discipline_free(struct sr_discipline *); @@ -1984,6 +1985,11 @@ sr_ioctl(struct device *dev, u_long cmd, caddr_t addr) case BIOCDELETERAID: rv = sr_ioctl_deleteraid(sc, (struct bioc_deleteraid *)addr); break; + + case BIOCDISCIPLINE: + rv = sr_ioctl_discipline(sc, (struct bioc_discipline *)addr); + break; + default: DNPRINTF(SR_D_IOCTL, "invalid ioctl\n"); rv = ENOTTY; @@ -3106,10 +3112,9 @@ bad: } int -sr_ioctl_discipline(struct sr_softc *sc, u_long cmd, caddr_t addr) +sr_ioctl_discipline(struct sr_softc *sc, struct bioc_discipline *bd) { struct sr_discipline *sd = NULL; - struct bio_device *bc = (struct bio_device *)addr; int i, rv = 1; /* Dispatch a discipline specific ioctl. */ @@ -3120,7 +3125,7 @@ sr_ioctl_discipline(struct sr_softc *sc, u_long cmd, caddr_t addr) for (i = 0; i < SR_MAXSCSIBUS; i++) if (sc->sc_dis[i]) { if (!strncmp(sc->sc_dis[i]->sd_meta->ssd_devname, - bc->dev, + bd->bd_dev, sizeof(sc->sc_dis[i]->sd_meta->ssd_devname))) { sd = sc->sc_dis[i]; break; @@ -3128,7 +3133,7 @@ sr_ioctl_discipline(struct sr_softc *sc, u_long cmd, caddr_t addr) } if (sd && sd->sd_ioctl_handler) - rv = sd->sd_ioctl_handler(sd, cmd, addr); + rv = sd->sd_ioctl_handler(sd, bd); return (rv); } diff --git a/sys/dev/softraidvar.h b/sys/dev/softraidvar.h index b9697157464..894ae0dbe5f 100644 --- a/sys/dev/softraidvar.h +++ b/sys/dev/softraidvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: softraidvar.h,v 1.82 2009/11/22 17:01:18 jsing Exp $ */ +/* $OpenBSD: softraidvar.h,v 1.83 2009/11/23 16:33:59 jsing Exp $ */ /* * Copyright (c) 2006 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org> @@ -464,7 +464,7 @@ struct sr_discipline { 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); + struct bioc_discipline *); int (*sd_start_discipline)(struct sr_discipline *); void (*sd_set_chunk_state)(struct sr_discipline *, int, int); |