All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add HybridISO support for PyGrub2
@ 2011-10-25  8:56 Philipp Hahn
  2011-10-25  9:17 ` Ian Campbell
  0 siblings, 1 reply; 10+ messages in thread
From: Philipp Hahn @ 2011-10-25  8:56 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com


[-- Attachment #1.1: Type: text/plain, Size: 1473 bytes --]

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 
table and uses the first partition instead of the complete ISO file.

Add a check to detech HybridISO files and fall back to unpartitioned 
operation.

Signed-off-by: Philipp Hahn <hahn@univention.de>
--- a/tools/pygrub/src/pygrub
+++ b/tools/pygrub/src/pygrub
@@ -41,12 +41,16 @@ def enable_cursor(ison):
         pass
 
 def is_disk_image(file):
+    """Detect DOS partition table."""
     fd = os.open(file, os.O_RDONLY)
-    buf = os.read(fd, 512)
+    buf = os.read(fd, 0x8006)
     os.close(fd)
 
     if len(buf) >= 512 and \
            struct.unpack("H", buf[0x1fe: 0x200]) == (0xaa55,):
+        # HybridISO contains a DOS partition table for booting from USB 
devices, but really is an ISO image
+        if len(buf) >= 0x8006 and buf[0x8001:0x8006] == 'CD001':
+            return False
         return True
     return False
 
-- 
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/

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-11-02 16:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-25  8:56 [PATCH] Add HybridISO support for PyGrub2 Philipp Hahn
2011-10-25  9:17 ` Ian Campbell
2011-10-25  9:51   ` Tim Deegan
2011-10-25 10:33   ` Philipp Hahn
2011-10-27 10:21     ` Ian Campbell
2011-10-28  7:46       ` [PATCH v2] " Philipp Hahn
2011-10-28 11:54         ` Ian Campbell
2011-11-01 18:53         ` Ian Jackson
2011-11-01 19:04           ` Philipp Hahn
2011-11-02 16:29             ` Ian Jackson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.