aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2016-11-02 14:40:31 +0100
committerKarel Zak <kzak@redhat.com>2016-11-02 14:40:31 +0100
commit5e2305ca5c2161279ac2577650b8f26789c1f751 (patch)
tree0b1016d612f70be2568ed28e2aba7e0930a15888
parent95a528ddbc27528e7bcd54cef5f539128b125658 (diff)
downloadutil-linux-5e2305ca5c2161279ac2577650b8f26789c1f751.tar.gz
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>
-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 8e6e6c5acd..b5042c5c1a 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);