Chromium Code Reviews
Help | Chromium Project | Sign in
(15)

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

Can't Edit
Can't Publish+Mail
Start Review
Created:
5 years ago by Bill Richardson
Modified:
3 years, 11 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
Trybot results:
Commit: CQ not working?

Messages

Total messages: 6 (0 generated)
Bill Richardson
5 years 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 ...
5 years ago (2010-05-14 21:10:42 UTC) #2
Bill Richardson
5 years ago (2010-05-14 23:52:43 UTC) #3
adlr
what about the snprintf comment?
5 years 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: > ...
5 years ago (2010-05-14 23:54:20 UTC) #5
adlr
5 years 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
>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld ec887be