PERFORCE change 112506 for review

Matt Jacob mjacob at FreeBSD.org
Thu Jan 4 16:26:33 PST 2007


http://perforce.freebsd.org/chv.cgi?CH=112506

Change 112506 by mjacob at mjexp on 2007/01/05 00:26:10

	Add 'clear' command.

Affected files ...

.. //depot/projects/mjexp/sbin/geom/class/multipath/geom_multipath.c#4 edit

Differences ...

==== //depot/projects/mjexp/sbin/geom/class/multipath/geom_multipath.c#4 (text+ko) ====

@@ -47,11 +47,16 @@
 
 static void mp_main(struct gctl_req *, unsigned int);
 static void mp_label(struct gctl_req *);
+static void mp_clear(struct gctl_req *);
 
 struct g_command class_commands[] = {
 	{
 		"label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, mp_main, G_NULL_OPTS,
-		"[-v] name prov prov"
+		"[-v] name prov ..."
+	},
+	{
+		"clear", G_FLAG_VERBOSE, mp_main, G_NULL_OPTS,
+		"[-v] prov ..."
 	},
 	{
 		"destroy", G_FLAG_VERBOSE, NULL, G_NULL_OPTS,
@@ -72,6 +77,8 @@
 	}
 	if (strcmp(name, "label") == 0) {
 		mp_label(req);
+	} if (strcmp(name, "clear") == 0) {
+		mp_clear(req);
 	} else {
 		gctl_error(req, "Unknown command: %s.", name);
 	}
@@ -90,7 +97,7 @@
 	int error, i, nargs;
 
 	nargs = gctl_get_int(req, "nargs");
-	if (nargs != 3) {
+	if (nargs < 2) {
 		gctl_error(req, "wrong number of arguments.");
 		return;
 	}
@@ -201,3 +208,28 @@
 		}
 	}
 }
+
+static void
+mp_clear(struct gctl_req *req)
+{
+	const char *name;
+	int error, i, nargs;
+
+	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;
+                }
+        }
+}
+


More information about the p4-projects mailing list