From bafac7479d065f5127cc28c7aa43da6c19475f62 Mon Sep 17 00:00:00 2001 From: longpanda Date: Wed, 11 Aug 2021 09:44:09 +0800 Subject: [PATCH] Fix the boot issue for Untangle ISO in legacy bios mode. (#1054) --- GRUB2/MOD_SRC/grub-2.04/grub-core/fs/iso9660.c | 8 ++++++++ .../grub-2.04/grub-core/ventoy/ventoy_cmd.c | 18 ++++++++++++++++++ GRUB2/MOD_SRC/grub-2.04/include/grub/ventoy.h | 1 + INSTALL/grub/grub.cfg | 8 ++++++++ 4 files changed, 35 insertions(+) diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/fs/iso9660.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/fs/iso9660.c index bd357564..9a26bb21 100644 --- a/GRUB2/MOD_SRC/grub-2.04/grub-core/fs/iso9660.c +++ b/GRUB2/MOD_SRC/grub-2.04/grub-core/fs/iso9660.c @@ -33,6 +33,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); static int g_ventoy_no_joliet = 0; +static int g_ventoy_cur_joliet = 0; static grub_uint64_t g_ventoy_last_read_pos = 0; static grub_uint64_t g_ventoy_last_read_offset = 0; static grub_uint64_t g_ventoy_last_read_dirent_pos = 0; @@ -451,6 +452,7 @@ grub_iso9660_mount (grub_disk_t disk) data->disk = disk; + g_ventoy_cur_joliet = 0; block = 16; do { @@ -484,6 +486,7 @@ grub_iso9660_mount (grub_disk_t disk) if (0 == g_ventoy_no_joliet) { copy_voldesc = 1; data->joliet = 1; + g_ventoy_cur_joliet = 1; } } @@ -1118,6 +1121,11 @@ void grub_iso9660_set_nojoliet(int nojoliet) g_ventoy_no_joliet = nojoliet; } +int grub_iso9660_is_joliet(void) +{ + return g_ventoy_cur_joliet; +} + grub_uint64_t grub_iso9660_get_last_read_pos(grub_file_t file) { (void)file; diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c index 97f4ee16..48ed7ed3 100644 --- a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c +++ b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c @@ -1221,6 +1221,23 @@ static grub_err_t ventoy_cmd_load_img_memdisk(grub_extcmd_context_t ctxt, int ar return rc; } +static grub_err_t ventoy_cmd_iso9660_is_joliet(grub_extcmd_context_t ctxt, int argc, char **args) +{ + (void)ctxt; + (void)argc; + (void)args; + + if (grub_iso9660_is_joliet()) + { + debug("This time has joliet process\n"); + return 0; + } + else + { + return 1; + } +} + static grub_err_t ventoy_cmd_iso9660_nojoliet(grub_extcmd_context_t ctxt, int argc, char **args) { (void)ctxt; @@ -4736,6 +4753,7 @@ static cmd_para ventoy_cmds[] = { "vt_select_conf_replace", ventoy_select_conf_replace, 0, NULL, "", "", NULL }, { "vt_iso9660_nojoliet", ventoy_cmd_iso9660_nojoliet, 0, NULL, "", "", NULL }, + { "vt_iso9660_isjoliet", ventoy_cmd_iso9660_is_joliet, 0, NULL, "", "", NULL }, { "vt_is_udf", ventoy_cmd_is_udf, 0, NULL, "", "", NULL }, { "vt_file_size", ventoy_cmd_file_size, 0, NULL, "", "", NULL }, { "vt_load_file_to_mem", ventoy_cmd_load_file_to_mem, 0, NULL, "", "", NULL }, diff --git a/GRUB2/MOD_SRC/grub-2.04/include/grub/ventoy.h b/GRUB2/MOD_SRC/grub-2.04/include/grub/ventoy.h index 56f357db..11384b25 100644 --- a/GRUB2/MOD_SRC/grub-2.04/include/grub/ventoy.h +++ b/GRUB2/MOD_SRC/grub-2.04/include/grub/ventoy.h @@ -267,6 +267,7 @@ typedef struct ventoy_grub_param int grub_ext_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_img_chunk_list *chunk_list); int grub_fat_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_img_chunk_list *chunk_list); void grub_iso9660_set_nojoliet(int nojoliet); +int grub_iso9660_is_joliet(void); grub_uint64_t grub_iso9660_get_last_read_pos(grub_file_t file); grub_uint64_t grub_iso9660_get_last_file_dirent_pos(grub_file_t file); grub_uint64_t grub_udf_get_file_offset(grub_file_t file); diff --git a/INSTALL/grub/grub.cfg b/INSTALL/grub/grub.cfg index 284cce08..b5354c8c 100644 --- a/INSTALL/grub/grub.cfg +++ b/INSTALL/grub/grub.cfg @@ -961,6 +961,14 @@ function legacy_linux_menu_func { set ventoy_fs_probe=iso9660 loopback loop "$1$2" fi + + if [ -f (loop)/isolinux/isolinux.cfg ]; then + if vt_iso9660_isjoliet; then + vt_iso9660_nojoliet 1 + loopback -d loop + loopback loop "$1$2" + fi + fi vt_load_cpio $vtoy_path "$2" "$1" "busybox=$ventoy_busybox_ver"