diff options
author | phk <phk@FreeBSD.org> | 2003-05-04 19:24:34 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2003-05-04 19:24:34 +0000 |
commit | f1297dcac658b45bda3dbe6d608b416447e94424 (patch) | |
tree | bdcea081c324b61cd5a6e9af679f42c178b837ff /sys/geom | |
parent | 65684800f05f3910147a2ddb35a28eb7c9f79109 (diff) | |
download | FreeBSD-src-f1297dcac658b45bda3dbe6d608b416447e94424.zip FreeBSD-src-f1297dcac658b45bda3dbe6d608b416447e94424.tar.gz |
Add gctl_set_param() function.
Diffstat (limited to 'sys/geom')
-rw-r--r-- | sys/geom/geom.h | 1 | ||||
-rw-r--r-- | sys/geom/geom_ctl.c | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/sys/geom/geom.h b/sys/geom/geom.h index ec4c9de..d90d2ce 100644 --- a/sys/geom/geom.h +++ b/sys/geom/geom.h @@ -311,6 +311,7 @@ extern struct sx topology_lock; #endif /* _KERNEL */ /* geom_ctl.c */ +int gctl_set_param(struct gctl_req *req, const char *param, void *ptr, int len); void *gctl_get_param(struct gctl_req *req, const char *param, int *len); void *gctl_get_paraml(struct gctl_req *req, const char *param, int len); int gctl_error(struct gctl_req *req, const char *fmt, ...); diff --git a/sys/geom/geom_ctl.c b/sys/geom/geom_ctl.c index aea950e..053f0ee 100644 --- a/sys/geom/geom_ctl.c +++ b/sys/geom/geom_ctl.c @@ -251,6 +251,31 @@ gctl_dump(struct gctl_req *req) } } +int +gctl_set_param(struct gctl_req *req, const char *param, void *ptr, int len) +{ + int i, error; + struct gctl_req_arg *ap; + + for (i = 0; i < req->narg; i++) { + ap = &req->arg[i]; + if (strcmp(param, ap->name)) + continue; + if (!(ap->flag & GCTL_PARAM_WR)) { + gctl_error(req, "No write access %s argument", param); + return (EINVAL); + } + if (ap->len != len) { + gctl_error(req, "Wrong length %s argument", param); + return (EINVAL); + } + error = copyout(ptr, ap->value, len); + return (error); + } + gctl_error(req, "Missing %s argument", param); + return (EINVAL); +} + void * gctl_get_param(struct gctl_req *req, const char *param, int *len) { |