From fb1adf6e622ce8079aaaae39d08014d0969de6d0 Mon Sep 17 00:00:00 2001 From: phk Date: Tue, 22 Apr 2003 21:01:46 +0000 Subject: [PATCH] Implement handling of CONFIG_GEOM OAM request. --- sys/geom/geom.h | 2 ++ sys/geom/geom_ctl.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/sys/geom/geom.h b/sys/geom/geom.h index 90b7d6043566..f8e227bb57c9 100644 --- a/sys/geom/geom.h +++ b/sys/geom/geom.h @@ -60,6 +60,7 @@ struct g_configargs; typedef int g_config_t (struct g_configargs *ca); typedef int g_ctl_create_geom_t (struct gctl_req *, struct g_class *cp, struct g_provider *pp); typedef int g_ctl_destroy_geom_t (struct gctl_req *, struct g_class *cp, struct g_geom *gp); +typedef int g_ctl_config_geom_t (struct gctl_req *, struct g_geom *gp, const char *verb); typedef struct g_geom * g_taste_t (struct g_class *, struct g_provider *, int flags); #define G_TF_NORMAL 0 @@ -87,6 +88,7 @@ struct g_class { g_config_t *config; g_ctl_create_geom_t *create_geom; g_ctl_destroy_geom_t *destroy_geom; + g_ctl_config_geom_t *config_geom; /* * The remaning elements are private and classes should use * the G_CLASS_INITIALIZER macro to initialize them. diff --git a/sys/geom/geom_ctl.c b/sys/geom/geom_ctl.c index ab50552ca43b..279156e35de9 100644 --- a/sys/geom/geom_ctl.c +++ b/sys/geom/geom_ctl.c @@ -381,6 +381,42 @@ gctl_destroy_geom(struct gctl_req *req) return (error); } +static int +gctl_config_geom(struct gctl_req *req) +{ + struct g_class *mp; + struct g_geom *gp; + char *verb; + int error, vlen; + + g_topology_assert(); + mp = gctl_get_class(req); + if (mp == NULL) + return (gctl_error(req, "Class not found")); + if (mp->config_geom == NULL) + return (gctl_error(req, "Class has no config_geom method")); + gp = gctl_get_geom(req, mp); + if (gp == NULL) + return (gctl_error(req, "Geom not specified")); + if (gp->class != mp) + return (gctl_error(req, "Geom not of specificed class")); + verb = gctl_get_param(req, "verb", &vlen); + if (verb == NULL) + return (gctl_error(req, "Missing verb parameter")); + if (vlen < 2) { + g_free(verb); + return (gctl_error(req, "Too short verb parameter")); + } + if (verb[vlen - 1] != '\0') { + g_free(verb); + return (gctl_error(req, "Unterminated verb parameter")); + } + error = mp->config_geom(req, gp, verb); + g_free(verb); + g_topology_assert(); + return (error); +} + /* * Handle ioctl from libgeom::geom_ctl.c */ @@ -426,6 +462,9 @@ g_ctl_ioctl_ctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *t case GCTL_DESTROY_GEOM: error = gctl_destroy_geom(req); break; + case GCTL_CONFIG_GEOM: + error = gctl_config_geom(req); + break; default: error = gctl_error(req, "XXX: TBD"); break;