From mboxrd@z Thu Jan 1 00:00:00 1970 From: Philipp Hahn Subject: Re: [PATCH v2] Add HybridISO support for PyGrub2 Date: Tue, 1 Nov 2011 20:04:25 +0100 Message-ID: <201111012004.30624.hahn@univention.de> References: <201110251057.06774.hahn@univention.de> <201110280946.51201.hahn@univention.de> <20144.16411.886176.254632@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0559150883==" Return-path: In-Reply-To: <20144.16411.886176.254632@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Jackson Cc: "xen-devel@lists.xensource.com" , Ian Campbell List-Id: xen-devel@lists.xenproject.org --===============0559150883== Content-Type: multipart/signed; boundary="nextPart1357777.BZilLcrcLS"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit --nextPart1357777.BZilLcrcLS Content-Type: multipart/mixed; boundary="Boundary-01=_5KEsO+rQqTHcdin" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_5KEsO+rQqTHcdin Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello Ian, Am Dienstag 01 November 2011 19:53:15 schrieb Ian Jackson: > Philipp Hahn writes ("Re: [Xen-devel] [PATCH v2] Add HybridISO support fo= r=20 PyGrub2"): > > v2: For HybrisISOs use offset 0 in addition instead of replacement. > > Thanks. I tried to apply this but it has been linewrapped. Can you > please resubmit it with a non-broken mailer ? If you avoid lines >75 > characters it probably won't linewrap, or you could attach it I guess. I've attached the patch. Thank you for asking back. Sincerely Philipp =2D-=20 Philipp Hahn Open Source Software Engineer hahn@univention.de Univention GmbH Linux for Your Business fon: +49 421 22 232- 0 Mary-Somerville-Str.1 D-28359 Bremen fax: +49 421 22 232-99 http://www.univention.de/ --Boundary-01=_5KEsO+rQqTHcdin Content-Type: text/x-diff; charset="iso-8859-15"; name="0003-pygrub-hybridiso.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0003-pygrub-hybridiso.patch" Bug #23812: Add HybridISO support for PyGrub2 grub-mkrescue internally uses xorriso, which generates a so-called "Hybrid ISO": The ISO images also contains a DOS partition table, which allows the identical ISO file to be stored on an USB stick for booting from it. This breaks PyGrub, since it (wrongly) detects only the DOS partition table and = uses the first partition instead of the complete ISO file. Add a check to detect HybridISO files and use offset 0 in addition to parti= tion table parsing. =2D-- a/tools/pygrub/src/pygrub +++ b/tools/pygrub/src/pygrub @@ -40,15 +40,20 @@ def enable_cursor(ison): except _curses.error: pass =20 =2Ddef is_disk_image(file): +DISK_TYPE_RAW, DISK_TYPE_HYBRIDISO, DISK_TYPE_DOS =3D range(3) +def identify_disk_image(file): + """Detect DOS partition table or HybridISO format.""" fd =3D os.open(file, os.O_RDONLY) =2D buf =3D os.read(fd, 512) + buf =3D os.read(fd, 0x8006) os.close(fd) =20 if len(buf) >=3D 512 and \ struct.unpack("H", buf[0x1fe: 0x200]) =3D=3D (0xaa55,): =2D return True =2D return False + # HybridISO contains a DOS partition table for booting from USB de= vices, but really is an ISO image + if len(buf) >=3D 0x8006 and buf[0x8001:0x8006] =3D=3D 'CD001': + return DISK_TYPE_HYBRIDISO + return DISK_TYPE_DOS + return DISK_TYPE_RAW =20 SECTOR_SIZE=3D512 DK_LABEL_LOC=3D1 @@ -87,12 +92,19 @@ FDISK_PART_SOLARIS_OLD=3D0x82 FDISK_PART_GPT=3D0xee =20 def get_partition_offsets(file): =2D if not is_disk_image(file): + image_type =3D identify_disk_image(file) + if image_type =3D=3D DISK_TYPE_RAW: # No MBR: assume whole disk filesystem, which is like a=20 # single partition starting at 0 return [0] =2D =2D part_offs =3D [] + elif image_type =3D=3D DISK_TYPE_HYBRIDISO: + # A HybridISO contains an ISO filesystem at 0 in addition + # to the DOS partition table + part_offs =3D [0] + elif image_type =3D=3D DISK_TYPE_DOS: + part_offs =3D [] + else: + raise ValueError('Unhandled image type returnd by identify_disk_im= age(): %d' % (image_type,)) =20 fd =3D os.open(file, os.O_RDONLY) buf =3D os.read(fd, 512) --Boundary-01=_5KEsO+rQqTHcdin-- --nextPart1357777.BZilLcrcLS Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEABECAAYFAk6wQrkACgkQYPlgoZpUDjnTxwCeKbaPY+RGGE0rW+Ab0rcuD3wL KzQAnj1aiVyPtwNwiG9VP+O6FyqYqI8w =lnVm -----END PGP SIGNATURE----- --nextPart1357777.BZilLcrcLS-- --===============0559150883== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============0559150883==--