Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dadigang
Ventoy
Commits
ebc5e2e9
Commit
ebc5e2e9
authored
Sep 24, 2022
by
longpanda
Browse files
1. Disable Fn hotkey during secondary boot menu.
2. Recover boot mode after boot fail from secondary boot menu.
parent
d58bd8c3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
105 additions
and
45 deletions
+105
-45
GRUB2/MOD_SRC/grub-2.04/grub-core/normal/menu.c
GRUB2/MOD_SRC/grub-2.04/grub-core/normal/menu.c
+67
-45
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
+33
-0
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
+1
-0
INSTALL/grub/grub.cfg
INSTALL/grub/grub.cfg
+4
-0
No files found.
GRUB2/MOD_SRC/grub-2.04/grub-core/normal/menu.c
View file @
ebc5e2e9
...
...
@@ -48,10 +48,11 @@ int g_ventoy_suppress_esc = 0;
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) \
{ \
...
...
@@ -933,70 +934,91 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
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
;
}
...
...
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
View file @
ebc5e2e9
...
...
@@ -158,6 +158,8 @@ const char *g_menu_prefix[img_type_max] =
"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
];
...
...
@@ -6009,6 +6011,7 @@ static grub_err_t ventoy_cmd_show_secondary_menu(grub_extcmd_context_t ctxt, int
return
1
;
}
g_vtoy_secondary_need_recover
=
0
;
grub_env_unset
(
"VTOY_CHKSUM_FILE_PATH"
);
env
=
grub_env_get
(
"VTOY_SECONDARY_TIMEOUT"
);
...
...
@@ -6049,25 +6052,30 @@ static grub_err_t ventoy_cmd_show_secondary_menu(grub_extcmd_context_t ctxt, int
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
)
{
...
...
@@ -6080,6 +6088,30 @@ static grub_err_t ventoy_cmd_show_secondary_menu(grub_extcmd_context_t ctxt, int
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
;
...
...
@@ -6303,6 +6335,7 @@ static cmd_para ventoy_cmds[] =
{
"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
)
...
...
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
View file @
ebc5e2e9
...
...
@@ -1039,6 +1039,7 @@ typedef struct menu_password
}
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
;
...
...
INSTALL/grub/grub.cfg
View file @
ebc5e2e9
...
...
@@ -936,6 +936,7 @@ function uefi_iso_menu_func {
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
...
...
@@ -957,6 +958,7 @@ function uefi_iso_menu_func {
fi
ventoy_gui_console
vt_secondary_recover_mode
}
function uefi_iso_memdisk {
...
...
@@ -1368,6 +1370,7 @@ function legacy_iso_menu_func {
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
...
...
@@ -1387,6 +1390,7 @@ function legacy_iso_menu_func {
vt_check_compatible_linux (loop)
legacy_linux_menu_func "$1" "${chosen_path}"
fi
vt_secondary_recover_mode
}
function legacy_iso_memdisk {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment