Blame SOURCES/bz1858752-Filesystem-support-whitespace-device-dir.patch

8b04f5
From a8051cf9e21d231ce3c445f09631266157ffc2e0 Mon Sep 17 00:00:00 2001
8b04f5
From: Reid wahl <nrwahl@protonmail.com>
8b04f5
Date: Fri, 10 Jul 2020 03:44:18 -0700
8b04f5
Subject: [PATCH 1/3] Filesystem: Support whitespace in device or directory
8b04f5
 name
8b04f5
8b04f5
Whitespace in a device name (e.g., a CIFS share) or a directory name
8b04f5
breaks resource operations.
8b04f5
8b04f5
One issue is that many of the variable occurrences aren't quoted, so a
8b04f5
string containing whitespace is split into multiple tokens. This is a
8b04f5
problem when the string meant to be passed as a single argument to a
8b04f5
function (e.g., `list_submounts()`).
8b04f5
8b04f5
Another issue involves the parsing of `list_mounts()` output.
8b04f5
`list_mounts()` can pull data from `/proc/mounts`, `/etc/mtab`, or the
8b04f5
`mount` command. `/proc/mounts` and `/etc/mtab` represent spaces within
8b04f5
a field as octal `\040` strings, while `mount` represents them as
8b04f5
literal space characters.
8b04f5
8b04f5
`list_mounts()` had to be modified to output the mount list as three
8b04f5
distinct fields ((`device`, `mountpoint`, `fstype`), separated by tab
8b04f5
characters) regardless of the data source. Parsers of `list_mounts()`
8b04f5
were modified to use tabs as field delimiters.
8b04f5
8b04f5
The for loop in `Filesystem_stop()` also had to become a while loop to
8b04f5
read line-by-line irrespective of spaces. A for loop splits on spaces.
8b04f5
8b04f5
Resolves: RHBZ#1624591
8b04f5
---
8b04f5
 heartbeat/Filesystem | 106 +++++++++++++++++++++++++------------------
8b04f5
 1 file changed, 61 insertions(+), 45 deletions(-)
8b04f5
8b04f5
diff --git a/heartbeat/Filesystem b/heartbeat/Filesystem
8b04f5
index 2f07a90ad..9a52aa712 100755
8b04f5
--- a/heartbeat/Filesystem
8b04f5
+++ b/heartbeat/Filesystem
8b04f5
@@ -91,6 +91,7 @@ fi
8b04f5
 
8b04f5
 # Variables used by multiple methods
8b04f5
 HOSTOS=`uname`
8b04f5
+TAB='	'
8b04f5
 
8b04f5
 # The status file is going to an extra directory, by default
8b04f5
 #
8b04f5
@@ -100,7 +101,7 @@ suffix="${OCF_RESOURCE_INSTANCE}"
8b04f5
 [ "$OCF_RESKEY_CRM_meta_clone" ] &&
8b04f5
 	suffix="${suffix}_$OCF_RESKEY_CRM_meta_clone"
8b04f5
 suffix="${suffix}_`uname -n`"
8b04f5
-STATUSFILE=${OCF_RESKEY_directory}/$prefix$suffix
8b04f5
+STATUSFILE="${OCF_RESKEY_directory}/$prefix$suffix"
8b04f5
 
8b04f5
 #######################################################################
8b04f5
 
