From: Philipp Hahn <hahn@univention.de>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
Ian Campbell <Ian.Campbell@citrix.com>
Subject: Re: [PATCH v2] Add HybridISO support for PyGrub2
Date: Tue, 1 Nov 2011 20:04:25 +0100 [thread overview]
Message-ID: <201111012004.30624.hahn@univention.de> (raw)
In-Reply-To: <20144.16411.886176.254632@mariner.uk.xensource.com>
[-- Attachment #1.1.1: Type: text/plain, Size: 854 bytes --]
Hello Ian,
Am Dienstag 01 November 2011 19:53:15 schrieb Ian Jackson:
> Philipp Hahn writes ("Re: [Xen-devel] [PATCH v2] Add HybridISO support for
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
--
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.1.2: 0003-pygrub-hybridiso.patch --]
[-- Type: text/x-diff, Size: 2231 bytes --]
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 partition
table parsing.
--- a/tools/pygrub/src/pygrub
+++ b/tools/pygrub/src/pygrub
@@ -40,15 +40,20 @@ def enable_cursor(ison):
except _curses.error:
pass
-def is_disk_image(file):
+DISK_TYPE_RAW, DISK_TYPE_HYBRIDISO, DISK_TYPE_DOS = range(3)
+def identify_disk_image(file):
+ """Detect DOS partition table or HybridISO format."""
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,):
- return True
- return False
+ # 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 DISK_TYPE_HYBRIDISO
+ return DISK_TYPE_DOS
+ return DISK_TYPE_RAW
SECTOR_SIZE=512
DK_LABEL_LOC=1
@@ -87,12 +92,19 @@ FDISK_PART_SOLARIS_OLD=0x82
FDISK_PART_GPT=0xee
def get_partition_offsets(file):
- if not is_disk_image(file):
+ image_type = identify_disk_image(file)
+ if image_type == DISK_TYPE_RAW:
# No MBR: assume whole disk filesystem, which is like a
# single partition starting at 0
return [0]
-
- part_offs = []
+ elif image_type == DISK_TYPE_HYBRIDISO:
+ # A HybridISO contains an ISO filesystem at 0 in addition
+ # to the DOS partition table
+ part_offs = [0]
+ elif image_type == DISK_TYPE_DOS:
+ part_offs = []
+ else:
+ raise ValueError('Unhandled image type returnd by identify_disk_image(): %d' % (image_type,))
fd = os.open(file, os.O_RDONLY)
buf = os.read(fd, 512)
[-- 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
next prev parent reply other threads:[~2011-11-01 19:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2011-11-02 16:29 ` Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201111012004.30624.hahn@univention.de \
--to=hahn@univention.de \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.