From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.33) id 1C7NuE-0002lp-Uf for mharc-grub-devel@gnu.org; Tue, 14 Sep 2004 20:44:18 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1C7NuD-0002lU-5U for grub-devel@gnu.org; Tue, 14 Sep 2004 20:44:17 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1C7NuA-0002kT-K8 for grub-devel@gnu.org; Tue, 14 Sep 2004 20:44:15 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1C7NuA-0002kQ-HM for grub-devel@gnu.org; Tue, 14 Sep 2004 20:44:14 -0400 Received: from [145.74.66.11] (helo=mail-cn.han.nl) by monty-python.gnu.org with esmtp (Exim 4.34) id 1C7NoU-00068A-LQ for grub-devel@gnu.org; Tue, 14 Sep 2004 20:38:23 -0400 Received: from localhost (charlie.han.nl [145.74.66.9]) by mail-cn.han.nl (Postfix) with ESMTP id 9786F947D for ; Wed, 15 Sep 2004 02:34:35 +0200 (CEST) Received: from mail-cn.han.nl ([145.74.66.11]) by localhost (charlie.han.nl [145.74.66.9]) (amavisd-new, port 10024) with ESMTP id 02621-07; Wed, 15 Sep 2004 02:34:31 +0200 (CEST) Received: from mail1.han.nl (mail1.han.nl [145.74.103.11]) by mail-cn.han.nl (Postfix) with ESMTP id B03299878; Wed, 15 Sep 2004 02:34:31 +0200 (CEST) Received: from marco.marco-g.com (mgerards.xs4all.nl [82.92.27.129]) by mail1.han.nl (Postfix) with ESMTP id 7AD2CC047; Wed, 15 Sep 2004 02:34:30 +0200 (CEST) Mail-Copies-To: metgerards@student.han.nl To: The development of GRUB 2 References: <874qm29gyk.fsf@marco.marco-g.com> From: Marco Gerards Date: Wed, 15 Sep 2004 00:34:32 +0000 In-Reply-To: <874qm29gyk.fsf@marco.marco-g.com> (Marco Gerards's message of "Mon, 13 Sep 2004 18:11:47 +0000") Message-ID: <87llfcpdyf.fsf@marco.marco-g.com> User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new@vscan-cn.han.nl Cc: Subject: Re: Normal mode linux and multiboot loaders X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Sep 2004 00:44:17 -0000 Marco Gerards writes: > As I have promised, I have written two modules to make it possible to > use the linux and multiboot loaders in GNU/Linux. It is a really > simple patch so I assume it is ok and check it in Wednesday. Now I have tested this a bit more. I found a small problem with fshelp and the command line parser when using GNU/Hurd. Because everything can be used as multiboot argument I disabled the argument parser for this command. I've also disabled the code that replace environment variables because GNU/Hurd uses variables with the same syntax in its bootscripts and it conflicts. :/ I will wait a bit longer with applying this patch so you can comment on these latest changes if you want to. As a bonus, the shellscript I use to create a GRUB 2 bootfloppy. I hope it is as useful to you as it was to me. Feel free to modify it so it can be included with GRUB 2 to produce floppy/hd images. As you can see I suck at shellscripting and I am not able to produce something useful in a reasonable time. I can upload a GRUB 2 floppy somewhere including a grub.cfg and GRUB 2 patched with this patch so people can test GRUB 2. Please tell me if you want that and I will do so. Thanks, Marco The script: #!/bin/sh IMAGE=grub2-floppy-i386.ext2fs MNT=/mnt/floppy rm $IMAGE dd if=/dev/zero of=$IMAGE bs=512 count=2880|| exit /sbin/mkfs.ext2 -F $IMAGE ./grub-mkimage -v -d . -o core.img ext2 sudo mount $IMAGE $MNT -o loop mkdir $MNT/grub cp *.img *.mod $MNT/grub echo '(fd0)' $PWD/$IMAGE > tmp_device.map ./grub-setup -d $MNT/grub -m tmp_device.map -r '(fd0)' '(fd0)' rm tmp_device.map cat >$MNT/grub/grub.cfg < Add `linux.mod' and `multiboot.mod' so linux and multiboot kernels can be loaded from normal mode. * conf/i386-pc.mk (pkgdata_MODULES): Add `linux.mod' and `multiboot.mod'. (linux_mod_SOURCES, linux_mod_CFLAGS, multiboot_mod_SOURCES) (multiboot_mod_CFLAGS): New variables. * loader/i386/pc/linux_normal.c: New file. * loader/i386/pc/multiboot_normal.c: Likewise. * loader/i386/pc/linux.c (grub_rescue_cmd_initrd): Don't use the attribute `unused'. * fs/ext2.c (grub_ext2_iterate_dir): Fix typos in inode type. Use `fdiro' to read the mode information from instead of `diro'. * fs/fshelp.c (grub_fshelp_find_file): Set type to foundtype after looking up a symlink. * include/grub/normal.h (GRUB_COMMAND_FLAG_NO_ARG_PARSE): New macro. * normal/command.c (grub_command_execute): Don't parse the arguments when `GRUB_COMMAND_FLAG_NO_ARG_PARSE' is set in the flags of the command. * grub/grub2/kern/misc.c (grub_split_cmdline): Disable envvar parsing code because it conflicts with multiboot. * normal/menu.c (grub_menu_run): Fix typo. Index: conf/i386-pc.rmk =================================================================== RCS file: /cvsroot/grub/grub2/conf/i386-pc.rmk,v retrieving revision 1.20 diff -u -p -u -p -r1.20 i386-pc.rmk --- conf/i386-pc.rmk 12 Sep 2004 12:20:52 -0000 1.20 +++ conf/i386-pc.rmk 15 Sep 2004 00:24:53 -0000 @@ -78,9 +78,9 @@ grub_emu_LDFLAGS = -lncurses genmoddep_SOURCES = util/genmoddep.c # Modules. -pkgdata_MODULES = _chain.mod _linux.mod fat.mod ufs.mod ext2.mod minix.mod \ +pkgdata_MODULES = _chain.mod _linux.mod linux.mod fat.mod ufs.mod ext2.mod minix.mod \ hfs.mod jfs.mod normal.mod hello.mod vga.mod font.mod _multiboot.mod ls.mod \ - boot.mod cmp.mod cat.mod terminal.mod fshelp.mod chain.mod + boot.mod cmp.mod cat.mod terminal.mod fshelp.mod chain.mod multiboot.mod # For _chain.mod. _chain_mod_SOURCES = loader/i386/pc/chainloader.c @@ -121,6 +121,10 @@ jfs_mod_CFLAGS = $(COMMON_CFLAGS) # For _linux.mod. _linux_mod_SOURCES = loader/i386/pc/linux.c _linux_mod_CFLAGS = $(COMMON_CFLAGS) + +# For linux.mod. +linux_mod_SOURCES = loader/i386/pc/linux_normal.c +linux_mod_CFLAGS = $(COMMON_CFLAGS) # For normal.mod. normal_mod_SOURCES = normal/cmdline.c normal/command.c normal/main.c \ @@ -163,3 +167,7 @@ font_mod_CFLAGS = $(COMMON_CFLAGS) # For _multiboot.mod. _multiboot_mod_SOURCES = loader/i386/pc/multiboot.c _multiboot_mod_CFLAGS = $(COMMON_CFLAGS) + +# For multiboot.mod. +multiboot_mod_SOURCES = loader/i386/pc/multiboot_normal.c +multiboot_mod_CFLAGS = $(COMMON_CFLAGS) Index: fs/ext2.c =================================================================== RCS file: /cvsroot/grub/grub2/fs/ext2.c,v retrieving revision 1.9 diff -u -p -u -p -r1.9 ext2.c --- fs/ext2.c 11 Sep 2004 11:42:43 -0000 1.9 +++ fs/ext2.c 15 Sep 2004 00:24:53 -0000 @@ -451,14 +451,14 @@ grub_ext2_iterate_dir (grub_fshelp_node_ fdiro->inode_read = 1; - if ((grub_le_to_cpu16 (diro->inode.mode) + if ((grub_le_to_cpu16 (fdiro->inode.mode) & FILETYPE_INO_MASK) == FILETYPE_INO_DIRECTORY) type = GRUB_FSHELP_DIR; - else if ((grub_le_to_cpu16 (diro->inode.mode) - & FILETYPE_INO_MASK) == FILETYPE_INO_DIRECTORY) + else if ((grub_le_to_cpu16 (fdiro->inode.mode) + & FILETYPE_INO_MASK) == FILETYPE_INO_SYMLINK) type = GRUB_FSHELP_SYMLINK; - else if ((grub_le_to_cpu16 (diro->inode.mode) - & FILETYPE_INO_MASK) == FILETYPE_INO_DIRECTORY) + else if ((grub_le_to_cpu16 (fdiro->inode.mode) + & FILETYPE_INO_MASK) == FILETYPE_INO_REG) type = GRUB_FSHELP_REG; } Index: fs/fshelp.c =================================================================== RCS file: /cvsroot/grub/grub2/fs/fshelp.c,v retrieving revision 1.1 diff -u -p -u -p -r1.1 fshelp.c --- fs/fshelp.c 11 Sep 2004 11:42:43 -0000 1.1 +++ fs/fshelp.c 15 Sep 2004 00:24:53 -0000 @@ -171,6 +171,7 @@ grub_fshelp_find_file (const char *path, /* Lookup the node the symlink points to. */ find_file (symlink, oldnode, &currnode); + type = foundtype; grub_free (symlink); if (grub_errno) Index: include/grub/normal.h =================================================================== RCS file: /cvsroot/grub/grub2/include/grub/normal.h,v retrieving revision 1.8 diff -u -p -u -p -r1.8 normal.h --- include/grub/normal.h 10 Sep 2004 20:31:55 -0000 1.8 +++ include/grub/normal.h 15 Sep 2004 00:24:53 -0000 @@ -39,6 +39,8 @@ #define GRUB_COMMAND_FLAG_TITLE 0x4 /* Don't print the command on booting. */ #define GRUB_COMMAND_FLAG_NO_ECHO 0x8 +/* Don't print the command on booting. */ +#define GRUB_COMMAND_FLAG_NO_ARG_PARSE 0x10 /* The command description. */ struct grub_command Index: kern/misc.c =================================================================== RCS file: /cvsroot/grub/grub2/kern/misc.c,v retrieving revision 1.15 diff -u -p -u -p -r1.15 misc.c --- kern/misc.c 14 Sep 2004 08:56:51 -0000 1.15 +++ kern/misc.c 15 Sep 2004 00:24:53 -0000 @@ -771,6 +771,7 @@ grub_split_cmdline (const char *cmdline, unput = 1; } +#if 0 /* Read a variable name from the commandline and insert its content into the buffer. */ void getenvvar (void) @@ -806,6 +807,7 @@ grub_split_cmdline (const char *cmdline, for (p = val; *p; p++) *(bp++) = *p; } +#endif /* Read one argument. Return 1 if no variables can be read anymore, otherwise return 0. If there is an error, return 1, the caller @@ -838,11 +840,13 @@ grub_split_cmdline (const char *cmdline, else if (c == '"') break; /* Read a variable. */ +#if 0 if (c == '$') { getenvvar (); continue; } +#endif *(bp++) = c; } break; @@ -875,6 +879,7 @@ grub_split_cmdline (const char *cmdline, c = getchar (); continue; } +#if 0 /* Read a variable. */ if (c == '$') { @@ -882,6 +887,7 @@ grub_split_cmdline (const char *cmdline, c = getchar (); continue; } +#endif *(bp++) = c; c = getchar (); } Index: loader/i386/pc/linux.c =================================================================== RCS file: /cvsroot/grub/grub2/loader/i386/pc/linux.c,v retrieving revision 1.6 diff -u -p -u -p -r1.6 linux.c --- loader/i386/pc/linux.c 4 Apr 2004 13:46:02 -0000 1.6 +++ loader/i386/pc/linux.c 15 Sep 2004 00:24:54 -0000 @@ -290,8 +290,7 @@ grub_rescue_cmd_linux (int argc, char *a } void -grub_rescue_cmd_initrd (int argc __attribute__ ((unused)), - char *argv[] __attribute__ ((unused))) +grub_rescue_cmd_initrd (int argc, char *argv[]) { grub_file_t file = 0; grub_ssize_t size; Index: loader/i386/pc/linux_normal.c =================================================================== RCS file: loader/i386/pc/linux_normal.c diff -N loader/i386/pc/linux_normal.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ loader/i386/pc/linux_normal.c 15 Sep 2004 00:24:54 -0000 @@ -0,0 +1,61 @@ +/* linux_normal.c - boot another boot loader */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2004 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include + +static grub_err_t +grub_normal_linux_command (struct grub_arg_list *state __attribute__ ((unused)), + int argc, char **args) +{ + grub_rescue_cmd_linux (argc, args); + return grub_errno; +} + + +static grub_err_t +grub_normal_initrd_command (struct grub_arg_list *state __attribute__ ((unused)), + int argc, char **args) +{ + grub_rescue_cmd_initrd (argc, args); + return grub_errno; +} + +GRUB_MOD_INIT +{ + (void) mod; /* To stop warning. */ + grub_register_command ("linux", grub_normal_linux_command, + GRUB_COMMAND_FLAG_BOTH, + "linux FILE [ARGS...]", + "Load linux", 0); + + grub_register_command ("initrd", grub_normal_initrd_command, + GRUB_COMMAND_FLAG_BOTH, + "initrd FILE", + "Load initrd", 0); +} + +GRUB_MOD_FINI +{ + grub_unregister_command ("linux"); + grub_unregister_command ("initrd"); +} Index: loader/i386/pc/multiboot_normal.c =================================================================== RCS file: loader/i386/pc/multiboot_normal.c diff -N loader/i386/pc/multiboot_normal.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ loader/i386/pc/multiboot_normal.c 15 Sep 2004 00:24:54 -0000 @@ -0,0 +1,61 @@ +/* multiboot_normal.c - boot another boot loader */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2004 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include + +static grub_err_t +grub_normal_cmd_multiboot (struct grub_arg_list *state __attribute__ ((unused)), + int argc, char **args) +{ + grub_rescue_cmd_multiboot (argc, args); + return grub_errno; +} + + +static grub_err_t +grub_normal_cmd_module (struct grub_arg_list *state __attribute__ ((unused)), + int argc, char **args) +{ + grub_rescue_cmd_module (argc, args); + return grub_errno; +} + +GRUB_MOD_INIT +{ + (void) mod; /* To stop warning. */ + grub_register_command ("multiboot", grub_normal_cmd_multiboot, + GRUB_COMMAND_FLAG_BOTH | GRUB_COMMAND_FLAG_NO_ARG_PARSE, + "multiboot FILE [ARGS...]", + "Load a multiboot kernel", 0); + + grub_register_command ("module", grub_normal_cmd_module, + GRUB_COMMAND_FLAG_BOTH | GRUB_COMMAND_FLAG_NO_ARG_PARSE, + "multiboot FILE [ARGS...]", + "Load a multiboot module", 0); +} + +GRUB_MOD_FINI +{ + grub_unregister_command ("multiboot"); + grub_unregister_command ("module"); +} Index: normal/command.c =================================================================== RCS file: /cvsroot/grub/grub2/normal/command.c,v retrieving revision 1.6 diff -u -p -u -p -r1.6 command.c --- normal/command.c 4 Apr 2004 13:46:02 -0000 1.6 +++ normal/command.c 15 Sep 2004 00:24:54 -0000 @@ -160,8 +160,14 @@ grub_command_execute (char *cmdline) state = grub_malloc (sizeof (struct grub_arg_list) * maxargs); grub_memset (state, 0, sizeof (struct grub_arg_list) * maxargs); - if (grub_arg_parse (cmd, num, &args[1], state, &arglist, &numargs)) - ret = (cmd->func) (state, numargs, arglist); + if (! (cmd->flags & GRUB_COMMAND_FLAG_NO_ARG_PARSE)) + { + if (grub_arg_parse (cmd, num, &args[1], state, &arglist, &numargs)) + ret = (cmd->func) (state, numargs, arglist); + } + else + ret = (cmd->func) (state, num, &args[1]); + grub_free (state); if (pager && (! grub_strcmp (pager, "1"))) Index: normal/menu.c =================================================================== RCS file: /cvsroot/grub/grub2/normal/menu.c,v retrieving revision 1.6 diff -u -p -u -p -r1.6 menu.c --- normal/menu.c 10 Sep 2004 20:31:55 -0000 1.6 +++ normal/menu.c 15 Sep 2004 00:24:54 -0000 @@ -357,7 +357,7 @@ grub_menu_run (grub_menu_t menu, int nes run_menu_entry (e); /* Deal with a fallback entry. */ - /* FIXME: Mutiple fallback entries like GRUB Legacy. */ + /* FIXME: Multiple fallback entries like GRUB Legacy. */ if (menu->fallback_entry >= 0) { grub_print_error ();