Skip to content

Commit

Permalink
grub-fs-tester: Fix losetup race
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
wjt authored and Daniel Kiper committed Jun 23, 2018
1 parent 14ec665 commit 0083541
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions tests/util/grub-fs-tester.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0083541

Please sign in to comment.