public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lsblk: add -O option to show all available columns
@ 2014-04-27  5:18 Masatake YAMATO
  2014-05-06  9:01 ` Karel Zak
  0 siblings, 1 reply; 2+ messages in thread
From: Masatake YAMATO @ 2014-04-27  5:18 UTC (permalink / raw)
  To: util-linux; +Cc: yamato

Simple command line for gathering information as many
as possible is useful when understanding a system,
especially when trouble shooting.

This patch introduces -O option which enables all
available columns.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
---
 misc-utils/lsblk.8 |  3 +++
 misc-utils/lsblk.c | 27 +++++++++++++++++++--------
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/misc-utils/lsblk.8 b/misc-utils/lsblk.8
index ea7e7be..e87689b 100644
--- a/misc-utils/lsblk.8
+++ b/misc-utils/lsblk.8
@@ -83,6 +83,9 @@ to get a list of all supported columns.
 The default list of columns may be extended if \fIlist\fP is
 specified in the format \fI+list\fP (e.g. \fBlsblk -o +UUID\fP).
 .TP
+.BR \-O , " \-\-output-all "
+Output all available columns.
+.TP
 .BR \-P , " \-\-pairs"
 Produce output in the form of key="value" pairs.
 All potentially unsafe characters are hex-escaped (\\x<code>).
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index 2efb2ec..ea4dc60 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -115,6 +115,7 @@ enum {
 	LSBLK_NOHEADINGS =	(1 << 2),
 	LSBLK_EXPORT =		(1 << 3),
 	LSBLK_TREE =		(1 << 4),
+	LSBLK_ALL_COL =		(1 << 5),
 };
 
 /* column names */
@@ -1358,6 +1359,7 @@ static void __attribute__((__noreturn__)) help(FILE *out)
 	fputs(_(" -m, --perms          output info about permissions\n"), out);
 	fputs(_(" -n, --noheadings     don't print headings\n"), out);
 	fputs(_(" -o, --output <list>  output columns\n"), out);
+	fputs(_(" -O, --output-all     output all columns\n"), out);
 	fputs(_(" -p, --paths          print complete device path\n"), out);
 	fputs(_(" -P, --pairs          use key=\"value\" output format\n"), out);
 	fputs(_(" -r, --raw            use raw output format\n"), out);
@@ -1399,6 +1401,7 @@ int main(int argc, char *argv[])
 		{ "discard",    0, 0, 'D' },
 		{ "help",	0, 0, 'h' },
 		{ "output",     1, 0, 'o' },
+		{ "output-all", 0, 0, 'O' },
 		{ "perms",      0, 0, 'm' },
 		{ "noheadings",	0, 0, 'n' },
 		{ "list",       0, 0, 'l' },
@@ -1432,7 +1435,7 @@ int main(int argc, char *argv[])
 	memset(lsblk, 0, sizeof(*lsblk));
 
 	while((c = getopt_long(argc, argv,
-			       "abdDe:fhlnmo:pPiI:rstVS", longopts, NULL)) != -1) {
+			       "abdDe:fhlnmo:OpPiI:rstVS", longopts, NULL)) != -1) {
 
 		err_exclusive_options(c, longopts, excl, excl_st);
 
@@ -1468,6 +1471,9 @@ int main(int argc, char *argv[])
 		case 'o':
 			outarg = optarg;
 			break;
+		case 'O':
+			scols_flags |= LSBLK_ALL_COL;
+			break;
 		case 'p':
 			lsblk->paths = 1;
 			break;
@@ -1537,13 +1543,18 @@ int main(int argc, char *argv[])
 	check_sysdevblock();
 
 	if (!ncolumns) {
-		columns[ncolumns++] = COL_NAME;
-		columns[ncolumns++] = COL_MAJMIN;
-		columns[ncolumns++] = COL_RM;
-		columns[ncolumns++] = COL_SIZE;
-		columns[ncolumns++] = COL_RO;
-		columns[ncolumns++] = COL_TYPE;
-		columns[ncolumns++] = COL_TARGET;
+		if ((scols_flags & LSBLK_ALL_COL)) {
+			for ( ; ncolumns < NCOLS; ncolumns++)
+				columns[ncolumns] = ncolumns;
+		} else {
+			columns[ncolumns++] = COL_NAME;
+			columns[ncolumns++] = COL_MAJMIN;
+			columns[ncolumns++] = COL_RM;
+			columns[ncolumns++] = COL_SIZE;
+			columns[ncolumns++] = COL_RO;
+			columns[ncolumns++] = COL_TYPE;
+			columns[ncolumns++] = COL_TARGET;
+		}
 	}
 
 	if (outarg && string_add_to_idarray(outarg, columns, ARRAY_SIZE(columns),
-- 
1.9.0


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

* Re: [PATCH] lsblk: add -O option to show all available columns
  2014-04-27  5:18 [PATCH] lsblk: add -O option to show all available columns Masatake YAMATO
@ 2014-05-06  9:01 ` Karel Zak
  0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2014-05-06  9:01 UTC (permalink / raw)
  To: Masatake YAMATO; +Cc: util-linux

On Sun, Apr 27, 2014 at 02:18:41PM +0900, Masatake YAMATO wrote:
> Simple command line for gathering information as many
> as possible is useful when understanding a system,
> especially when trouble shooting.
> 
> This patch introduces -O option which enables all
> available columns.

 Applied with some changes, thanks.

 (I want so huge LCD you have, my 24" is not enough for -O ;-)

    Karel


-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

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

end of thread, other threads:[~2014-05-06  9:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-27  5:18 [PATCH] lsblk: add -O option to show all available columns Masatake YAMATO
2014-05-06  9:01 ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox