[2040] 2009-03-22 Yoshinori K.

"Yoshinori K. Okuji" <[email protected]>
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 2040
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2040
Author:   okuji
Date:     2009-03-22 10:05:31 +0000 (Sun, 22 Mar 2009)
Log Message:
-----------
2009-03-22  Yoshinori K. Okuji  <[email protected]>

    * 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): 

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/commands/configfile.c
    trunk/grub2/include/grub/normal.h
    trunk/grub2/normal/main.c

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2009-03-22 00:37:49 UTC (rev 2039)
+++ trunk/grub2/ChangeLog	2009-03-22 10:05:31 UTC (rev 2040)
@@ -1,3 +1,14 @@
+2009-03-22  Yoshinori K. Okuji  <[email protected]>
+
+	* 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  <[email protected]>
 
 	* kern/powerpc/ieee1275/startup.S: Replace EXT_C(start) with

Modified: trunk/grub2/commands/configfile.c
===================================================================
--- trunk/grub2/commands/configfile.c	2009-03-22 00:37:49 UTC (rev 2039)
+++ trunk/grub2/commands/configfile.c	2009-03-22 10:05:31 UTC (rev 2040)
@@ -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_env_context_open ();
     }
 
-  grub_normal_execute (args[0], 1);
+  grub_normal_execute (args[0], 1, ! new_env);
 
   if (new_env)
     grub_env_context_close ();

Modified: trunk/grub2/include/grub/normal.h
===================================================================
--- trunk/grub2/include/grub/normal.h	2009-03-22 00:37:49 UTC (rev 2039)
+++ trunk/grub2/include/grub/normal.h	2009-03-22 10:05:31 UTC (rev 2040)
@@ -75,7 +75,7 @@
 *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,

Modified: trunk/grub2/normal/main.c
===================================================================
--- trunk/grub2/normal/main.c	2009-03-22 00:37:49 UTC (rev 2039)
+++ trunk/grub2/normal/main.c	2009-03-22 10:05:31 UTC (rev 2040)
@@ -164,8 +164,8 @@
 }
 
 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 @@
   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 @@
 	    {
 	      /* 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 @@
       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 @@
 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 @@
 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 @@
 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 @@
   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_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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.