Skip to content

Commit b836c57

Browse files
committed
Only consider lspci if /sys/bus/pci/devices exists
1 parent 909178d commit b836c57

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

scripts/common/filesystem.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ ROOT_PROC="${ROOT_PATH}/proc"
5656
ROOT_ROOT="${ROOT_PATH}/root"
5757
ROOT_SRV="${ROOT_PATH}/srv"
5858
ROOT_SYS="${ROOT_PATH}/sys"
59+
ROOT_SYS_BUS="${ROOT_SYS}/bus"
60+
ROOT_SYS_BUS_PCI="${ROOT_SYS_BUS}/pci"
61+
ROOT_SYS_BUS_PCI_DEVICES="${ROOT_SYS_BUS_PCI}/devices"
5962
ROOT_SYS_DEVICES="${ROOT_SYS}/devices"
6063
ROOT_USR="${ROOT_PATH}/usr"
6164

@@ -134,6 +137,8 @@ function does_bin_exist() {
134137

135138
if grep -q '^/' <<< "${BINARY_NAME}" \
136139
&& does_file_exist "${BINARY_NAME}"; then
140+
[ "${BINARY_NAME}" = 'lspci' ] && [ ! -e "${ROOT_SYS_BUS_PCI_DEVICES}" ] && return 1 # False
141+
137142
return 0 # True
138143
fi
139144
done

scripts/common/system-info.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ function get_soc_name() {
213213
fi
214214

215215
if [ -z "${SOC_MODEL}" ] \
216-
&& does_bin_exist "lspci"; then
216+
&& [ -f "${ROOT_SYS_PCI_DEVICES}" ] \
217+
&& does_bin_exist 'lspci'; then
217218
if lspci | grep -q "\sPCI bridge:.*BCM[0-9]\+\s"; then
218219
SOC_MODEL=$(lspci | \
219220
grep "\sPCI bridge:" | \
@@ -292,7 +293,8 @@ function get_cpu_model() {
292293
fi
293294

294295
if [ -z "${MODEL}" ] \
295-
&& does_bin_exist "lspci"; then
296+
&& [ -f "${ROOT_SYS_PCI_DEVICES}" ] \
297+
&& does_bin_exist 'lspci'; then
296298
if lspci | grep -q "\sPCI bridge:.*BCM[0-9]\+\s"; then
297299
MODEL=$(lspci | \
298300
grep "\sPCI bridge:" | \
@@ -364,7 +366,8 @@ function get_cpu_family() {
364366
fi
365367

366368
if [ -z "${VENDOR}" ] \
367-
&& does_bin_exist "lspci"; then
369+
&& [ -f "${ROOT_SYS_PCI_DEVICES}" ] \
370+
&& does_bin_exist 'lspci'; then
368371
CPU_LINE=$(lspci | grep "\sPCI bridge:" | head -n 1)
369372
VENDOR="$(get_cpu_vendor_from_line ${CPU_LINE})"
370373
fi

0 commit comments

Comments
 (0)