Skip to content

Commit 17f9e2f

Browse files
committed
1.0.80 release
1 parent 6b22a62 commit 17f9e2f

31 files changed

+843
-119
lines changed

GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c

Lines changed: 149 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3659,12 +3659,12 @@ static grub_err_t ventoy_cmd_sel_auto_install(grub_extcmd_context_t ctxt, int ar
36593659
vtoy_ssprintf(buf, pos, "set timeout=%d\n", node->timeout);
36603660
}
36613661

3662-
vtoy_ssprintf(buf, pos, "menuentry \"Boot without auto installation template\" {\n"
3662+
vtoy_ssprintf(buf, pos, "menuentry \"Boot without auto installation template\" --class=\"sel_auto_install\" {\n"
36633663
" echo %s\n}\n", "");
36643664

36653665
for (i = 0; i < node->templatenum; i++)
36663666
{
3667-
vtoy_ssprintf(buf, pos, "menuentry \"Boot with %s\"{\n"
3667+
vtoy_ssprintf(buf, pos, "menuentry \"Boot with %s\" --class=\"sel_auto_install\" {\n"
36683668
" echo \"\"\n}\n",
36693669
node->templatepath[i].path);
36703670
}
@@ -3765,12 +3765,12 @@ static grub_err_t ventoy_cmd_sel_persistence(grub_extcmd_context_t ctxt, int arg
37653765
vtoy_ssprintf(buf, pos, "set timeout=%d\n", node->timeout);
37663766
}
37673767

3768-
vtoy_ssprintf(buf, pos, "menuentry \"Boot without persistence\" {\n"
3768+
vtoy_ssprintf(buf, pos, "menuentry \"Boot without persistence\" --class=\"sel_persistence\" {\n"
37693769
" echo %s\n}\n", "");
37703770

37713771
for (i = 0; i < node->backendnum; i++)
37723772
{
3773-
vtoy_ssprintf(buf, pos, "menuentry \"Boot with %s\" {\n"
3773+
vtoy_ssprintf(buf, pos, "menuentry \"Boot with %s\" --class=\"sel_persistence\" {\n"
37743774
" echo \"\"\n}\n",
37753775
node->backendpath[i].path);
37763776

@@ -5958,6 +5958,145 @@ static grub_err_t ventoy_cmd_dump_rsv_page(grub_extcmd_context_t ctxt, int argc,
59585958
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
59595959
}
59605960

5961+
static grub_err_t ventoy_cmd_need_secondary_menu(grub_extcmd_context_t ctxt, int argc, char **args)
5962+
{
5963+
const char *env = NULL;
5964+
5965+
(void)ctxt;
5966+
(void)argc;
5967+
5968+
if (g_ventoy_memdisk_mode || g_ventoy_grub2_mode || g_ventoy_wimboot_mode || g_ventoy_iso_raw)
5969+
{
5970+
return 1;
5971+
}
5972+
5973+
if (ventoy_check_mode_by_name(args[0], "vtmemdisk") ||
5974+
ventoy_check_mode_by_name(args[0], "vtgrub2") ||
5975+
ventoy_check_mode_by_name(args[0], "vtwimboot"))
5976+
{
5977+
return 1;
5978+
}
5979+
5980+
env = grub_env_get("VTOY_SECONDARY_BOOT_MENU");
5981+
if (env && env[0] == '0' && env[1] == 0)
5982+
{
5983+
return 1;
5984+
}
5985+
5986+
return 0;
5987+
}
5988+
5989+
static grub_err_t ventoy_cmd_show_secondary_menu(grub_extcmd_context_t ctxt, int argc, char **args)
5990+
{
5991+
int n = 0;
5992+
int pos = 0;
5993+
int len = 0;
5994+
int select = 0;
5995+
int timeout = 0;
5996+
char *cmd = NULL;
5997+
const char *env = NULL;
5998+
ulonglong fsize = 0;
5999+
char cfgfile[128];
6000+
int seldata[16] = {0};
6001+
6002+
(void)ctxt;
6003+
(void)argc;
6004+
6005+
len = 8 * VTOY_SIZE_1KB;
6006+
cmd = (char *)grub_malloc(len);
6007+
if (!cmd)
6008+
{
6009+
return 1;
6010+
}
6011+
6012+
grub_env_unset("VTOY_CHKSUM_FILE_PATH");
6013+
6014+
env = grub_env_get("VTOY_SECONDARY_TIMEOUT");
6015+
if (env)
6016+
{
6017+
timeout = (int)grub_strtol(env, NULL, 10);
6018+
}
6019+
6020+
if (timeout > 0)
6021+
{
6022+
vtoy_len_ssprintf(cmd, pos, len, "set timeout=%d\n", timeout);
6023+
}
6024+
6025+
fsize = grub_strtoull(args[2], NULL, 10);
6026+
6027+
vtoy_dummy_menuentry(cmd, pos, len, "Boot in normal mode", "second_normal"); seldata[n++] = 1;
6028+
6029+
if (grub_strcmp(args[1], "Unix") != 0)
6030+
{
6031+
if (grub_strcmp(args[1], "Windows") == 0)
6032+
{
6033+
vtoy_dummy_menuentry(cmd, pos, len, "Boot in wimboot mode", "second_wimboot"); seldata[n++] = 2;
6034+
}
6035+
else
6036+
{
6037+
vtoy_dummy_menuentry(cmd, pos, len, "Boot in grub2 mode", "second_grub2"); seldata[n++] = 3;
6038+
}
6039+
6040+
if (fsize <= VTOY_SIZE_1GB)
6041+
{
6042+
vtoy_dummy_menuentry(cmd, pos, len, "Boot in memdisk mode", "second_memdisk"); seldata[n++] = 4;
6043+
}
6044+
}
6045+
6046+
vtoy_dummy_menuentry(cmd, pos, len, "File checksum", "second_checksum"); seldata[n++] = 5;
6047+
6048+
do {
6049+
g_ventoy_menu_esc = 1;
6050+
g_ventoy_suppress_esc = 1;
6051+
g_ventoy_suppress_esc_default = 0;
6052+
grub_snprintf(cfgfile, sizeof(cfgfile), "configfile mem:0x%llx:size:%d", (ulonglong)(ulong)cmd, pos);
6053+
grub_script_execute_sourcecode(cfgfile);
6054+
g_ventoy_menu_esc = 0;
6055+
g_ventoy_suppress_esc = 0;
6056+
g_ventoy_suppress_esc_default = 1;
6057+
6058+
select = seldata[g_ventoy_last_entry];
6059+
6060+
if (select == 2)
6061+
{
6062+
g_ventoy_wimboot_mode = 1;
6063+
}
6064+
else if (select == 3)
6065+
{
6066+
g_ventoy_grub2_mode = 1;
6067+
}
6068+
else if (select == 4)
6069+
{
6070+
g_ventoy_memdisk_mode = 1;
6071+
}
6072+
else if (select == 5)
6073+
{
6074+
grub_env_set("VTOY_CHKSUM_FILE_PATH", args[0]);
6075+
grub_script_execute_sourcecode("configfile $vtoy_efi_part/grub/checksum.cfg");
6076+
}
6077+
}while (select == 5);
6078+
6079+
grub_free(cmd);
6080+
return 0;
6081+
}
6082+
6083+
static grub_err_t ventoy_cmd_fs_ignore_case(grub_extcmd_context_t ctxt, int argc, char **args)
6084+
{
6085+
(void)ctxt;
6086+
(void)argc;
6087+
6088+
if (args[0][0] == '0')
6089+
{
6090+
g_ventoy_case_insensitive = 0;
6091+
}
6092+
else
6093+
{
6094+
g_ventoy_case_insensitive = 1;
6095+
}
6096+
6097+
return 0;
6098+
}
6099+
59616100
int ventoy_env_init(void)
59626101
{
59636102
int i;
@@ -6158,6 +6297,12 @@ static cmd_para ventoy_cmds[] =
61586297
{ "vt_iso_vd_id_begin", ventoy_cmd_iso_vd_id_begin, 0, NULL, "", "", NULL },
61596298
{ "vt_fn_mutex_lock", ventoy_cmd_fn_mutex_lock, 0, NULL, "", "", NULL },
61606299
{ "vt_efi_dump_rsv_page", ventoy_cmd_dump_rsv_page, 0, NULL, "", "", NULL },
6300+
{ "vt_is_standard_winiso", ventoy_cmd_is_standard_winiso, 0, NULL, "", "", NULL },
6301+
{ "vt_sel_winpe_wim", ventoy_cmd_sel_winpe_wim, 0, NULL, "", "", NULL },
6302+
{ "vt_need_secondary_menu", ventoy_cmd_need_secondary_menu, 0, NULL, "", "", NULL },
6303+
{ "vt_show_secondary_menu", ventoy_cmd_show_secondary_menu, 0, NULL, "", "", NULL },
6304+
{ "vt_fs_ignore_case", ventoy_cmd_fs_ignore_case, 0, NULL, "", "", NULL },
6305+
{ "vt_systemd_menu", ventoy_cmd_linux_systemd_menu, 0, NULL, "", "", NULL },
61616306
};
61626307

61636308
int ventoy_register_all_cmd(void)

GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
#define VTOY_FILT_MIN_FILE_SIZE 32768
3131

32+
#define VTOY_LINUX_SYSTEMD_MENU_MAX_BUF 16384
33+
3234
#define VTOY_SIZE_1GB 1073741824
3335
#define VTOY_SIZE_1MB (1024 * 1024)
3436
#define VTOY_SIZE_2MB (2 * 1024 * 1024)
@@ -329,9 +331,16 @@ void ventoy_debug(const char *fmt, ...);
329331
#define vtoy_ssprintf(buf, pos, fmt, args...) \
330332
pos += grub_snprintf(buf + pos, VTOY_MAX_SCRIPT_BUF - pos, fmt, ##args)
331333

334+
#define vtoy_len_ssprintf(buf, pos, len, fmt, args...) \
335+
pos += grub_snprintf(buf + pos, len - pos, fmt, ##args)
336+
332337
#define browser_ssprintf(mbuf, fmt, args...) \
333338
(mbuf)->pos += grub_snprintf((mbuf)->buf + (mbuf)->pos, (mbuf)->max - (mbuf)->pos, fmt, ##args)
334339

340+
#define vtoy_dummy_menuentry(buf, pos, len, title, class) \
341+
vtoy_len_ssprintf(buf, pos, len, "menuentry \"%s\" --class=\"%s\" {\n echo \"\"\n}\n", title, class)
342+
343+
335344
#define FLAG_HEADER_RESERVED 0x00000001
336345
#define FLAG_HEADER_COMPRESSION 0x00000002
337346
#define FLAG_HEADER_READONLY 0x00000004
@@ -613,6 +622,7 @@ grub_err_t ventoy_cmd_clear_initrd_list(grub_extcmd_context_t ctxt, int argc, ch
613622
grub_uint32_t ventoy_get_iso_boot_catlog(grub_file_t file);
614623
int ventoy_has_efi_eltorito(grub_file_t file, grub_uint32_t sector);
615624
grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
625+
grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, char **args);
616626
grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc, char **args);
617627
grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
618628
grub_err_t ventoy_cmd_valid_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
@@ -633,6 +643,7 @@ grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, c
633643
grub_err_t ventoy_cmd_windows_wimboot_data(grub_extcmd_context_t ctxt, int argc, char **args);
634644
grub_err_t ventoy_cmd_wim_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
635645
grub_err_t ventoy_cmd_wim_check_bootable(grub_extcmd_context_t ctxt, int argc, char **args);
646+
grub_err_t ventoy_cmd_is_standard_winiso(grub_extcmd_context_t ctxt, int argc, char **args);
636647
grub_err_t ventoy_cmd_dump_wim_patch(grub_extcmd_context_t ctxt, int argc, char **args);
637648
grub_err_t ventoy_cmd_sel_wimboot(grub_extcmd_context_t ctxt, int argc, char **args);
638649
grub_err_t ventoy_cmd_set_wim_prompt(grub_extcmd_context_t ctxt, int argc, char **args);
@@ -1111,6 +1122,7 @@ grub_err_t ventoy_cmd_linux_get_main_initrd_index(grub_extcmd_context_t ctxt, in
11111122
grub_err_t ventoy_cmd_collect_wim_patch(grub_extcmd_context_t ctxt, int argc, char **args);
11121123
grub_err_t ventoy_cmd_wim_patch_count(grub_extcmd_context_t ctxt, int argc, char **args);
11131124
grub_err_t ventoy_cmd_locate_wim_patch(grub_extcmd_context_t ctxt, int argc, char **args);
1125+
grub_err_t ventoy_cmd_sel_winpe_wim(grub_extcmd_context_t ctxt, int argc, char **args);
11141126
grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
11151127
int ventoy_get_disk_guid(const char *filename, grub_uint8_t *guid, grub_uint8_t *signature);
11161128
grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **args);
@@ -1218,6 +1230,16 @@ typedef struct var_node
12181230
struct var_node *next;
12191231
}var_node;
12201232

1233+
typedef struct systemd_menu_ctx
1234+
{
1235+
char *dev;
1236+
char *buf;
1237+
int pos;
1238+
int len;
1239+
}systemd_menu_ctx;
1240+
1241+
#define vtoy_check_goto_out(p) if (!p) goto out
1242+
12211243
extern char *g_tree_script_buf;
12221244
extern int g_tree_script_pos;
12231245
extern int g_tree_script_pre;

0 commit comments

Comments
 (0)