summaryrefslogtreecommitdiffstats
path: root/src/utils/sys-utils/xlosetup.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/sys-utils/xlosetup.c')
-rw-r--r--src/utils/sys-utils/xlosetup.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/utils/sys-utils/xlosetup.c b/src/utils/sys-utils/xlosetup.c
index 60fa0ba..cbc2e69 100644
--- a/src/utils/sys-utils/xlosetup.c
+++ b/src/utils/sys-utils/xlosetup.c
@@ -469,7 +469,7 @@ static int create_loop(struct loopdev_cxt *lc,
uint64_t blocksize, uint32_t file_fmt_type)
{
int hasdev = loopcxt_has_device(lc);
- int rc = 0;
+ int rc = 0, ntries = 0;
/* xlosetup --find --noverlap file.img */
if (!hasdev && nooverlap) {
@@ -501,7 +501,7 @@ static int create_loop(struct loopdev_cxt *lc,
errx(EXIT_FAILURE, _("%s: overlapping encrypted xloop device exists"), file);
}
- lc->info.lo_flags &= ~LO_FLAGS_AUTOCLEAR;
+ lc->config.info.lo_flags &= ~LO_FLAGS_AUTOCLEAR;
if (loopcxt_ioctl_status(lc)) {
loopcxt_deinit(lc);
errx(EXIT_FAILURE, _("%s: failed to re-use xloop device"), file);
@@ -571,8 +571,12 @@ static int create_loop(struct loopdev_cxt *lc,
rc = loopcxt_setup_device(lc);
if (rc == 0)
break; /* success */
- if (errno == EBUSY && !hasdev)
+
+ if (errno == EBUSY && !hasdev && ntries < 64) {
+ xusleep(200000);
+ ntries++;
continue;
+ }
/* errors */
errpre = hasdev && loopcxt_get_fd(lc) < 0 ?