Blame 0021-multipath-fix-majmin_to_mpath_dev.patch

Harald Hoyer b38677
From 28058a2e373eb268d9b1cd5b65c2ad607961dad1 Mon Sep 17 00:00:00 2001
Harald Hoyer b38677
From: Pekka Wallendahl <wyrmiyu@gmail.com>
Harald Hoyer b38677
Date: Mon, 18 Jan 2016 20:28:22 +0200
Harald Hoyer b38677
Subject: [PATCH] multipath: fix majmin_to_mpath_dev()
Harald Hoyer b38677
Harald Hoyer b38677
* Multipath device names only start with the mpath-prefix if the option
Harald Hoyer b38677
  use_userfriendly_names is set true in /etc/multipath.conf and if user
Harald Hoyer b38677
  has not set any aliases in the said file. Thus the for-loop should go
Harald Hoyer b38677
  through all files in /dev/mapper/, not just ones starting with 'mpath'
Harald Hoyer b38677
Harald Hoyer b38677
* Bash is perfectly capable to extend `/dev/mapper/*` notation without a
Harald Hoyer b38677
  need to pass it to an external ls
Harald Hoyer b38677
Harald Hoyer b38677
* Changed the function to use a local variable $_dev instead of the
Harald Hoyer b38677
  global $dev, which seemed to be the original intention as the local
Harald Hoyer b38677
  _dev was defined but not used
Harald Hoyer b38677
---
Harald Hoyer b38677
 modules.d/90multipath/module-setup.sh | 7 ++++---
Harald Hoyer b38677
 1 file changed, 4 insertions(+), 3 deletions(-)
Harald Hoyer b38677
Harald Hoyer b38677
diff --git a/modules.d/90multipath/module-setup.sh b/modules.d/90multipath/module-setup.sh
Harald Hoyer b38677
index 831c99f..a808678 100755
Harald Hoyer b38677
--- a/modules.d/90multipath/module-setup.sh
Harald Hoyer b38677
+++ b/modules.d/90multipath/module-setup.sh
Harald Hoyer b38677
@@ -9,9 +9,10 @@ is_mpath() {
Harald Hoyer b38677
 
Harald Hoyer b38677
 majmin_to_mpath_dev() {
Harald Hoyer b38677
     local _dev
Harald Hoyer b38677
-    for i in `ls -1 /dev/mapper/mpath*`; do
Harald Hoyer b38677
-        dev=$(get_maj_min $i)
Harald Hoyer b38677
-        if [ "$dev" = "$1" ]; then
Harald Hoyer b38677
+    for i in /dev/mapper/*; do
Harald Hoyer b38677
+        [[ $i == /dev/mapper/control ]] && continue
Harald Hoyer b38677
+        _dev=$(get_maj_min $i)
Harald Hoyer b38677
+        if [ "$_dev" = "$1" ]; then
Harald Hoyer b38677
             echo $i
Harald Hoyer b38677
             return
Harald Hoyer b38677
         fi