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