]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2004-09-17 Marco Gerards <metgerards@student.han.nl>
authormarco_g <marco_g@localhost>
Fri, 17 Sep 2004 09:36:52 +0000 (09:36 +0000)
committermarco_g <marco_g@localhost>
Fri, 17 Sep 2004 09:36:52 +0000 (09:36 +0000)
Add `linux.mod' and `multiboot.mod' so linux and multiboot kernels
can be loaded from normal mode.

* conf/i386-pc.rmk (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.

* normal/menu.c (grub_menu_run): Fix typo.

ChangeLog
conf/i386-pc.mk
conf/i386-pc.rmk
fs/ext2.c
fs/fshelp.c
include/grub/normal.h
loader/i386/pc/linux.c
loader/i386/pc/linux_normal.c [new file with mode: 0644]
loader/i386/pc/multiboot_normal.c [new file with mode: 0644]
normal/command.c
normal/menu.c

index 6496b924c159426b4d3573e52e7ae834aa3ab4ee..4c84761c973653f5d5147ca818c924fdc2d2afcd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2004-09-17  Marco Gerards  <metgerards@student.han.nl>
+
+       Add `linux.mod' and `multiboot.mod' so linux and multiboot kernels
+       can be loaded from normal mode.
+       
+       * conf/i386-pc.rmk (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.
+
+       * normal/menu.c (grub_menu_run): Fix typo.
+
 2004-09-14  Hollis Blanchard  <hollis@penguinppc.org>
 
        * kern/powerpc/ieee1275/init.c (abort): Trap into Open Firmware.
index 828df9de0df017a03c4b81488cef11307b1e1eef..80b8145cc5eceaca14a4a41137268aa11927e484 100644 (file)
@@ -786,9 +786,9 @@ genmoddep-util_genmoddep.d: 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
@@ -1179,6 +1179,45 @@ _linux_mod-loader_i386_pc_linux.d: loader/i386/pc/linux.c
 -include _linux_mod-loader_i386_pc_linux.d
 
 _linux_mod_CFLAGS = $(COMMON_CFLAGS)
+# For linux.mod.
+linux_mod_SOURCES = loader/i386/pc/linux_normal.c
+CLEANFILES += linux.mod mod-linux.o mod-linux.c pre-linux.o linux_mod-loader_i386_pc_linux_normal.o def-linux.lst und-linux.lst
+MOSTLYCLEANFILES += linux_mod-loader_i386_pc_linux_normal.d
+DEFSYMFILES += def-linux.lst
+UNDSYMFILES += und-linux.lst
+
+linux.mod: pre-linux.o mod-linux.o
+       -rm -f $@
+       $(LD) -r -o $@ $^
+       $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
+
+pre-linux.o: linux_mod-loader_i386_pc_linux_normal.o
+       -rm -f $@
+       $(LD) -r -o $@ $^
+
+mod-linux.o: mod-linux.c
+       $(CC) $(CPPFLAGS) $(CFLAGS) $(linux_mod_CFLAGS) -c -o $@ $<
+
+mod-linux.c: moddep.lst genmodsrc.sh
+       sh $(srcdir)/genmodsrc.sh 'linux' $< > $@ || (rm -f $@; exit 1)
+
+def-linux.lst: pre-linux.o
+       $(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 linux/' > $@
+
+und-linux.lst: pre-linux.o
+       echo 'linux' > $@
+       $(NM) -u -P -p $< | cut -f1 -d' ' >> $@
+
+linux_mod-loader_i386_pc_linux_normal.o: loader/i386/pc/linux_normal.c
+       $(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(linux_mod_CFLAGS) -c -o $@ $<
+
+linux_mod-loader_i386_pc_linux_normal.d: loader/i386/pc/linux_normal.c
+       set -e;           $(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(linux_mod_CFLAGS) -M $<       | sed 's,linux_normal\.o[ :]*,linux_mod-loader_i386_pc_linux_normal.o $@ : ,g' > $@;    [ -s $@ ] || rm -f $@
+
+-include linux_mod-loader_i386_pc_linux_normal.d
+
+linux_mod_CFLAGS = $(COMMON_CFLAGS)
 
 # For normal.mod.
 normal_mod_SOURCES = normal/cmdline.c normal/command.c normal/main.c \
@@ -1611,6 +1650,45 @@ _multiboot_mod-loader_i386_pc_multiboot.d: loader/i386/pc/multiboot.c
 -include _multiboot_mod-loader_i386_pc_multiboot.d
 
 _multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
+
+# For multiboot.mod.
+multiboot_mod_SOURCES = loader/i386/pc/multiboot_normal.c
+CLEANFILES += multiboot.mod mod-multiboot.o mod-multiboot.c pre-multiboot.o multiboot_mod-loader_i386_pc_multiboot_normal.o def-multiboot.lst und-multiboot.lst
+MOSTLYCLEANFILES += multiboot_mod-loader_i386_pc_multiboot_normal.d
+DEFSYMFILES += def-multiboot.lst
+UNDSYMFILES += und-multiboot.lst
+
+multiboot.mod: pre-multiboot.o mod-multiboot.o
+       -rm -f $@
+       $(LD) -r -o $@ $^
+       $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
+
+pre-multiboot.o: multiboot_mod-loader_i386_pc_multiboot_normal.o
+       -rm -f $@
+       $(LD) -r -o $@ $^
+
+mod-multiboot.o: mod-multiboot.c
+       $(CC) $(CPPFLAGS) $(CFLAGS) $(multiboot_mod_CFLAGS) -c -o $@ $<
+
+mod-multiboot.c: moddep.lst genmodsrc.sh
+       sh $(srcdir)/genmodsrc.sh 'multiboot' $< > $@ || (rm -f $@; exit 1)
+
+def-multiboot.lst: pre-multiboot.o
+       $(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 multiboot/' > $@
+
+und-multiboot.lst: pre-multiboot.o
+       echo 'multiboot' > $@
+       $(NM) -u -P -p $< | cut -f1 -d' ' >> $@
+
+multiboot_mod-loader_i386_pc_multiboot_normal.o: loader/i386/pc/multiboot_normal.c
+       $(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(multiboot_mod_CFLAGS) -c -o $@ $<
+
+multiboot_mod-loader_i386_pc_multiboot_normal.d: loader/i386/pc/multiboot_normal.c
+       set -e;           $(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(multiboot_mod_CFLAGS) -M $<           | sed 's,multiboot_normal\.o[ :]*,multiboot_mod-loader_i386_pc_multiboot_normal.o $@ : ,g' > $@;        [ -s $@ ] || rm -f $@
+
+-include multiboot_mod-loader_i386_pc_multiboot_normal.d
+
+multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
 CLEANFILES += moddep.lst
 pkgdata_DATA += moddep.lst
 moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep
index 1e5d20af5bc3664784e3f4b565ad88c099a071be..41f562f69f6b324e9dcf87d71c468c8889470de9 100644 (file)
@@ -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 c82eb17bf2ba8c312ef8ca281a76b28e1fa428ce..056f38ac11d73b0d0fc9c59c680b66f7ca6257b8 100644 (file)
--- a/fs/ext2.c
+++ b/fs/ext2.c
@@ -451,14 +451,14 @@ grub_ext2_iterate_dir (grub_fshelp_node_t dir,
              
              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 45f8f9d5697b01f14b1cc90464d3785fb15d51ae..bc838d223459ccd0258e84ed1187bd16d05db66b 100644 (file)
@@ -171,6 +171,7 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
              
              /* Lookup the node the symlink points to.  */
              find_file (symlink, oldnode, &currnode);
+             type = foundtype;
              grub_free (symlink);
              
              if (grub_errno)
index 665fb85c846586c874d6dbc6bc39465389b1cb74..ee53daa102f516a944a2c4b33ed205714465c504 100644 (file)
@@ -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 5f2276c49c4482d891c58da840184d9301903cad..50369cebb97ff1cee2eff07b72458e9d060717dd 100644 (file)
@@ -290,8 +290,7 @@ grub_rescue_cmd_linux (int argc, char *argv[])
 }
 
 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;
diff --git a/loader/i386/pc/linux_normal.c b/loader/i386/pc/linux_normal.c
new file mode 100644 (file)
index 0000000..00e9cea
--- /dev/null
@@ -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 <grub/machine/loader.h>
+#include <grub/err.h>
+#include <grub/normal.h>
+#include <grub/dl.h>
+
+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");
+}
diff --git a/loader/i386/pc/multiboot_normal.c b/loader/i386/pc/multiboot_normal.c
new file mode 100644 (file)
index 0000000..3860574
--- /dev/null
@@ -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 <grub/machine/loader.h>
+#include <grub/err.h>
+#include <grub/normal.h>
+#include <grub/dl.h>
+
+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 d26392759764510b58a5b4ff528bf2b2f870b88b..e6c397ce9c48313e2d43c91fae40c06477ffadbb 100644 (file)
@@ -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 f001b11ab738f069899838c2c21d2539f4028989..5d720adda848788c80528f74f34a3048e61b248a 100644 (file)
@@ -357,7 +357,7 @@ grub_menu_run (grub_menu_t menu, int nested)
       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 ();