Received: from mailman by lists.gnu.org with archive (Exim 4.33) id 1C6vR9-0005qh-Pp for mharc-grub-devel@gnu.org; Mon, 13 Sep 2004 14:20:23 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1C6vR7-0005pI-O5 for grub-devel@gnu.org; Mon, 13 Sep 2004 14:20:21 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1C6vR5-0005of-Tj for grub-devel@gnu.org; Mon, 13 Sep 2004 14:20:21 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1C6vR5-0005oW-Po for grub-devel@gnu.org; Mon, 13 Sep 2004 14:20:19 -0400 Received: from [145.74.66.11] (helo=mail-cn.han.nl) by monty-python.gnu.org with esmtp (Exim 4.34) id 1C6vLO-00037n-IJ for grub-devel@gnu.org; Mon, 13 Sep 2004 14:14:27 -0400 Received: from localhost (charlie.han.nl [145.74.66.9]) by mail-cn.han.nl (Postfix) with ESMTP id 99E6C96CC for ; Mon, 13 Sep 2004 20:11:49 +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 02525-02 for ; Mon, 13 Sep 2004 20:11:46 +0200 (CEST) Received: from mail1.han.nl (mail1.han.nl [145.74.103.11]) by mail-cn.han.nl (Postfix) with ESMTP id E1A0F96CB for ; Mon, 13 Sep 2004 20:11:46 +0200 (CEST) Received: from marco.marco-g.com (mgerards.xs4all.nl [82.92.27.129]) by mail1.han.nl (Postfix) with ESMTP id 75FEAC045 for ; Mon, 13 Sep 2004 20:11:46 +0200 (CEST) Mail-Copies-To: metgerards@student.han.nl To: grub-devel@gnu.org From: Marco Gerards Date: Mon, 13 Sep 2004 18:11:47 +0000 Message-ID: <874qm29gyk.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 Subject: 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: Mon, 13 Sep 2004 18:20:22 -0000 Hi, 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. It also fixed a bug in ext2 that I noticed when using a GNU/Hurd ext2 filesystem. And I noticed `__attribute__ ((unused))' in linux.c for the initrd function. The arguments are used so I removed this. Thanks, Marco 2004-09-13 Marco Gerards 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'. 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 13 Sep 2004 18:06:19 -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 13 Sep 2004 18:06:19 -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: 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 13 Sep 2004 18:06:19 -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 13 Sep 2004 18:06:19 -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 13 Sep 2004 18:06:19 -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, + "multiboot FILE [ARGS...]", + "Load a multiboot kernel", 0); + + grub_register_command ("module", grub_normal_cmd_module, + GRUB_COMMAND_FLAG_BOTH, + "multiboot FILE [ARGS...]", + "Load a multiboot module", 0); +} + +GRUB_MOD_FINI +{ + grub_unregister_command ("multiboot"); + grub_unregister_command ("module"); +}