ia64/xen-unstable
changeset 14844:986b102f84c2
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>
- 64 bit support for starting of a GPT partition.
- detect partition types precisely.
Signed-off-by: KUWAMURA Shin'ya <kuwa@jp.fujitsu.com>
author | kfraser@localhost.localdomain |
---|---|
date | Fri Apr 13 11:23:26 2007 +0100 (2007-04-13) |
parents | 52d1022c431a |
children | abea8d171503 |
files | tools/pygrub/src/pygrub |
line diff
1.1 --- a/tools/pygrub/src/pygrub Fri Apr 13 11:20:11 2007 +0100 1.2 +++ b/tools/pygrub/src/pygrub Fri Apr 13 11:23:26 2007 +0100 1.3 @@ -61,13 +61,6 @@ def get_active_partition(file): 1.4 if struct.unpack("<c", buf[poff:poff+1]) == ('\x80',): 1.5 return buf[poff:poff+16] 1.6 1.7 - # type=0xee: GUID partition table 1.8 - # XXX assume the first partition is active 1.9 - if struct.unpack("<c", buf[poff+4:poff+5]) == ('\xee',): 1.10 - os.lseek(fd, 0x400, 0) 1.11 - buf = os.read(fd, 512) 1.12 - return buf[24:40] # XXX buf[32:40] 1.13 - 1.14 # if there's not a partition marked as active, fall back to 1.15 # the first partition 1.16 return buf[446:446+16] 1.17 @@ -97,8 +90,16 @@ def get_solaris_slice(file, offset): 1.18 1.19 raise RuntimeError, "No root slice found" 1.20 1.21 +def get_fs_offset_gpt(file): 1.22 + fd = os.open(file, os.O_RDONLY) 1.23 + # assume the first partition is an EFI system partition. 1.24 + os.lseek(fd, SECTOR_SIZE * 2, 0) 1.25 + buf = os.read(fd, 512) 1.26 + return struct.unpack("<Q", buf[32:40])[0] * SECTOR_SIZE 1.27 + 1.28 FDISK_PART_SOLARIS=0xbf 1.29 FDISK_PART_SOLARIS_OLD=0x82 1.30 +FDISK_PART_GPT=0xee 1.31 1.32 def get_fs_offset(file): 1.33 if not is_disk_image(file): 1.34 @@ -115,6 +116,9 @@ def get_fs_offset(file): 1.35 if type == FDISK_PART_SOLARIS or type == FDISK_PART_SOLARIS_OLD: 1.36 offset += get_solaris_slice(file, offset) 1.37 1.38 + if type == FDISK_PART_GPT: 1.39 + offset = get_fs_offset_gpt(file) 1.40 + 1.41 return offset 1.42 1.43 class GrubLineEditor(curses.textpad.Textbox):