Fix/finish modularization
[mapsector.git] / mapsector
index 353c6de..9eb97c6 100755 (executable)
--- a/mapsector
+++ b/mapsector
@@ -25,13 +25,13 @@ load()
 
 # Map device/sector through blockdevice mappings (e.g. lvm)
 
-run()
+map()
 {
     local found
-    foundm=1
+    found=1
     while [ -n "$found" ]; do
        found=""
-       for name in "$@"; do
+       for name in $mappers; do
            if detect_$name; then
                found=1
                if do_$name; then
@@ -43,6 +43,17 @@ run()
     done
 }
 
+scan()
+{
+    for name in $scanners; do
+       if detect_$name; then
+           if do_$name; then
+               return
+           fi
+       fi
+    done
+}
+
 ###########################################################################
 
 unset LANG
@@ -134,7 +145,7 @@ sector="$2"
 echo "device $device"
 echo "sector $sector"
 
-run $mappers
+map
 if [ -z "$noscan" ]; then
-    run $scanners
+    scan
 fi