WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] pygriub: Fix GPT support.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] pygriub: Fix GPT support.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 13 Apr 2007 10:50:26 -0700
Delivery-date: Fri, 13 Apr 2007 10:50:27 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1176459806 -3600
# Node ID 986b102f84c2934678d51c2c599da42b411e1504
# Parent  52d1022c431aa058a9df7c8591c42e2614b0b6a7
pygriub: Fix GPT support.
- 64 bit support for starting of a GPT partition.
- detect partition types precisely.

Signed-off-by: KUWAMURA Shin'ya <kuwa@xxxxxxxxxxxxxx>
---
 tools/pygrub/src/pygrub |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff -r 52d1022c431a -r 986b102f84c2 tools/pygrub/src/pygrub
--- a/tools/pygrub/src/pygrub   Fri Apr 13 11:20:11 2007 +0100
+++ b/tools/pygrub/src/pygrub   Fri Apr 13 11:23:26 2007 +0100
@@ -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):

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] pygriub: Fix GPT support., Xen patchbot-unstable <=