2. Recover boot mode after boot fail from secondary boot menu.
int g_ventoy_suppress_esc_default = 1;
int g_ventoy_menu_esc = 0;
int g_ventoy_fn_mutex = 0;
+int g_ventoy_secondary_menu_on = 0;
int g_ventoy_terminal_output = 0;
#define VTOY_COMM_HOTKEY(cmdkey) \
-if (0 == g_ventoy_fn_mutex) { \
+if (0 == g_ventoy_fn_mutex && 0 == g_ventoy_secondary_menu_on) { \
cmdstr = grub_env_get(cmdkey); \
if (cmdstr) \
{ \
goto refresh;
case GRUB_TERM_KEY_F1:
case '1':
- menu_fini ();
- g_ventoy_memdisk_mode = 1 - g_ventoy_memdisk_mode;
- g_ventoy_menu_refresh = 1;
- goto refresh;
-
+ if (0 == g_ventoy_secondary_menu_on)
+ {
+ menu_fini ();
+ g_ventoy_memdisk_mode = 1 - g_ventoy_memdisk_mode;
+ g_ventoy_menu_refresh = 1;
+ goto refresh;
+ }
+ break;
case (GRUB_TERM_CTRL | 'i'):
case 'i':
- menu_fini ();
- g_ventoy_iso_raw = 1 - g_ventoy_iso_raw;
- g_ventoy_menu_refresh = 1;
- goto refresh;
-
+ if (0 == g_ventoy_secondary_menu_on)
+ {
+ menu_fini ();
+ g_ventoy_iso_raw = 1 - g_ventoy_iso_raw;
+ g_ventoy_menu_refresh = 1;
+ goto refresh;
+ }
+ break;
case (GRUB_TERM_CTRL | 'r'):
case 'r':
- menu_fini ();
- g_ventoy_grub2_mode = 1 - g_ventoy_grub2_mode;
- g_ventoy_menu_refresh = 1;
- goto refresh;
-
+ if (0 == g_ventoy_secondary_menu_on)
+ {
+ menu_fini ();
+ g_ventoy_grub2_mode = 1 - g_ventoy_grub2_mode;
+ g_ventoy_menu_refresh = 1;
+ goto refresh;
+ }
+ break;
case (GRUB_TERM_CTRL | 'w'):
case 'w':
- menu_fini ();
- g_ventoy_wimboot_mode = 1 - g_ventoy_wimboot_mode;
- g_ventoy_menu_refresh = 1;
- goto refresh;
-
+ if (0 == g_ventoy_secondary_menu_on)
+ {
+ menu_fini ();
+ g_ventoy_wimboot_mode = 1 - g_ventoy_wimboot_mode;
+ g_ventoy_menu_refresh = 1;
+ goto refresh;
+ }
+ break;
case (GRUB_TERM_CTRL | 'u'):
case 'u':
- menu_fini ();
- g_ventoy_iso_uefi_drv = 1 - g_ventoy_iso_uefi_drv;
- g_ventoy_menu_refresh = 1;
- goto refresh;
-
- case (GRUB_TERM_CTRL | 'h'):
- case 'h':
- {
- cmdstr = grub_env_get("VTOY_HELP_CMD");
- if (cmdstr)
+ if (0 == g_ventoy_secondary_menu_on)
{
- grub_script_execute_sourcecode(cmdstr);
- while (grub_getkey() != GRUB_TERM_ESC)
- ;
menu_fini ();
+ g_ventoy_iso_uefi_drv = 1 - g_ventoy_iso_uefi_drv;
+ g_ventoy_menu_refresh = 1;
goto refresh;
}
break;
- }
- case (GRUB_TERM_CTRL | 'm'):
- case 'm':
+ case (GRUB_TERM_CTRL | 'h'):
+ case 'h':
{
- if (g_ventoy_cur_img_path)
+ if (0 == g_ventoy_secondary_menu_on)
{
- grub_env_set("VTOY_CHKSUM_FILE_PATH", g_ventoy_cur_img_path);
- cmdstr = grub_env_get("VTOY_CHKSUM_CMD");
+ cmdstr = grub_env_get("VTOY_HELP_CMD");
if (cmdstr)
{
- menu_fini();
grub_script_execute_sourcecode(cmdstr);
+ while (grub_getkey() != GRUB_TERM_ESC)
+ ;
+ menu_fini ();
goto refresh;
- }
+ }
}
- else
- {
- grub_env_set("VTOY_CHKSUM_FILE_PATH", "X");
+ break;
+ }
+ case (GRUB_TERM_CTRL | 'm'):
+ case 'm':
+ {
+ if (0 == g_ventoy_secondary_menu_on)
+ {
+ if (g_ventoy_cur_img_path)
+ {
+ grub_env_set("VTOY_CHKSUM_FILE_PATH", g_ventoy_cur_img_path);
+ cmdstr = grub_env_get("VTOY_CHKSUM_CMD");
+ if (cmdstr)
+ {
+ menu_fini();
+ grub_script_execute_sourcecode(cmdstr);
+ goto refresh;
+ }
+ }
+ else
+ {
+ grub_env_set("VTOY_CHKSUM_FILE_PATH", "X");
+ }
}
break;
}
"iso", "wim", "efi", "img", "vhd", "vtoy"
};
+static int g_vtoy_secondary_need_recover = 0;
+
static int g_vtoy_load_prompt = 0;
static char g_vtoy_prompt_msg[64];
return 1;
}
+ g_vtoy_secondary_need_recover = 0;
grub_env_unset("VTOY_CHKSUM_FILE_PATH");
env = grub_env_get("VTOY_SECONDARY_TIMEOUT");
g_ventoy_menu_esc = 1;
g_ventoy_suppress_esc = 1;
g_ventoy_suppress_esc_default = 0;
+ g_ventoy_secondary_menu_on = 1;
grub_snprintf(cfgfile, sizeof(cfgfile), "configfile mem:0x%llx:size:%d", (ulonglong)(ulong)cmd, pos);
grub_script_execute_sourcecode(cfgfile);
g_ventoy_menu_esc = 0;
g_ventoy_suppress_esc = 0;
g_ventoy_suppress_esc_default = 1;
+ g_ventoy_secondary_menu_on = 0;
select = seldata[g_ventoy_last_entry];
if (select == 2)
{
g_ventoy_wimboot_mode = 1;
+ g_vtoy_secondary_need_recover = 1;
}
else if (select == 3)
{
g_ventoy_grub2_mode = 1;
+ g_vtoy_secondary_need_recover = 2;
}
else if (select == 4)
{
g_ventoy_memdisk_mode = 1;
+ g_vtoy_secondary_need_recover = 3;
}
else if (select == 5)
{
return 0;
}
+static grub_err_t ventoy_cmd_secondary_recover_mode(grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ (void)ctxt;
+ (void)argc;
+ (void)args;
+
+ if (g_vtoy_secondary_need_recover == 1)
+ {
+ g_ventoy_wimboot_mode = 0;
+ }
+ else if (g_vtoy_secondary_need_recover == 2)
+ {
+ g_ventoy_grub2_mode = 0;
+ }
+ else if (g_vtoy_secondary_need_recover == 3)
+ {
+ g_ventoy_memdisk_mode = 0;
+ }
+
+ g_vtoy_secondary_need_recover = 0;
+
+ VENTOY_CMD_RETURN(GRUB_ERR_NONE);
+}
+
static grub_err_t ventoy_cmd_fs_ignore_case(grub_extcmd_context_t ctxt, int argc, char **args)
{
(void)ctxt;
{ "vt_show_secondary_menu", ventoy_cmd_show_secondary_menu, 0, NULL, "", "", NULL },
{ "vt_fs_ignore_case", ventoy_cmd_fs_ignore_case, 0, NULL, "", "", NULL },
{ "vt_systemd_menu", ventoy_cmd_linux_systemd_menu, 0, NULL, "", "", NULL },
+ { "vt_secondary_recover_mode", ventoy_cmd_secondary_recover_mode, 0, NULL, "", "", NULL },
};
int ventoy_register_all_cmd(void)
}menu_password;
extern int g_ventoy_menu_esc;
+extern int g_ventoy_secondary_menu_on;
extern int g_ventoy_suppress_esc;
extern int g_ventoy_suppress_esc_default;
extern int g_ventoy_last_entry;
vt_show_secondary_menu "$vt_chosen_path" "$vtoy_os" $vt_chosen_size
if vt_check_mode 0 "$vt_chosen_name"; then
uefi_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
+ vt_secondary_recover_mode
return
fi
fi
fi
ventoy_gui_console
+ vt_secondary_recover_mode
}
function uefi_iso_memdisk {
vt_show_secondary_menu "$vt_chosen_path" "$vtoy_os" $vt_chosen_size
if vt_check_mode 0 "$vt_chosen_name"; then
legacy_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
+ vt_secondary_recover_mode
return
fi
fi
vt_check_compatible_linux (loop)
legacy_linux_menu_func "$1" "${chosen_path}"
fi
+ vt_secondary_recover_mode
}
function legacy_iso_memdisk {