add quit command
This commit is contained in:
parent
d3b0391801
commit
45d89b3d1a
7 changed files with 92 additions and 30 deletions
20
ChangeLog
20
ChangeLog
|
@ -1,3 +1,23 @@
|
||||||
|
1999-06-22 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
|
||||||
|
|
||||||
|
* shared_src/char_io.c (get_cmdline): Add two missing `break's.
|
||||||
|
|
||||||
|
* shared_src/cmdline.c (commands): Add quit.
|
||||||
|
(enter_cmdline): Change the return type to cmdline_t, and return
|
||||||
|
CMDLINE_OK if successful, otherwise CMDLINE_ERROR if fail.
|
||||||
|
(enter_cmdline) [GRUB_UTIL]: Return CMDLINE_ABORT if CUR_HEAP
|
||||||
|
contains "quit".
|
||||||
|
[!GRUB_UTIL]: Just print an annotation message.
|
||||||
|
* shared_src/shared.h (cmdline_t): New enum type.
|
||||||
|
(enter_cmdline): Change the return type to cmdline_t.
|
||||||
|
(cmain): Remove ``noreturn'' attribute.
|
||||||
|
* shared_src/stage2.c (menu_t): New enum type.
|
||||||
|
(run_menu): Change the return type to menu_t.
|
||||||
|
If enter_cmdline returns CMDLINE_ABORT, then return MENU_ABORT,
|
||||||
|
otherwise return MENU_OK.
|
||||||
|
(cmain): If enter_cmdline aborts, then break the command-line
|
||||||
|
loop and return. If run_menu aborts, then return.
|
||||||
|
|
||||||
1999-06-22 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
|
1999-06-22 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
|
||||||
|
|
||||||
* shared_src/Makefile.am (EXTRA_DIST): Add bios.c. Reported by
|
* shared_src/Makefile.am (EXTRA_DIST): Add bios.c. Reported by
|
||||||
|
|
1
NEWS
1
NEWS
|
@ -11,6 +11,7 @@ New:
|
||||||
* stage2_debug is removed, and the debugging features are added into
|
* stage2_debug is removed, and the debugging features are added into
|
||||||
stage2.
|
stage2.
|
||||||
* Color menu support.
|
* Color menu support.
|
||||||
|
* New command "quit".
|
||||||
|
|
||||||
New in 0.5.91 - 1999-03-14, Gordon Matzigkeit:
|
New in 0.5.91 - 1999-03-14, Gordon Matzigkeit:
|
||||||
* LBA and preliminary AWARD BIOS disk extension support.
|
* LBA and preliminary AWARD BIOS disk extension support.
|
||||||
|
|
2
TODO
2
TODO
|
@ -38,6 +38,4 @@ Add ``configfile'' command, in a clean way.
|
||||||
|
|
||||||
Add keyboard layout configuration support.
|
Add keyboard layout configuration support.
|
||||||
|
|
||||||
Add ``quit'' command for /sbin/grub.
|
|
||||||
|
|
||||||
Finish the GNU GRUB manual, grub.texi.
|
Finish the GNU GRUB manual, grub.texi.
|
||||||
|
|
|
@ -241,8 +241,10 @@ get_cmdline (char *prompt, char *commands, char *cmdline, int maxlen,
|
||||||
break;
|
break;
|
||||||
case KEY_DC:
|
case KEY_DC:
|
||||||
c = 4;
|
c = 4;
|
||||||
|
break;
|
||||||
case KEY_BACKSPACE:
|
case KEY_BACKSPACE:
|
||||||
c = 8;
|
c = 8;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ char commands[] =
|
||||||
\"rootnoverify= <device>\", \"chainloader= <file>\", \"kernel= <file> ...\",
|
\"rootnoverify= <device>\", \"chainloader= <file>\", \"kernel= <file> ...\",
|
||||||
\"testload= <file>\", \"read= <addr>\", \"displaymem\", \"impsprobe\",
|
\"testload= <file>\", \"read= <addr>\", \"displaymem\", \"impsprobe\",
|
||||||
\"fstest\", \"debug\", \"module= <file> ...\", \"modulenounzip= <file> ...\",
|
\"fstest\", \"debug\", \"module= <file> ...\", \"modulenounzip= <file> ...\",
|
||||||
\"color= <normal> [<highlight>]\", \"makeactive\", \"boot\", and
|
\"color= <normal> [<highlight>]\", \"makeactive\", \"boot\", \"quit\" and
|
||||||
\"install= <stage1_file> [d] <dest_dev> <file> <addr> [p] [<config_file>]\"\n";
|
\"install= <stage1_file> [d] <dest_dev> <file> <addr> [p] [<config_file>]\"\n";
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -149,7 +149,11 @@ debug_fs_blocklist_func(int sector)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
/* Run the command-line interface or execute a command from SCRIPT if
|
||||||
|
SCRIPT is not NULL. Return CMDLINE_OK if successful, CMDLINE_ABORT
|
||||||
|
if ``quit'' command is executed, and CMDLINE_ERROR if an error
|
||||||
|
occures or ESC is pushed. */
|
||||||
|
cmdline_t
|
||||||
enter_cmdline (char *script, char *heap)
|
enter_cmdline (char *script, char *heap)
|
||||||
{
|
{
|
||||||
int bootdev, cmd_len, type = 0, run_cmdline = 1, have_run_cmdline = 0;
|
int bootdev, cmd_len, type = 0, run_cmdline = 1, have_run_cmdline = 0;
|
||||||
|
@ -188,7 +192,7 @@ restart:
|
||||||
printf("Press any key to continue...");
|
printf("Press any key to continue...");
|
||||||
(void) getkey ();
|
(void) getkey ();
|
||||||
returnit:
|
returnit:
|
||||||
return 0;
|
return CMDLINE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
run_cmdline = 1;
|
run_cmdline = 1;
|
||||||
|
@ -220,7 +224,7 @@ returnit:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (run_cmdline && get_cmdline (PACKAGE "> ", commands, cur_heap, 2048, 0))
|
if (run_cmdline && get_cmdline (PACKAGE "> ", commands, cur_heap, 2048, 0))
|
||||||
return 1;
|
return CMDLINE_ERROR;
|
||||||
|
|
||||||
if (substring("boot", cur_heap) == 0 || (script && !*cur_heap))
|
if (substring("boot", cur_heap) == 0 || (script && !*cur_heap))
|
||||||
{
|
{
|
||||||
|
@ -269,7 +273,7 @@ returnit:
|
||||||
else if (substring("pause", cur_heap) < 1)
|
else if (substring("pause", cur_heap) < 1)
|
||||||
{
|
{
|
||||||
if (ASCII_CHAR (getkey ()) == 27)
|
if (ASCII_CHAR (getkey ()) == 27)
|
||||||
return 1;
|
return CMDLINE_ERROR;
|
||||||
}
|
}
|
||||||
else if (substring("uppermem", cur_heap) < 1)
|
else if (substring("uppermem", cur_heap) < 1)
|
||||||
{
|
{
|
||||||
|
@ -489,7 +493,7 @@ returnit:
|
||||||
if (script)
|
if (script)
|
||||||
{
|
{
|
||||||
fallback = -1;
|
fallback = -1;
|
||||||
return 1;
|
return CMDLINE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (substring("testload", cur_heap) < 1)
|
else if (substring("testload", cur_heap) < 1)
|
||||||
|
@ -654,6 +658,14 @@ returnit:
|
||||||
| ((normal_color & 0xf) << 4));
|
| ((normal_color & 0xf) << 4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (substring ("quit", cur_heap) < 1)
|
||||||
|
{
|
||||||
|
#ifdef GRUB_UTIL
|
||||||
|
return CMDLINE_ABORT;
|
||||||
|
#else
|
||||||
|
grub_printf (" The quit command is ignored in Stage2\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
else if (*cur_heap && *cur_heap != ' ')
|
else if (*cur_heap && *cur_heap != ' ')
|
||||||
errnum = ERR_UNRECOGNIZED;
|
errnum = ERR_UNRECOGNIZED;
|
||||||
|
|
||||||
|
|
|
@ -383,7 +383,7 @@ extern char *cur_cmdline;
|
||||||
extern entry_func entry_addr;
|
extern entry_func entry_addr;
|
||||||
|
|
||||||
/* Enter the stage1.5/stage2 C code after the stack is set up. */
|
/* Enter the stage1.5/stage2 C code after the stack is set up. */
|
||||||
void cmain (void) __attribute__ ((noreturn));
|
void cmain (void);
|
||||||
|
|
||||||
/* Halt the processor (called after an unrecoverable error). */
|
/* Halt the processor (called after an unrecoverable error). */
|
||||||
void stop (void) __attribute__ ((noreturn));
|
void stop (void) __attribute__ ((noreturn));
|
||||||
|
@ -466,7 +466,20 @@ void stop_floppy (void);
|
||||||
#ifndef STAGE1_5
|
#ifndef STAGE1_5
|
||||||
char *skip_to (int after_equal, char *cmdline);
|
char *skip_to (int after_equal, char *cmdline);
|
||||||
void init_cmdline (void);
|
void init_cmdline (void);
|
||||||
int enter_cmdline (char *script, char *heap);
|
|
||||||
|
/* The constants for the return value of enter_cmdline. */
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CMDLINE_OK = 0,
|
||||||
|
CMDLINE_ABORT,
|
||||||
|
CMDLINE_ERROR
|
||||||
|
} cmdline_t;
|
||||||
|
|
||||||
|
/* Run the command-line interface or execute a command from SCRIPT if
|
||||||
|
SCRIPT is not NULL. Return CMDLINE_OK if successful, CMDLINE_ABORT
|
||||||
|
if ``quit'' command is executed, and CMDLINE_ERROR if an error
|
||||||
|
occures or ESC is pushed. */
|
||||||
|
cmdline_t enter_cmdline (char *script, char *heap);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* C library replacement functions with identical semantics. */
|
/* C library replacement functions with identical semantics. */
|
||||||
|
|
|
@ -147,7 +147,13 @@ set_line(int y, int attr)
|
||||||
static int grub_timeout;
|
static int grub_timeout;
|
||||||
|
|
||||||
|
|
||||||
static void
|
typedef enum
|
||||||
|
{
|
||||||
|
MENU_OK = 0,
|
||||||
|
MENU_ABORT
|
||||||
|
} menu_t;
|
||||||
|
|
||||||
|
static menu_t
|
||||||
run_menu(char *menu_entries, char *config_entries, int num_entries,
|
run_menu(char *menu_entries, char *config_entries, int num_entries,
|
||||||
char *heap, int entryno)
|
char *heap, int entryno)
|
||||||
{
|
{
|
||||||
|
@ -353,7 +359,7 @@ restart:
|
||||||
|
|
||||||
cur_entry = menu_entries;
|
cur_entry = menu_entries;
|
||||||
if (c == 27)
|
if (c == 27)
|
||||||
return;
|
return MENU_OK;
|
||||||
if (c == 'b')
|
if (c == 'b')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -378,7 +384,7 @@ restart:
|
||||||
while (isspace (*pptr))
|
while (isspace (*pptr))
|
||||||
pptr ++;
|
pptr ++;
|
||||||
while ((*(new_file ++) = *(pptr ++)) != 0);
|
while ((*(new_file ++) = *(pptr ++)) != 0);
|
||||||
return;
|
return MENU_OK;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -464,7 +470,11 @@ restart:
|
||||||
}
|
}
|
||||||
if (c == 'c')
|
if (c == 'c')
|
||||||
{
|
{
|
||||||
enter_cmdline (NULL, heap);
|
/* Call the command-line interface, and if it aborts
|
||||||
|
(by ``quit'' command), then return. */
|
||||||
|
if (enter_cmdline (NULL, heap) == CMDLINE_ABORT)
|
||||||
|
return MENU_ABORT;
|
||||||
|
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -488,7 +498,7 @@ restart:
|
||||||
if (!cur_entry)
|
if (!cur_entry)
|
||||||
cur_entry = get_entry(config_entries, first_entry+entryno, 1);
|
cur_entry = get_entry(config_entries, first_entry+entryno, 1);
|
||||||
|
|
||||||
if (!(c = enter_cmdline (cur_entry, heap)))
|
if ((c = enter_cmdline (cur_entry, heap)) == CMDLINE_OK)
|
||||||
{
|
{
|
||||||
if (fallback < 0)
|
if (fallback < 0)
|
||||||
break;
|
break;
|
||||||
|
@ -501,7 +511,11 @@ restart:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (!c);
|
while (c == CMDLINE_OK);
|
||||||
|
|
||||||
|
/* If aborted, then return. */
|
||||||
|
if (c == CMDLINE_ABORT)
|
||||||
|
return MENU_ABORT;
|
||||||
|
|
||||||
/* Both the entry and the fallback failed, so wait for input. */
|
/* Both the entry and the fallback failed, so wait for input. */
|
||||||
printf (" Press any key to continue...");
|
printf (" Press any key to continue...");
|
||||||
|
@ -675,20 +689,22 @@ cmain(void)
|
||||||
menu_entries = config_entries + config_len;
|
menu_entries = config_entries + config_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* If no acceptable config file, goto command-line, starting heap from
|
|
||||||
* where the config entries would have been stored if there were any.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (! num_entries)
|
if (! num_entries)
|
||||||
while (1)
|
{
|
||||||
enter_cmdline (NULL, config_entries);
|
/* If no acceptable config file, goto command-line, starting
|
||||||
|
heap from where the config entries would have been stored
|
||||||
|
if there were any. */
|
||||||
|
while (enter_cmdline (NULL, config_entries) != CMDLINE_ABORT)
|
||||||
|
;
|
||||||
|
|
||||||
/*
|
return;
|
||||||
* Run menu interface (this shouldn't return!).
|
}
|
||||||
*/
|
else
|
||||||
|
{
|
||||||
run_menu(menu_entries, config_entries, num_entries,
|
/* Run menu interface. */
|
||||||
menu_entries+menu_len, default_entry);
|
if (run_menu(menu_entries, config_entries, num_entries,
|
||||||
|
menu_entries+menu_len, default_entry) == MENU_ABORT)
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue