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

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