From d6c499f3ee26f8db737ec48b86f93d27af4e855c Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Thu, 3 Sep 2020 13:37:07 +0200 Subject: [PATCH] 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 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4046 Reviewed-by: Karol Latecki Reviewed-by: Maciej Wawryk Reviewed-by: Jim Harris Reviewed-by: Tomasz Zawadzki Tested-by: SPDK CI Jenkins --- scripts/setup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index 82d6d2092..78becd7e5 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -160,7 +160,8 @@ function get_mounted_part_dev_from_bdf_block() { for block in "${blocks[@]}"; 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##*/}" fi done