gen_nvme: Be FreeBSD friendly

Since sysfs is not used by the FreeBSD the following error can be
seen each time gen_nvme.sh is run:

  grep: /sys/bus/pci/devices/$bdf/uevent: No such file or directory

Avoid that by looking up the pci address in a way specific to
FreeBSD.

Change-Id: If81e71cece52c2f27dcf68f7a7eba3dd7d8ce10f
Signed-off-by: Michal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2227
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Michal Berger 2020-05-06 21:43:50 +02:00 committed by Tomasz Zawadzki
parent d51345c0b9
commit c8c4f71efe

View File

@ -39,10 +39,11 @@ bdfs=()
# then most likely PCI_WHITELIST option was used for setup.sh
# and we do not want to use that disk.
for bdf in $(iter_pci_class_code 01 08 02); do
driver=$(grep DRIVER /sys/bus/pci/devices/$bdf/uevent | awk -F"=" '{print $2}')
if [ "$driver" != "nvme" ]; then
bdfs+=("$bdf")
if [[ -e /sys/bus/pci/drivers/nvme/$bdf ]] \
|| [[ $(uname -s) == FreeBSD && $(pciconf -l "pci$bdf") == nvme* ]]; then
continue
fi
bdfs+=("$bdf")
done
if [ "$1" = "--json" ]; then