diff options
author | Karel Zak | 2017-04-13 11:39:22 +0200 |
---|---|---|
committer | Karel Zak | 2017-04-13 11:39:22 +0200 |
commit | 091683a82f85b4cc81a829b2c1155d4d09cf03cd (patch) | |
tree | 9bb214e1d6c8ce85b037484e31dfc723fe7dcaa7 /misc-utils | |
parent | libsmartcols: add scols_sort_table_by_tree() (diff) | |
download | kernel-qcow2-util-linux-091683a82f85b4cc81a829b2c1155d4d09cf03cd.tar.gz kernel-qcow2-util-linux-091683a82f85b4cc81a829b2c1155d4d09cf03cd.tar.xz kernel-qcow2-util-linux-091683a82f85b4cc81a829b2c1155d4d09cf03cd.zip |
lsblk: fix --inverse --list
Let's follow --inverse dependencies although --list output requested.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1441175
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils')
-rw-r--r-- | misc-utils/lsblk.8 | 3 | ||||
-rw-r--r-- | misc-utils/lsblk.c | 7 |
2 files changed, 9 insertions, 1 deletions
diff --git a/misc-utils/lsblk.8 b/misc-utils/lsblk.8 index 8eebc8de7..ee1d873d0 100644 --- a/misc-utils/lsblk.8 +++ b/misc-utils/lsblk.8 @@ -114,7 +114,8 @@ Produce output in raw format. All potentially unsafe characters are hex-escaped Output info about SCSI devices only. All partitions, slaves and holder devices are ignored. .TP .BR \-s , " \-\-inverse" -Print dependencies in inverse order. +Print dependencies in inverse order. If the \fB\-\-list\fR output is requested then +the lines are still ordered by dependencies. .TP .BR \-t , " \-\-topology" Output info about block-device topology. diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index c30573e8b..4742a4de1 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -216,6 +216,7 @@ struct lsblk { unsigned int scsi:1; /* print only device with HCTL (SCSI) */ unsigned int paths:1; /* print devnames with "/dev" prefix */ unsigned int sort_hidden:1; /* sort column not between output columns */ + unsigned int force_tree_order:1;/* sort lines by parent->tree relation */ }; static struct lsblk *lsblk; /* global handler */ @@ -1859,6 +1860,10 @@ int main(int argc, char *argv[]) * /sys is no more sorted */ lsblk->sort_id = COL_MAJMIN; + /* For --inverse --list we still follow parent->child relation */ + if (lsblk->inverse && !(lsblk->flags & LSBLK_TREE)) + lsblk->force_tree_order = 1; + if (lsblk->sort_id >= 0 && column_id_to_number(lsblk->sort_id) < 0) { /* the sort column is not between output columns -- add as hidden */ add_column(columns, ncolumns++, lsblk->sort_id); @@ -1923,6 +1928,8 @@ int main(int argc, char *argv[]) if (lsblk->sort_col) scols_sort_table(lsblk->table, lsblk->sort_col); + if (lsblk->force_tree_order) + scols_sort_table_by_tree(lsblk->table); scols_print_table(lsblk->table); |