summaryrefslogtreecommitdiffstats
path: root/misc-utils/lsblk.c
diff options
context:
space:
mode:
authorKarel Zak2016-11-02 14:40:31 +0100
committerKarel Zak2016-11-02 14:40:31 +0100
commit5e2305ca5c2161279ac2577650b8f26789c1f751 (patch)
tree0b1016d612f70be2568ed28e2aba7e0930a15888 /misc-utils/lsblk.c
parentlibsmartcols: make scols_sort_table() usable for trees (diff)
downloadkernel-qcow2-util-linux-5e2305ca5c2161279ac2577650b8f26789c1f751.tar.gz
kernel-qcow2-util-linux-5e2305ca5c2161279ac2577650b8f26789c1f751.tar.xz
kernel-qcow2-util-linux-5e2305ca5c2161279ac2577650b8f26789c1f751.zip
lsblk: sort by MAJ:MIN by default
Since Linux kernel 4.8 /sys entries are no more sorted and all is in the native order. It makes lsblk output messy. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/lsblk.c')
-rw-r--r--misc-utils/lsblk.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index 8e6e6c5ac..b5042c5c1 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -1853,6 +1853,11 @@ int main(int argc, char *argv[])
if (nexcludes == 0 && nincludes == 0)
excludes[nexcludes++] = 1; /* default: ignore RAM disks */
+ if (lsblk->sort_id < 0)
+ /* Since Linux 4.8 we have sort devices by default, because
+ * /sys is no more sorted */
+ lsblk->sort_id = COL_MAJMIN;
+
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);