]> git.pld-linux.org Git - packages/util-linux.git/commitdiff
- optimize in a way that nothing is done if config is empty
authorElan Ruusamäe <glen@pld-linux.org>
Tue, 5 Dec 2006 19:23:14 +0000 (19:23 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    util-linux-blockdev.init -> 1.9

util-linux-blockdev.init

index 7515eaef8fb543825ff8cd3e708985fc5171198a..e5c9e2e2b1f2616e53228f5ded3b429516d46507 100644 (file)
 
 start() {
        if [ ! -f /var/lock/subsys/blockdev ]; then
-               for drive in $(ls /sys/block 2> /dev/null; ls /dev/mapper 2> /dev/null); do
-                       if [ [ -d "/sys/block/${drive}" -a -e "/dev/${drive}" ]; then
+               for var in $(awk -F= '!/^#/ && !/^$/ {if ($2) print $1}' /etc/sysconfig/blockdev); do
+                       realdrive=
+                       drive=${var#BLOCKDEV_}
+                       if [ -d "/sys/block/${drive}" -a -e "/dev/${drive}" ]; then
+                               realdrive="/dev/${drive}"
+                       elif [ -e "/dev/mapper/${drive}" ]; then
+                               realdrive="/dev/mapper/${drive}"
+                       elif drive=$(echo $drive | tr _ -) && [ -d "/sys/block/${drive}" -a -e "/dev/${drive}" ]; then
                                realdrive="/dev/${drive}"
                        elif [ -e "/dev/mapper/${drive}" ]; then
                                realdrive="/dev/mapper/${drive}"
                        fi
+
                        if [ -n "$realdrive" ]; then
-                               eval PARAMS=\$BLOCKDEV_$(echo $drive | tr - _)
+                               eval PARAMS=\$$var
                                if [ -n "${PARAMS}" ]; then
                                        show "Setting parameters for block drive %s (%s)" "$drive" "$PARAMS"
                                        busy
-                                       /sbin/blockdev ${PARAMS} ${realdrive}
+                                       /sbin/blockdev ${PARAMS} $realdrive
                                        ok
                                fi
                        fi
This page took 0.142803 seconds and 4 git commands to generate.