]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
multipath: fix majmin_to_mpath_dev() 111/head
authorPekka Wallendahl <wyrmiyu@gmail.com>
Mon, 18 Jan 2016 18:28:22 +0000 (20:28 +0200)
committerPekka Wallendahl <wyrmiyu@gmail.com>
Mon, 18 Jan 2016 18:28:22 +0000 (20:28 +0200)
* Multipath device names only start with the mpath-prefix if the option
  use_userfriendly_names is set true in /etc/multipath.conf and if user
  has not set any aliases in the said file. Thus the for-loop should go
  through all files in /dev/mapper/, not just ones starting with 'mpath'

* Bash is perfectly capable to extend `/dev/mapper/*` notation without a
  need to pass it to an external ls

* Changed the function to use a local variable $_dev instead of the
  global $dev, which seemed to be the original intention as the local
  _dev was defined but not used

modules.d/90multipath/module-setup.sh

index 831c99ff8d739cb37869185bd7a01cd76502ba65..a8086788c0e7f8d4558344f17d6eaf2b39e44754 100755 (executable)
@@ -9,9 +9,10 @@ is_mpath() {
 
 majmin_to_mpath_dev() {
     local _dev
-    for i in `ls -1 /dev/mapper/mpath*`; do
-        dev=$(get_maj_min $i)
-        if [ "$dev" = "$1" ]; then
+    for i in /dev/mapper/*; do
+        [[ $i == /dev/mapper/control ]] && continue
+        _dev=$(get_maj_min $i)
+        if [ "$_dev" = "$1" ]; then
             echo $i
             return
         fi