summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Horák <dan@danny.cz>2010-04-21 09:00:17 +0200
committerDan Horák <dan@danny.cz>2010-04-21 09:00:17 +0200
commit1f469816273add2b2903b3abd67c5007c5e75475 (patch)
treed2f636354ac8080bd3630548fc725963bc9daf68
parent6edb59800ba0e6109d63e937e16a3c6e134271d0 (diff)
downloadutils-1f469816273add2b2903b3abd67c5007c5e75475.tar.gz
utils-1f469816273add2b2903b3abd67c5007c5e75475.tar.xz
utils-1f469816273add2b2903b3abd67c5007c5e75475.zip
place code for waiting on all devices to a function
-rw-r--r--device_cio_free109
1 files changed, 57 insertions, 52 deletions
diff --git a/device_cio_free b/device_cio_free
index 42d3cfd..87d31ee 100644
--- a/device_cio_free
+++ b/device_cio_free
@@ -82,6 +82,62 @@ wait_on_single_device()
echo "Error: device $DEV still not ready"
}
+# wait until recently unblocked devices are ready
+# at this point we know the content of ALL_DEVICES is syntacticly correct
+wait_on_devices()
+{
+ OLD_IFS=$IFS
+ IFS=","
+ set $ALL_DEVICES
+ for DEV in $*
+ do
+ IFS="."
+
+ # get the lower bound for range or get the single device
+ LOWER=${DEV%%-*}
+ set $LOWER
+ if [ $# -eq 1 ]; then
+ L0=0
+ L1=0
+ L2=$(printf "%d" "0x$1")
+ else
+ L0=$(printf "%d" "0x$1")
+ L1=$(printf "%d" "0x$2")
+ L2=$(printf "%d" "0x$3")
+ fi
+
+ # get the upper bound for range or get the single device
+ UPPER=${DEV##*-}
+ set $UPPER
+ if [ $# -eq 1 ]; then
+ U0=0
+ U1=0
+ U2=$(printf "%d" "0x$1")
+ else
+ U0=$(printf "%d" "0x$1")
+ U1=$(printf "%d" "0x$2")
+ U2=$(printf "%d" "0x$3")
+ fi
+
+ IFS=$OLD_IFS
+
+ # iterate thru all devices
+ for i in $(seq $L0 $U0); do
+ [ $i -eq $L0 ] && LJ=$L1 || LJ=0
+ [ $i -eq $U0 ] && UJ=$U1 || UJ=3
+
+ for j in $(seq $LJ $UJ); do
+ [ $i -eq $L0 -a $j -eq $L1 ] && LK=$L2 || LK=0
+ [ $i -eq $U0 -a $j -eq $U1 ] && UK=$U2 || UK=65535
+
+ for k in $(seq $LK $UK); do
+ wait_on_single_device "$(printf %x.%x.%04x $i $j $k)"
+ done
+ done
+ done
+ done
+}
+
process_config_file()
{
local CONFIG
@@ -203,55 +259,4 @@ fi
[ -z "$ALL_DEVICES" ] && exit 0
-# wait until recently unblocked devices are ready
-# at this point we know the content of ALL_DEVICES is syntacticly correct
-OLD_IFS=$IFS
-IFS=","
-set $ALL_DEVICES
-for DEV in $*
-do
- IFS="."
-
- # get the lower bound for range or get the single device
- LOWER=${DEV%%-*}
- set $LOWER
- if [ $# -eq 1 ]; then
- L0=0
- L1=0
- L2=$(printf "%d" "0x$1")
- else
- L0=$(printf "%d" "0x$1")
- L1=$(printf "%d" "0x$2")
- L2=$(printf "%d" "0x$3")
- fi
-
- # get the upper bound for range or get the single device
- UPPER=${DEV##*-}
- set $UPPER
- if [ $# -eq 1 ]; then
- U0=0
- U1=0
- U2=$(printf "%d" "0x$1")
- else
- U0=$(printf "%d" "0x$1")
- U1=$(printf "%d" "0x$2")
- U2=$(printf "%d" "0x$3")
- fi
-
- IFS=$OLD_IFS
-
- # iterate thru all devices
- for i in $(seq $L0 $U0); do
- [ $i -eq $L0 ] && LJ=$L1 || LJ=0
- [ $i -eq $U0 ] && UJ=$U1 || UJ=3
-
- for j in $(seq $LJ $UJ); do
- [ $i -eq $L0 -a $j -eq $L1 ] && LK=$L2 || LK=0
- [ $i -eq $U0 -a $j -eq $U1 ] && UK=$U2 || UK=65535
-
- for k in $(seq $LK $UK); do
- wait_on_single_device "$(printf %x.%x.%04x $i $j $k)"
- done
- done
- done
-done
+wait_on_devices