* [PATCH 1 of 6] pygrub should check all GPT partitions
@ 2011-10-19 23:03 M A Young
2011-10-20 7:38 ` Paolo Bonzini
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: M A Young @ 2011-10-19 23:03 UTC (permalink / raw)
To: xen-devel; +Cc: Ian Campbell
[-- Attachment #1: Type: TEXT/PLAIN, Size: 0 bytes --]
[-- Attachment #2: Type: TEXT/PLAIN, Size: 1510 bytes --]
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.
Signed-off-by: Michael Young <m.a.young@durham.ac.uk>
--- a/tools/pygrub/src/pygrub 2011-10-16 20:58:02.000000000 +0100
+++ b/tools/pygrub/src/pygrub 2011-10-16 20:59:52.000000000 +0100
@@ -78,9 +78,17 @@
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 +122,9 @@
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.
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1 of 6] pygrub should check all GPT partitions
2011-10-19 23:03 [PATCH 1 of 6] pygrub should check all GPT partitions M A Young
@ 2011-10-20 7:38 ` Paolo Bonzini
2011-10-20 8:25 ` Ian Campbell
2011-10-20 8:25 ` Ian Campbell
2011-10-25 18:23 ` Ian Jackson
2 siblings, 1 reply; 8+ messages in thread
From: Paolo Bonzini @ 2011-10-20 7:38 UTC (permalink / raw)
To: M A Young; +Cc: xen-devel, Ian Campbell
The patches are not enough to get "e" to work, but still an improvement
of course, so:
Tested-by: Paolo Bonzini <pbonzini@redhat.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1 of 6] pygrub should check all GPT partitions
2011-10-19 23:03 [PATCH 1 of 6] pygrub should check all GPT partitions M A Young
2011-10-20 7:38 ` Paolo Bonzini
@ 2011-10-20 8:25 ` Ian Campbell
2011-10-20 8:34 ` M A Young
2011-10-25 18:23 ` Ian Jackson
2 siblings, 1 reply; 8+ messages in thread
From: Ian Campbell @ 2011-10-20 8:25 UTC (permalink / raw)
To: M A Young; +Cc: xen-devel@lists.xensource.com
On Thu, 2011-10-20 at 00:03 +0100, M A Young wrote:
> 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.
> Signed-off-by: Michael Young <m.a.young@durham.ac.uk>
>
> --- a/tools/pygrub/src/pygrub 2011-10-16 20:58:02.000000000 +0100
> +++ b/tools/pygrub/src/pygrub 2011-10-16 20:59:52.000000000 +0100
> @@ -78,9 +78,17 @@
> def get_fs_offset_gpt(file):
> fd = os.open(file, os.O_RDONLY)
> # assume the first partition is an EFI system partition.
Is this comment now inaccurate?
> - 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 +122,9 @@
> 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.
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1 of 6] pygrub should check all GPT partitions
2011-10-20 7:38 ` Paolo Bonzini
@ 2011-10-20 8:25 ` Ian Campbell
2011-10-20 8:52 ` Paolo Bonzini
0 siblings, 1 reply; 8+ messages in thread
From: Ian Campbell @ 2011-10-20 8:25 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: xen-devel@lists.xensource.com, M A Young
On Thu, 2011-10-20 at 08:38 +0100, Paolo Bonzini wrote:
> The patches are not enough to get "e" to work, but still an improvement
> of course, so:
"e" ?
Ian.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1 of 6] pygrub should check all GPT partitions
2011-10-20 8:25 ` Ian Campbell
@ 2011-10-20 8:34 ` M A Young
0 siblings, 0 replies; 8+ messages in thread
From: M A Young @ 2011-10-20 8:34 UTC (permalink / raw)
To: Ian Campbell; +Cc: xen-devel@lists.xensource.com
On Thu, 20 Oct 2011, Ian Campbell wrote:
> On Thu, 2011-10-20 at 00:03 +0100, M A Young wrote:
>> 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.
>> Signed-off-by: Michael Young <m.a.young@durham.ac.uk>
>>
>> --- a/tools/pygrub/src/pygrub 2011-10-16 20:58:02.000000000 +0100
>> +++ b/tools/pygrub/src/pygrub 2011-10-16 20:59:52.000000000 +0100
>> @@ -78,9 +78,17 @@
>> def get_fs_offset_gpt(file):
>> fd = os.open(file, os.O_RDONLY)
>> # assume the first partition is an EFI system partition.
>
> Is this comment now inaccurate?
Yes. I haven't tested the case where the first partition is an EFI system
partition though I think my changes would be harmless.
Michael Young
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1 of 6] pygrub should check all GPT partitions
2011-10-20 8:25 ` Ian Campbell
@ 2011-10-20 8:52 ` Paolo Bonzini
2011-10-20 8:53 ` Ian Campbell
0 siblings, 1 reply; 8+ messages in thread
From: Paolo Bonzini @ 2011-10-20 8:52 UTC (permalink / raw)
To: Ian Campbell; +Cc: xen-devel@lists.xensource.com, M A Young
On 10/20/2011 10:25 AM, Ian Campbell wrote:
>> > The patches are not enough to get "e" to work, but still an improvement
>> > of course, so:
> "e" ?
Edit entry mode. It fails with a curses error when I use it on the F16
grub2.cfg, which is what prompted me to do the patch for NotFoundError.
Paolo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1 of 6] pygrub should check all GPT partitions
2011-10-20 8:52 ` Paolo Bonzini
@ 2011-10-20 8:53 ` Ian Campbell
0 siblings, 0 replies; 8+ messages in thread
From: Ian Campbell @ 2011-10-20 8:53 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: xen-devel@lists.xensource.com, M A Young
On Thu, 2011-10-20 at 09:52 +0100, Paolo Bonzini wrote:
> On 10/20/2011 10:25 AM, Ian Campbell wrote:
> >> > The patches are not enough to get "e" to work, but still an improvement
> >> > of course, so:
> > "e" ?
>
> Edit entry mode. It fails with a curses error when I use it on the F16
> grub2.cfg, which is what prompted me to do the patch for NotFoundError.
Ah, right. Cool thanks.
Ian.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1 of 6] pygrub should check all GPT partitions
2011-10-19 23:03 [PATCH 1 of 6] pygrub should check all GPT partitions M A Young
2011-10-20 7:38 ` Paolo Bonzini
2011-10-20 8:25 ` Ian Campbell
@ 2011-10-25 18:23 ` Ian Jackson
2 siblings, 0 replies; 8+ messages in thread
From: Ian Jackson @ 2011-10-25 18:23 UTC (permalink / raw)
To: M A Young; +Cc: xen-devel, Ian Campbell
M A Young writes ("[Xen-devel] [PATCH 1 of 6] pygrub should 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.
Thanks. I have applied all six of these. I also removed this
obsolete comment:
> # assume the first partition is an EFI system partition.
and fixed up the commit messages a bit.
Thanks,
Ian.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-10-25 18:23 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-19 23:03 [PATCH 1 of 6] pygrub should check all GPT partitions M A Young
2011-10-20 7:38 ` Paolo Bonzini
2011-10-20 8:25 ` Ian Campbell
2011-10-20 8:52 ` Paolo Bonzini
2011-10-20 8:53 ` Ian Campbell
2011-10-20 8:25 ` Ian Campbell
2011-10-20 8:34 ` M A Young
2011-10-25 18:23 ` Ian Jackson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.