All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carles Pina i Estany <carles@pina.cat>
To: grub-devel@gnu.org
Subject: [PATCH] Warning if grub.cfg not found
Date: Sat, 23 Aug 2008 16:43:14 +0200	[thread overview]
Message-ID: <20080823144313.GA24757@pina.cat> (raw)

[-- 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.  */

             reply	other threads:[~2008-08-23 14:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-23 14:43 Carles Pina i Estany [this message]
2008-08-23 14:48 ` [PATCH] Warning if grub.cfg not found 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080823144313.GA24757@pina.cat \
    --to=carles@pina.cat \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.