mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-08-27 16:01:14 +00:00
update
This commit is contained in:
1551
GRUB2/MOD_SRC/grub-2.04/grub-core/lib/syslinux_parse.c
Normal file
1551
GRUB2/MOD_SRC/grub-2.04/grub-core/lib/syslinux_parse.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2498,6 +2498,49 @@ end:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_file_strstr(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int rc = 1;
|
||||
grub_file_t file;
|
||||
char *buf = NULL;
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s file str \n", cmd_raw_name);
|
||||
}
|
||||
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", args[0]);
|
||||
if (!file)
|
||||
{
|
||||
debug("failed to open file %s\n", args[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
buf = grub_malloc(file->size + 1);
|
||||
if (!buf)
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
|
||||
buf[file->size] = 0;
|
||||
grub_file_read(file, buf, file->size);
|
||||
|
||||
if (grub_strstr(buf, args[1]))
|
||||
{
|
||||
rc = 0;
|
||||
}
|
||||
|
||||
end:
|
||||
|
||||
grub_check_free(buf);
|
||||
grub_file_close(file);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_parse_volume(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int len;
|
||||
@@ -2790,6 +2833,9 @@ static cmd_para ventoy_cmds[] =
|
||||
{ "vt_check_plugin_json", ventoy_cmd_plugin_check_json, 0, NULL, "", "", NULL },
|
||||
|
||||
{ "vt_1st_line", ventoy_cmd_read_1st_line, 0, NULL, "", "", NULL },
|
||||
{ "vt_file_strstr", ventoy_cmd_file_strstr, 0, NULL, "", "", NULL },
|
||||
|
||||
|
||||
{ "vt_parse_iso_volume", ventoy_cmd_parse_volume, 0, NULL, "", "", NULL },
|
||||
{ "vt_parse_iso_create_date", ventoy_cmd_parse_create_date, 0, NULL, "", "", NULL },
|
||||
{ "vt_parse_freenas_ver", ventoy_cmd_parse_freenas_ver, 0, NULL, "", "", NULL },
|
||||
|
@@ -910,6 +910,40 @@ grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc,
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
static int ventoy_cpio_busybox64(cpio_newc_header *head)
|
||||
{
|
||||
char *name;
|
||||
int namelen;
|
||||
int offset;
|
||||
int count = 0;
|
||||
|
||||
name = (char *)(head + 1);
|
||||
while (name[0] && count < 2)
|
||||
{
|
||||
if (grub_strcmp(name, "ventoy/busybox/ash") == 0)
|
||||
{
|
||||
grub_memcpy(name, "ventoy/busybox/32h", 18);
|
||||
count++;
|
||||
}
|
||||
else if (grub_strcmp(name, "ventoy/busybox/64h") == 0)
|
||||
{
|
||||
grub_memcpy(name, "ventoy/busybox/ash", 18);
|
||||
count++;
|
||||
}
|
||||
|
||||
namelen = ventoy_cpio_newc_get_int(head->c_namesize);
|
||||
offset = sizeof(cpio_newc_header) + namelen;
|
||||
offset = ventoy_align(offset, 4);
|
||||
offset += ventoy_cpio_newc_get_int(head->c_filesize);
|
||||
offset = ventoy_align(offset, 4);
|
||||
|
||||
head = (cpio_newc_header *)((char *)head + offset);
|
||||
name = (char *)(head + 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int rc;
|
||||
@@ -934,7 +968,7 @@ grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **arg
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
|
||||
if (argc != 3)
|
||||
if (argc != 4)
|
||||
{
|
||||
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s cpiofile\n", cmd_raw_name);
|
||||
}
|
||||
@@ -1087,6 +1121,12 @@ grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **arg
|
||||
|
||||
grub_file_close(file);
|
||||
|
||||
if (grub_strcmp(args[3], "busybox=64") == 0)
|
||||
{
|
||||
debug("cpio busybox proc %s\n", args[3]);
|
||||
ventoy_cpio_busybox64((cpio_newc_header *)g_ventoy_cpio_buf);
|
||||
}
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user