From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1N7VjH-0004jt-2H for mharc-grub-devel@gnu.org; Mon, 09 Nov 2009 10:00:27 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N7VjF-0004j7-95 for grub-devel@gnu.org; Mon, 09 Nov 2009 10:00:25 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N7VjA-0004gk-PO for grub-devel@gnu.org; Mon, 09 Nov 2009 10:00:24 -0500 Received: from [199.232.76.173] (port=44410 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N7VjA-0004gh-K9 for grub-devel@gnu.org; Mon, 09 Nov 2009 10:00:20 -0500 Received: from xvm-190-8.ghst.net ([217.70.190.8]:58687 helo=aybabtu.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N7VjA-0002gn-0z for grub-devel@gnu.org; Mon, 09 Nov 2009 10:00:20 -0500 Received: from [192.168.10.10] (helo=thorin) by aybabtu.com with esmtp (Exim 4.69) (envelope-from ) id 1N7Vj8-0007nB-5n for grub-devel@gnu.org; Mon, 09 Nov 2009 16:00:18 +0100 Received: from rmh by thorin with local (Exim 4.69) (envelope-from ) id 1N7Vj7-0003Pc-0m for grub-devel@gnu.org; Mon, 09 Nov 2009 16:00:17 +0100 Date: Mon, 9 Nov 2009 16:00:17 +0100 From: Robert Millan To: The development of GNU GRUB Message-ID: <20091109150017.GA13079@thorin> References: <4AF6FB4D.8030501@t-online.de> <20091109141338.GB19358@thorin> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="7JfCtLOvnd9MIVvH" Content-Disposition: inline In-Reply-To: <20091109141338.GB19358@thorin> Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.18 (2008-05-17) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [PATCH] prefix redefinition fix (Re: hdparm documentation) X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Nov 2009 15:00:25 -0000 --7JfCtLOvnd9MIVvH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Nov 09, 2009 at 03:13:38PM +0100, Robert Millan wrote: > On Sun, Nov 08, 2009 at 06:09:33PM +0100, Christian Franke wrote: > > > > After 'insmod ata', loading of further modules typically fails because > > the drive in the 'prefix' variable is no longer valid. > > Actually, there's a bit more to it: even if you reset prefix, it won't > use the new path. > > I'm working on a fix for that right now. Here. The problem is that command.lst (and friends) are only processed once. I fixed this by inserting a write hook in ${prefix}. Would you please test and/or review? -- Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all." --7JfCtLOvnd9MIVvH Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="prefix_redefinition_fix.diff" sftp://bzr.savannah.gnu.org/srv/bzr/grub/people/robertmh/prefix-redefinition-fix/ === modified file 'normal/autofs.c' --- normal/autofs.c 2009-11-09 14:45:28 +0000 +++ normal/autofs.c 2009-11-09 14:55:27 +0000 @@ -51,12 +51,6 @@ 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) @@ -72,6 +66,15 @@ file = grub_file_open (filename); if (file) { + /* Override previous fs.lst. */ + while (fs_module_list) + { + grub_named_list_t tmp; + tmp = fs_module_list->next; + grub_free (fs_module_list); + fs_module_list = tmp; + } + while (1) { char *buf; === modified file 'normal/dyncmd.c' --- normal/dyncmd.c 2009-11-09 14:50:20 +0000 +++ normal/dyncmd.c 2009-11-09 14:55:27 +0000 @@ -62,12 +62,6 @@ 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) @@ -84,6 +78,16 @@ if (file) { char *buf = NULL; + + /* Override previous commands.lst. */ + while (grub_command_list) + { + grub_command_t tmp; + tmp = grub_command_list->next; + grub_free (grub_command_list); + grub_command_list = tmp; + } + for (;; grub_free (buf)) { char *p, *name, *modname; === modified file 'normal/handler.c' --- normal/handler.c 2009-11-09 14:50:20 +0000 +++ normal/handler.c 2009-11-09 14:55:27 +0000 @@ -135,7 +135,6 @@ read_handler_list (void) { const char *prefix; - static int first_time = 1; const char *class_name; auto int iterate_handler (grub_handler_t handler); @@ -162,11 +161,6 @@ return 0; } - /* Make sure that this function does not get executed twice. */ - if (! first_time) - return; - first_time = 0; - prefix = grub_env_get ("prefix"); if (prefix) { @@ -182,6 +176,16 @@ if (file) { char *buf = NULL; + + /* Override previous handler.lst. */ + while (grub_handler_class_list) + { + grub_handler_class_t tmp; + tmp = grub_handler_class_list->next; + grub_free (grub_handler_class_list); + grub_handler_class_list = tmp; + } + for (;; grub_free (buf)) { char *p; === modified file 'normal/main.c' --- normal/main.c 2009-08-24 23:55:06 +0000 +++ normal/main.c 2009-11-09 14:55:27 +0000 @@ -404,6 +404,16 @@ static int reader_nested; +static char * +read_lists (struct grub_env_var *var __attribute__ ((unused)), + const char *val) +{ + read_command_list (); + read_fs_list (); + read_handler_list (); + return val ? grub_strdup (val) : NULL; +} + /* Read the config file CONFIG and execute the menu interface or the command line interface if BATCH is false. */ void @@ -411,9 +421,8 @@ { grub_menu_t menu = 0; - read_command_list (); - read_fs_list (); - read_handler_list (); + read_lists (NULL, NULL); + grub_register_variable_hook ("prefix", NULL, read_lists); grub_command_execute ("parser.sh", 0, 0); reader_nested = nested; --7JfCtLOvnd9MIVvH--