Blame SOURCES/bz1744103-Filesystem-4-fix-readlink-issue.patch

b4b3ce
From 48a7ebcea5ce0522021cf3079b62107a06b530b9 Mon Sep 17 00:00:00 2001
b4b3ce
From: James Oakley <jfunk@funktronics.ca>
b4b3ce
Date: Thu, 8 Aug 2019 05:56:14 -0700
b4b3ce
Subject: [PATCH] Don't call readlink on path if it does not exist
b4b3ce
b4b3ce
---
b4b3ce
 heartbeat/Filesystem | 12 ++++++++----
b4b3ce
 1 file changed, 8 insertions(+), 4 deletions(-)
b4b3ce
b4b3ce
diff --git a/heartbeat/Filesystem b/heartbeat/Filesystem
b4b3ce
index 4bbbc06d3..738e3c08e 100755
b4b3ce
--- a/heartbeat/Filesystem
b4b3ce
+++ b/heartbeat/Filesystem
b4b3ce
@@ -858,10 +858,14 @@ if [ -z "$OCF_RESKEY_directory" ]; then
b4b3ce
 else
b4b3ce
 	MOUNTPOINT=$(echo $OCF_RESKEY_directory | sed 's/\/*$//')
b4b3ce
 	: ${MOUNTPOINT:=/}
b4b3ce
-	CANONICALIZED_MOUNTPOINT=$(readlink -f "$MOUNTPOINT")
b4b3ce
-	if [ $? -ne 0 ]; then
b4b3ce
-		ocf_exit_reason "Could not canonicalize $MOUNTPOINT because readlink failed"
b4b3ce
-		exit $OCF_ERR_GENERIC
b4b3ce
+	if [ -e "$MOUNTPOINT" ] ; then
b4b3ce
+		CANONICALIZED_MOUNTPOINT=$(readlink -f "$MOUNTPOINT")
b4b3ce
+		if [ $? -ne 0 ]; then
b4b3ce
+			ocf_exit_reason "Could not canonicalize $MOUNTPOINT because readlink failed"
b4b3ce
+			exit $OCF_ERR_GENERIC
b4b3ce
+		fi
b4b3ce
+	else
b4b3ce
+		CANONICALIZED_MOUNTPOINT="$MOUNTPOINT"
b4b3ce
 	fi
b4b3ce
 	# At this stage, $MOUNTPOINT does not contain trailing "/" unless it is "/"
b4b3ce
 	# TODO: / mounted via Filesystem sounds dangerous. On stop, we'll