From: Milan Broz Date: Thu, 26 Jul 2012 13:52:05 +0000 (+0200) Subject: lsblk: support -o + for adding attribute to output fields. X-Git-Tag: v2.22-rc1~31 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=43bca8278647ad5a3ae233da56fe1e87c086afe2;p=thirdparty%2Futil-linux.git lsblk: support -o + for adding attribute to output fields. Signed-off-by: Milan Broz --- diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index cfd1d3b9ed..1a0943b3e6 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; static const struct option longopts[] = { { "all", 0, 0, 'a' }, @@ -1286,11 +1287,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': tt_flags |= TT_FL_EXPORT; @@ -1356,6 +1353,10 @@ int main(int argc, char *argv[]) columns[ncolumns++] = COL_TARGET; } + if (outarg && string_add_to_idarray(outarg, columns, ARRAY_SIZE(columns), + &ncolumns, column_name_to_id) < 0) + return EXIT_FAILURE; + if (nexcludes == 0 && nincludes == 0) excludes[nexcludes++] = 1; /* default: ignore RAM disks */