]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsblk: sort by MAJ:MIN by default
authorKarel Zak <kzak@redhat.com>
Wed, 2 Nov 2016 13:40:31 +0000 (14:40 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 2 Nov 2016 13:40:31 +0000 (14:40 +0100)
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>
misc-utils/lsblk.c

index 8e6e6c5acd0ca58de3bb9f20210aa62009584230..b5042c5c1a103f3e47a312f4ca43080b10a524e2 100644 (file)
@@ -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);