lib/loopdev: cosmetic changes to LOOP_CONFIGURE
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
558880dd35
commit
a61955ba1f
|
@ -67,7 +67,10 @@ struct loop_info64 {
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef LOOP_CONFIGURE
|
#ifndef LOOP_CONFIGURE
|
||||||
#define LOOP_CONFIGURE 0x4C0A
|
/*
|
||||||
|
* Since Linux v5.8-rc1 (commit 3448914e8cc550ba792d4ccc74471d1ca4293aae)
|
||||||
|
*/
|
||||||
|
# define LOOP_CONFIGURE 0x4C0A
|
||||||
struct loop_config {
|
struct loop_config {
|
||||||
uint32_t fd;
|
uint32_t fd;
|
||||||
uint32_t block_size;
|
uint32_t block_size;
|
||||||
|
|
|
@ -1335,32 +1335,33 @@ int loopcxt_setup_device(struct loopdev_cxt *lc)
|
||||||
|
|
||||||
DBG(SETUP, ul_debugobj(lc, "device open: OK"));
|
DBG(SETUP, ul_debugobj(lc, "device open: OK"));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Atomic way to configure all by one ioctl call
|
||||||
|
* -- since Linux v5.8-rc1, commit 3448914e8cc550ba792d4ccc74471d1ca4293aae
|
||||||
|
*/
|
||||||
lc->config.fd = file_fd;
|
lc->config.fd = file_fd;
|
||||||
if (ioctl(dev_fd, LOOP_CONFIGURE, &lc->config) < 0) {
|
if (ioctl(dev_fd, LOOP_CONFIGURE, &lc->config) < 0) {
|
||||||
rc = -errno;
|
rc = -errno;
|
||||||
errsv = errno;
|
errsv = errno;
|
||||||
if (errno != EINVAL)
|
if (errno != EINVAL) {
|
||||||
{
|
|
||||||
DBG(SETUP, ul_debugobj(lc, "LOOP_CONFIGURE failed: %m"));
|
DBG(SETUP, ul_debugobj(lc, "LOOP_CONFIGURE failed: %m"));
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
fallback = 1;
|
fallback = 1;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if (lc->blocksize > 0
|
if (lc->blocksize > 0
|
||||||
&& (rc = loopcxt_ioctl_blocksize(lc, lc->blocksize)) < 0) {
|
&& (rc = loopcxt_ioctl_blocksize(lc, lc->blocksize)) < 0) {
|
||||||
errsv = -rc;
|
errsv = -rc;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG(SETUP, ul_debugobj(lc, "LOOP_CONFIGURE: OK"));
|
DBG(SETUP, ul_debugobj(lc, "LOOP_CONFIGURE: OK"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Old deprecated way; first assign backing file FD and then in the
|
||||||
|
* second step set loop device properties.
|
||||||
|
*/
|
||||||
if (fallback) {
|
if (fallback) {
|
||||||
/*
|
|
||||||
* Set FD
|
|
||||||
*/
|
|
||||||
if (ioctl(dev_fd, LOOP_SET_FD, file_fd) < 0) {
|
if (ioctl(dev_fd, LOOP_SET_FD, file_fd) < 0) {
|
||||||
rc = -errno;
|
rc = -errno;
|
||||||
errsv = errno;
|
errsv = errno;
|
||||||
|
@ -1382,6 +1383,7 @@ int loopcxt_setup_device(struct loopdev_cxt *lc)
|
||||||
if (again)
|
if (again)
|
||||||
xusleep(250000);
|
xusleep(250000);
|
||||||
} while (again);
|
} while (again);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
rc = -errno;
|
rc = -errno;
|
||||||
errsv = errno;
|
errsv = errno;
|
||||||
|
|
Loading…
Reference in New Issue