Add gctl_set_param() function.
This commit is contained in:
parent
65684800f0
commit
f1297dcac6
@ -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, ...);
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user