]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2009-03-22 Yoshinori K. Okuji <okuji@enbug.org>
authorokuji <okuji@localhost>
Sun, 22 Mar 2009 10:05:31 +0000 (10:05 +0000)
committerokuji <okuji@localhost>
Sun, 22 Mar 2009 10:05:31 +0000 (10:05 +0000)
    * normal/main.c (grub_normal_execute): Added an argument
    BATCH to specify if an interactive interface should be provided
    after reading a config file.
    All callers updated.
    (read_command_list): Prevent being executed twice.
    (read_fs_list): Likewise.

    * include/grub/normal.h (grub_normal_execute):

ChangeLog
commands/configfile.c
include/grub/normal.h
normal/main.c

index dba06c26037b29548ac69420b80c14103f882a88..350d44ff6b68b02b21de4262a1fcdde0fa243fc3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-03-22  Yoshinori K. Okuji  <okuji@enbug.org>
+
+       * normal/main.c (grub_normal_execute): Added an argument
+       BATCH to specify if an interactive interface should be provided
+       after reading a config file.
+       All callers updated.
+       (read_command_list): Prevent being executed twice.
+       (read_fs_list): Likewise.
+
+       * include/grub/normal.h (grub_normal_execute): 
+
 2009-03-22  Pavel Roskin  <proski@gno.org>
 
        * kern/powerpc/ieee1275/startup.S: Replace EXT_C(start) with
index 77b9c37cb88bcd60603c7c5548440e7bd669d524..4c85d3c3f90ca75a6094e8d1ca0950220cd9b046 100644 (file)
@@ -1,7 +1,7 @@
 /* configfile.c - command to manually load config file  */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2005,2006,2007  Free Software Foundation, Inc.
+ *  Copyright (C) 2005,2006,2007,2009  Free Software Foundation, Inc.
  *
  *  GRUB is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -39,7 +39,7 @@ grub_cmd_source (grub_command_t cmd, int argc, char **args)
       grub_env_context_open ();
     }
 
-  grub_normal_execute (args[0], 1);
+  grub_normal_execute (args[0], 1, ! new_env);
 
   if (new_env)
     grub_env_context_close ();
index 48cd91f085c5322f705ec73fd469714c94f4a2db..27978dc09f220afeeb5efc97984a2eb19a657131 100644 (file)
@@ -75,7 +75,7 @@ typedef struct grub_menu_execute_callback
 *grub_menu_execute_callback_t;
 
 void grub_enter_normal_mode (const char *config);
-void grub_normal_execute (const char *config, int nested);
+void grub_normal_execute (const char *config, int nested, int batch);
 void grub_menu_execute_with_fallback (grub_menu_t menu,
                                      grub_menu_entry_t entry,
                                      grub_menu_execute_callback_t callback,
index c6199ae672bfb0662040e6467dc784017e09ee8c..9f906d860f6bbc19385c661ceb034a5001e60c66 100644 (file)
@@ -164,8 +164,8 @@ free_menu_entry_classes (struct grub_menu_entry_class *head)
 }
 
 grub_err_t
-grub_normal_menu_addentry (int argc, const char **args, struct grub_script *script,
-                          const char *sourcecode)
+grub_normal_menu_addentry (int argc, const char **args,
+                           struct grub_script *script, const char *sourcecode)
 {
   const char *menutitle = 0;
   const char *menusourcecode;
@@ -184,7 +184,7 @@ grub_normal_menu_addentry (int argc, const char **args, struct grub_script *scri
   classes_head->next = 0;
   classes_tail = classes_head;
 
-  menu = grub_env_get_data_slot("menu");
+  menu = grub_env_get_data_slot ("menu");
   if (! menu)
     return grub_error (GRUB_ERR_MENU, "no menu context");
 
@@ -236,7 +236,8 @@ grub_normal_menu_addentry (int argc, const char **args, struct grub_script *scri
            {
              /* Handle invalid argument.  */
              failed = 1;
-             grub_error (GRUB_ERR_MENU, "invalid argument for menuentry: %s", args[i]);
+             grub_error (GRUB_ERR_MENU,
+                          "invalid argument for menuentry: %s", args[i]);
              break;
            }
        }
@@ -249,7 +250,8 @@ grub_normal_menu_addentry (int argc, const char **args, struct grub_script *scri
       else
        {
          failed = 1;
-         grub_error (GRUB_ERR_MENU, "too many titles for menuentry: %s", args[i]);
+         grub_error (GRUB_ERR_MENU,
+                      "too many titles for menuentry: %s", args[i]);
          break;
        }
     }
@@ -382,7 +384,7 @@ void
 grub_enter_normal_mode (const char *config)
 {
   if (grub_setjmp (grub_exit_env) == 0)
-    grub_normal_execute (config, 0);
+    grub_normal_execute (config, 0, 0);
 }
 
 /* Initialize the screen.  */
@@ -445,7 +447,13 @@ static void
 read_command_list (void)
 {
   const char *prefix;
-  
+  static int first_time = 1;
+
+  /* Make sure that this function does not get executed twice.  */
+  if (! first_time)
+    return;
+  first_time = 0;
+    
   prefix = grub_env_get ("prefix");
   if (prefix)
     {
@@ -558,6 +566,12 @@ static void
 read_fs_list (void)
 {
   const char *prefix;
+  static int first_time = 1;
+
+  /* Make sure that this function does not get executed twice.  */
+  if (! first_time)
+    return;
+  first_time = 0;
   
   prefix = grub_env_get ("prefix");
   if (prefix)
@@ -627,10 +641,10 @@ read_fs_list (void)
   grub_fs_autoload_hook = autoload_fs_module;
 }
 
-/* Read the config file CONFIG and execute the menu interface or
-   the command-line interface.  */
+/* Read the config file COFIG, and execute the menu interface or
+   the command-line interface if BATCH is false.  */
 void
-grub_normal_execute (const char *config, int nested)
+grub_normal_execute (const char *config, int nested, int batch)
 {
   grub_menu_t menu = 0;
 
@@ -645,14 +659,17 @@ grub_normal_execute (const char *config, int nested)
       grub_errno = GRUB_ERR_NONE;
     }
 
-  if (menu && menu->size)
+  if (! batch)
     {
-      grub_menu_viewer_show_menu (menu, nested);
-      if (nested)
-       free_menu (menu);
+      if (menu && menu->size)
+        {
+          grub_menu_viewer_show_menu (menu, nested);
+          if (nested)
+            free_menu (menu);
+        }
+      else
+        grub_cmdline_run (nested);
     }
-  else
-    grub_cmdline_run (nested);
 }
 
 static grub_err_t