- updated device_cio_free script (#533494)

This commit is contained in:
Dan Horák 2010-01-08 07:47:01 +00:00
parent aea23e74fb
commit 2d050c5e5f
2 changed files with 52 additions and 31 deletions

View File

@ -39,7 +39,7 @@ free_device()
DEV=$(echo $1 | tr "A-Z" "a-z") DEV=$(echo $1 | tr "A-Z" "a-z")
[ $VERBOSE ] && echo "Freeing device(s) $DEV" [ $VERBOSE ] && echo "Freeing device(s) $DEV"
if [ echo "free $DEV" > $BLACKLIST 2> /dev/null ]; then if ! echo "free $DEV" > $BLACKLIST 2> /dev/null ; then
echo "Error: can't free device(s) $DEV" echo "Error: can't free device(s) $DEV"
else else
if [ -z $ALL_DEVICES ]; then if [ -z $ALL_DEVICES ]; then
@ -53,12 +53,16 @@ free_device()
# wait until a device appears on the ccw bus # wait until a device appears on the ccw bus
wait_on_device() wait_on_device()
{ {
local DEVICE_ONLINE DEV local DEVICE_CCW DEVICE_ONLINE DEV
[ -z "$1" ] && return [ -z "$1" ] && return
DEV=$1 DEV=$1
DEVICE_ONLINE=/sys/bus/ccw/devices/$DEV/online DEVICE_CCW=/sys/bus/ccw/devices/$DEV
DEVICE_ONLINE=$DEVICE_CCW/online
# [ -f $DEVICE_CCW ] || sleep 1
# [ -f $DEVICE_CCW ] || return
[ $VERBOSE ] && echo "Waiting on device $DEV" [ $VERBOSE ] && echo "Waiting on device $DEV"
[ -f "$DEVICE_ONLINE" ] && return [ -f "$DEVICE_ONLINE" ] && return
@ -72,7 +76,8 @@ wait_on_device()
} }
# check how we were called # check how we were called
case $(basename "$0") in CMD=$(basename "$0")
case $CMD in
"dasd_cio_free") "dasd_cio_free")
CONFIG=$DASDCONFIG CONFIG=$DASDCONFIG
MODE=dasd MODE=dasd
@ -148,14 +153,14 @@ if [ $MODE = "znet" ]; then
*) *)
[ -z "$line" ] && continue [ -z "$line" ] && continue
# grep 2 or 3 channels from beginning of each line # grep 2 or 3 channels from beginning of each line
DEVICES=$(echo $line | egrep -i -o "^([0-9]\.[0-9]\.[a-f0-9]+,){1,2}([0-9]\.[0-9]\.[a-f0-9]+)") DEVICES=$(echo $line | grep -E -i -o "^([0-9]\.[0-9]\.[a-f0-9]+,){1,2}([0-9]\.[0-9]\.[a-f0-9]+)")
free_device $DEVICES free_device $DEVICES
;; ;;
esac esac
done < $CONFIG done < $CONFIG
fi fi
# process channels from network interface configurations # process channels from network interface configurations
for line in $(egrep -i -h "^[[:space:]]*SUBCHANNELS=['\"]?([0-9]\.[0-9]\.[a-f0-9]+,){1,2}([0-9]\.[0-9]\.[a-f0-9]+)['\"]?([[:space:]]+#|[[:space:]]*$)" /etc/sysconfig/network-scripts/ifcfg-* 2> /dev/null) for line in $(grep -E -i -h "^[[:space:]]*SUBCHANNELS=['\"]?([0-9]\.[0-9]\.[a-f0-9]+,){1,2}([0-9]\.[0-9]\.[a-f0-9]+)['\"]?([[:space:]]+#|[[:space:]]*$)" /etc/sysconfig/network-scripts/ifcfg-* 2> /dev/null)
do do
eval "$line" eval "$line"
free_device $SUBCHANNELS free_device $SUBCHANNELS
@ -164,40 +169,53 @@ fi
# wait until recently unblocked devices are ready # wait until recently unblocked devices are ready
# at this point we know the content of ALL_DEVICES is syntacticly correct # at this point we know the content of ALL_DEVICES is syntacticly correct
OLD_IFS=$IFS
IFS="," IFS=","
set $ALL_DEVICES set $ALL_DEVICES
while [ "$1" ] for DEV in $*
do do
DEV="$1"
IFS="." IFS="."
# get the lower bound for range or get the single device # get the lower bound for range or get the single device
LOWER=${DEV%%-*} LOWER=${DEV%%-*}
read -a L <<< "$LOWER" set $LOWER
if [ ${#L[@]} -eq 1 ]; then if [ $# -eq 1 ]; then
L[2]=${L[0]} L0=0
L[0]=0 L1=0
L[1]=0 L2=$(printf "%d" "0x$1")
else
L0=$(printf "%d" "0x$1")
L1=$(printf "%d" "0x$2")
L2=$(printf "%d" "0x$3")
fi fi
# get the upper bound for range or get the single device # get the upper bound for range or get the single device
UPPER=${DEV##*-} UPPER=${DEV##*-}
read -a U <<< "$UPPER" set $UPPER
if [ ${#U[@]} -eq 1 ]; then if [ $# -eq 1 ]; then
U[2]=${U[0]} U0=0
U[0]=0 U1=0
U[1]=0 U2=$(printf "%d" "0x$1")
else
U0=$(printf "%d" "0x$1")
U1=$(printf "%d" "0x$2")
U2=$(printf "%d" "0x$3")
fi fi
IFS=$OLD_IFS
# iterate thru all devices # iterate thru all devices
for (( i=0x${L[0]}; i<=0x${U[0]}; i++ )); do for i in $(seq $L0 $U0); do
for (( j=0x${L[1]}; j<=0x${U[1]}; j++ )); do [ $i -eq $L0 ] && LJ=$L1 || LJ=0
for (( k=0x${L[2]}; k<=0x${U[2]}; k++ )); do [ $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_device "$(printf %x.%x.%04x $i $j $k)" wait_on_device "$(printf %x.%x.%04x $i $j $k)"
done done
done done
done done
# go to the next device
shift
done done

View File

@ -8,7 +8,7 @@ Name: s390utils
Summary: Utilities and daemons for IBM System/z Summary: Utilities and daemons for IBM System/z
Group: System Environment/Base Group: System Environment/Base
Version: 1.8.2 Version: 1.8.2
Release: 6%{?dist} Release: 7%{?dist}
Epoch: 2 Epoch: 2
License: GPLv2 and GPLv2+ and CPL License: GPLv2 and GPLv2+ and CPL
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -826,12 +826,15 @@ User-space development files for the s390/s390x architecture.
%changelog %changelog
* Fri Jan 8 2010 Dan Horák <dan[at]danny.cz> 2:1.8.2-7
- updated device_cio_free script (#533494)
* Tue Dec 22 2009 Dan Horák <dan[at]danny.cz> 2:1.8.2-6 * Tue Dec 22 2009 Dan Horák <dan[at]danny.cz> 2:1.8.2-6
- fixed return value in cpi initscript (#541389) - fixed return value in cpi initscript (#541389)
- updated zfcpconf.sh script from dracut - updated zfcpconf.sh script from dracut
- added device-mapper support into zipl (#546280) - added device-mapper support into zipl (#546280)
- added missing check and print NSS name in case an NSS has been IPLed (#546297) - added missing check and print NSS name in case an NSS has been IPLed (#546297)
- added device_cio_free script and its symlinks - added device_cio_free script and its symlinks (#533494)
- added qualified return codes and further error handling in znetconf (#548487) - added qualified return codes and further error handling in znetconf (#548487)
* Fri Nov 13 2009 Dan Horák <dan[at]danny.cz> 2:1.8.2-5 * Fri Nov 13 2009 Dan Horák <dan[at]danny.cz> 2:1.8.2-5