Skip to content

Commit

Permalink
lsblk: sort by MAJ:MIN by default
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
karelzak committed Nov 2, 2016
1 parent 95a528d commit 5e2305c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions misc-utils/lsblk.c
Expand Up @@ -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);
Expand Down

0 comments on commit 5e2305c

Please sign in to comment.