summaryrefslogtreecommitdiffstats
path: root/sys-utils/losetup.c
diff options
context:
space:
mode:
authorKarel Zak2013-08-06 11:04:35 +0200
committerKarel Zak2013-08-06 11:04:35 +0200
commit3cb2413b02ff01f535b82eb630bd4f157ed7b1c8 (patch)
tree36e3c1b83da117dce3be08eac039a1d0e2387a00 /sys-utils/losetup.c
parentblkdiscard: use fstat() rather than stat() [coverity scan] (diff)
downloadkernel-qcow2-util-linux-3cb2413b02ff01f535b82eb630bd4f157ed7b1c8.tar.gz
kernel-qcow2-util-linux-3cb2413b02ff01f535b82eb630bd4f157ed7b1c8.tar.xz
kernel-qcow2-util-linux-3cb2413b02ff01f535b82eb630bd4f157ed7b1c8.zip
losetup: use loop-control to explicitly ask for device
Now we use LOOP_CTL_GET_FREE ioctl to ask for free device, for example losetup -f foo.img Unfortunately, losetup(8) allows to ask for specified device losetup /dev/loop100 foo.img and in this case we assume that the device already exists in the system. This is incorrect, we should be able to use loop-control LOOP_CTL_ADD ioctl to ask for the specified device. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/losetup.c')
-rw-r--r--sys-utils/losetup.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c
index c1166b039..234a15b0c 100644
--- a/sys-utils/losetup.c
+++ b/sys-utils/losetup.c
@@ -641,6 +641,8 @@ int main(int argc, char **argv)
{
int hasdev = loopcxt_has_device(&lc);
+ if (hasdev && !is_loopdev(loopcxt_get_device(&lc)))
+ loopcxt_add_device(&lc);
do {
const char *errpre;