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-ia64-devel

[Xen-ia64-devel] Re: [Xen-devel] [PATCH][RFC] Support GPT (GUID Partitio

Hi Keir,

On <20070412.172818.73333117.kuwa@xxxxxxxxxxxxxx>
 "KUWAMURA Shin'ya" wrote:
> 
>  - pygrub cannot access a domain more than 2^32 * SECTOR_SIZE because
>    get_fs_offset() treats the offset as a 32-bit integer. In GPT, the
>    offset must be treated as 64-bit integer.
> 
>  - This patch returns a part of a GUID unique to the partition as
>    legacy partition types. pygrub may misunderstand partition types.

I fixed these problems.

Best Regards,
-- 
  KUWAMURA Shin'ya
# HG changeset patch
# User KUWAMURA Shin'ya <kuwa@xxxxxxxxxxxxxx>
# Date 1176447935 -32400
# Node ID 998f640f53bda5a18d7452192b8b3f140609862a
# Parent  a839e331f06f7b19ca601b277de9fcbedbeb4a77
fix GPT support.
- 64 bit support for starting of a GPT partition.
- detect partition types precisely.

Signed-off-by: KUWAMURA Shin'ya <kuwa@xxxxxxxxxxxxxx>

diff -r a839e331f06f -r 998f640f53bd tools/pygrub/src/pygrub
--- a/tools/pygrub/src/pygrub   Thu Apr 12 14:13:04 2007 +0100
+++ b/tools/pygrub/src/pygrub   Fri Apr 13 16:05:35 2007 +0900
@@ -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-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel
<Prev in Thread] Current Thread [Next in Thread>