mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
tests: extend prepare_loop
Treat args after size as 'extra' params for losetup.
This commit is contained in:
parent
d37a26b680
commit
d73a83e8cf
@ -553,6 +553,7 @@ teardown() {
|
||||
|
||||
prepare_loop() {
|
||||
local size=${1=32}
|
||||
local losetup_params=${@:2}
|
||||
local i
|
||||
local slash
|
||||
|
||||
@ -577,9 +578,9 @@ prepare_loop() {
|
||||
local LOOPFILE="$PWD/test.img"
|
||||
rm -f "$LOOPFILE"
|
||||
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
|
||||
:
|
||||
else
|
||||
@ -590,7 +591,7 @@ prepare_loop() {
|
||||
local dev="$DM_DEV_DIR/loop$slash$i"
|
||||
! losetup "$dev" >/dev/null 2>&1 || continue
|
||||
# got a free
|
||||
losetup "$dev" "$LOOPFILE"
|
||||
losetup ${losetup_params} "$dev" "$LOOPFILE"
|
||||
LOOP=$dev
|
||||
break
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user