[dm-devel] [PATCH] Fix loopback file with kpartx -av

Christophe Varoqui christophe.varoqui at opensvc.com
Wed Feb 3 08:27:23 UTC 2016


Commited,
Thanks.

On Tue, Feb 2, 2016 at 10:37 PM, Mathieu Trudel-Lapierre <
mathieu.trudel-lapierre at canonical.com> wrote:

> 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
>
>
> --
> dm-devel mailing list
> dm-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/dm-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/dm-devel/attachments/20160203/1a28cfc9/attachment.htm>


More information about the dm-devel mailing list