losetup -f returns the next free loop device, which may not be
/dev/loop0. If you blindly follow the readmy you may end up destroying
an existing device.
Make it more robust with a variable to store the loop device.
Signed-off-by: Cherniaev Andrei <dungeonlords789@naver.com>
[Arnout: keep the actual losetup atomic]
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
(cherry picked from commit 7dd56b6cd928ee36c96a697075e3fa47b0c52d5e)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>