8b04f5
@@ -283,6 +284,7 @@ flushbufs() {
8b04f5
 is_bind_mount() {
8b04f5
 	echo "$options" | grep -w bind >/dev/null 2>&1
8b04f5
 }
8b04f5
+
8b04f5
 list_mounts() {
8b04f5
 	local inpf=""
8b04f5
 	local mount_list=""
8b04f5
@@ -296,15 +298,23 @@ list_mounts() {
8b04f5
 
8b04f5
 	# Make sure that the mount list has not been changed while reading.
8b04f5
 	while [ "$mount_list" != "$check_list" ]; do
8b04f5
-		check_list=$mount_list
8b04f5
+		check_list="$mount_list"
8b04f5
 		if [ "$inpf" ]; then
8b04f5
-			mount_list=$(cut -d' ' -f1,2,3 < $inpf)
8b04f5
+			# <device> <mountpoint> <fstype> ...
8b04f5
+			# Spaces in device or mountpoint are octal \040 in $inpf
8b04f5
+			# Convert literal spaces (field separators) to tabs
8b04f5
+			mount_list=$(cut -d' ' -f1,2,3 < $inpf | tr ' ' "$TAB")
8b04f5
 		else
8b04f5
-			mount_list=$($MOUNT | cut -d' ' -f1,3,5)
8b04f5
+			# <device> on <mountpoint> type <fstype> ...
8b04f5
+			# Use tabs as field separators
8b04f5
+			match_string='\(.*\) on \(.*\) type \([^[:space:]]\)'
8b04f5
+			replace_string="\\1${TAB}\\3${TAB}\\5"
8b04f5
+			mount_list=$($MOUNT | sed "s/$match_string/$replace_string/g")
8b04f5
 		fi
8b04f5
 	done
8b04f5
 
8b04f5
-	echo "$mount_list"
8b04f5
+	# Convert octal \040 to space characters
8b04f5
+	printf "$mount_list"
8b04f5
 }
8b04f5
 
8b04f5
 determine_blockdevice() {
8b04f5
@@ -318,7 +328,8 @@ determine_blockdevice() {
8b04f5
 	nfs4|nfs|smbfs|cifs|glusterfs|ceph|tmpfs|overlay|overlayfs|rozofs|zfs|cvfs|none|lustre)
8b04f5
 		: ;;
8b04f5
 	*)
8b04f5
-		DEVICE=`list_mounts | grep " $CANONICALIZED_MOUNTPOINT " | cut -d' ' -f1`
8b04f5
+		match_string="${TAB}${CANONICALIZED_MOUNTPOINT}${TAB}"
8b04f5
+		DEVICE=`list_mounts | grep "$match_string" | cut -d"$TAB" -f1`
8b04f5
 		if [ -b "$DEVICE" ]; then
8b04f5
 			blockdevice=yes
8b04f5
 		fi
8b04f5
@@ -329,7 +340,7 @@ determine_blockdevice() {
8b04f5
 # Lists all filesystems potentially mounted under a given path,
8b04f5
 # excluding the path itself.
8b04f5
 list_submounts() {
8b04f5
-	list_mounts | grep " $1/" | cut -d' ' -f2 | sort -r
8b04f5
+	list_mounts | grep "${TAB}${1}/" | cut -d"$TAB" -f2 | sort -r
8b04f5
 }
8b04f5
 
8b04f5
 # kernels < 2.6.26 can't handle bind remounts
8b04f5
@@ -358,15 +369,15 @@ bind_mount() {
8b04f5
 	if is_bind_mount && [ "$options" != "-o bind" ]
8b04f5
 	then
8b04f5
 		bind_kernel_check
8b04f5
-		bind_opts=`echo $options | sed 's/bind/remount/'`
8b04f5
-		$MOUNT $bind_opts $MOUNTPOINT
8b04f5
+		bind_opts=`echo "$options" | sed 's/bind/remount/'`
8b04f5
+		$MOUNT $bind_opts "$MOUNTPOINT"
8b04f5
 	else
8b04f5
 		true # make sure to return OK
8b04f5
 	fi
8b04f5
 }
8b04f5
 
8b04f5
 is_option() {
8b04f5
-	echo $OCF_RESKEY_options | grep -w "$1" >/dev/null 2>&1
8b04f5
+	echo "$OCF_RESKEY_options" | grep -w "$1" >/dev/null 2>&1
8b04f5
 }
8b04f5
 
8b04f5
 is_fsck_needed() {
8b04f5
@@ -374,7 +385,7 @@ is_fsck_needed() {
8b04f5
 		force) true;;
8b04f5
 		no)    false;;
8b04f5
 		""|auto)
8b04f5
-		case $FSTYPE in
8b04f5
+		case "$FSTYPE" in
8b04f5
 			ext4|ext4dev|ext3|reiserfs|reiser4|nss|xfs|jfs|vfat|fat|nfs4|nfs|cifs|smbfs|ocfs2|gfs2|none|lustre|glusterfs|ceph|tmpfs|overlay|overlayfs|rozofs|zfs|cvfs)
8b04f5
 			false;;
8b04f5
 			*)
8b04f5
@@ -403,7 +414,7 @@ fstype_supported()
8b04f5
 	fi
8b04f5
 
8b04f5
 	# support fuse-filesystems (e.g. GlusterFS)
8b04f5
-	case $FSTYPE in
8b04f5
+	case "$FSTYPE" in
8b04f5
 		fuse.*|glusterfs|rozofs) support="fuse";;
8b04f5
 	esac
8b04f5
 
8b04f5
@@ -486,7 +497,8 @@ trigger_udev_rules_if_needed()
8b04f5
 Filesystem_start()
