File powerpc-utils-bug-886123_01-l2of_scsi.patch of Package powerpc-utils
commit e7ee16163122f5c6f1ae600a2bc59a4eeab0c965
Author: Aruna Balakrishnaiah <aruna@linux.vnet.ibm.com>
Date: Mon Sep 15 13:54:54 2014 +0530
ofpathname: Convert logical path to OF device path for virtio-scsi devices
Add support to convert logical device path to Open firmware device path
for virtio-scsi devices.
Signed-off-by: Aruna Balakrishnaiah <aruna@linux.vnet.ibm.com>
diff --git a/scripts/ofpathname b/scripts/ofpathname
index 52df06c..f7baef7 100755
--- a/scripts/ofpathname
+++ b/scripts/ofpathname
@@ -139,6 +139,39 @@ get_hbtl()
}
#
+# get_scsi_disk_no
+# Given a path that ends in an HBTL, convert the HBTL values into a
+# virtual disk number (not sure what the real terminology is for it).
+# To do the conversion, the HBTL (A:B:C:D) is split apart and
+# calculated as;
+# no = (0x1000000 | C << 16 | D)
+#
+# $1 path ending in HBTL
+get_scsi_disk_no()
+{
+ get_hbtl $1
+
+ local C D
+
+ C=$((0x$ID << 16))
+ D=$((0x$LUN))
+
+ local vdiskno vdisk
+ typeset -i vdiskno
+ vdiskno=$((0x1000000 | $C | $D ))
+ vdisk=${vdiskno##-}
+
+ vdisk=`echo \`bc << END
+ibase=10
+obase=16
+$vdisk
+END\``
+
+ local extrazeroes="00000000"
+ echo $vdisk$extrazeroes
+}
+
+#
# get_vdisk_no
# Given a path that ends in an HBTL, convert the HBTL values into a
# virtual disk number (not sure what the real terminology is for it).
@@ -804,7 +837,19 @@ l2of_scsi()
OF_PATH=$OF_PATH/$scsi_name
fi
- OF_PATH=$OF_PATH/sd@$ID,$LUN
+ local modalias=""
+ goto_dir $device_path "device"
+ if [ $? -eq 0 ]; then
+ modalias=`$CAT $PWD/modalias`
+ fi
+
+ if [[ $modalias =~ "virtio" ]]; then
+ local diskno
+ diskno=`get_scsi_disk_no $device_dir`
+ OF_PATH=$OF_PATH/disk\@$diskno
+ else
+ OF_PATH=$OF_PATH/sd@$ID,$LUN
+ fi
fi
}