return 0;
}
-static int ventoy_colect_img_files(const char *filename, const struct grub_dirhook_info *info, void *data)
+static int ventoy_collect_img_files(const char *filename, const struct grub_dirhook_info *info, void *data)
{
//int i = 0;
int type = 0;
{
type = img_type_vtoy;
}
+ else if (len >= 9 && 0 == grub_strcasecmp(filename + len - 5, ".vcfg"))
+ {
+ if (filename[len - 9] == '.' || (len >= 10 && filename[len - 10] == '.'))
+ {
+ grub_snprintf(g_img_swap_tmp_buf, sizeof(g_img_swap_tmp_buf), "%s%s", node->dir, filename);
+ ventoy_plugin_add_custom_boot(g_img_swap_tmp_buf);
+ }
+ return 0;
+ }
else
{
return 0;
for (node = &g_img_iterator_head; node; node = node->next)
{
- fs->fs_dir(dev, node->dir, ventoy_colect_img_files, node);
+ fs->fs_dir(dev, node->dir, ventoy_collect_img_files, node);
}
strdata = ventoy_get_env("VTOY_TREE_VIEW_MENU_STYLE");
return 0;
}
+static grub_err_t ventoy_cmd_check_custom_boot(grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ int ret = 1;
+ const char *vcfg = NULL;
+
+ (void)argc;
+ (void)ctxt;
+
+ vcfg = ventoy_plugin_get_custom_boot(args[0]);
+ if (vcfg)
+ {
+ debug("custom boot <%s>:<%s>\n", args[0], vcfg);
+ grub_env_set(args[1], vcfg);
+ ret = 0;
+ }
+ else
+ {
+ debug("custom boot <%s>:<NOT FOUND>\n", args[0]);
+ }
+
+ grub_errno = 0;
+ return ret;
+}
+
+
static grub_err_t ventoy_cmd_part_exist(grub_extcmd_context_t ctxt, int argc, char **args)
{
int id;
return 0;
}
+static grub_err_t ventoy_cmd_basefile(grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ int i;
+ int len;
+ const char *buf;
+
+ (void)ctxt;
+
+ if (argc != 2)
+ {
+ debug("ventoy_cmd_basefile, invalid param num %d\n", argc);
+ return 1;
+ }
+
+ buf = args[0];
+ len = (int)grub_strlen(buf);
+ for (i = len; i > 0; i--)
+ {
+ if (buf[i - 1] == '/')
+ {
+ grub_env_set(args[1], buf + i);
+ return 0;
+ }
+ }
+
+ grub_env_set(args[1], buf);
+
+ return 0;
+}
+
static grub_err_t ventoy_cmd_enum_video_mode(grub_extcmd_context_t ctxt, int argc, char **args)
{
struct grub_video_mode_info info;
{ "vt_patch_vhdboot", ventoy_cmd_patch_vhdboot, 0, NULL, "", "", NULL },
{ "vt_raw_chain_data", ventoy_cmd_raw_chain_data, 0, NULL, "", "", NULL },
{ "vt_get_vtoy_type", ventoy_cmd_get_vtoy_type, 0, NULL, "", "", NULL },
+ { "vt_check_custom_boot", ventoy_cmd_check_custom_boot, 0, NULL, "", "", NULL },
+ { "vt_dump_custom_boot", ventoy_cmd_dump_custom_boot, 0, NULL, "", "", NULL },
{ "vt_skip_svd", ventoy_cmd_skip_svd, 0, NULL, "", "", NULL },
{ "vt_cpio_busybox64", ventoy_cmd_cpio_busybox_64, 0, NULL, "", "", NULL },
{ "vt_get_fs_label", ventoy_cmd_get_fs_label, 0, NULL, "", "", NULL },
{ "vt_fs_enum_1st_file", ventoy_cmd_fs_enum_1st_file, 0, NULL, "", "", NULL },
{ "vt_file_basename", ventoy_cmd_basename, 0, NULL, "", "", NULL },
+ { "vt_file_basefile", ventoy_cmd_basefile, 0, NULL, "", "", NULL },
{ "vt_enum_video_mode", ventoy_cmd_enum_video_mode, 0, NULL, "", "", NULL },
{ "vt_get_video_mode", ventoy_cmd_get_video_mode, 0, NULL, "", "", NULL },
{ "vt_update_cur_video_mode", vt_cmd_update_cur_video_mode, 0, NULL, "", "", NULL },
struct menu_class *next;
}menu_class;
+#define vtoy_custom_boot_image_file 0
+#define vtoy_custom_boot_directory 1
+
+typedef struct custom_boot
+{
+ int type;
+ int pathlen;
+ char path[256];
+ char cfg[256];
+
+ struct custom_boot *next;
+}custom_boot;
+
#define vtoy_max_replace_file_size (2 * 1024 * 1024)
typedef struct conf_replace
{
int ventoy_check_password(const vtoy_password *pwd, int retry);
int ventoy_gzip_compress(void *mem_in, int mem_in_len, void *mem_out, int mem_out_len);
grub_uint64_t ventoy_get_part1_size(ventoy_gpt_info *gpt);
+int ventoy_plugin_add_custom_boot(const char *vcfgpath);
+const char * ventoy_plugin_get_custom_boot(const char *isopath);
+grub_err_t ventoy_cmd_dump_custom_boot(grub_extcmd_context_t ctxt, int argc, char **args);
#endif /* __VENTOY_DEF_H__ */
static persistence_config *g_persistence_head = NULL;
static menu_alias *g_menu_alias_head = NULL;
static menu_class *g_menu_class_head = NULL;
+static custom_boot *g_custom_boot_head = NULL;
static injection_config *g_injection_head = NULL;
static auto_memdisk *g_auto_memdisk_head = NULL;
static image_list *g_image_list_head = NULL;
return 0;
}
+static int ventoy_plugin_custom_boot_entry(VTOY_JSON *json, const char *isodisk)
+{
+ int type;
+ int len;
+ const char *key = NULL;
+ const char *cfg = NULL;
+ VTOY_JSON *pNode = NULL;
+ custom_boot *tail = NULL;
+ custom_boot *node = NULL;
+ custom_boot *next = NULL;
+
+ (void)isodisk;
+
+ if (json->enDataType != JSON_TYPE_ARRAY)
+ {
+ debug("Not array %d\n", json->enDataType);
+ return 0;
+ }
+
+ if (g_custom_boot_head)
+ {
+ for (node = g_custom_boot_head; node; node = next)
+ {
+ next = node->next;
+ grub_free(node);
+ }
+
+ g_custom_boot_head = NULL;
+ }
+
+ for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
+ {
+ type = vtoy_custom_boot_image_file;
+ key = vtoy_json_get_string_ex(pNode->pstChild, "file");
+ if (!key)
+ {
+ key = vtoy_json_get_string_ex(pNode->pstChild, "dir");
+ type = vtoy_custom_boot_directory;
+ }
+
+ cfg = vtoy_json_get_string_ex(pNode->pstChild, "vcfg");
+ if (key && cfg)
+ {
+ node = grub_zalloc(sizeof(custom_boot));
+ if (node)
+ {
+ node->type = type;
+ node->pathlen = grub_snprintf(node->path, sizeof(node->path), "%s", key);
+ len = (int)grub_snprintf(node->cfg, sizeof(node->cfg), "%s", cfg);
+
+ if (len >= 5 && grub_strncmp(node->cfg + len - 5, ".vcfg", 5) == 0)
+ {
+ if (g_custom_boot_head)
+ {
+ tail->next = node;
+ }
+ else
+ {
+ g_custom_boot_head = node;
+ }
+ tail = node;
+ }
+ else
+ {
+ grub_free(node);
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+static int ventoy_plugin_custom_boot_check(VTOY_JSON *json, const char *isodisk)
+{
+ int type;
+ int len;
+ const char *key = NULL;
+ const char *cfg = NULL;
+ VTOY_JSON *pNode = NULL;
+
+ (void)isodisk;
+
+ if (json->enDataType != JSON_TYPE_ARRAY)
+ {
+ grub_printf("Not array %d\n", json->enDataType);
+ return 1;
+ }
+
+ for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
+ {
+ type = vtoy_custom_boot_image_file;
+ key = vtoy_json_get_string_ex(pNode->pstChild, "file");
+ if (!key)
+ {
+ key = vtoy_json_get_string_ex(pNode->pstChild, "dir");
+ type = vtoy_custom_boot_directory;
+ }
+
+ cfg = vtoy_json_get_string_ex(pNode->pstChild, "vcfg");
+ len = (int)grub_strlen(cfg);
+ if (key && cfg)
+ {
+ if (len < 5 || grub_strncmp(cfg + len - 5, ".vcfg", 5))
+ {
+ grub_printf("<%s> does not have \".vcfg\" suffix\n\n", cfg);
+ }
+ else
+ {
+ grub_printf("%s: <%s>\n", (type == vtoy_custom_boot_directory) ? "dir" : "file", key);
+ grub_printf("vcfg: <%s>\n\n", cfg);
+ }
+ }
+ }
+
+ return 0;
+}
+
static int ventoy_plugin_conf_replace_entry(VTOY_JSON *json, const char *isodisk)
{
const char *isof = NULL;
{ "conf_replace", ventoy_plugin_conf_replace_entry, ventoy_plugin_conf_replace_check },
{ "dud", ventoy_plugin_dud_entry, ventoy_plugin_dud_check },
{ "password", ventoy_plugin_pwd_entry, ventoy_plugin_pwd_check },
+ { "custom_boot", ventoy_plugin_custom_boot_entry, ventoy_plugin_custom_boot_check },
};
static int ventoy_parse_plugin_config(VTOY_JSON *json, const char *isodisk)
return NULL;
}
+int ventoy_plugin_add_custom_boot(const char *vcfgpath)
+{
+ int len;
+ custom_boot *node = NULL;
+
+ node = grub_zalloc(sizeof(custom_boot));
+ if (node)
+ {
+ node->type = vtoy_custom_boot_image_file;
+ node->pathlen = grub_snprintf(node->path, sizeof(node->path), "%s", vcfgpath);
+ grub_snprintf(node->cfg, sizeof(node->cfg), "%s", vcfgpath);
+
+ /* .vcfg */
+ len = node->pathlen - 5;
+ node->path[len] = 0;
+ node->pathlen = len;
+
+ if (g_custom_boot_head)
+ {
+ node->next = g_custom_boot_head;
+ }
+ g_custom_boot_head = node;
+ }
+
+ return 0;
+}
+
+const char * ventoy_plugin_get_custom_boot(const char *isopath)
+{
+ int i;
+ int len;
+ custom_boot *node = NULL;
+
+ if (!g_custom_boot_head)
+ {
+ return NULL;
+ }
+
+ len = (int)grub_strlen(isopath);
+
+ for (node = g_custom_boot_head; node; node = node->next)
+ {
+ if (node->type == vtoy_custom_boot_image_file)
+ {
+ if (node->pathlen == len && grub_strncmp(isopath, node->path, len) == 0)
+ {
+ return node->cfg;
+ }
+ }
+ else
+ {
+ if (node->pathlen < len && isopath[node->pathlen] == '/' &&
+ grub_strncmp(isopath, node->path, node->pathlen) == 0)
+ {
+ for (i = node->pathlen + 1; i < len; i++)
+ {
+ if (isopath[i] == '/')
+ {
+ break;
+ }
+ }
+
+ if (i >= len)
+ {
+ return node->cfg;
+ }
+ }
+ }
+ }
+
+ return NULL;
+}
+
+grub_err_t ventoy_cmd_dump_custom_boot(grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ custom_boot *node = NULL;
+
+ (void)argc;
+ (void)ctxt;
+ (void)args;
+
+ for (node = g_custom_boot_head; node; node = node->next)
+ {
+ grub_printf("[%s] <%s>:<%s>\n", (node->type == vtoy_custom_boot_directory) ? "dir" : "file",
+ node->path, node->cfg);
+ }
+
+ return 0;
+}
+
int ventoy_plugin_check_memdisk(const char *isopath)
{
int len;
all_modules_legacy="setkey date drivemap blocklist regexp newc vga_text ntldr search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio lspci pci ext2 xfs ventoy chain read halt iso9660 linux16 test true sleep reboot echo videotest videoinfo videotest_checksum video_colors video_cirrus video_bochs vga vbe video_fb font video gettext extcmd terminal linux minicmd help configfile tr trig boot biosdisk disk ls tar squash4 password_pbkdf2 all_video png jpeg part_gpt part_msdos fat exfat ntfs loopback gzio normal udf gfxmenu gfxterm gfxterm_background gfxterm_menu"
net_modules_uefi="efinet net tftp http"
-all_modules_uefi="setkey blocklist ventoy test regexp newc search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux relocator jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop efi_uga video_bochs video_cirrus video video_fb gfxterm_background gfxterm_menu"
+all_modules_uefi="setkey blocklist ventoy test true regexp newc search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux relocator jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop efi_uga video_bochs video_cirrus video video_fb gfxterm_background gfxterm_menu"
-all_modules_arm64_uefi="setkey blocklist ventoy test regexp newc search gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop video video_fb gfxterm_background gfxterm_menu"
+all_modules_arm64_uefi="setkey blocklist ventoy test true regexp newc search gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop video video_fb gfxterm_background gfxterm_menu"
if [ "$1" = "uefi" ]; then
fi
}
+function ventoy_vcfg_proc {
+ if vt_check_custom_boot "${1}" vt_vcfg; then
+ set vtoy_chosen_path="${1}"
+ vt_file_basefile "${vtoy_chosen_path}" vtoy_chosen_file
+
+ export vtoy_chosen_path
+ export vtoy_chosen_file
+ ventoy_debug_pause
+ configfile "${vtoy_iso_part}${vt_vcfg}"
+ true
+ else
+ false
+ fi
+}
+
function ventoy_power {
configfile $prefix/power.cfg
}
fi
}
+
function iso_common_menuentry {
unset vt_system_id
unset vt_volume_id
if vt_check_password "${vt_chosen_path}"; then
return
fi
-
+
+ if ventoy_vcfg_proc "${vt_chosen_path}"; then
+ return
+ fi
+
if vt_str_begin "$vt_volume_id" "Avira"; then
vt_skip_svd "${vtoy_iso_part}${vt_chosen_path}"
fi
return
fi
+ if ventoy_vcfg_proc "${vt_chosen_path}"; then
+ return
+ fi
+
if vt_wim_check_bootable "${vtoy_iso_part}${vt_chosen_path}"; then
vt_wim_chain_data "${vtoy_iso_part}${vt_chosen_path}"
else
return
fi
+ if ventoy_vcfg_proc "${vt_chosen_path}"; then
+ return
+ fi
+
vt_concat_efi_iso "${vtoy_iso_part}${vt_chosen_path}" vtoy_iso_buf
ventoy_debug_pause
return
fi
+ if ventoy_vcfg_proc "${vt_chosen_path}"; then
+ return
+ fi
+
vt_patch_vhdboot "$vt_chosen_path"
ventoy_debug_pause
return
fi
+ if ventoy_vcfg_proc "${vt_chosen_path}"; then
+ return
+ fi
+
vtoyboot_common_func "${vtoy_iso_part}${vt_chosen_path}"
}
return
fi
+ if ventoy_vcfg_proc "${vt_chosen_path}"; then
+ return
+ fi
+
if [ -d (vtimghd)/ ]; then
loopback -d vtimghd
fi
#############################################################
#############################################################
-set VENTOY_VERSION="1.0.33"
+set VENTOY_VERSION="1.0.34"
#ACPI not compatible with Window7/8, so disable by default
set VTOY_PARAM_NO_ACPI=1