aboutsummaryrefslogtreecommitdiffstats
path: root/sbin/geom/misc
diff options
context:
space:
mode:
authorMarcel Moolenaar <marcel@FreeBSD.org>2008-06-06 22:44:03 +0000
committerMarcel Moolenaar <marcel@FreeBSD.org>2008-06-06 22:44:03 +0000
commit59458baf2bfb02791b5a4863d11e799e2df8cdae (patch)
treee0227a2691ad9565930c3ac13f0b75c3e565daef /sbin/geom/misc
parent47b4fb40305999f1c7f625950e34a463c25de4b9 (diff)
downloadsrc-59458baf2bfb02791b5a4863d11e799e2df8cdae.tar.gz
src-59458baf2bfb02791b5a4863d11e799e2df8cdae.zip
Add two support functions:
o gctl_delete_param() -- intended for parameters that are consumed by geom(8) itself and which should not be passed to the kernel. o gctl_has_param() -- intended to check if optional parameters are present. Both are needed by gpart(8) to process the optional parameter for writing bootcode to a partition (as part of the bootcode verb). However, the kernel is itself not involved in this matter and the parameter needs to be removed from the request destined for the kernel.
Notes
Notes: svn path=/head/; revision=179628
Diffstat (limited to 'sbin/geom/misc')
-rw-r--r--sbin/geom/misc/subr.c44
-rw-r--r--sbin/geom/misc/subr.h3
2 files changed, 47 insertions, 0 deletions
diff --git a/sbin/geom/misc/subr.c b/sbin/geom/misc/subr.c
index 745d91955d3d..64df7c6845ed 100644
--- a/sbin/geom/misc/subr.c
+++ b/sbin/geom/misc/subr.c
@@ -414,3 +414,47 @@ gctl_change_param(struct gctl_req *req, const char *name, int len,
}
return (ENOENT);
}
+
+int
+gctl_delete_param(struct gctl_req *req, const char *name)
+{
+ struct gctl_req_arg *ap;
+ unsigned int i;
+
+ if (req == NULL || req->error != NULL)
+ return (EDOOFUS);
+
+ i = 0;
+ while (i < req->narg) {
+ ap = &req->arg[i];
+ if (strcmp(ap->name, name) == 0)
+ break;
+ i++;
+ }
+ if (i == req->narg)
+ return (ENOENT);
+
+ req->narg--;
+ while (i < req->narg) {
+ req->arg[i] = req->arg[i + 1];
+ i++;
+ }
+ return (0);
+}
+
+int
+gctl_has_param(struct gctl_req *req, const char *name)
+{
+ struct gctl_req_arg *ap;
+ unsigned int i;
+
+ if (req == NULL || req->error != NULL)
+ return (0);
+
+ for (i = 0; i < req->narg; i++) {
+ ap = &req->arg[i];
+ if (strcmp(ap->name, name) == 0)
+ return (1);
+ }
+ return (0);
+}
diff --git a/sbin/geom/misc/subr.h b/sbin/geom/misc/subr.h
index 4c54142891bc..c3242a3bdc9b 100644
--- a/sbin/geom/misc/subr.h
+++ b/sbin/geom/misc/subr.h
@@ -47,4 +47,7 @@ intmax_t gctl_get_intmax(struct gctl_req *req, const char *pfmt, ...) __printfli
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);
+int gctl_delete_param(struct gctl_req *req, const char *name);
+int gctl_has_param(struct gctl_req *req, const char *name);
+
#endif /* !_SUBR_H_ */