grub2/0149-grub-fs-tester-Fix-losetup-race.patch
Peter Jones 752ceb1640 Rebased to newer upstream for fedora-29
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-07-10 15:12:02 -04:00

32 lines
1.3 KiB
Diff

From 0083541593e05704961db229aefea0542446c07c Mon Sep 17 00:00:00 2001
From: Will Thompson <wjt@endlessm.com>
Date: Fri, 15 Jun 2018 18:34:04 +0100
Subject: [PATCH] grub-fs-tester: Fix losetup race
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.
Signed-off-by: Will Thompson <wjt@endlessm.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
tests/util/grub-fs-tester.in | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in
index 26bd57a8027..ef65fbc9341 100644
--- a/tests/util/grub-fs-tester.in
+++ b/tests/util/grub-fs-tester.in
@@ -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
MOUNTDEVICE="$LODEVICE"
fi