File util-linux-losetup-don-t-ignore-EBUSY-in-losetup.patch of Package util-linux.openSUSE_13.1_Update
From 5383a3c98c4c33d8e6af9629315fe6d681f56f1f Mon Sep 17 00:00:00 2001
From: Ruediger Meier <ruediger.meier@ga-group.nl>
Date: Wed, 1 Jul 2015 16:34:47 +0200
Subject: [PATCH] Squashed commit of the following:
commit d6ef7d6c69201190d9623885d418f9bdcf31642e
Author: Stanislav Brabec <sbrabec@suse.cz>
Date: Tue May 27 20:38:17 2014 +0200
losetup: don't ignore EBUSY in losetup when the loop device is given
losetup ignores the EBUSY error. In the loop fo A_CREATE action, it skips
the error handling when errno = EBUSY. It's OK for the case where no loop
device is specified, but the error has to be handled when the device is given
explicitly.
Author: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
commit f7e21185087c30c5f13bf92009238e316f8c1cf4
Author: Stanislav Brabec <sbrabec@suse.cz>
Date: Tue May 27 20:38:10 2014 +0200
losetup: don't clear FD at EBUSY error in loopcxt_setup_device()
loopback lib clears the existing FD unconditionally at error in
loopcxt_setup_device(). This is done even after EBUSY, thus the second call
actually clears the previous setup wrongly.
Author: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
lib/loopdev.c | 2 +-
sys-utils/losetup.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/loopdev.c b/lib/loopdev.c
index 0107168..61fc8af 100644
--- a/lib/loopdev.c
+++ b/lib/loopdev.c
@@ -1257,7 +1257,7 @@ int loopcxt_setup_device(struct loopdev_cxt *lc)
err:
if (file_fd >= 0)
close(file_fd);
- if (dev_fd >= 0)
+ if (dev_fd >= 0 && rc != -EBUSY)
ioctl(dev_fd, LOOP_CLR_FD, 0);
DBG(lc, loopdev_debug("setup failed [rc=%d]", rc));
diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c
index 28d87fa..0998546 100644
--- a/sys-utils/losetup.c
+++ b/sys-utils/losetup.c
@@ -624,7 +624,7 @@ int main(int argc, char **argv)
res = loopcxt_setup_device(&lc);
if (res == 0)
break; /* success */
- if (errno == EBUSY)
+ if (errno == EBUSY && !hasdev)
continue;
/* errors */
--
1.8.4.5