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

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