From db9e1c907a5b9d9a8a9d084ecaac0f4a0277599c Mon Sep 17 00:00:00 2001 From: Tony Hutter Date: Fri, 29 Oct 2021 15:33:34 -0700 Subject: [PATCH] vdev_id: Fix PHY sorting One of our developers noticed a bug in vdev_id where we were incorrectly sorting PHYs using alphabetical sorting (which usually works) instead of natural sorting (-v). For example: [port-0:0]# ls -d phy* phy-0:10 phy-0:11 phy-0:8 phy-0:9 [port-0:0]# ls -vd phy* phy-0:8 phy-0:9 phy-0:10 phy-0:11 This fixes the issue. Reviewed-by: Brian Behlendorf Signed-off-by: Tony Hutter Closes #12699 --- cmd/vdev_id/vdev_id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/vdev_id/vdev_id b/cmd/vdev_id/vdev_id index ab9d7326f..8cc4399a5 100755 --- a/cmd/vdev_id/vdev_id +++ b/cmd/vdev_id/vdev_id @@ -375,7 +375,7 @@ sas_handler() { i=$((i + 1)) done - PHY=$(ls -d "$port_dir"/phy* 2>/dev/null | head -1 | awk -F: '{print $NF}') + PHY=$(ls -vd "$port_dir"/phy* 2>/dev/null | head -1 | awk -F: '{print $NF}') if [ -z "$PHY" ] ; then PHY=0 fi