]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsblk: support -o +<attr> for adding attribute to output fields.
authorMilan Broz <mbroz@redhat.com>
Thu, 26 Jul 2012 13:52:05 +0000 (15:52 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 26 Jul 2012 14:37:03 +0000 (16:37 +0200)
Signed-off-by: Milan Broz <mbroz@redhat.com>
misc-utils/lsblk.c

index cfd1d3b9ed5e3bb56f854f4987344f71ec1bc2bc..1a0943b3e661c532ca1edfbce081276ba718840e 100644 (file)
@@ -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 */