8b04f5
 {
8b04f5
 	# Check if there are any mounts mounted under the mountpoint
8b04f5
-	if list_mounts | grep -q -E " $CANONICALIZED_MOUNTPOINT/\w+" >/dev/null 2>&1; then
8b04f5
+	match_string="${TAB}${CANONICALIZED_MOUNTPOINT}"
8b04f5
+	if list_mounts | grep -q -E "$match_string/\w+" >/dev/null 2>&1; then
8b04f5
 		ocf_log err "There is one or more mounts mounted under $MOUNTPOINT."
8b04f5
 		return $OCF_ERR_CONFIGURED
8b04f5
 	fi
8b04f5
@@ -514,9 +526,9 @@ Filesystem_start()
8b04f5
 		if is_fsck_needed; then
8b04f5
 			ocf_log info  "Starting filesystem check on $DEVICE"
8b04f5
 			if [ -z "$FSTYPE" ]; then
8b04f5
-				$FSCK -p $DEVICE
8b04f5
+				$FSCK -p "$DEVICE"
8b04f5
 			else
8b04f5
-				$FSCK -t $FSTYPE -p $DEVICE
8b04f5
+				$FSCK -t "$FSTYPE" -p "$DEVICE"
8b04f5
 			fi
8b04f5
 
8b04f5
 			# NOTE: if any errors at all are detected, it returns non-zero
8b04f5
@@ -529,20 +541,20 @@ Filesystem_start()
8b04f5
 	fi
8b04f5
 
8b04f5
 	[ -d "$MOUNTPOINT" ] ||
8b04f5
-		ocf_run mkdir -p $MOUNTPOINT
8b04f5
+		ocf_run mkdir -p "$MOUNTPOINT"
8b04f5
 	if [ ! -d "$MOUNTPOINT" ] ; then
8b04f5
 		ocf_exit_reason "Couldn't find directory  [$MOUNTPOINT] to use as a mount point"
8b04f5
 		exit $OCF_ERR_INSTALLED
8b04f5
 	fi
8b04f5
 
8b04f5
-	flushbufs $DEVICE
8b04f5
+	flushbufs "$DEVICE"
8b04f5
 	# Mount the filesystem.
8b04f5
 	case "$FSTYPE" in
8b04f5
-		none) $MOUNT $options $DEVICE $MOUNTPOINT &&
8b04f5
+		none) $MOUNT $options "$DEVICE" "$MOUNTPOINT" &&
8b04f5
 			bind_mount
8b04f5
 			;;
8b04f5
-		"") $MOUNT $options $DEVICE $MOUNTPOINT ;;
8b04f5
-		*) $MOUNT -t $FSTYPE $options $DEVICE $MOUNTPOINT ;;
8b04f5
+		"") $MOUNT $options "$DEVICE" "$MOUNTPOINT" ;;
8b04f5
+		*) $MOUNT -t "$FSTYPE" $options "$DEVICE" "$MOUNTPOINT" ;;
8b04f5
 	esac
8b04f5
 
8b04f5
 	if [ $? -ne 0 ]; then
8b04f5
@@ -595,23 +607,23 @@ signal_processes() {
8b04f5
 	done
8b04f5
 }
8b04f5
 try_umount() {
8b04f5
-	local SUB=$1
8b04f5
-	$UMOUNT $umount_force $SUB
8b04f5
-	list_mounts | grep -q " $SUB " >/dev/null 2>&1 || {
8b04f5
+	local SUB="$1"
8b04f5
+	$UMOUNT $umount_force "$SUB"
8b04f5
+	list_mounts | grep -q "${TAB}${SUB}${TAB}" >/dev/null 2>&1 || {
8b04f5
 		ocf_log info "unmounted $SUB successfully"
8b04f5
 		return $OCF_SUCCESS
8b04f5
 	}
8b04f5
 	return $OCF_ERR_GENERIC
8b04f5
 }
8b04f5
 fs_stop() {
8b04f5
-	local SUB=$1 timeout=$2 sig cnt
8b04f5
+	local SUB="$1" timeout=$2 sig cnt
8b04f5
 	for sig in TERM KILL; do
8b04f5
 		cnt=$((timeout/2)) # try half time with TERM
8b04f5
 		while [ $cnt -gt 0 ]; do
8b04f5
-			try_umount $SUB &&
8b04f5
+			try_umount "$SUB" &&
8b04f5
 				return $OCF_SUCCESS
8b04f5
 			ocf_exit_reason "Couldn't unmount $SUB; trying cleanup with $sig"
8b04f5
-			signal_processes $SUB $sig
8b04f5
+			signal_processes "$SUB" $sig
8b04f5
 			cnt=$((cnt-1))
8b04f5
 			sleep 1
8b04f5
 		done
8b04f5
@@ -633,7 +645,7 @@ Filesystem_stop()
8b04f5
 		# Wipe the status file, but continue with a warning if
8b04f5
 		# removal fails -- the file system might be read only
8b04f5
 		if [ $OCF_CHECK_LEVEL -eq 20 ]; then
8b04f5
-			rm -f ${STATUSFILE}
8b04f5
+			rm -f "${STATUSFILE}"
8b04f5
 			if [ $? -ne 0 ]; then
8b04f5
 				ocf_log warn "Failed to remove status file ${STATUSFILE}."
8b04f5
 			fi
8b04f5
@@ -650,7 +662,7 @@ Filesystem_stop()
8b04f5
 
8b04f5
 		# Umount all sub-filesystems mounted under $MOUNTPOINT/ too.
8b04f5
 		local timeout
8b04f5
-		for SUB in `list_submounts $MOUNTPOINT` $MOUNTPOINT; do
8b04f5
+		while read SUB; do
8b04f5
 			ocf_log info "Trying to unmount $SUB"
8b04f5
 			if ocf_is_true "$FAST_STOP"; then
8b04f5
 				timeout=6
8b04f5
@@ -658,15 +670,18 @@ Filesystem_stop()
8b04f5
 				timeout=${OCF_RESKEY_CRM_meta_timeout:="20000"}
8b04f5
 				timeout=$((timeout/1000))
8b04f5
 			fi
8b04f5
-			fs_stop $SUB $timeout
8b04f5
+			fs_stop "$SUB" $timeout
8b04f5
 			rc=$?
8b04f5
 			if [ $rc -ne $OCF_SUCCESS ]; then
8b04f5
 				ocf_exit_reason "Couldn't unmount $SUB, giving up!"
8b04f5
 			fi
8b04f5
-		done
8b04f5
+		done <<-EOF
8b04f5
+			$(list_submounts "$CANONICALIZED_MOUNTPOINT"; \
8b04f5
+				echo $CANONICALIZED_MOUNTPOINT)
8b04f5
+			EOF
8b04f5
 	fi
8b04f5
 
8b04f5
-	flushbufs $DEVICE
8b04f5
+	flushbufs "$DEVICE"
8b04f5
 
8b04f5
 	return $rc
8b04f5
 }
8b04f5
@@ -677,7 +692,8 @@ Filesystem_stop()
8b04f5
 #
8b04f5
 Filesystem_status()
8b04f5
 {
8b04f5
-	if list_mounts | grep -q " $CANONICALIZED_MOUNTPOINT " >/dev/null 2>&1; then
8b04f5
+	match_string="${TAB}${CANONICALIZED_MOUNTPOINT}${TAB}"
8b04f5
+	if list_mounts | grep -q "$match_string" >/dev/null 2>&1; then
8b04f5
 		rc=$OCF_SUCCESS
8b04f5
 		msg="$MOUNTPOINT is mounted (running)"
8b04f5
 	else
8b04f5
@@ -712,7 +728,7 @@ Filesystem_monitor_10()
8b04f5
 		return $OCF_SUCCESS
8b04f5
 	fi
8b04f5
 	dd_opts="iflag=direct bs=4k count=1"
8b04f5
-	err_output=`dd if=$DEVICE $dd_opts 2>&1 >/dev/null`
8b04f5
+	err_output=`dd if="$DEVICE" $dd_opts 2>&1 >/dev/null`
8b04f5
 	if [ $? -ne 0 ]; then
8b04f5
 		ocf_exit_reason "Failed to read device $DEVICE"
8b04f5
 		ocf_log err "dd said: $err_output"
8b04f5
@@ -733,20 +749,20 @@ Filesystem_monitor_20()
8b04f5
 		# to bypass caches.
8b04f5
 		dd_opts="oflag=direct,sync bs=4k conv=fsync,sync"
8b04f5
 	fi
8b04f5
-	status_dir=`dirname $STATUSFILE`
8b04f5
+	status_dir=$(dirname "$STATUSFILE")
8b04f5
 	[ -d "$status_dir" ] || mkdir -p "$status_dir"
8b04f5
-	err_output=`echo "${OCF_RESOURCE_INSTANCE}" | dd of=${STATUSFILE} $dd_opts 2>&1`
8b04f5
+	err_output=`echo "${OCF_RESOURCE_INSTANCE}" | dd of="${STATUSFILE}" $dd_opts 2>&1`
8b04f5
 	if [ $? -ne 0 ]; then
8b04f5
 		ocf_exit_reason "Failed to write status file ${STATUSFILE}"
8b04f5
 		ocf_log err "dd said: $err_output"
8b04f5
 		return $OCF_ERR_GENERIC
8b04f5
 	fi
8b04f5
-	test -f ${STATUSFILE}
8b04f5
+	test -f "${STATUSFILE}"
8b04f5
 	if [ $? -ne 0 ]; then
8b04f5
 		ocf_exit_reason "Cannot stat the status file ${STATUSFILE}"
8b04f5
 		return $OCF_ERR_GENERIC
8b04f5
 	fi
8b04f5
-	cat ${STATUSFILE} > /dev/null
8b04f5
+	cat "${STATUSFILE}" > /dev/null
8b04f5
 	if [ $? -ne 0 ]; then
8b04f5
 		ocf_exit_reason "Cannot read the status file ${STATUSFILE}"
8b04f5
 		return $OCF_ERR_GENERIC
8b04f5
@@ -791,9 +807,9 @@ Filesystem_validate_all()
8b04f5
 	# NOTE: Without inserting the $FSTYPE module, this step may be imprecise
8b04f5
 	# TODO: This is Linux specific crap.
8b04f5
 	if [ ! -z "$FSTYPE" -a "$FSTYPE" != none ]; then
8b04f5
-		cut -f2 /proc/filesystems |grep -q ^$FSTYPE$
8b04f5
+		cut -f2 /proc/filesystems |grep -q "^${FSTYPE}$"
8b04f5
 		if [ $? -ne 0 ]; then
8b04f5
-			modpath=/lib/modules/`uname -r` 
8b04f5
+			modpath=/lib/modules/`uname -r`
8b04f5
 			moddep=$modpath/modules.dep
8b04f5
 			# Do we have $FSTYPE in modules.dep?
8b04f5
 			cut -d' ' -f1 $moddep |grep -q "^$modpath.*$FSTYPE\.k\?o:$"
8b04f5
@@ -826,7 +842,7 @@ set_blockdevice_var() {
8b04f5
 	blockdevice=no
8b04f5
 
8b04f5
 	# these are definitely not block devices
8b04f5
-	case $FSTYPE in
8b04f5
+	case "$FSTYPE" in
8b04f5
 	nfs4|nfs|smbfs|cifs|none|glusterfs|ceph|tmpfs|overlay|overlayfs|rozofs|zfs|cvfs) return;;
8b04f5
 	esac
8b04f5
 
8b04f5
@@ -834,7 +850,7 @@ set_blockdevice_var() {
8b04f5
 		return
8b04f5
 	fi
8b04f5
 
8b04f5
-	case $DEVICE in
8b04f5
+	case "$DEVICE" in
8b04f5
 	-*) # Oh... An option to mount instead...  Typically -U or -L
8b04f5
 		;;
8b04f5
 	/dev/null) # Special case for BSC
8b04f5
@@ -863,7 +879,7 @@ if [ -n "${OCF_RESKEY_force_unmount}" ]; then
8b04f5
 	FORCE_UNMOUNT=$OCF_RESKEY_force_unmount
8b04f5
 fi
8b04f5
 
8b04f5
-DEVICE=$OCF_RESKEY_device
8b04f5
+DEVICE="$OCF_RESKEY_device"
8b04f5
 FSTYPE=$OCF_RESKEY_fstype
8b04f5
 if [ ! -z "$OCF_RESKEY_options" ]; then
8b04f5
 	options="-o $OCF_RESKEY_options"
8b04f5
@@ -899,10 +915,10 @@ if [ -z "$OCF_RESKEY_directory" ]; then
8b04f5
 		exit $OCF_ERR_CONFIGURED 
8b04f5
 	fi
8b04f5
 else
8b04f5
-	MOUNTPOINT=$(echo $OCF_RESKEY_directory | sed 's/\/*$//')
8b04f5
+	MOUNTPOINT="$(echo "$OCF_RESKEY_directory" | sed 's/\/*$//')"
8b04f5
 	: ${MOUNTPOINT:=/}
8b04f5
 	if [ -e "$MOUNTPOINT" ] ; then
8b04f5
-		CANONICALIZED_MOUNTPOINT=$(readlink -f "$MOUNTPOINT")
8b04f5
+		CANONICALIZED_MOUNTPOINT="$(readlink -f "$MOUNTPOINT")"
8b04f5
 		if [ $? -ne 0 ]; then
8b04f5
 			ocf_exit_reason "Could not canonicalize $MOUNTPOINT because readlink failed"
8b04f5
 			exit $OCF_ERR_GENERIC
8b04f5
@@ -947,7 +963,7 @@ CLUSTERSAFE=0
8b04f5
 is_option "ro" &&
8b04f5
 	CLUSTERSAFE=2
8b04f5
 
8b04f5
-case $FSTYPE in
8b04f5
+case "$FSTYPE" in
8b04f5
 nfs4|nfs|smbfs|cifs|none|gfs2|glusterfs|ceph|ocfs2|overlay|overlayfs|tmpfs|cvfs)
