Blob Blame History Raw
From b67278bc92cfb0b9947ff5fff65f46f420a42c2c Mon Sep 17 00:00:00 2001
From: Kazutomo Nakahira <kazutomo_nakahira@newson.co.jp>
Date: Fri, 10 May 2019 14:30:51 +0900
Subject: [PATCH] Low: Filesystem: Fix missing mount point due to corrupted
 mount list

---
 heartbeat/Filesystem | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/heartbeat/Filesystem b/heartbeat/Filesystem
index 2a43d1daa..c38ae12d4 100755
--- a/heartbeat/Filesystem
+++ b/heartbeat/Filesystem
@@ -255,16 +255,26 @@ is_bind_mount() {
 }
 list_mounts() {
 	local inpf=""
+	local mount_list=""
+	local check_list="x"
+
 	if [ -e "/proc/mounts" ] && ! is_bind_mount; then
 		inpf=/proc/mounts
 	elif [ -f "/etc/mtab" -a -r "/etc/mtab" ]; then
 		inpf=/etc/mtab
 	fi
-	if [ "$inpf" ]; then
-		cut -d' ' -f1,2,3 < $inpf
-	else
-		$MOUNT | cut -d' ' -f1,3,5
-	fi
+
+	# Make sure that the mount list has not been changed while reading.
+	while [ "$mount_list" != "$check_list" ]; do
+		check_list=$mount_list
+		if [ "$inpf" ]; then
+			mount_list=$(cut -d' ' -f1,2,3 < $inpf)
+		else
+			mount_list=$($MOUNT | cut -d' ' -f1,3,5)
+		fi
+	done
+
+	echo "$mount_list"
 }
 
 determine_blockdevice() {