mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-21 14:59:34 +00:00
add quit command
This commit is contained in:
1 parent
d3b0391801
commit
45d89b3d1a
7 files changed
+92
-30
No files matched your search
@@ -241,8 +241,10 @@ get_cmdline (char *prompt, char *commands, char *cmdline, int maxlen,
|
||||
break;
|
||||
case KEY_DC:
|
||||
c = 4;
|
||||
break;
|
||||
case KEY_BACKSPACE:
|
||||
c = 8;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
|
||||
+18
-6
@@ -111,7 +111,7 @@ char commands[] =
|
||||
\"rootnoverify= <device>\", \"chainloader= <file>\", \"kernel= <file> ...\",
|
||||
\"testload= <file>\", \"read= <addr>\", \"displaymem\", \"impsprobe\",
|
||||
\"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";
|
||||
|
||||
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)
|
||||
{
|
||||
int bootdev, cmd_len, type = 0, run_cmdline = 1, have_run_cmdline = 0;
|
||||
@@ -188,7 +192,7 @@ restart:
|
||||
printf("Press any key to continue...");
|
||||
(void) getkey ();
|
||||
returnit:
|
||||
return 0;
|
||||
return CMDLINE_OK;
|
||||
}
|
||||
|
||||
run_cmdline = 1;
|
||||
@@ -220,7 +224,7 @@ returnit:
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
@@ -269,7 +273,7 @@ returnit:
|
||||
else if (substring("pause", cur_heap) < 1)
|
||||
{
|
||||
if (ASCII_CHAR (getkey ()) == 27)
|
||||
return 1;
|
||||
return CMDLINE_ERROR;
|
||||
}
|
||||
else if (substring("uppermem", cur_heap) < 1)
|
||||
{
|
||||
@@ -489,7 +493,7 @@ returnit:
|
||||
if (script)
|
||||
{
|
||||
fallback = -1;
|
||||
return 1;
|
||||
return CMDLINE_ERROR;
|
||||
}
|
||||
}
|
||||
else if (substring("testload", cur_heap) < 1)
|
||||
@@ -654,6 +658,14 @@ returnit:
|
||||
| ((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 != ' ')
|
||||
errnum = ERR_UNRECOGNIZED;
|
||||
|
||||
|
||||
+15
-2
@@ -383,7 +383,7 @@ extern char *cur_cmdline;
|
||||
extern entry_func entry_addr;
|
||||
|
||||
/* 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). */
|
||||
void stop (void) __attribute__ ((noreturn));
|
||||
@@ -466,7 +466,20 @@ void stop_floppy (void);
|
||||
#ifndef STAGE1_5
|
||||
char *skip_to (int after_equal, char *cmdline);
|
||||
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
|
||||
|
||||
/* C library replacement functions with identical semantics. */
|
||||
|
||||
+36
-20
@@ -147,7 +147,13 @@ set_line(int y, int attr)
|
||||
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,
|
||||
char *heap, int entryno)
|
||||
{
|
||||
@@ -353,7 +359,7 @@ restart:
|
||||
|
||||
cur_entry = menu_entries;
|
||||
if (c == 27)
|
||||
return;
|
||||
return MENU_OK;
|
||||
if (c == 'b')
|
||||
break;
|
||||
}
|
||||
@@ -378,7 +384,7 @@ restart:
|
||||
while (isspace (*pptr))
|
||||
pptr ++;
|
||||
while ((*(new_file ++) = *(pptr ++)) != 0);
|
||||
return;
|
||||
return MENU_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -464,7 +470,11 @@ restart:
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -488,7 +498,7 @@ restart:
|
||||
if (!cur_entry)
|
||||
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)
|
||||
break;
|
||||
@@ -501,8 +511,12 @@ 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. */
|
||||
printf (" Press any key to continue...");
|
||||
getkey ();
|
||||
@@ -675,20 +689,22 @@ cmain(void)
|
||||
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 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)
|
||||
;
|
||||
|
||||
if (!num_entries)
|
||||
while (1)
|
||||
enter_cmdline (NULL, config_entries);
|
||||
|
||||
/*
|
||||
* Run menu interface (this shouldn't return!).
|
||||
*/
|
||||
|
||||
run_menu(menu_entries, config_entries, num_entries,
|
||||
menu_entries+menu_len, default_entry);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Run menu interface. */
|
||||
if (run_menu(menu_entries, config_entries, num_entries,
|
||||
menu_entries+menu_len, default_entry) == MENU_ABORT)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user