]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Fix *.lst handling after ${prefix} redefinition.
authorRobert Millan <rmh@aybabtu.com>
Mon, 9 Nov 2009 14:55:27 +0000 (14:55 +0000)
committerRobert Millan <rmh@aybabtu.com>
Mon, 9 Nov 2009 14:55:27 +0000 (14:55 +0000)
normal/autofs.c
normal/dyncmd.c
normal/handler.c
normal/main.c

index ce354a22c2151310f265ea7cf8b0b32ad782fcc0..cf552052a10056cf87b7f0f26401b6e6f28612a2 100644 (file)
@@ -51,12 +51,6 @@ void
 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 @@ read_fs_list (void)
          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;
index dc530b07bcbcd32fde251fe19e10c2868a6e9e1e..6e50289061f1f36c29eea3845e4d444437c35b29 100644 (file)
@@ -62,12 +62,6 @@ void
 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 @@ read_command_list (void)
          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;
index eb19f912f7331a4b04f6ba19258b289ac1d6dfdc..b32209a44126b7ae1ea5b2e45a209ca7e1a0de16 100644 (file)
@@ -135,7 +135,6 @@ void
 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 @@ read_handler_list (void)
       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 @@ read_handler_list (void)
          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;
index 748eef80534114ed1249a47be90c55e1d6c54742..499eb59f691f8f8dec96cfde4e51a4fc7c670652 100644 (file)
@@ -404,6 +404,16 @@ grub_normal_init_page (void)
 
 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_normal_execute (const char *config, int nested, int batch)
 {
   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;