setup.sh: updated to support older linux kernel

When looking up nvme devices by name in older linux kernel versions, setup.sh
was throwing errors while trying to follow a symlink on
/sys/block/. This patch adds a fallback to the proper location of this
symlink in those versions of the kernel.

Change-Id: I13b5c1ce6f7505251789b64c740aba04d67f39a9
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/391019
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Seth Howell 2017-12-08 12:24:46 -07:00 committed by Jim Harris
parent ea11d68481
commit afec8f1476

View File

@ -69,7 +69,11 @@ function get_nvme_name_from_bdf {
nvme_devs=`lsblk -d --output NAME | grep "^nvme"`
set -e
for dev in $nvme_devs; do
bdf=$(basename $(readlink /sys/block/$dev/device/device))
link_name=$(readlink /sys/block/$dev/device/device) || true
if [ -z "$link_name" ]; then
link_name=$(readlink /sys/block/$dev/device)
fi
bdf=$(basename "$link_name")
if [ "$bdf" = "$1" ]; then
eval "$2=$dev"
return