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/geom_ctl.c | |
parent | 65684800f05f3910147a2ddb35a28eb7c9f79109 (diff) | |
download | FreeBSD-src-f1297dcac658b45bda3dbe6d608b416447e94424.zip FreeBSD-src-f1297dcac658b45bda3dbe6d608b416447e94424.tar.gz |
Add gctl_set_param() function.
Diffstat (limited to 'sys/geom/geom_ctl.c')
-rw-r--r-- | sys/geom/geom_ctl.c | 25 |
1 files changed, 25 insertions, 0 deletions
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) { |