From: Robert Millan <rmh@aybabtu.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: [PATCH] prefix redefinition fix (Re: hdparm documentation)
Date: Mon, 9 Nov 2009 16:00:17 +0100 [thread overview]
Message-ID: <20091109150017.GA13079@thorin> (raw)
In-Reply-To: <20091109141338.GB19358@thorin>
[-- Attachment #1: Type: text/plain, Size: 822 bytes --]
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."
[-- Attachment #2: prefix_redefinition_fix.diff --]
[-- Type: text/x-diff, Size: 3298 bytes --]
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;
next prev parent reply other threads:[~2009-11-09 15:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-08 15:27 hdparm documentation Pedro A ARANDA
2009-11-08 17:09 ` Christian Franke
2009-11-09 14:13 ` Robert Millan
2009-11-09 15:00 ` Robert Millan [this message]
2009-11-09 21:06 ` [PATCH] prefix redefinition fix (Re: hdparm documentation) Robert Millan
[not found] <COL0-MC1-F14MZ9CxvH0084d84c@col0-mc1-f14.Col0.hotmail.com>
2009-11-12 6:43 ` Pedro A ARANDA
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=20091109150017.GA13079@thorin \
--to=rmh@aybabtu.com \
--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.