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

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