Blame SOURCES/bz1744140-Filesystem-1-avoid-corrupt-mount-list.patch

734564
From b67278bc92cfb0b9947ff5fff65f46f420a42c2c Mon Sep 17 00:00:00 2001
734564
From: Kazutomo Nakahira <kazutomo_nakahira@newson.co.jp>
734564
Date: Fri, 10 May 2019 14:30:51 +0900
734564
Subject: [PATCH] Low: Filesystem: Fix missing mount point due to corrupted
734564
 mount list
734564
734564
---
734564
 heartbeat/Filesystem | 20 +++++++++++++++-----
734564
 1 file changed, 15 insertions(+), 5 deletions(-)
734564
734564
diff --git a/heartbeat/Filesystem b/heartbeat/Filesystem
734564
index 2a43d1daa..c38ae12d4 100755
734564
--- a/heartbeat/Filesystem
734564
+++ b/heartbeat/Filesystem
734564
@@ -255,16 +255,26 @@ is_bind_mount() {
734564
 }
734564
 list_mounts() {
734564
 	local inpf=""
734564
+	local mount_list=""
734564
+	local check_list="x"
734564
+
734564
 	if [ -e "/proc/mounts" ] && ! is_bind_mount; then
734564
 		inpf=/proc/mounts
734564
 	elif [ -f "/etc/mtab" -a -r "/etc/mtab" ]; then
734564
 		inpf=/etc/mtab
734564
 	fi
734564
-	if [ "$inpf" ]; then
734564
-		cut -d' ' -f1,2,3 < $inpf
734564
-	else
734564
-		$MOUNT | cut -d' ' -f1,3,5
734564
-	fi
734564
+
734564
+	# Make sure that the mount list has not been changed while reading.
734564
+	while [ "$mount_list" != "$check_list" ]; do
734564
+		check_list=$mount_list
734564
+		if [ "$inpf" ]; then
734564
+			mount_list=$(cut -d' ' -f1,2,3 < $inpf)
734564
+		else
734564
+			mount_list=$($MOUNT | cut -d' ' -f1,3,5)
734564
+		fi
734564
+	done
734564
+
734564
+	echo "$mount_list"
734564
 }
734564
 
734564
 determine_blockdevice() {