util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lsblk: support -o +<attr> for adding attribute to output fields.
@ 2012-07-26 12:14 Milan Broz
  2012-07-26 13:52 ` [PATCH 1/5] Add string_add_to_idarray() - parse and add to id list Milan Broz
  0 siblings, 1 reply; 11+ messages in thread
From: Milan Broz @ 2012-07-26 12:14 UTC (permalink / raw)
  To: util-linux; +Cc: Milan Broz

E.g. lsblk -o +model
(Maybe it would be nice to add this to other tools as well?)

Signed-off-by: Milan Broz <mbroz@redhat.com>
---
 misc-utils/lsblk.c |   22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index cb2b768..471f2d5 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -1213,6 +1213,7 @@ int main(int argc, char *argv[])
 	struct lsblk _ls;
 	int tt_flags = TT_FL_TREE;
 	int i, c, status = EXIT_FAILURE;
+	char *outarg = NULL;
 
 	enum {
 		EXCL_NONE,
@@ -1290,11 +1291,7 @@ int main(int argc, char *argv[])
 			tt_flags |= TT_FL_NOHEADINGS;
 			break;
 		case 'o':
-			ncolumns = string_to_idarray(optarg,
-						columns, ARRAY_SIZE(columns),
-						column_name_to_id);
-			if (ncolumns < 0)
-				return EXIT_FAILURE;
+			outarg = optarg;
 			break;
 		case 'P':
 			exclusive_option(&excl_rlP, EXCL_PAIRS, "--{raw,list,pairs}");
@@ -1363,6 +1360,21 @@ int main(int argc, char *argv[])
 		columns[ncolumns++] = COL_TARGET;
 	}
 
+	if (outarg) {
+		if (outarg[0] == '+')
+			outarg++;
+		else
+			ncolumns = 0;
+
+		c = string_to_idarray(outarg, &columns[ncolumns],
+					ARRAY_SIZE(columns) - ncolumns,
+					column_name_to_id);
+		if (c < 0)
+			return EXIT_FAILURE;
+
+		ncolumns += c;
+	}
+
 	if (nexcludes == 0 && nincludes == 0)
 		excludes[nexcludes++] = 1;	/* default: ignore RAM disks */
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-07-26 14:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-26 12:14 [PATCH] lsblk: support -o +<attr> for adding attribute to output fields Milan Broz
2012-07-26 13:52 ` [PATCH 1/5] Add string_add_to_idarray() - parse and add to id list Milan Broz
2012-07-26 13:52   ` [PATCH 2/5] lsblk: support -o +<attr> for adding attribute to output fields Milan Broz
2012-07-26 14:47     ` Karel Zak
2012-07-26 13:52   ` [PATCH 3/5] partx: " Milan Broz
2012-07-26 14:47     ` Karel Zak
2012-07-26 13:52   ` [PATCH 4/5] findmnt: " Milan Broz
2012-07-26 14:47     ` Karel Zak
2012-07-26 13:52   ` [PATCH 5/5] wdctl: " Milan Broz
2012-07-26 14:48     ` Karel Zak
2012-07-26 14:46   ` [PATCH 1/5] Add string_add_to_idarray() - parse and add to id list Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).