mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-06-03 08:28:50 -04:00
1.0.04 release
This commit is contained in:
parent
c72f96312c
commit
790fa744f8
19 changed files with 458 additions and 86 deletions
|
@ -32,6 +32,7 @@
|
|||
#include <grub/script_sh.h>
|
||||
#include <grub/gfxterm.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/env.h>
|
||||
|
||||
/* Time to delay after displaying an error message about a default/fallback
|
||||
entry failing to boot. */
|
||||
|
@ -786,6 +787,36 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
|||
}
|
||||
goto refresh;
|
||||
|
||||
case GRUB_TERM_KEY_F1:
|
||||
menu_fini ();
|
||||
if (grub_env_get("VTOY_MEM_DISK")) {
|
||||
grub_env_unset("VTOY_MEM_DISK");
|
||||
}else {
|
||||
grub_env_set("VTOY_MEM_DISK", grub_env_get("VTOY_MEM_DISK_STR"));
|
||||
}
|
||||
grub_env_set("VTOY_MENU_REFRESH", "1");
|
||||
goto refresh;
|
||||
|
||||
case GRUB_TERM_KEY_F3:
|
||||
menu_fini ();
|
||||
if (grub_env_get("VTOY_ISO_RAW")) {
|
||||
grub_env_unset("VTOY_ISO_RAW");
|
||||
}else {
|
||||
grub_env_set("VTOY_ISO_RAW", grub_env_get("VTOY_ISO_RAW_STR"));
|
||||
}
|
||||
grub_env_set("VTOY_MENU_REFRESH", "1");
|
||||
goto refresh;
|
||||
|
||||
case GRUB_TERM_KEY_F4:
|
||||
menu_fini ();
|
||||
if (grub_env_get("VTOY_ISO_UEFI_DRV")) {
|
||||
grub_env_unset("VTOY_ISO_UEFI_DRV");
|
||||
}else {
|
||||
grub_env_set("VTOY_ISO_UEFI_DRV", grub_env_get("VTOY_ISO_UEFI_DRV_STR"));
|
||||
}
|
||||
grub_env_set("VTOY_MENU_REFRESH", "1");
|
||||
goto refresh;
|
||||
|
||||
default:
|
||||
{
|
||||
int entry;
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
#include <grub/datetime.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/net.h>
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
#include <grub/efi/efi.h>
|
||||
#endif
|
||||
#include <grub/time.h>
|
||||
#include <grub/ventoy.h>
|
||||
#include "ventoy_def.h"
|
||||
|
@ -261,6 +264,84 @@ static grub_err_t ventoy_cmd_incr(grub_extcmd_context_t ctxt, int argc, char **a
|
|||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_file_size(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int rc = 1;
|
||||
char buf[32];
|
||||
grub_file_t file;
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
return rc;
|
||||
}
|
||||
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", args[0]);
|
||||
if (file == NULL)
|
||||
{
|
||||
debug("failed to open file <%s> for udf check\n", args[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
grub_snprintf(buf, sizeof(buf), "%llu", (unsigned long long)file->size);
|
||||
|
||||
grub_env_set(args[1], buf);
|
||||
|
||||
grub_file_close(file);
|
||||
rc = 0;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_load_iso_to_mem(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int rc = 1;
|
||||
char name[32];
|
||||
char value[32];
|
||||
char *buf = NULL;
|
||||
grub_file_t file;
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
return rc;
|
||||
}
|
||||
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", args[0]);
|
||||
if (file == NULL)
|
||||
{
|
||||
debug("failed to open file <%s> for udf check\n", args[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
buf = (char *)grub_efi_allocate_iso_buf(file->size);
|
||||
#else
|
||||
buf = (char *)grub_malloc(file->size);
|
||||
#endif
|
||||
|
||||
grub_file_read(file, buf, file->size);
|
||||
|
||||
grub_snprintf(name, sizeof(name), "%s_addr", args[1]);
|
||||
grub_snprintf(value, sizeof(value), "0x%llx", (unsigned long long)(unsigned long)buf);
|
||||
grub_env_set(name, value);
|
||||
|
||||
grub_snprintf(name, sizeof(name), "%s_size", args[1]);
|
||||
grub_snprintf(value, sizeof(value), "%llu", (unsigned long long)file->size);
|
||||
grub_env_set(name, value);
|
||||
|
||||
grub_file_close(file);
|
||||
rc = 0;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_is_udf(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int i;
|
||||
|
@ -1107,6 +1188,8 @@ static cmd_para ventoy_cmds[] =
|
|||
{ "vt_load_cpio", ventoy_cmd_load_cpio, 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_iso_to_mem", ventoy_cmd_load_iso_to_mem, 0, NULL, "", "", NULL },
|
||||
|
||||
{ "vt_linux_parse_initrd_isolinux", ventoy_cmd_isolinux_initrd_collect, 0, NULL, "{cfgfile}", "", NULL },
|
||||
{ "vt_linux_parse_initrd_grub", ventoy_cmd_grub_initrd_collect, 0, NULL, "{cfgfile}", "", NULL },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue