Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1140)

Issue 2113004: Add variables to grub2 for Chrome OS bringup workarounds. (Closed)

Created:
10 years, 7 months ago by Bill Richardson
Modified:
9 years, 6 months ago
Reviewers:
Nick Sanders, adlr
CC:
chromium-os-reviews_chromium.org
Base URL:
ssh://git@chromiumos-git//grub2.git
Visibility:
Public.

Description

Add variables to grub2 for Chrome OS bringup workarounds. This adds a temporary hack to grub2, which we're using while the full BIOS changes aren't yet completed. We set four variables automatically that we can use in the grub.cfg file to ensure that we get the kernel and rootfs from the boot device, regardless of which device that is. Grub refers to the boot device as hd0, hd1, etc. The kernel needs it to be sda, sdb (and yes, I know that's dependent on the architecture and media, but so is grub). In addtion, our current BIOS doesn't enumerate the hard disk in recovery mode, so the first removable drive is hd0, not hd1. Linux always sees it though. Grub now sets two variables to specify the rootfs in grub's terms: grubpartA == (hdX,3) grubpartB == (hdX,5) where X is the boot device, so we can pick the right kernel in grub.cfg: linux $grubpartA/boot/vmlinuz ... linux $grubpartB/boot/vmlinuz ... But we also need to provide "rootfs=/dev/sdX" for the kernel. We'll map this normally: (hd0) -> sda (hd1) -> sdb etc. But if the booted media is removable, we'll map like this: (hd0) -> sdb (hd1) -> sdc etc. and so grub can set two more variables: linuxpartA == /dev/sdX3 linuxpartB == /dev/sdX5 and now our grub.cfg can say: linux $grubpartA/boot/vmlinuz root=/dev/$linuxpartA ... linux $grubpartB/boot/vmlinuz root=/dev/$linuxpartB ... And this will let the same grub.cfg file work on any boot device, regardless of how many others are plugged in or how they're numbered. Note that once we've switched to our official BIOS we'll no longer be needing grub at all, so this is just temporary.

Patch Set 1 #

Total comments: 4

Patch Set 2 : respond to feedback #

Unified diffs Side-by-side diffs Delta from patch set Stats (+43 lines, -0 lines) Patch
M disk/efi/efidisk.c View 1 2 chunks +43 lines, -0 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
Bill Richardson
10 years, 7 months ago (2010-05-14 18:39:25 UTC) #1
adlr
LGTM w/ minor nits http://codereview.chromium.org/2113004/diff/1/2 File disk/efi/efidisk.c (right): http://codereview.chromium.org/2113004/diff/1/2#newcode825 disk/efi/efidisk.c:825: grub_sprintf(tmpbuf, "(%s,3)", parent->name); following apparent ...
10 years, 7 months ago (2010-05-14 21:10:42 UTC) #2
Bill Richardson
10 years, 7 months ago (2010-05-14 23:52:43 UTC) #3
adlr
what about the snprintf comment?
10 years, 7 months ago (2010-05-14 23:54:03 UTC) #4
Bill Richardson
http://codereview.chromium.org/2113004/diff/1/2 File disk/efi/efidisk.c (right): http://codereview.chromium.org/2113004/diff/1/2#newcode825 disk/efi/efidisk.c:825: grub_sprintf(tmpbuf, "(%s,3)", parent->name); On 2010/05/14 21:10:42, adlr wrote: > ...
10 years, 7 months ago (2010-05-14 23:54:20 UTC) #5
adlr
10 years, 7 months ago (2010-05-14 23:55:33 UTC) #6
LGTM

On Fri, May 14, 2010 at 4:54 PM, <wfrichar@chromium.org> wrote:

>
> http://codereview.chromium.org/2113004/diff/1/2
> File disk/efi/efidisk.c (right):
>
> http://codereview.chromium.org/2113004/diff/1/2#newcode825
> disk/efi/efidisk.c:825: grub_sprintf(tmpbuf, "(%s,3)", parent->name);
> On 2010/05/14 21:10:42, adlr wrote:
>
>> following apparent style, put a space between function names and '('.
>>
> also, can
>
>> you use an snprintf-equivalent to avoid a buffer overrun?
>>
>
> There isn't a grub snprintf. And the size of the buffer is allocated
> based on the length of what I'm printing, so it's safe.
>
> I did forget to check the result of the malloc, though.
>
>
> http://codereview.chromium.org/2113004/diff/1/2#newcode841
> disk/efi/efidisk.c:841: index++;
> On 2010/05/14 21:10:42, adlr wrote:
>
>> indent by 2 (seems to be the style they use)
>>
>
> Oops. thanks.
>
>
> http://codereview.chromium.org/2113004/show
>

Powered by Google App Engine
This is Rietveld 408576698