From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christophe Varoqui Subject: Re: [PATCH] Fix loopback file with kpartx -av Date: Wed, 3 Feb 2016 09:27:23 +0100 Message-ID: References: <1453297965-32278-1-git-send-email-mauricfo@linux.vnet.ibm.com> <56B121AF.6090100@canonical.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6912207586195045335==" Return-path: In-Reply-To: <56B121AF.6090100@canonical.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: Mathieu Trudel-Lapierre Cc: device-mapper development List-Id: dm-devel.ids --===============6912207586195045335== Content-Type: multipart/alternative; boundary=047d7b3a84c4305dc7052ad96324 --047d7b3a84c4305dc7052ad96324 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Commited, Thanks. On Tue, Feb 2, 2016 at 10:37 PM, Mathieu Trudel-Lapierre < mathieu.trudel-lapierre@canonical.com> wrote: > Le 2016-01-20 09:53, Christophe Varoqui a =C3=A9crit : > > 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 =3D 1; > } > device =3D loopdev; > + > + if (stat(device, &buf)) { > + printf("failed to stat() %s\n", device); > + exit (1); > + } > } > > off =3D find_devname_offset(device); > > > > > -- > Mathieu Trudel-Lapierre > Freenode: cyphermox, Jabber: mathieu.tl@gmail.com > 4096R/65B58DA1 818A D123 0992 275B 23C2 CF89 C67B B4D6 65B5 8DA1 > > > -- > dm-devel mailing list > dm-devel@redhat.com > https://www.redhat.com/mailman/listinfo/dm-devel > --047d7b3a84c4305dc7052ad96324 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Commited,
Thanks.

On Tue, Feb 2, 2016 at 10:37 PM, Mathieu T= rudel-Lapierre <mathieu.trudel-lapierre@canonical.com<= /a>> wrote:
Le 2016-01-20 09:53= , Christophe Varoqui a =C3=A9crit :
> 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){
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 loopcreated =3D 1;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 device =3D loopdev;=
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (stat(device, &a= mp;buf)) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0printf("failed to stat() %s\n", device);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0exit (1);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }

=C2=A0 =C2=A0 =C2=A0 =C2=A0 off =3D find_devname_offset(device);




--
Mathieu Trudel-Lapierre <
mathieu.trudel-lapierre@canonical.com>
Freenode: cyphermox, Jabber: mathie= u.tl@gmail.com
4096R/65B58DA1 818A D123 0992 275B 23C2=C2=A0 CF89 C67B B4D6 65B5 8DA1


--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel=

--047d7b3a84c4305dc7052ad96324-- --===============6912207586195045335== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============6912207586195045335==--