Port-i386 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Multiboot(8) command-line format/parsing



Hello Grégoire,

Can you please file a PR, include your patch in it, and assign it to
me?  This will prevent this getting lost in the mailing list.

More comments below.


2010/1/9 Grégoire Sutre <gregoire.sutre%labri.fr@localhost>:
> Hi,
>
> I've been experimenting with multibooting NetBSD/i386 (5.0_STABLE) from GRUB
> 2, and I had some problems passing the right arguments on the multiboot
> command line.  I thought this list might be a good place to report them,
> especially since the problems are not so specific to GRUB 2.
>
> This started with the fact that, in GRUB 2, the command-line passed to the
> kernel does not contain the kernel itself, i.e. with the command
>
> multiboot (hd0,1,a)/netbsd -z root=wd0a
>
> the command-line passed to the kernel is "-z root=wd0a".  The option
> root=wd0a is detected ok by the kernel, but -z is ignored.  Looking at
> sys/arch/i386/i386/multiboot.c  (the code is  very clear by the way :-))
> revealed the reason: when parsing boothowto(9) options, the first argument
> of the multiboot command-line is assumed to be the kernel file name, and is
> thus ignored.  The other parsing functions do not make this assumption, for
> instance, the command line "root=wd0a -z" works fine.

Well, that shouldn't be allowed in my opinion, just as you cannot pass
options in any order when using getopt() (despite what gnu getopt
does).

> If the multiboot kernel code expects the command-line to be in a specific
> format, then I would find it helpful to have the detailed format in the
> multiboot(8) man page.  As far as I understand the code, the command-line
> passed to the kernel (by the boot-loader) is expected to be of the form:
>
> absolutefilename [-1234abcdmqsvxz] [extraopt=value ...]

Yup, that's correct.

> An alternative solution would be to accept a more general format for the
> multiboot command-line, with no pre-supposed ordering of the arguments.  For
> instance `-zs root=wd0a /netbsd console=pc' would be accepted.  I believe

That looks really confusing; please not do that.  We should stick to
the convention of executable, options and later arguments.

> that all functions in multiboot.c already authorize this, except
> setup_howto.  A small patch that allows this for setup_howto is attached.
>  The patch actually also accepts boothowto options that are not grouped
> together, e.g. `-z root=wd0a -s' but this can be removed.

The non-grouping of options is a good thing, though, for consistency
with getopt().

> The patch also removes an if test in the function setup_bootpath that checks
> whether Multiboot_Loader_Name is lexicographically greater than "GNU GRUB ".
>  I fail to see why this is required, and, moreover, this is specific to GRUB
> Legacy, since GRUB 2 identifies itself as "GRUB ". Maybe the intention here
> is to avoid setting an empty bootpath, but this could be checked by actually
> testing the guessed the bootpath before setting it.

We should use this name difference to see if the command line contains
the kernel name at the very beginning or not, and act accordingly.

-- 
Julio Merino


Home | Main Index | Thread Index | Old Index