2009-03-22 Yoshinori K. Okuji <okuji@enbug.org>

* normal/main.c (grub_normal_execute): Added an argument
    BATCH to specify if an interactive interface should be provided
    after reading a config file.
    All callers updated.
    (read_command_list): Prevent being executed twice.
    (read_fs_list): Likewise.

    * include/grub/normal.h (grub_normal_execute):
This commit is contained in:
okuji 2009-03-22 10:05:31 +00:00
parent fbc00b0ca1
commit f04f02e496
4 changed files with 47 additions and 19 deletions

View file

@ -1,3 +1,14 @@
2009-03-22 Yoshinori K. Okuji <okuji@enbug.org>
* normal/main.c (grub_normal_execute): Added an argument
BATCH to specify if an interactive interface should be provided
after reading a config file.
All callers updated.
(read_command_list): Prevent being executed twice.
(read_fs_list): Likewise.
* include/grub/normal.h (grub_normal_execute):
2009-03-22 Pavel Roskin <proski@gno.org> 2009-03-22 Pavel Roskin <proski@gno.org>
* kern/powerpc/ieee1275/startup.S: Replace EXT_C(start) with * kern/powerpc/ieee1275/startup.S: Replace EXT_C(start) with

View file

@ -1,7 +1,7 @@
/* configfile.c - command to manually load config file */ /* configfile.c - command to manually load config file */
/* /*
* GRUB -- GRand Unified Bootloader * GRUB -- GRand Unified Bootloader
* Copyright (C) 2005,2006,2007 Free Software Foundation, Inc. * Copyright (C) 2005,2006,2007,2009 Free Software Foundation, Inc.
* *
* GRUB is free software: you can redistribute it and/or modify * GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -39,7 +39,7 @@ grub_cmd_source (grub_command_t cmd, int argc, char **args)
grub_env_context_open (); grub_env_context_open ();
} }
grub_normal_execute (args[0], 1); grub_normal_execute (args[0], 1, ! new_env);
if (new_env) if (new_env)
grub_env_context_close (); grub_env_context_close ();

View file

@ -75,7 +75,7 @@ typedef struct grub_menu_execute_callback
*grub_menu_execute_callback_t; *grub_menu_execute_callback_t;
void grub_enter_normal_mode (const char *config); void grub_enter_normal_mode (const char *config);
void grub_normal_execute (const char *config, int nested); void grub_normal_execute (const char *config, int nested, int batch);
void grub_menu_execute_with_fallback (grub_menu_t menu, void grub_menu_execute_with_fallback (grub_menu_t menu,
grub_menu_entry_t entry, grub_menu_entry_t entry,
grub_menu_execute_callback_t callback, grub_menu_execute_callback_t callback,

View file

@ -164,8 +164,8 @@ free_menu_entry_classes (struct grub_menu_entry_class *head)
} }
grub_err_t grub_err_t
grub_normal_menu_addentry (int argc, const char **args, struct grub_script *script, grub_normal_menu_addentry (int argc, const char **args,
const char *sourcecode) struct grub_script *script, const char *sourcecode)
{ {
const char *menutitle = 0; const char *menutitle = 0;
const char *menusourcecode; const char *menusourcecode;
@ -184,7 +184,7 @@ grub_normal_menu_addentry (int argc, const char **args, struct grub_script *scri
classes_head->next = 0; classes_head->next = 0;
classes_tail = classes_head; classes_tail = classes_head;
menu = grub_env_get_data_slot("menu"); menu = grub_env_get_data_slot ("menu");
if (! menu) if (! menu)
return grub_error (GRUB_ERR_MENU, "no menu context"); return grub_error (GRUB_ERR_MENU, "no menu context");
@ -236,7 +236,8 @@ grub_normal_menu_addentry (int argc, const char **args, struct grub_script *scri
{ {
/* Handle invalid argument. */ /* Handle invalid argument. */
failed = 1; failed = 1;
grub_error (GRUB_ERR_MENU, "invalid argument for menuentry: %s", args[i]); grub_error (GRUB_ERR_MENU,
"invalid argument for menuentry: %s", args[i]);
break; break;
} }
} }
@ -249,7 +250,8 @@ grub_normal_menu_addentry (int argc, const char **args, struct grub_script *scri
else else
{ {
failed = 1; failed = 1;
grub_error (GRUB_ERR_MENU, "too many titles for menuentry: %s", args[i]); grub_error (GRUB_ERR_MENU,
"too many titles for menuentry: %s", args[i]);
break; break;
} }
} }
@ -382,7 +384,7 @@ void
grub_enter_normal_mode (const char *config) grub_enter_normal_mode (const char *config)
{ {
if (grub_setjmp (grub_exit_env) == 0) if (grub_setjmp (grub_exit_env) == 0)
grub_normal_execute (config, 0); grub_normal_execute (config, 0, 0);
} }
/* Initialize the screen. */ /* Initialize the screen. */
@ -445,6 +447,12 @@ static void
read_command_list (void) read_command_list (void)
{ {
const char *prefix; 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"); prefix = grub_env_get ("prefix");
if (prefix) if (prefix)
@ -558,6 +566,12 @@ static void
read_fs_list (void) read_fs_list (void)
{ {
const char *prefix; 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"); prefix = grub_env_get ("prefix");
if (prefix) if (prefix)
@ -627,10 +641,10 @@ read_fs_list (void)
grub_fs_autoload_hook = autoload_fs_module; grub_fs_autoload_hook = autoload_fs_module;
} }
/* Read the config file CONFIG and execute the menu interface or /* Read the config file COFIG, and execute the menu interface or
the command-line interface. */ the command-line interface if BATCH is false. */
void void
grub_normal_execute (const char *config, int nested) grub_normal_execute (const char *config, int nested, int batch)
{ {
grub_menu_t menu = 0; grub_menu_t menu = 0;
@ -645,6 +659,8 @@ grub_normal_execute (const char *config, int nested)
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
} }
if (! batch)
{
if (menu && menu->size) if (menu && menu->size)
{ {
grub_menu_viewer_show_menu (menu, nested); grub_menu_viewer_show_menu (menu, nested);
@ -653,6 +669,7 @@ grub_normal_execute (const char *config, int nested)
} }
else else
grub_cmdline_run (nested); grub_cmdline_run (nested);
}
} }
static grub_err_t static grub_err_t