Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Sep 2009 22:25:05 +0200
From:      Mel Flynn <mel.flynn+fbsd.fs@mailing.thruhere.net>
To:        freebsd-fs@freebsd.org
Cc:        Pawel Jakub Dawidek <pjd@freebsd.org>, freebsd-geom@freebsd.org
Subject:   Re: Patch to allow gmirror to set priority of a disk
Message-ID:  <200909052225.06185.mel.flynn%2Bfbsd.fs@mailing.thruhere.net>
In-Reply-To: <20090905192251.GJ1665@garage.freebsd.pl>
References:  <200909030000.11961.mel.flynn%2Bfbsd.fs@mailing.thruhere.net> <200909052111.27667.mel.flynn%2Bfbsd.fs@mailing.thruhere.net> <20090905192251.GJ1665@garage.freebsd.pl>

next in thread | previous in thread | raw e-mail | index | archive | help
--Boundary-00=_iksoKYVobZGJI9m
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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

--Boundary-00=_iksoKYVobZGJI9m
Content-Type: text/plain;
  charset="UTF-8";
  name="geom-core.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="geom-core.txt"

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++) {

--Boundary-00=_iksoKYVobZGJI9m--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200909052225.06185.mel.flynn%2Bfbsd.fs>