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

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