All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Warning if grub.cfg not found
@ 2008-08-23 14:43 Carles Pina i Estany
  2008-08-23 14:48 ` Carles Pina i Estany
  2008-08-30 11:43 ` Robert Millan
  0 siblings, 2 replies; 8+ messages in thread
From: Carles Pina i Estany @ 2008-08-23 14:43 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 755 bytes --]


Hi,

I send attached a patch that shows a warning when Grub it's falling back
to the command line if grub.cfg is not found (so user knows why the menu
is not showed).

I'm not 100% that this is the best way to handle it, mainly because I'm
not used about the Grub execution workflow. The changes are:

a) in normal/main.c, grub_normal_execute I've changed grub_cmdline_run
(nested) by grub_cmdlin_run (-1) (I don't see any bad consequence of it)

b) in normal/cmdline.c in grub_cmdline_run if I receive a nested == -1 I
show the warning

Any better way to do it? Or I will write the ChangeLog.

Thanks,

PS: warning_with_function_names.patch includes the function names that
I've changed.

-- 
Carles Pina i Estany		GPG id: 0x17756391
	http://pinux.info

[-- Attachment #2: warning.patch --]
[-- Type: text/x-diff, Size: 1258 bytes --]

Index: normal/cmdline.c
===================================================================
--- normal/cmdline.c	(revision 1826)
+++ normal/cmdline.c	(working copy)
@@ -137,12 +137,17 @@
 {
   grub_normal_init_page ();
   grub_setcursor (1);
+
+  if ( nested == -1 )
+     grub_printf ("\n\
+ WARNING: GNU GRUB couldn't open /boot/grub/grub.cfg\n\
+ Falling back to GNU GRUB Command Line\n\n");
   
   grub_printf ("\
  [ Minimal BASH-like line editing is supported. For the first word, TAB\n\
    lists possible command completions. Anywhere else TAB lists possible\n\
    device/file completions.%s ]\n\n",
-	       nested ? " ESC at any time exits." : "");
+	       nested !=- 1 ? " ESC at any time exits." : "");
   
   while (1)
     {
@@ -153,7 +158,7 @@
       cmdline[0] = '\0';
       
       if (! grub_cmdline_get ("grub> ", cmdline, sizeof (cmdline), 0, 1)
-	  && nested)
+	  && nested > 0)
 	return;
 
       if (! *cmdline)
Index: normal/main.c
===================================================================
--- normal/main.c	(revision 1826)
+++ normal/main.c	(working copy)
@@ -481,7 +481,7 @@
 	free_menu (menu);
     }
   else
-    grub_cmdline_run (nested);
+    grub_cmdline_run (-1);
 }
 
 /* Enter normal mode from rescue mode.  */

[-- Attachment #3: warning_with_function_names.patch --]
[-- Type: text/x-diff, Size: 1359 bytes --]

Index: normal/cmdline.c
===================================================================
--- normal/cmdline.c	(revision 1826)
+++ normal/cmdline.c	(working copy)
@@ -137,12 +137,17 @@ grub_cmdline_run (int nested)
 {
   grub_normal_init_page ();
   grub_setcursor (1);
+
+  if ( nested == -1 )
+     grub_printf ("\n\
+ WARNING: GNU GRUB couldn't open /boot/grub/grub.cfg\n\
+ Falling back to GNU GRUB Command Line\n\n");
   
   grub_printf ("\
  [ Minimal BASH-like line editing is supported. For the first word, TAB\n\
    lists possible command completions. Anywhere else TAB lists possible\n\
    device/file completions.%s ]\n\n",
-	       nested ? " ESC at any time exits." : "");
+	       nested !=- 1 ? " ESC at any time exits." : "");
   
   while (1)
     {
@@ -153,7 +158,7 @@ grub_cmdline_run (int nested)
       cmdline[0] = '\0';
       
       if (! grub_cmdline_get ("grub> ", cmdline, sizeof (cmdline), 0, 1)
-	  && nested)
+	  && nested > 0)
 	return;
 
       if (! *cmdline)
Index: normal/main.c
===================================================================
--- normal/main.c	(revision 1826)
+++ normal/main.c	(working copy)
@@ -481,7 +481,7 @@ grub_normal_execute (const char *config,
 	free_menu (menu);
     }
   else
-    grub_cmdline_run (nested);
+    grub_cmdline_run (-1);
 }
 
 /* Enter normal mode from rescue mode.  */

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-09-29 14:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-23 14:43 [PATCH] Warning if grub.cfg not found Carles Pina i Estany
2008-08-23 14:48 ` Carles Pina i Estany
2008-08-30 11:43 ` Robert Millan
2008-09-05 16:59   ` Carles Pina i Estany
2008-09-27 17:37     ` Carles Pina i Estany
2008-09-28 13:26       ` Robert Millan
2008-09-28 21:41         ` Carles Pina i Estany
2008-09-29 14:54           ` Robert Millan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.