[dm-devel] [PATCH] Fix loopback file with kpartx -av
Mathieu Trudel-Lapierre
mathieu.trudel-lapierre at canonical.com
Tue Feb 2 21:37:51 UTC 2016
Le 2016-01-20 09:53, Christophe Varoqui a écrit :
> Applied,
> thanks.
>
This patch apparently breaks the use of loopback-mounted files if you
try to use them directly with kpartx -av.
For instance:
qemu-img create foo.img 20M
sgdisk -n 1 foo.img
kpartx -av foo.img
Fails with the following error:
device-mapper: reload ioctl on loop0p1 failed: No such device
create/reload failed on loop0p1
add map loop0p1 (0:0): 0 4192256 linear 0:0 2048
This can be fixed by stat()'ing the loop device again after picking it:
--- a/kpartx/kpartx.c
+++ b/kpartx/kpartx.c
@@ -322,6 +322,11 @@ main(int argc, char **argv){
loopcreated = 1;
}
device = loopdev;
+
+ if (stat(device, &buf)) {
+ printf("failed to stat() %s\n", device);
+ exit (1);
+ }
}
off = find_devname_offset(device);
--
Mathieu Trudel-Lapierre <mathieu.trudel-lapierre at canonical.com>
Freenode: cyphermox, Jabber: mathieu.tl at gmail.com
4096R/65B58DA1 818A D123 0992 275B 23C2 CF89 C67B B4D6 65B5 8DA1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/dm-devel/attachments/20160202/9f2e19ab/attachment.sig>
More information about the dm-devel
mailing list