Patch to allow gmirror to set priority of a disk

Mel Flynn mel.flynn+fbsd.fs at mailing.thruhere.net
Sat Sep 5 20:25:09 UTC 2009


On Saturday 05 September 2009 21:22:51 Pawel Jakub Dawidek wrote:

> And tech core geom(8) utility to split usage based on \n.
> usage_command() function from sbin/geom/core/geom.c would have to be
> modified. If you agree with this idea, would you also like to work on
> this?

Yes and see attached. Since utility exists after displaying usage, I didn't 
take the trouble of freeing ptr, but if this is preferred then I'll add the 
line.

% geom mirror foo
geom: Unknown command: foo.
usage: geom mirror activate [-v] name prov ...
       geom mirror clear [-v] prov ...
       geom mirror configure[-adfFhnv] [-b balance] [-s slice] name
       geom mirror configure -p priority name prov

-- 
Mel
-------------- next part --------------
Index: sbin/geom/core/geom.c
===================================================================
--- sbin/geom/core/geom.c	(revision 196868)
+++ sbin/geom/core/geom.c	(working copy)
@@ -98,11 +98,23 @@
 	struct g_option *opt;
 	unsigned i;
 
-	fprintf(stderr, "%s %s %s", prefix, comm, cmd->gc_name);
 	if (cmd->gc_usage != NULL) {
-		fprintf(stderr, " %s\n", cmd->gc_usage);
+		char *pos, *ptr;
+
+		ptr = strdup(cmd->gc_usage);
+		while ((pos = strchr(ptr, '\n')) != NULL) {
+			*pos = '\0';
+			fprintf(stderr, "%s %s %s", prefix, comm, cmd->gc_name);
+			fprintf(stderr, "%s\n", ptr);
+			ptr = pos + 1;
+		}
+		/* Tail or no \n at all */
+		fprintf(stderr, "%s %s %s", prefix, comm, cmd->gc_name);
+		fprintf(stderr, " %s\n", ptr);
 		return;
 	}
+
+	fprintf(stderr, "%s %s %s", prefix, comm, cmd->gc_name);
 	if ((cmd->gc_flags & G_FLAG_VERBOSE) != 0)
 		fprintf(stderr, " [-v]");
 	for (i = 0; ; i++) {


More information about the freebsd-fs mailing list