2002-01-06 Yoshinori K. Okuji <okuji@gnu.org>
The preset menu has a priority over the configuration file. Suggested by Christoph Plattner. * stage2/stage2.c [PRESET_MENU_STRING] (open_preset_menu): Check if PRESET_MENU is not NULL. [PRESET_MENU_STRING] (close_preset_menu): Set PRESET_MENU to NULL. (cmain): New internal function, reset. This function resets AUTO_FILL, CONFIG_LEN, MENU_LEN, NUM_ENTRIES, CONFIG_ENTRIES, MENU_ENTRIES and call init_config. Try to open the preset menu first, and try to open the configuration file, only if that failed. Even if the preset menu was read, try to open the configuration file. This time, opening the preset menu never succeed, because close_preset_menu ensures that the preset menu is available at most once.
This commit is contained in:
parent
41e19993b5
commit
686f75d678
2 changed files with 148 additions and 110 deletions
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
|||
2002-01-06 Yoshinori K. Okuji <okuji@gnu.org>
|
||||
|
||||
The preset menu has a priority over the configuration file.
|
||||
Suggested by Christoph Plattner.
|
||||
|
||||
* stage2/stage2.c [PRESET_MENU_STRING] (open_preset_menu):
|
||||
Check if PRESET_MENU is not NULL.
|
||||
[PRESET_MENU_STRING] (close_preset_menu): Set PRESET_MENU to
|
||||
NULL.
|
||||
(cmain): New internal function, reset. This function resets
|
||||
AUTO_FILL, CONFIG_LEN, MENU_LEN, NUM_ENTRIES, CONFIG_ENTRIES,
|
||||
MENU_ENTRIES and call init_config.
|
||||
Try to open the preset menu first, and try to open the
|
||||
configuration file, only if that failed.
|
||||
Even if the preset menu was read, try to open the configuration
|
||||
file. This time, opening the preset menu never succeed, because
|
||||
close_preset_menu ensures that the preset menu is available at
|
||||
most once.
|
||||
|
||||
2002-01-06 Yoshinori K. Okuji <okuji@gnu.org>
|
||||
|
||||
* netboot/misc.c (inet_aton): Don't check if *P is an asterisk,
|
||||
|
|
|
@ -30,7 +30,7 @@ static int
|
|||
open_preset_menu (void)
|
||||
{
|
||||
preset_menu_offset = 0;
|
||||
return 1;
|
||||
return preset_menu != 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -50,7 +50,8 @@ read_from_preset_menu (char *buf, int maxlen)
|
|||
static void
|
||||
close_preset_menu (void)
|
||||
{
|
||||
/* Do nothing. */
|
||||
/* Disable the preset menu. */
|
||||
preset_menu = 0;
|
||||
}
|
||||
|
||||
#else /* ! PRESET_MENU_STRING */
|
||||
|
@ -899,6 +900,18 @@ cmain (void)
|
|||
char *config_entries, *menu_entries;
|
||||
char *kill_buf = (char *) KILL_BUF;
|
||||
|
||||
auto void reset (void);
|
||||
void reset (void)
|
||||
{
|
||||
auto_fill = 1;
|
||||
config_len = 0;
|
||||
menu_len = 0;
|
||||
num_entries = 0;
|
||||
config_entries = (char *) mbi.drives_addr + mbi.drives_length;
|
||||
menu_entries = (char *) MENU_BUF;
|
||||
init_config ();
|
||||
}
|
||||
|
||||
/* Initialize the environment for restarting Stage 2. */
|
||||
grub_setjmp (restart_env);
|
||||
|
||||
|
@ -908,16 +921,9 @@ cmain (void)
|
|||
/* Never return. */
|
||||
for (;;)
|
||||
{
|
||||
int is_opened = 0;
|
||||
int is_preset = 0;
|
||||
int is_opened, is_preset;
|
||||
|
||||
auto_fill = 1;
|
||||
config_len = 0;
|
||||
menu_len = 0;
|
||||
num_entries = 0;
|
||||
config_entries = (char *) mbi.drives_addr + mbi.drives_length;
|
||||
menu_entries = (char *) MENU_BUF;
|
||||
init_config ();
|
||||
reset ();
|
||||
|
||||
/* Here load the configuration file. */
|
||||
|
||||
|
@ -925,13 +931,7 @@ cmain (void)
|
|||
if (use_config_file)
|
||||
#endif /* GRUB_UTIL */
|
||||
{
|
||||
is_opened = grub_open (config_file);
|
||||
errnum = ERR_NONE;
|
||||
if (! is_opened)
|
||||
is_opened = is_preset = open_preset_menu ();
|
||||
}
|
||||
|
||||
if (is_opened)
|
||||
do
|
||||
{
|
||||
/* STATE 0: Before any title command.
|
||||
STATE 1: In a title command.
|
||||
|
@ -939,8 +939,24 @@ cmain (void)
|
|||
int state = 0, prev_config_len = 0, prev_menu_len = 0;
|
||||
char *cmdline;
|
||||
|
||||
/* Try the preset menu first. This will succeed at most once,
|
||||
because close_preset_menu disables the preset menu. */
|
||||
is_opened = is_preset = open_preset_menu ();
|
||||
if (! is_opened)
|
||||
{
|
||||
is_opened = grub_open (config_file);
|
||||
errnum = ERR_NONE;
|
||||
}
|
||||
|
||||
if (! is_opened)
|
||||
break;
|
||||
|
||||
/* This is necessary, because the menu must be overrided. */
|
||||
reset ();
|
||||
|
||||
cmdline = (char *) CMDLINE_BUF;
|
||||
while (get_line_from_config (cmdline, NEW_HEAPSIZE, ! is_preset))
|
||||
while (get_line_from_config (cmdline, NEW_HEAPSIZE,
|
||||
! is_preset))
|
||||
{
|
||||
struct builtin *builtin;
|
||||
|
||||
|
@ -1017,7 +1033,8 @@ cmain (void)
|
|||
|
||||
menu_entries[menu_len++] = 0;
|
||||
config_entries[config_len++] = 0;
|
||||
grub_memmove (config_entries + config_len, menu_entries, menu_len);
|
||||
grub_memmove (config_entries + config_len, menu_entries,
|
||||
menu_len);
|
||||
menu_entries = config_entries + config_len;
|
||||
|
||||
/* Check if the default entry is present. Otherwise reset
|
||||
|
@ -1036,6 +1053,8 @@ cmain (void)
|
|||
else
|
||||
grub_close ();
|
||||
}
|
||||
while (is_preset);
|
||||
}
|
||||
|
||||
if (! num_entries)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue