diff options
-rwxr-xr-x | rc.d/init.d/functions | 29 | ||||
-rwxr-xr-x | rc.d/rc.sysinit | 7 |
2 files changed, 35 insertions, 1 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions index 7ba1090a..59dca79a 100755 --- a/rc.d/init.d/functions +++ b/rc.d/init.d/functions @@ -475,3 +475,32 @@ confirm() { fi done } + +# resolve a device node to its major:minor numbers in decimal or hex +get_numeric_dev() { +( + fmt="%d:%d" + if [ "$1" == "hex" ]; then + fmt="%x:%x" + fi + eval printf "$fmt" $(stat -c "0x%t 0x%T" $2) +) 2>/dev/null +} + +# find the working name for a running dm device with the same table as one +# that dmraid would create +resolve_dm_name() { +( + name="$1" + + line=$(/sbin/dmraid -ay -t --ignorelocking | grep "^$name:" | cut -d\ -f2-) + newline=$line + for x in $line ; do + if [[ "$x" =~ "^/dev/" ]] ; then + majmin=$(get_numeric_dev dec $x) + newline=$(echo $newline | sed -e "s,$x\( \|$\),$majmin\1,g") + fi + done + /sbin/dmsetup table | sed -n "s/\(^[^:]\+\): $newline\( \+$\|$\)/\1/p" +) 2>/dev/null +} diff --git a/rc.d/rc.sysinit b/rc.d/rc.sysinit index ac61126f..f7d849e1 100755 --- a/rc.d/rc.sysinit +++ b/rc.d/rc.sysinit @@ -249,7 +249,12 @@ if [ -c /dev/mapper/control ]; then if [ -x /sbin/dmraid ]; then modprobe dm-mirror >/dev/null 2>&1 - /sbin/dmraid -a y --ignorelocking + for x in $(dmraid -ay -t --ignorelocking | cut -d: -f1) ; do + dmname=$(resolve_dm_name $x) + if [ -z "$dmname" ]; then + /sbin/dmraid -a y --ignorelocking "$dmname" + fi + done fi if [ -x /sbin/lvm.static ]; then |