[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/1] grub-fs-tester: fix losetup race

From: Will Thompson
Subject: [PATCH 1/1] grub-fs-tester: fix losetup race
Date: Fri, 15 Jun 2018 18:34:04 +0100

If something else on the system is using loopback devices, then the
device that's free at the call to `losetup -f` may not be free in the
following call to try to use it. Instead, find and use the first free
loopback device in a single call to losetup.
 tests/util/ | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tests/util/ b/tests/util/
index 26bd57a80..ef65fbc93 100644
--- a/tests/util/
+++ b/tests/util/
@@ -616,9 +616,8 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" "$MAXLOGSECSIZE" 
1); do
                    mkdir -p "$MNTPOINTRO"
                    for i in $(range 0 $((NDEVICES-1)) 1); do
                        dd if=/dev/zero of="$FSIMAGEP${i}.img" count=1 bs=1 
seek=$((DISKSIZE-1)) &> /dev/null
-                       LODEVICE="$(losetup -f)"
+                       LODEVICE=$(losetup --find --show "$FSIMAGEP${i}.img")
                        LODEVICES="$LODEVICES $LODEVICE"
-                       losetup "$LODEVICE" "$FSIMAGEP${i}.img"
                        if test "$i" = 0; then

reply via email to

[Prev in Thread] Current Thread [Next in Thread]