return 0;
}
+static int ventoy_check_mode_by_name(char *filename, const char *suffix)
+{
+ int i;
+ int len1;
+ int len2;
+
+ len1 = (int)grub_strlen(filename);
+ len2 = (int)grub_strlen(suffix);
+
+ if (len1 <= len2)
+ {
+ return 0;
+ }
+
+ for (i = len1 - 1; i >= 0; i--)
+ {
+ if (filename[i] == '.')
+ {
+ break;
+ }
+ }
+
+ if (i < len2 + 1)
+ {
+ return 0;
+ }
+
+ if (filename[i - len2 - 1] != '_')
+ {
+ return 0;
+ }
+
+ if (grub_strncasecmp(filename + (i - len2), suffix, len2) == 0)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
static grub_err_t ventoy_cmd_check_mode(grub_extcmd_context_t ctxt, int argc, char **args)
{
(void)ctxt;
(void)argc;
(void)args;
- if (argc != 1)
+ if (argc != 1 && argc != 2)
{
return 1;
}
if (args[0][0] == '0')
{
- return g_ventoy_memdisk_mode ? 0 : 1;
+ if (g_ventoy_memdisk_mode)
+ {
+ return 0;
+ }
+
+ if (argc == 2 && ventoy_check_mode_by_name(args[1], "vtmemdisk"))
+ {
+ return 0;
+ }
+
+ return 1;
}
else if (args[0][0] == '1')
{
}
else if (args[0][0] == '3')
{
- return g_ventoy_grub2_mode ? 0 : 1;
+ if (g_ventoy_grub2_mode)
+ {
+ return 0;
+ }
+
+ if (argc == 2 && ventoy_check_mode_by_name(args[1], "vtgrub2"))
+ {
+ return 0;
+ }
+
+ return 1;
}
else if (args[0][0] == '4')
{
- return g_ventoy_wimboot_mode ? 0 : 1;
+ if (g_ventoy_wimboot_mode)
+ {
+ return 0;
+ }
+
+ if (argc == 2 && ventoy_check_mode_by_name(args[1], "vtwimboot"))
+ {
+ return 0;
+ }
+
+ return 1;
}
return 1;
vt_windows_chain_data "${1}${chosen_path}"
ventoy_debug_pause
- if vt_check_mode 4; then
+ if vt_check_mode 4 "$vt_chosen_name"; then
vtoy_windows_wimboot_func
fi
ventoy_cli_console
unset vtGrub2Mode
- if vt_check_mode 3; then
+ if vt_check_mode 3 "$vt_chosen_name"; then
set vtGrub2Mode=1
elif vt_str_begin "$vt_volume_id" "KRD"; then
if [ -f (loop)/boot/grub/grub.cfg.sig ]; then
if [ -n "$vtisouefi" ]; then
set LoadIsoEfiDriver=on
unset vtisouefi
- elif vt_check_mode 2; then
+ elif vt_check_mode 2 "$vt_chosen_name"; then
set LoadIsoEfiDriver=on
else
unset LoadIsoEfiDriver
if [ -n "$vtcompat" ]; then
set ventoy_compatible=YES
unset vtcompat
- elif vt_check_mode 1; then
+ elif vt_check_mode 1 "$vt_chosen_name"; then
set ventoy_compatible=YES
else
vt_check_compatible (loop)
vt_windows_chain_data "${1}${chosen_path}"
ventoy_debug_pause
- if vt_check_mode 4; then
+ if vt_check_mode 4 "$vt_chosen_name"; then
vtoy_windows_wimboot_func
fi
ventoy_debug_pause
if [ -n "$vtoy_chain_mem_addr" ]; then
- if vt_check_mode 3; then
+ if vt_check_mode 3 "$vt_chosen_name"; then
ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
ventoy_cli_console
if [ -n "$vtcompat" ]; then
set ventoy_compatible=YES
unset vtcompat
- elif vt_check_mode 1; then
+ elif vt_check_mode 1 "$vt_chosen_name"; then
set ventoy_compatible=YES
else
vt_check_compatible (loop)
# auto memdisk mode for some special ISO files
vt_iso_vd_id_parse "${vtoy_iso_part}${vt_chosen_path}"
unset vtMemDiskBoot
- if vt_check_mode 0; then
+ if vt_check_mode 0 "$vt_chosen_name"; then
set vtMemDiskBoot=1
else
if [ "$grub_platform" = "pc" ]; then
}
function miso_common_menuentry {
- vt_chosen_img_path vt_chosen_path vt_chosen_size
+ vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
if vt_check_password "${vt_chosen_path}"; then
return
}
function wim_common_menuentry {
- vt_chosen_img_path vt_chosen_path vt_chosen_size
+ vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
if vt_check_password "${vt_chosen_path}"; then
return
}
function efi_common_menuentry {
- vt_chosen_img_path vt_chosen_path vt_chosen_size
+ vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
if vt_check_password "${vt_chosen_path}"; then
return
}
function vhd_common_menuentry {
- vt_chosen_img_path vt_chosen_path vt_chosen_size
+ vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
if vt_check_password "${vt_chosen_path}"; then
return
}
function vtoy_common_menuentry {
- vt_chosen_img_path vt_chosen_path vt_chosen_size
+ vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
if vt_check_password "${vt_chosen_path}"; then
return
set ventoy_busybox_ver=32
unset LoadIsoEfiDriver
- vt_chosen_img_path vt_chosen_path vt_chosen_size
+ vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
if vt_check_password "${vt_chosen_path}"; then
return
fi
if [ "$grub_platform" = "pc" ]; then
- if vt_check_mode 0; then
+ if vt_check_mode 0 "$vt_chosen_name"; then
legacy_img_memdisk $vtoy_iso_part "$vt_chosen_path"
return
fi