8b04f5
 	CLUSTERSAFE=1 # this is kind of safe too
8b04f5
 	;;
8b04f5
8b04f5
From eca9a96ad3356df3636bfa3187afe1b1954693b2 Mon Sep 17 00:00:00 2001
8b04f5
From: Reid wahl <nrwahl@protonmail.com>
8b04f5
Date: Fri, 10 Jul 2020 16:38:04 -0700
8b04f5
Subject: [PATCH 2/3] Filesystem: POSIX-compliant syntax for portability
8b04f5
8b04f5
Updated to use POSIX `$()` instead of Bourne-shell backticks, and to
8b04f5
use `grep ... >/dev/null 2>&1` instead of `grep -q`. (Note: `grep -q`
8b04f5
only suppresses `stdout` anyway. `grep -q -s` would be required to
8b04f5
suppress both `stdout` and `stderr`.)
8b04f5
---
8b04f5
 heartbeat/Filesystem | 33 +++++++++++++++++----------------
8b04f5
 1 file changed, 17 insertions(+), 16 deletions(-)
8b04f5
8b04f5
diff --git a/heartbeat/Filesystem b/heartbeat/Filesystem
8b04f5
index 9a52aa712..34ade20d7 100755
8b04f5
--- a/heartbeat/Filesystem
8b04f5
+++ b/heartbeat/Filesystem
8b04f5
@@ -90,7 +90,7 @@ fi
8b04f5
 : ${OCF_RESKEY_force_unmount=${OCF_RESKEY_force_unmount_default}}
