xcp-1.6-updates/xen-4.1.hg

changeset 23208:ee80c2ef9400

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>
author Michael Young <m.a.young@durham.ac.uk>
date Tue Jan 10 17:05:02 2012 +0000 (2012-01-10)
parents 95a0e0b47e95
children d581b9a3c726
files tools/pygrub/src/pygrub
line diff
     1.1 --- a/tools/pygrub/src/pygrub	Tue Jan 10 16:10:00 2012 +0000
     1.2 +++ b/tools/pygrub/src/pygrub	Tue Jan 10 17:05:02 2012 +0000
     1.3 @@ -77,10 +77,17 @@ def get_solaris_slice(file, offset):
     1.4  
     1.5  def get_fs_offset_gpt(file):
     1.6      fd = os.open(file, os.O_RDONLY)
     1.7 -    # assume the first partition is an EFI system partition.
     1.8 -    os.lseek(fd, SECTOR_SIZE * 2, 0)
     1.9 +    os.lseek(fd, SECTOR_SIZE, 0)
    1.10      buf = os.read(fd, 512)
    1.11 -    return struct.unpack("<Q", buf[32:40])[0] * SECTOR_SIZE
    1.12 +    partcount = struct.unpack("<L", buf[80:84])[0]
    1.13 +    partsize = struct.unpack("<L", buf[84:88])[0]
    1.14 +    i = partcount
    1.15 +    offsets = []
    1.16 +    while i>0:
    1.17 +        buf = os.read(fd, partsize)
    1.18 +        offsets.append(struct.unpack("<Q", buf[32:40])[0] * SECTOR_SIZE)
    1.19 +        i -= 1
    1.20 +    return offsets
    1.21  
    1.22  FDISK_PART_SOLARIS=0xbf
    1.23  FDISK_PART_SOLARIS_OLD=0x82
    1.24 @@ -114,7 +121,9 @@ def get_partition_offsets(file):
    1.25                  continue # no solaris magic at that offset, ignore partition
    1.26  
    1.27          if type == FDISK_PART_GPT:
    1.28 -            offset = get_fs_offset_gpt(file)
    1.29 +            for offset in get_fs_offset_gpt(file):
    1.30 +                part_offs.append(offset)
    1.31 +            break
    1.32  
    1.33          # Active partition has 0x80 as the first byte.
    1.34          # If active, prepend to front of list, otherwise append to back.