mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-08-27 16:01:14 +00:00
1.0.07 release
This commit is contained in:
@@ -558,7 +558,7 @@ grub_fat_read_data (grub_disk_t disk, grub_fshelp_node_t node,
|
||||
if (next_cluster >= node->data->cluster_eof_mark)
|
||||
return ret;
|
||||
|
||||
if (next_cluster < 2 || next_cluster >= node->data->num_clusters)
|
||||
if (next_cluster < 2 || (next_cluster - 2) >= node->data->num_clusters)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FS, "invalid cluster %u",
|
||||
next_cluster);
|
||||
@@ -1409,7 +1409,7 @@ int grub_fat_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_i
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (next_cluster < 2 || next_cluster >= node->data->num_clusters)
|
||||
if (next_cluster < 2 || (next_cluster - 2) >= node->data->num_clusters)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FS, "invalid cluster %u", next_cluster);
|
||||
return -1;
|
||||
|
@@ -65,7 +65,7 @@ grub_uint32_t g_ventoy_cpio_size = 0;
|
||||
cpio_newc_header *g_ventoy_initrd_head = NULL;
|
||||
grub_uint8_t *g_ventoy_runtime_buf = NULL;
|
||||
|
||||
ventoy_grub_param g_grub_param;
|
||||
ventoy_grub_param *g_grub_param = NULL;
|
||||
|
||||
ventoy_guid g_ventoy_guid = VENTOY_GUID;
|
||||
|
||||
@@ -1085,6 +1085,8 @@ static grub_err_t ventoy_cmd_img_sector(grub_extcmd_context_t ctxt, int argc, ch
|
||||
|
||||
grub_file_close(file);
|
||||
|
||||
grub_memset(&g_grub_param->file_replace, 0, sizeof(g_grub_param->file_replace));
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
@@ -1109,6 +1111,33 @@ static grub_err_t ventoy_cmd_dump_img_sector(grub_extcmd_context_t ctxt, int arg
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_add_replace_file(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int i;
|
||||
ventoy_grub_param_file_replace *replace = NULL;
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
if (argc >= 2)
|
||||
{
|
||||
replace = &(g_grub_param->file_replace);
|
||||
replace->magic = GRUB_FILE_REPLACE_MAGIC;
|
||||
|
||||
replace->old_name_cnt = 0;
|
||||
for (i = 0; i < 4 && i + 1 < argc; i++)
|
||||
{
|
||||
replace->old_name_cnt++;
|
||||
grub_snprintf(replace->old_file_name[i], sizeof(replace->old_file_name[i]), "%s", args[i + 1]);
|
||||
}
|
||||
|
||||
replace->new_file_virtual_id = (grub_uint32_t)grub_strtoul(args[0], NULL, 10);
|
||||
}
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
grub_file_t ventoy_grub_file_open(enum grub_file_type type, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
@@ -1162,10 +1191,14 @@ static int ventoy_env_init(void)
|
||||
grub_env_set("vtdebug_flag", "");
|
||||
|
||||
ventoy_filt_register(0, ventoy_wrapper_open);
|
||||
|
||||
g_grub_param.grub_env_get = grub_env_get;
|
||||
grub_snprintf(buf, sizeof(buf), "%p", &g_grub_param);
|
||||
grub_env_set("env_param", buf);
|
||||
|
||||
g_grub_param = (ventoy_grub_param *)grub_zalloc(sizeof(ventoy_grub_param));
|
||||
if (g_grub_param)
|
||||
{
|
||||
g_grub_param->grub_env_get = grub_env_get;
|
||||
grub_snprintf(buf, sizeof(buf), "%p", g_grub_param);
|
||||
grub_env_set("env_param", buf);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1204,6 +1237,9 @@ static cmd_para ventoy_cmds[] =
|
||||
{ "vt_windows_reset", ventoy_cmd_wimdows_reset, 0, NULL, "", "", NULL },
|
||||
{ "vt_windows_locate_wim", ventoy_cmd_wimdows_locate_wim, 0, NULL, "", "", NULL },
|
||||
{ "vt_windows_chain_data", ventoy_cmd_windows_chain_data, 0, NULL, "", "", NULL },
|
||||
|
||||
{ "vt_add_replace_file", ventoy_cmd_add_replace_file, 0, NULL, "", "", NULL },
|
||||
|
||||
|
||||
{ "vt_load_plugin", ventoy_cmd_load_plugin, 0, NULL, "", "", NULL },
|
||||
};
|
||||
|
@@ -183,9 +183,22 @@ typedef struct ventoy_img_chunk_list
|
||||
typedef const char * (*grub_env_get_pf)(const char *name);
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
#define GRUB_FILE_REPLACE_MAGIC 0x1258BEEF
|
||||
|
||||
typedef struct ventoy_grub_param_file_replace
|
||||
{
|
||||
grub_uint32_t magic;
|
||||
char old_file_name[4][256];
|
||||
grub_uint32_t old_name_cnt;
|
||||
grub_uint32_t new_file_virtual_id;
|
||||
}ventoy_grub_param_file_replace;
|
||||
|
||||
typedef struct ventoy_grub_param
|
||||
{
|
||||
grub_env_get_pf grub_env_get;
|
||||
|
||||
ventoy_grub_param_file_replace file_replace;
|
||||
}ventoy_grub_param;
|
||||
|
||||
#pragma pack()
|
||||
|
Reference in New Issue
Block a user