From 42f24e153a717367d9e8b5de3507e12f135ab5fd Mon Sep 17 00:00:00 2001 From: Pawel Wodkowski Date: Thu, 7 Feb 2019 13:20:38 +0100 Subject: [PATCH] setup.sh: try harder to find out if driver is loaded Change-Id: I098285ff42271a7577a260cd864c015b235833b5 Signed-off-by: Pawel Wodkowski Reviewed-on: https://review.gerrithub.io/c/443765 (master) Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448425 Reviewed-by: Jim Harris Reviewed-by: Ben Walker Tested-by: Darek Stojaczyk --- scripts/setup.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index 0bf4c19b6e..0f3b8833c6 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -60,18 +60,19 @@ function usage() } # In monolithic kernels the lsmod won't work. So -# back that with a /sys/modules check. Return a different code for -# built-in vs module just in case we want that down the road. +# back that with a /sys/modules. We also check +# /sys/bus/pci/drivers/ as neither lsmod nor /sys/modules might +# contain needed info (like in Fedora-like OS). function check_for_driver { - $(lsmod | grep $1 > /dev/null) - if [ $? -eq 0 ]; then + if lsmod | grep -q ${1//-/_}; then return 1 - else - if [[ -d /sys/module/$1 ]]; then - return 2 - else - return 0 - fi + fi + + if [[ -d /sys/module/${1} || \ + -d /sys/module/${1//-/_} || \ + -d /sys/bus/pci/drivers/${1} || \ + -d /sys/bus/pci/drivers/${1//-/_} ]]; then + return 2 fi return 0 }