From 5d8d4137df765bfc59eaab99ee6cca493948f420 Mon Sep 17 00:00:00 2001 From: Matt Jacob Date: Sun, 4 Jul 2010 22:17:56 +0000 Subject: [PATCH] Fix the clear function which has been broken for a bit. MFC after: 1 week --- sbin/geom/class/multipath/geom_multipath.c | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/sbin/geom/class/multipath/geom_multipath.c b/sbin/geom/class/multipath/geom_multipath.c index 288492c90fad..2d2cdaf5613d 100644 --- a/sbin/geom/class/multipath/geom_multipath.c +++ b/sbin/geom/class/multipath/geom_multipath.c @@ -222,17 +222,28 @@ mp_label(struct gctl_req *req) } } + static void mp_clear(struct gctl_req *req) { const char *name; - int error; + int error, i, nargs; - name = gctl_get_ascii(req, "arg1"); - error = g_metadata_clear(name, G_MULTIPATH_MAGIC); - if (error != 0) { - fprintf(stderr, "Can't clear metadata on %s: %s.\n", name, strerror(error)); - gctl_error(req, "Not fully done."); + nargs = gctl_get_int(req, "nargs"); + if (nargs < 1) { + gctl_error(req, "Too few arguments."); + return; + } + + for (i = 0; i < nargs; i++) { + name = gctl_get_ascii(req, "arg%d", i); + error = g_metadata_clear(name, G_MULTIPATH_MAGIC); + if (error != 0) { + fprintf(stderr, "Can't clear metadata on %s: %s.\n", + name, strerror(error)); + gctl_error(req, "Not fully done."); + continue; + } } }