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