loop-util: apparently opening a loop device sometimes results in ENXIO, handle this
authorLennart Poettering <lennart@poettering.net>
Thu, 24 Sep 2020 13:08:22 +0000 (15:08 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 8 Dec 2020 13:34:28 +0000 (14:34 +0100)
(cherry picked from commit 77ad674b51ceb598aae1adaa7abe572ad0262f39)

src/shared/loop-util.c

index 4a593b05f3c90073b6fd87e8ad60d66d040b7562..51a8ef7e216e20ed3f1d0b69067c5537a6105e9d 100644 (file)
@@ -116,7 +116,7 @@ int loop_device_make(
                 if (loop < 0) {
                         /* Somebody might've gotten the same number from the kernel, used the device,
                          * and called LOOP_CTL_REMOVE on it. Let's retry with a new number. */
-                        if (errno != ENOENT)
+                        if (!IN_SET(errno, ENOENT, ENXIO))
                                 return -errno;
                 } else {
                         if (ioctl(loop, LOOP_SET_FD, fd) >= 0) {