Auto use memdisk mode when booting iKuai OS.

This commit is contained in:
longpanda
2022-05-31 17:39:54 +08:00
parent 2cd22da8fb
commit 7f2f845a68
2 changed files with 32 additions and 5 deletions

View File

@@ -2612,24 +2612,38 @@ static grub_err_t ventoy_cmd_chosen_img_path(grub_extcmd_context_t ctxt, int arg
{
char value[32];
char *pos = NULL;
char *last = NULL;
const char *id = NULL;
img_info *cur = NULL;
(void)ctxt;
if (argc < 1 || argc > 2)
if (argc < 1 || argc > 3)
{
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s {var}", cmd_raw_name);
}
if (g_fake_vlnk_src[0] && g_fake_vlnk_dst[0])
{
grub_env_set(args[0], grub_strchr(g_fake_vlnk_src, '/'));
pos = grub_strchr(g_fake_vlnk_src, '/');
grub_env_set(args[0], pos);
if (argc > 1)
{
grub_snprintf(value, sizeof(value), "%llu", (ulonglong)(g_fake_vlnk_size));
grub_env_set(args[1], value);
}
if (argc > 2)
{
for (last = pos; *pos; pos++)
{
if (*pos == '/')
{
last = pos;
}
}
grub_env_set(args[2], last + 1);
}
goto end;
}
@@ -2658,6 +2672,12 @@ static grub_err_t ventoy_cmd_chosen_img_path(grub_extcmd_context_t ctxt, int arg
grub_snprintf(value, sizeof(value), "%llu", (ulonglong)(cur->size));
grub_env_set(args[1], value);
}
if (argc > 2)
{
grub_snprintf(value, sizeof(value), "%llu", (ulonglong)(cur->size));
grub_env_set(args[2], cur->name);
}
end:
g_svd_replace_offset = 0;