From 24a39bb8baf827133c1cc6445021170502c18b94 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 8 Mar 2022 13:02:38 +0100 Subject: lib/loopdev: remove duplicate code Use loopcxt_ioctl_status() rather than duplicate code. Addresses: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2117203 Signed-off-by: Karel Zak --- lib/loopdev.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/lib/loopdev.c b/lib/loopdev.c index e8ccf6ae6..fda0e1210 100644 --- a/lib/loopdev.c +++ b/lib/loopdev.c @@ -1296,7 +1296,8 @@ static int loopcxt_check_size(struct loopdev_cxt *lc, int file_fd) */ int loopcxt_setup_device(struct loopdev_cxt *lc) { - int file_fd, dev_fd, mode = O_RDWR, rc = -1, cnt = 0, err, again; + int file_fd, dev_fd, mode = O_RDWR; + int rc = -1, cnt = 0; int errsv = 0; int fallback = 0; @@ -1400,21 +1401,10 @@ int loopcxt_setup_device(struct loopdev_cxt *lc) goto err; } - do { - err = ioctl(dev_fd, LOOP_SET_STATUS64, &lc->config.info); - again = err && errno == EAGAIN; - if (again) - xusleep(250000); - } while (again); - - if (err) { - rc = -errno; - errsv = errno; - DBG(SETUP, ul_debugobj(lc, "LOOP_SET_STATUS64 failed: %m")); + if ((rc = loopcxt_ioctl_status(lc)) < 0) { + errsv = -rc; goto err; } - - DBG(SETUP, ul_debugobj(lc, "LOOP_SET_STATUS64: OK")); } if ((rc = loopcxt_check_size(lc, file_fd))) -- 2.37.1