aboutsummaryrefslogtreecommitdiffstats
path: root/sbin/geom/misc
diff options
context:
space:
mode:
authorPawel Jakub Dawidek <pjd@FreeBSD.org>2007-01-25 11:35:27 +0000
committerPawel Jakub Dawidek <pjd@FreeBSD.org>2007-01-25 11:35:27 +0000
commit1378624c2e663cfee46a224c0ae1ae768616d686 (patch)
tree175d17a3e4ed80b502ea89880607a3463d493220 /sbin/geom/misc
parentc4b1628e07bbc09ad531852c8affea7a5e352a77 (diff)
downloadsrc-1378624c2e663cfee46a224c0ae1ae768616d686.tar.gz
src-1378624c2e663cfee46a224c0ae1ae768616d686.zip
Implement gctl_change_param() function, which changes value of existing
parameter. MFC after: 1 week
Notes
Notes: svn path=/head/; revision=166215
Diffstat (limited to 'sbin/geom/misc')
-rw-r--r--sbin/geom/misc/subr.c26
-rw-r--r--sbin/geom/misc/subr.h2
2 files changed, 28 insertions, 0 deletions
diff --git a/sbin/geom/misc/subr.c b/sbin/geom/misc/subr.c
index 1faafe5bdd46..745d91955d3d 100644
--- a/sbin/geom/misc/subr.c
+++ b/sbin/geom/misc/subr.c
@@ -388,3 +388,29 @@ gctl_get_ascii(struct gctl_req *req, const char *pfmt, ...)
va_end(ap);
return (p);
}
+
+int
+gctl_change_param(struct gctl_req *req, const char *name, int len,
+ const void *value)
+{
+ struct gctl_req_arg *ap;
+ unsigned i;
+
+ if (req == NULL || req->error != NULL)
+ return (EDOOFUS);
+ for (i = 0; i < req->narg; i++) {
+ ap = &req->arg[i];
+ if (strcmp(ap->name, name) != 0)
+ continue;
+ ap->value = __DECONST(void *, value);
+ if (len >= 0) {
+ ap->flag &= ~GCTL_PARAM_ASCII;
+ ap->len = len;
+ } else if (len < 0) {
+ ap->flag |= GCTL_PARAM_ASCII;
+ ap->len = strlen(value) + 1;
+ }
+ return (0);
+ }
+ return (ENOENT);
+}
diff --git a/sbin/geom/misc/subr.h b/sbin/geom/misc/subr.h
index 865e855f09bf..4c54142891bc 100644
--- a/sbin/geom/misc/subr.h
+++ b/sbin/geom/misc/subr.h
@@ -45,4 +45,6 @@ void gctl_error(struct gctl_req *req, const char *error, ...) __printflike(2, 3)
int gctl_get_int(struct gctl_req *req, const char *pfmt, ...) __printflike(2, 3);
intmax_t gctl_get_intmax(struct gctl_req *req, const char *pfmt, ...) __printflike(2, 3);
const char *gctl_get_ascii(struct gctl_req *req, const char *pfmt, ...) __printflike(2, 3);
+int gctl_change_param(struct gctl_req *req, const char *name, int len,
+ const void *value);
#endif /* !_SUBR_H_ */