aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMichael Young <m.a.young@durham.ac.uk>2012-01-10 17:05:02 +0000
committerMichael Young <m.a.young@durham.ac.uk>2012-01-10 17:05:02 +0000
commit4561139953fc7f518fda34ba9a37e459272bd031 (patch)
tree3fcdee69293e0ae5de7ec75cfa788b1a20cdc042 /tools
parent33eae84c59ff6ca6797748624ac5685fe01f5ea5 (diff)
downloadxen-4561139953fc7f518fda34ba9a37e459272bd031.tar.gz
xen-4561139953fc7f518fda34ba9a37e459272bd031.tar.bz2
xen-4561139953fc7f518fda34ba9a37e459272bd031.zip
pygrub: check all GPT partitions
On Fedora 16 the first GPT partition is a boot partition for grub2 with the grub2 configuration in the second partition. Check all GPT partitions for grub configuration, not just the first. [ Also remove now-inaccurate comment. -iwj ] Signed-off-by: Michael Young <m.a.young@durham.ac.uk> Tested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com> xen-unstable changeset: 23998:85d7b207fabc Backport-requested-by: Pasi Karkkainen <pasik@iki.fi> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/pygrub/src/pygrub17
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub
index df58f813bc..be5a3164f1 100644
--- a/tools/pygrub/src/pygrub
+++ b/tools/pygrub/src/pygrub
@@ -77,10 +77,17 @@ def get_solaris_slice(file, offset):
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)
+ os.lseek(fd, SECTOR_SIZE, 0)
buf = os.read(fd, 512)
- return struct.unpack("<Q", buf[32:40])[0] * SECTOR_SIZE
+ partcount = struct.unpack("<L", buf[80:84])[0]
+ partsize = struct.unpack("<L", buf[84:88])[0]
+ i = partcount
+ offsets = []
+ while i>0:
+ buf = os.read(fd, partsize)
+ offsets.append(struct.unpack("<Q", buf[32:40])[0] * SECTOR_SIZE)
+ i -= 1
+ return offsets
FDISK_PART_SOLARIS=0xbf
FDISK_PART_SOLARIS_OLD=0x82
@@ -114,7 +121,9 @@ def get_partition_offsets(file):
continue # no solaris magic at that offset, ignore partition
if type == FDISK_PART_GPT:
- offset = get_fs_offset_gpt(file)
+ for offset in get_fs_offset_gpt(file):
+ part_offs.append(offset)
+ break
# Active partition has 0x80 as the first byte.
# If active, prepend to front of list, otherwise append to back.