1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-02-01 09:47:48 +03:00

test: Make it possible to enable/disable devices silently.

This commit is contained in:
Petr Rockai 2014-05-26 14:37:45 +02:00
parent dba6dec661
commit eda4c3a41d

View File

@ -406,19 +406,50 @@ delay_dev() {
disable_dev() {
local dev
local silent
local error
local notify
while test -n "$1"; do
if test "$1" = "--silent"; then
silent=1
shift
elif test "$1" = "--error"; then
error=1
shift
else
break
fi
done
udev_wait
for dev in "$@"; do
maj=$(($(stat -L --printf=0x%t "$dev")))
min=$(($(stat -L --printf=0x%T "$dev")))
echo "Disabling device $dev ($maj:$min)"
dmsetup remove -f "$dev" 2>/dev/null || true
notify_lvmetad --major "$maj" --minor "$min"
notify="$notify $maj:$min"
if test -n "$error"; then
echo 0 10000000 error | dmsetup load $dev
dmsetup resume $dev
else
dmsetup remove -f "$dev" 2>/dev/null || true
fi
done
test -n "$silent" || for num in $notify; do
notify_lvmetad --major $(echo $num | sed -e "s,:.*,,") \
--minor $(echo $num | sed -e "s,.*:,,")
done
}
enable_dev() {
local dev
local silent
if test "$1" = "--silent"; then
silent=1
shift
fi
rm -f debug.log
init_udev_transaction
@ -431,7 +462,7 @@ enable_dev() {
done
finish_udev_transaction
for dev in "$@"; do
test -n "$silent" || for dev in "$@"; do
notify_lvmetad "$dev"
done
}
@ -450,6 +481,7 @@ error_dev() {
local type
local pvdev
local offset
local silent
read pos size type pvdev offset < $name.table
@ -480,7 +512,7 @@ error_dev() {
# using device name (since device path does not exists yet with udev)
dmsetup resume "$name"
finish_udev_transaction
notify_lvmetad "$dev"
test -n "$silent" || notify_lvmetad "$dev"
}
backup_dev() {