Implement handling of CONFIG_GEOM OAM request.
This commit is contained in:
parent
a486cc42e4
commit
fb1adf6e62
@ -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.
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user