1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-18 10:04:20 +03:00

tests: extend prepare_loop

Treat args after size  as 'extra' params for losetup.
This commit is contained in:
Zdenek Kabelac 2016-06-01 17:25:06 +02:00
parent d37a26b680
commit d73a83e8cf

View File

@ -553,6 +553,7 @@ teardown() {
prepare_loop() { prepare_loop() {
local size=${1=32} local size=${1=32}
local losetup_params=${@:2}
local i local i
local slash local slash
@ -577,9 +578,9 @@ prepare_loop() {
local LOOPFILE="$PWD/test.img" local LOOPFILE="$PWD/test.img"
rm -f "$LOOPFILE" rm -f "$LOOPFILE"
dd if=/dev/zero of="$LOOPFILE" bs=$((1024*1024)) count=0 seek=$(($size + 1)) 2> /dev/null dd if=/dev/zero of="$LOOPFILE" bs=$((1024*1024)) count=0 seek=$(($size + 1)) 2> /dev/null
if LOOP=$(losetup -s -f "$LOOPFILE" 2>/dev/null); then if LOOP=$(losetup ${losetup_params} -s -f "$LOOPFILE" 2>/dev/null); then
: :
elif LOOP=$(losetup -f) && losetup "$LOOP" "$LOOPFILE"; then elif LOOP=$(losetup -f) && losetup ${losetup_params} "$LOOP" "$LOOPFILE"; then
# no -s support # no -s support
: :
else else
@ -590,7 +591,7 @@ prepare_loop() {
local dev="$DM_DEV_DIR/loop$slash$i" local dev="$DM_DEV_DIR/loop$slash$i"
! losetup "$dev" >/dev/null 2>&1 || continue ! losetup "$dev" >/dev/null 2>&1 || continue
# got a free # got a free
losetup "$dev" "$LOOPFILE" losetup ${losetup_params} "$dev" "$LOOPFILE"
LOOP=$dev LOOP=$dev
break break
done done