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

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