]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsblk: add --pairs to output in key="value" format
authorKarel Zak <kzak@redhat.com>
Tue, 10 May 2011 08:38:29 +0000 (10:38 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 10 May 2011 08:38:29 +0000 (10:38 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/lsblk.8
misc-utils/lsblk.c

index d7d7aa8b4d8b68deb62be43ba12a34a0443fe141..2fcc7e522111a56b3124ea6e0371f5f72e21de11 100644 (file)
@@ -42,7 +42,7 @@ command.
 .IP "\fB\-h, \-\-help\fP"
 Print a help text and exit.
 .IP "\fB\-i, \-\-ascii\fP"
-Use ascii characters for tree formatting.
+Use ASCII characters for tree formatting.
 .IP "\fB\-m, \-\-perms\fP
 Output info about device owner, group and mode.  This option is equivalent to "-o NAME,SIZE,OWNER,GROUP,MODE".
 .IP "\fB\-l, \-\-list\fP"
@@ -53,6 +53,8 @@ Do not print a header line.
 Specify which output columns to print.  Use
 .B "--help"
 to get a list of all supported columns.
+.IP "\fB\-P, \-\-pairs\fP"
+Use key="value" output format.
 .IP "\fB\-r, \-\-raw\fP"
 Use the raw output format.
 .IP "\fB\-t, \-\-topology\fP"
index dc4e15aafd1b4266a37a76f5d67c4d71c5315981..2110113dd66a6e6775d120ea74ade74bc73b1049 100644 (file)
@@ -612,7 +612,8 @@ static void set_tt_data(struct blkdev_cxt *cxt, int col, int id, struct tt_line
                break;
        }
        case COL_MAJMIN:
-               if (lsblk->tt->flags & TT_FL_RAW)
+               if ((lsblk->tt->flags & TT_FL_RAW) ||
+                   (lsblk->tt->flags & TT_FL_EXPORT))
                        snprintf(buf, sizeof(buf), "%u:%u", cxt->maj, cxt->min);
                else
                        snprintf(buf, sizeof(buf), "%3u:%-3u", cxt->maj, cxt->min);
@@ -971,7 +972,8 @@ static void __attribute__((__noreturn__)) help(FILE *out)
                " -l, --list           use list format ouput\n"
                " -n, --noheadings     don't print headings\n"
                " -o, --output <list>  output columns\n"
-               " -r, --raw            use raw format output\n"
+               " -P, --pairs          use key=\"value\" output format\n"
+               " -r, --raw            use raw output format\n"
                " -t, --topology       output info about topology\n"));
 
        fprintf(out, _("\nAvailable columns:\n"));
@@ -1011,6 +1013,7 @@ int main(int argc, char *argv[])
                { "fs",         0, 0, 'f' },
                { "exclude",    1, 0, 'e' },
                { "topology",   0, 0, 't' },
+               { "pairs",      0, 0, 'P' },
                { NULL, 0, 0, 0 },
        };
 
@@ -1021,7 +1024,7 @@ int main(int argc, char *argv[])
        lsblk = &_ls;
        memset(lsblk, 0, sizeof(*lsblk));
 
-       while((c = getopt_long(argc, argv, "abdDe:fhlnmo:irt", longopts, NULL)) != -1) {
+       while((c = getopt_long(argc, argv, "abdDe:fhlnmo:Pirt", longopts, NULL)) != -1) {
                switch(c) {
                case 'a':
                        lsblk->all_devices = 1;
@@ -1046,8 +1049,8 @@ int main(int argc, char *argv[])
                        help(stdout);
                        break;
                case 'l':
-                       if (tt_flags & TT_FL_RAW)
-                               errx_mutually_exclusive("--{raw,list}");
+                       if ((tt_flags & TT_FL_RAW)|| (tt_flags & TT_FL_EXPORT))
+                               errx_mutually_exclusive("--{raw,list,export}");
 
                        tt_flags &= ~TT_FL_TREE; /* disable the default */
                        break;
@@ -1059,6 +1062,10 @@ int main(int argc, char *argv[])
                                                column_name_to_id))
                                return EXIT_FAILURE;
                        break;
+               case 'P':
+                       tt_flags |= TT_FL_EXPORT;
+                       tt_flags &= ~TT_FL_TREE;        /* disable the default */
+                       break;
                case 'i':
                        tt_flags |= TT_FL_ASCII;
                        break;