scripts/setup: Fix check for mounted devices

The previous approach didn't take into the account systems where root
partition is representend in a virtual form of /dev/root (see
clearlinux). In case the device was bound to virtio this would fool
setup.sh into thinking nothing is mounted and proceed with unbinding
the entire rootfs.

Fix this by checking the maj:min numbers of the device instead of its
name against the mountinfo list.

Change-Id: I0feb2584869f6bb72df3e9a4e619620240cfce3b
Signed-off-by: Michal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4046
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Michal Berger 2020-09-03 13:37:07 +02:00 committed by Tomasz Zawadzki
parent 44775a8062
commit d6c499f3ee

View File

@ -160,7 +160,8 @@ function get_mounted_part_dev_from_bdf_block() {
for block in "${blocks[@]}"; do for block in "${blocks[@]}"; do
for part in "/sys/block/$block/$block"*; do for part in "/sys/block/$block/$block"*; do
if [[ $(< /proc/mounts) == *"/dev/${part##*/} "* ]]; then [[ -b /dev/${part##*/} ]] || continue
if [[ $(< /proc/self/mountinfo) == *" $(< "$part/dev") "* ]]; then
echo "${part##*/}" echo "${part##*/}"
fi fi
done done