diff --git a/ChangeLog b/ChangeLog index b937e3e2b..a5823bd8f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2010-01-07 Robert Millan +2010-01-07 Vladimir Serbinenko + + Fix breakage introduced with previous commit. + + * normal/dyncmd.c (read_command_list): Avoid unregistering kernel + commands. + * normal/handler.c (read_handler_list): Revert part of previous commit + affecting this file. + * normal/main.c (read_lists): Move read_handler_list() call back to ... + (grub_normal_execute): ... here. + 2010-01-07 Robert Millan Merge prefix-redefinition-fix branch. diff --git a/normal/dyncmd.c b/normal/dyncmd.c index e20945b0d..e797d574f 100644 --- a/normal/dyncmd.c +++ b/normal/dyncmd.c @@ -79,14 +79,22 @@ read_command_list (void) if (file) { char *buf = NULL; + grub_command_t ptr, last = 0, next; /* Override previous commands.lst. */ - while (grub_command_list) + for (ptr = grub_command_list; ptr; ptr = next) { - grub_command_t tmp; - tmp = grub_command_list->next; - grub_free (grub_command_list); - grub_command_list = tmp; + next = ptr->next; + if (ptr->func == grub_dyncmd_dispatcher) + { + if (last) + last->next = ptr->next; + else + grub_command_list = ptr->next; + grub_free (ptr); + } + else + last = ptr; } for (;; grub_free (buf)) diff --git a/normal/handler.c b/normal/handler.c index 1a03d485d..b44dc7a68 100644 --- a/normal/handler.c +++ b/normal/handler.c @@ -135,6 +135,7 @@ 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); @@ -161,6 +162,11 @@ 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) { @@ -176,16 +182,6 @@ 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; diff --git a/normal/main.c b/normal/main.c index b50e17025..84162c08a 100644 --- a/normal/main.c +++ b/normal/main.c @@ -424,7 +424,6 @@ read_lists (struct grub_env_var *var __attribute__ ((unused)), { read_command_list (); read_fs_list (); - read_handler_list (); read_crypto_list (); return val ? grub_strdup (val) : NULL; } @@ -437,6 +436,7 @@ grub_normal_execute (const char *config, int nested, int batch) grub_menu_t menu = 0; read_lists (NULL, NULL); + read_handler_list (); grub_register_variable_hook ("prefix", NULL, read_lists); grub_command_execute ("parser.grub", 0, 0);