diff options
author | phk <phk@FreeBSD.org> | 2002-10-14 10:05:23 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2002-10-14 10:05:23 +0000 |
commit | d855c322044dff7473bc10f78b996febcd65bb07 (patch) | |
tree | 138c12b029e1cb5fb20e9a7d67f5a378686e57f1 /sys/geom/geom_ctl.c | |
parent | 8298a7f6adc2cfd2fc6b8357666aafea5f738ed5 (diff) | |
download | FreeBSD-src-d855c322044dff7473bc10f78b996febcd65bb07.zip FreeBSD-src-d855c322044dff7473bc10f78b996febcd65bb07.tar.gz |
Implement the GEOMCONFIGGEOM ioctl which can be used to manually create
and configure an instance of a class on a give provider.
Sponsored by: DARPA & NAI Labs
Diffstat (limited to 'sys/geom/geom_ctl.c')
-rw-r--r-- | sys/geom/geom_ctl.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/sys/geom/geom_ctl.c b/sys/geom/geom_ctl.c index b6e18c7..8e1ce84 100644 --- a/sys/geom/geom_ctl.c +++ b/sys/geom/geom_ctl.c @@ -147,7 +147,7 @@ g_ctl_start(struct bio *bp) } /* - * All the stuff above is really just needed to get to this one. + * All the stuff above is really just needed to get to the stuff below */ static int @@ -172,6 +172,37 @@ g_ctl_ioctl_getconf(dev_t dev, u_long cmd, caddr_t data, int fflag, struct threa } static int +g_ctl_ioctl_configgeom(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td) +{ + struct geomconfiggeom *gcp; + struct g_createargs ga; + int error; + + error = 0; + gcp = (struct geomconfiggeom *)data; + ga.class = g_idclass(&gcp->class); + if (ga.class == NULL) + return (EINVAL); + if (ga.class->create_geom == NULL) + return (EOPNOTSUPP); + ga.provider = g_idprovider(&gcp->provider); + if (ga.provider == NULL) + return (EINVAL); + ga.len = gcp->len; + if (gcp->len > 64 * 1024) + return (EINVAL); + else if (gcp->len == 0) { + ga.ptr = NULL; + } else { + ga.ptr = g_malloc(gcp->len, M_WAITOK); + copyin(gcp->ptr, ga.ptr, gcp->len); + } + error = ga.class->create_geom(&ga); + gcp->geom = (uintptr_t)ga.geom; + return(error); +} + +static int g_ctl_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td) { int error; @@ -182,6 +213,9 @@ g_ctl_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td) case GEOMGETCONF: error = g_ctl_ioctl_getconf(dev, cmd, data, fflag, td); break; + case GEOMCONFIGGEOM: + error = g_ctl_ioctl_configgeom(dev, cmd, data, fflag, td); + break; default: error = ENOTTY; break; |