Blame SOURCES/bz1744140-Filesystem-3-improved-bind-mount-check.patch

9cf66a
From f8e5d2afc5b9bbf676ac20894f0f26e6ec998557 Mon Sep 17 00:00:00 2001
9cf66a
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
9cf66a
Date: Tue, 10 Sep 2019 15:40:12 +0200
9cf66a
Subject: [PATCH] Filesystem: improve "/" check for bind mounts
9cf66a
9cf66a
---
9cf66a
 heartbeat/Filesystem | 15 +++------------
9cf66a
 1 file changed, 3 insertions(+), 12 deletions(-)
9cf66a
9cf66a
diff --git a/heartbeat/Filesystem b/heartbeat/Filesystem
9cf66a
index 738e3c08e..e66ddc77f 100755
9cf66a
--- a/heartbeat/Filesystem
9cf66a
+++ b/heartbeat/Filesystem
9cf66a
@@ -337,17 +337,8 @@ bind_kernel_check() {
9cf66a
 		ocf_log warn "kernel `uname -r` cannot handle read only bind mounts"
9cf66a
 }
9cf66a
 
9cf66a
-bind_rootfs_check() {
9cf66a
-        local SOURCE
9cf66a
-        local TARGET
9cf66a
-        local ROOTFS
9cf66a
-
9cf66a
-        SOURCE=$1
9cf66a
-        TARGET=$(df --output=target $SOURCE | tail -n 1)
9cf66a
-
9cf66a
-        ROOTFS=$(list_mounts | grep -w rootfs | cut -d' ' -f 2)
9cf66a
-
9cf66a
-        if [ "${TARGET}" = "${ROOTFS}" ]; then
9cf66a
+bind_root_mount_check() {
9cf66a
+	if [ "$(df -P "$1"  | awk 'END{print $6}')" = "/" ]; then
9cf66a
                 return 1
9cf66a
         else
9cf66a
                 return 0
9cf66a
@@ -516,7 +507,7 @@ get_pids()
9cf66a
 	local procs
9cf66a
 	local mmap_procs
9cf66a
 
9cf66a
-        if is_bind_mount && ocf_is_true "$FORCE_UNMOUNT" && ! bind_rootfs_check "$DEVICE"; then
9cf66a
+        if is_bind_mount && ocf_is_true "$FORCE_UNMOUNT" && ! bind_root_mount_check "$DEVICE"; then
9cf66a
                 ocf_log debug "Change force_umount from '$FORCE_UNMOUNT' to 'safe'"
9cf66a
                 FORCE_UNMOUNT=safe
9cf66a
         fi