8b04f5
 
8b04f5
 # Variables used by multiple methods
8b04f5
-HOSTOS=`uname`
8b04f5
+HOSTOS=$(uname)
8b04f5
 TAB='	'
8b04f5
 
8b04f5
 # The status file is going to an extra directory, by default
8b04f5
@@ -100,7 +100,7 @@ prefix=${OCF_RESKEY_statusfile_prefix}
8b04f5
 suffix="${OCF_RESOURCE_INSTANCE}"
8b04f5
 [ "$OCF_RESKEY_CRM_meta_clone" ] &&
8b04f5
 	suffix="${suffix}_$OCF_RESKEY_CRM_meta_clone"
8b04f5
-suffix="${suffix}_`uname -n`"
8b04f5
+suffix="${suffix}_$(uname -n)"
8b04f5
 STATUSFILE="${OCF_RESKEY_directory}/$prefix$suffix"
8b04f5
 
8b04f5
 #######################################################################
8b04f5
@@ -329,7 +329,7 @@ determine_blockdevice() {
8b04f5
 		: ;;
8b04f5
 	*)
8b04f5
 		match_string="${TAB}${CANONICALIZED_MOUNTPOINT}${TAB}"
8b04f5
-		DEVICE=`list_mounts | grep "$match_string" | cut -d"$TAB" -f1`
8b04f5
+		DEVICE=$(list_mounts | grep "$match_string" | cut -d"$TAB" -f1)
8b04f5
 		if [ -b "$DEVICE" ]; then
8b04f5
 			blockdevice=yes
8b04f5
 		fi
8b04f5
@@ -354,7 +354,7 @@ bind_kernel_check() {
8b04f5
 			exit(1);
8b04f5
 	}'
8b04f5
 	[ $? -ne 0 ] &&
8b04f5
-		ocf_log warn "kernel `uname -r` cannot handle read only bind mounts"
8b04f5
+		ocf_log warn "kernel $(uname -r) cannot handle read only bind mounts"
8b04f5
 }
8b04f5
 
