From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KWuL3-0008ET-Ee for mharc-grub-devel@gnu.org; Sat, 23 Aug 2008 10:43:37 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KWuL1-0008Dn-Iu for grub-devel@gnu.org; Sat, 23 Aug 2008 10:43:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KWuL0-0008DF-5V for grub-devel@gnu.org; Sat, 23 Aug 2008 10:43:34 -0400 Received: from [199.232.76.173] (port=42562 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KWuKz-0008DB-Rj for grub-devel@gnu.org; Sat, 23 Aug 2008 10:43:33 -0400 Received: from 197.red-80-32-81.staticip.rima-tde.net ([80.32.81.197]:36807 helo=mail.pina.cat) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KWuKz-0006kr-2G for grub-devel@gnu.org; Sat, 23 Aug 2008 10:43:33 -0400 Received: from pinux (unknown [77.210.166.177]) by mail.pina.cat (Postfix) with ESMTP id 9642C288F30C3 for ; Sat, 23 Aug 2008 16:43:20 +0200 (CEST) Received: by pinux (Postfix, from userid 1000) id 07F2A1B03D; Sat, 23 Aug 2008 16:43:14 +0200 (CEST) Date: Sat, 23 Aug 2008 16:43:14 +0200 From: Carles Pina i Estany To: grub-devel@gnu.org Message-ID: <20080823144313.GA24757@pina.cat> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="qMm9M+Fa2AknHoGS" Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Subject: [PATCH] Warning if grub.cfg not found X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Aug 2008 14:43:35 -0000 --qMm9M+Fa2AknHoGS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --qMm9M+Fa2AknHoGS Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="warning.patch" 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. */ --qMm9M+Fa2AknHoGS Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="warning_with_function_names.patch" 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. */ --qMm9M+Fa2AknHoGS--