Blame SOURCES/0138-RHBZ-1288660-fix-mpathconf-allow.patch

f20720
---
f20720
 multipath/mpathconf |   37 ++++++++++++++++++++++++++-----------
f20720
 1 file changed, 26 insertions(+), 11 deletions(-)
f20720
f20720
Index: multipath-tools-130222/multipath/mpathconf
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/multipath/mpathconf
f20720
+++ multipath-tools-130222/multipath/mpathconf
f20720
@@ -42,6 +42,19 @@ function usage
f20720
 	echo ""
f20720
 }
f20720
 
f20720
+function add_wwid
f20720
+{
f20720
+	INDEX=0
f20720
+	while [ "$INDEX" -lt "$WWIDS" ] ; do
f20720
+		if [ "$1" = "${WWID_LIST[$INDEX]}" ] ; then
f20720
+			return
f20720
+		fi
f20720
+		((INDEX++))
f20720
+	done
f20720
+	WWID_LIST[$WWIDS]="$1"
f20720
+	((WWIDS++))
f20720
+}
f20720
+
f20720
 function get_dm_deps
f20720
 {
f20720
 	shift 3
f20720
@@ -59,11 +72,9 @@ function get_dm_deps
f20720
 function set_dm_wwid
f20720
 {
f20720
 	if [[ "$1" =~ ^part[[:digit:]]+-mpath- ]] ; then
f20720
-		WWID_LIST[$WWIDS]="${1##part*-mpath-}"
f20720
-		((WWIDS++))
f20720
+		add_wwid "${1##part*-mpath-}"
f20720
 	elif [[ "$1" =~ ^mpath- ]] ; then
f20720
-		WWID_LIST[$WWIDS]="${1##mpath-}"
f20720
-		((WWIDS++))
f20720
+		add_wwid "${1##mpath-}"
f20720
 	else
f20720
 		get_dm_deps `dmsetup deps -u $1`
f20720
 	fi
f20720
@@ -82,8 +93,7 @@ function set_wwid
f20720
 	if [ -n "$UUID" ] ; then
f20720
 		set_dm_wwid $UUID
f20720
 	else
f20720
-		WWID_LIST[$WWIDS]="$1"
f20720
-		((WWIDS++))
f20720
+		add_wwid "$1"
f20720
 	fi
f20720
 }
f20720
 
f20720
@@ -198,13 +208,13 @@ function validate_args
f20720
 
f20720
 function add_blacklist_exceptions
f20720
 {
f20720
-	echo "blacklist_exceptions {" >> $TMPFILE
f20720
 	INDEX=0
f20720
 	while [ "$INDEX" -lt "$WWIDS" ] ; do
f20720
-		echo "	wwid \"${WWID_LIST[$INDEX]}\"" >> $TMPFILE
f20720
+		sed -i '/^blacklist_exceptions[[:space:]]*{/ a\
f20720
+	wwid '"\"${WWID_LIST[$INDEX]}\""'
f20720
+' $TMPFILE
f20720
 		((INDEX++))
f20720
 	done
f20720
-	echo "}" >> $TMPFILE
f20720
 }
f20720
 
f20720
 umask 0077
f20720
@@ -350,9 +360,14 @@ if [ "$ENABLE" = 2 ]; then
f20720
 		sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*#[[:space:]]*wwid \"\.\?\*\"/	wwid ".*"/' $TMPFILE
f20720
 	fi
f20720
 	if [ "$HAVE_EXCEPTIONS" = 1 ]; then
f20720
-		sed -i '/^blacklist_exceptions[[:space:]]*{/,/^}/d' $TMPFILE
f20720
+		sed -i '/^blacklist_exceptions[[:space:]]*{/,/^}/ {/^[[:space:]]*wwid/ d}' $TMPFILE
f20720
+	else
f20720
+		cat >> $TMPFILE <<- _EOF_
f20720
+
f20720
+blacklist_exceptions {
f20720
+}
f20720
+_EOF_
f20720
 	fi
f20720
-	echo $HAVE_WWID_DISABLE
f20720
 	add_blacklist_exceptions
f20720
 elif [ "$ENABLE" = 1 ]; then
f20720
 	if [ "$HAVE_DISABLE" = 1 ]; then