8b04f5
 bind_root_mount_check() {
8b04f5
@@ -369,7 +369,7 @@ bind_mount() {
8b04f5
 	if is_bind_mount && [ "$options" != "-o bind" ]
8b04f5
 	then
8b04f5
 		bind_kernel_check
8b04f5
-		bind_opts=`echo "$options" | sed 's/bind/remount/'`
8b04f5
+		bind_opts=$(echo "$options" | sed 's/bind/remount/')
8b04f5
 		$MOUNT $bind_opts "$MOUNTPOINT"
8b04f5
 	else
8b04f5
 		true # make sure to return OK
8b04f5
@@ -469,7 +469,7 @@ trigger_udev_rules_if_needed()
8b04f5
 			refresh_flag="yes"
8b04f5
 		fi
8b04f5
 	else
8b04f5
-		tmp="`echo $DEVICE|awk '{$1=""; print substr($0,2)}'`"
8b04f5
+		tmp="$(echo $DEVICE|awk '{$1=""; print substr($0,2)}')"
8b04f5
 		case "$DEVICE" in 
8b04f5
 		-U*|--uuid*) 
8b04f5
 			tmp="/dev/disk/by-uuid/$tmp" 
8b04f5
@@ -498,7 +498,7 @@ Filesystem_start()
8b04f5
 {
8b04f5
 	# Check if there are any mounts mounted under the mountpoint
8b04f5
 	match_string="${TAB}${CANONICALIZED_MOUNTPOINT}"
8b04f5
-	if list_mounts | grep -q -E "$match_string/\w+" >/dev/null 2>&1; then
8b04f5
+	if list_mounts | grep -E "$match_string/\w+" >/dev/null 2>&1; then
8b04f5
 		ocf_log err "There is one or more mounts mounted under $MOUNTPOINT."
8b04f5
 		return $OCF_ERR_CONFIGURED
8b04f5
 	fi
8b04f5
@@ -602,14 +602,14 @@ signal_processes() {
8b04f5
 		return
8b04f5
 	fi
8b04f5
 	for pid in $pids; do
8b04f5
-		ocf_log info "sending signal $sig to: `ps -f $pid | tail -1`"
8b04f5
+		ocf_log info "sending signal $sig to: $(ps -f $pid | tail -1)"
8b04f5
 		kill -s $sig $pid
8b04f5
 	done
8b04f5
 }
8b04f5
 try_umount() {
8b04f5
 	local SUB="$1"
8b04f5
 	$UMOUNT $umount_force "$SUB"
8b04f5
-	list_mounts | grep -q "${TAB}${SUB}${TAB}" >/dev/null 2>&1 || {
8b04f5
+	list_mounts | grep "${TAB}${SUB}${TAB}" >/dev/null 2>&1 || {
8b04f5
 		ocf_log info "unmounted $SUB successfully"
8b04f5
 		return $OCF_SUCCESS
8b04f5
 	}
8b04f5
@@ -693,7 +693,7 @@ Filesystem_stop()
8b04f5
 Filesystem_status()
8b04f5
 {
8b04f5
 	match_string="${TAB}${CANONICALIZED_MOUNTPOINT}${TAB}"
8b04f5
-	if list_mounts | grep -q "$match_string" >/dev/null 2>&1; then
8b04f5
+	if list_mounts | grep "$match_string" >/dev/null 2>&1; then
8b04f5
 		rc=$OCF_SUCCESS
8b04f5
 		msg="$MOUNTPOINT is mounted (running)"
8b04f5
 	else
8b04f5
@@ -728,7 +728,7 @@ Filesystem_monitor_10()
8b04f5
 		return $OCF_SUCCESS
8b04f5
 	fi
8b04f5
 	dd_opts="iflag=direct bs=4k count=1"
8b04f5
-	err_output=`dd if="$DEVICE" $dd_opts 2>&1 >/dev/null`
8b04f5
+	err_output=$(dd if="$DEVICE" $dd_opts 2>&1 >/dev/null)
8b04f5
 	if [ $? -ne 0 ]; then
8b04f5
 		ocf_exit_reason "Failed to read device $DEVICE"
8b04f5
 		ocf_log err "dd said: $err_output"
8b04f5
@@ -751,7 +751,7 @@ Filesystem_monitor_20()
8b04f5
 	fi
8b04f5
 	status_dir=$(dirname "$STATUSFILE")
8b04f5
 	[ -d "$status_dir" ] || mkdir -p "$status_dir"
8b04f5
-	err_output=`echo "${OCF_RESOURCE_INSTANCE}" | dd of="${STATUSFILE}" $dd_opts 2>&1`
8b04f5
+	err_output=$(echo "${OCF_RESOURCE_INSTANCE}" | dd of="${STATUSFILE}" $dd_opts 2>&1)
8b04f5
 	if [ $? -ne 0 ]; then
8b04f5
 		ocf_exit_reason "Failed to write status file ${STATUSFILE}"
8b04f5
 		ocf_log err "dd said: $err_output"
8b04f5
@@ -807,12 +807,13 @@ Filesystem_validate_all()
8b04f5
 	# NOTE: Without inserting the $FSTYPE module, this step may be imprecise
8b04f5
 	# TODO: This is Linux specific crap.
8b04f5
 	if [ ! -z "$FSTYPE" -a "$FSTYPE" != none ]; then
8b04f5
-		cut -f2 /proc/filesystems |grep -q "^${FSTYPE}$"
8b04f5
+		cut -f2 /proc/filesystems | grep "^${FSTYPE}$" >/dev/null 2>&1
8b04f5
 		if [ $? -ne 0 ]; then
8b04f5
-			modpath=/lib/modules/`uname -r`
8b04f5
+			modpath=/lib/modules/$(uname -r)
8b04f5
 			moddep=$modpath/modules.dep
8b04f5
 			# Do we have $FSTYPE in modules.dep?
8b04f5
-			cut -d' ' -f1 $moddep |grep -q "^$modpath.*$FSTYPE\.k\?o:$"
8b04f5
+			cut -d' ' -f1 $moddep \
8b04f5
+				| grep "^${modpath}.*${FSTYPE}\.k\?o:$" >/dev/null 2>&1
8b04f5
 			if [ $? -ne 0 ]; then
8b04f5
 				ocf_log info "It seems we do not have $FSTYPE support"
8b04f5
 			fi
8b04f5
@@ -846,7 +847,7 @@ set_blockdevice_var() {
8b04f5
 	nfs4|nfs|smbfs|cifs|none|glusterfs|ceph|tmpfs|overlay|overlayfs|rozofs|zfs|cvfs|lustre) return;;
8b04f5
 	esac
8b04f5
 
8b04f5
-	if `is_option "loop"`; then
8b04f5
+	if $(is_option "loop"); then
8b04f5
 		return
8b04f5
 	fi
8b04f5
 
8b04f5
8b04f5
From 5517712f4bb6e90b23cde6310c03509c9061cb36 Mon Sep 17 00:00:00 2001
8b04f5
From: Reid wahl <nrwahl@protonmail.com>
8b04f5
Date: Fri, 10 Jul 2020 16:44:17 -0700
8b04f5
Subject: [PATCH 3/3] Filesystem: Convert leading space characters to tabs
8b04f5
8b04f5
A few lines started with spaces instead of tabs. Tabs are the
8b04f5
convention in this file.
8b04f5
---
8b04f5
 heartbeat/Filesystem | 16 ++++++++--------
8b04f5
 1 file changed, 8 insertions(+), 8 deletions(-)
8b04f5
8b04f5
diff --git a/heartbeat/Filesystem b/heartbeat/Filesystem
8b04f5
index 34ade20d7..501e5a0d0 100755
8b04f5
--- a/heartbeat/Filesystem
8b04f5
+++ b/heartbeat/Filesystem
8b04f5
@@ -359,10 +359,10 @@ bind_kernel_check() {
8b04f5
 
8b04f5
 bind_root_mount_check() {
8b04f5
 	if [ "$(df -P "$1"  | awk 'END{print $6}')" = "/" ]; then
8b04f5
-                return 1
8b04f5
-        else
8b04f5
-                return 0
8b04f5
-        fi
8b04f5
+		return 1
8b04f5
+	else
8b04f5
+		return 0
8b04f5
+	fi
8b04f5
 }
8b04f5
 
8b04f5
 bind_mount() {
8b04f5
@@ -571,10 +571,10 @@ get_pids()
8b04f5
 	local procs
8b04f5
 	local mmap_procs
8b04f5
 
8b04f5
-        if is_bind_mount && ocf_is_true "$FORCE_UNMOUNT" && ! bind_root_mount_check "$DEVICE"; then
8b04f5
-                ocf_log debug "Change force_umount from '$FORCE_UNMOUNT' to 'safe'"
8b04f5
-                FORCE_UNMOUNT=safe
8b04f5
-        fi
8b04f5
+	if is_bind_mount && ocf_is_true "$FORCE_UNMOUNT" && ! bind_root_mount_check "$DEVICE"; then
8b04f5
+		ocf_log debug "Change force_umount from '$FORCE_UNMOUNT' to 'safe'"
8b04f5
+		FORCE_UNMOUNT=safe
8b04f5
+	fi
8b04f5
 
8b04f5
 	if ocf_is_true  "$FORCE_UNMOUNT"; then
8b04f5
 		if [ "X${HOSTOS}" = "XOpenBSD" ];then