From mboxrd@z Thu Jan 1 00:00:00 1970 From: Philipp Hahn Subject: [PATCH] Add HybridISO support for PyGrub2 Date: Tue, 25 Oct 2011 10:56:58 +0200 Message-ID: <201110251057.06774.hahn@univention.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0924498185==" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org --===============0924498185== Content-Type: multipart/signed; boundary="nextPart1452174.cQtgZb4KhV"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit --nextPart1452174.cQtgZb4KhV Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 the DOS partition=20 table and uses the first partition instead of the complete ISO file. Add a check to detech HybridISO files and fall back to unpartitioned=20 operation. Signed-off-by: Philipp Hahn =2D-- a/tools/pygrub/src/pygrub +++ b/tools/pygrub/src/pygrub @@ -41,12 +41,16 @@ def enable_cursor(ison): pass =20 def is_disk_image(file): + """Detect DOS partition table.""" 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,): + # HybridISO contains a DOS partition table for booting from USB=20 devices, but really is an ISO image + if len(buf) >=3D 0x8006 and buf[0x8001:0x8006] =3D=3D 'CD001': + return False return True return False =20 =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/ --nextPart1452174.cQtgZb4KhV 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) iEYEABECAAYFAk6medsACgkQYPlgoZpUDjk60wCfaXd9eORanvf6zP4cwaq/9eIa KgUAniqA8d7A69KknhLmY90Q2991W3wo =rrSS -----END PGP SIGNATURE----- --nextPart1452174.cQtgZb4KhV-- --===============0924498185== 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 --===============0924498185==--