]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/loopdev: remove duplicate code
authorKarel Zak <kzak@redhat.com>
Tue, 8 Mar 2022 12:02:38 +0000 (13:02 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 30 Mar 2022 09:14:30 +0000 (11:14 +0200)
Use loopcxt_ioctl_status() rather than duplicate code.

Signed-off-by: Karel Zak <kzak@redhat.com>
lib/loopdev.c

index d89c795ed2d8090331b19b7137f55849027fde65..3cf72ebb9472c4477544ada76a5cc5cc7b5f9756 100644 (file)
@@ -1297,7 +1297,7 @@ 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, flags = O_CLOEXEC;
-       int rc = -1, cnt = 0, err, again;
+       int rc = -1, cnt = 0;
        int errsv = 0;
        int fallback = 0;
 
@@ -1404,21 +1404,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)))