Discussion:
[PATCH 1/1] grub-fs-tester: fix losetup race
Will Thompson
2018-06-15 17:34:04 UTC
Permalink
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/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 26bd57a80..ef65fbc93 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
--
2.17.1
Daniel Kiper
2018-06-20 09:33:56 UTC
Permalink
Post by Will Thompson
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.
In general LGTM except lack of SOB. I can add it (Signed-off-by: Will
Thompson <***@endlessm.com>) before committing if you are OK with that.
Next time please do not forget about that.

Daniel
Will Thompson
2018-06-20 11:15:46 UTC
Permalink
Post by Daniel Kiper
Post by Will Thompson
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.
In general LGTM except lack of SOB. I can add it (Signed-off-by: Will
Next time please do not forget about that.
That's fine by me – I'll include it in the submitted patch in future.
Thanks!

Continue reading on narkive:
Loading...