diff options
author | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2007-04-13 11:23:26 +0100 |
---|---|---|
committer | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2007-04-13 11:23:26 +0100 |
commit | 5e0ae4b087587433571507f711788bde1a83c2d9 (patch) | |
tree | df2b2ec7b506cea687eb9dc83b67aa8f32b93891 /tools/pygrub | |
parent | 1abe8d9d1ec34d80930bb524cd398da7e6746745 (diff) | |
download | xen-5e0ae4b087587433571507f711788bde1a83c2d9.tar.gz xen-5e0ae4b087587433571507f711788bde1a83c2d9.tar.bz2 xen-5e0ae4b087587433571507f711788bde1a83c2d9.zip |
pygriub: Fix GPT support.
- 64 bit support for starting of a GPT partition.
- detect partition types precisely.
Signed-off-by: KUWAMURA Shin'ya <kuwa@jp.fujitsu.com>
Diffstat (limited to 'tools/pygrub')
-rw-r--r-- | tools/pygrub/src/pygrub | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub index 0e3cd4701d..76eb313c30 100644 --- a/tools/pygrub/src/pygrub +++ b/tools/pygrub/src/pygrub @@ -61,13 +61,6 @@ def get_active_partition(file): if struct.unpack("<c", buf[poff:poff+1]) == ('\x80',): return buf[poff:poff+16] - # type=0xee: GUID partition table - # XXX assume the first partition is active - if struct.unpack("<c", buf[poff+4:poff+5]) == ('\xee',): - os.lseek(fd, 0x400, 0) - buf = os.read(fd, 512) - return buf[24:40] # XXX buf[32:40] - # if there's not a partition marked as active, fall back to # the first partition return buf[446:446+16] @@ -97,8 +90,16 @@ def get_solaris_slice(file, offset): raise RuntimeError, "No root slice found" +def get_fs_offset_gpt(file): + fd = os.open(file, os.O_RDONLY) + # assume the first partition is an EFI system partition. + os.lseek(fd, SECTOR_SIZE * 2, 0) + buf = os.read(fd, 512) + return struct.unpack("<Q", buf[32:40])[0] * SECTOR_SIZE + FDISK_PART_SOLARIS=0xbf FDISK_PART_SOLARIS_OLD=0x82 +FDISK_PART_GPT=0xee def get_fs_offset(file): if not is_disk_image(file): @@ -115,6 +116,9 @@ def get_fs_offset(file): if type == FDISK_PART_SOLARIS or type == FDISK_PART_SOLARIS_OLD: offset += get_solaris_slice(file, offset) + if type == FDISK_PART_GPT: + offset = get_fs_offset_gpt(file) + return offset class GrubLineEditor(curses.textpad.Textbox): |