Compare commits

..

6 Commits

Author SHA1 Message Date
longpanda
ce6d379564 1.0.25 release 2020-10-21 20:33:15 +08:00
longpanda
40fdfa66b9 Optimization for Linux vDisk boot in Legacy BIOS mode 2020-10-21 17:45:44 +08:00
longpanda
9ddee7394d support different themes for Legacy BIOS mode and UEFI mode 2020-10-21 17:15:31 +08:00
longpanda
c9b316a757 Fix bug for VTOY_DEFAULT_IMAGE in TreeView mode when VTOY_DEFAULT_SEARCH_ROOT was set. 2020-10-21 13:17:29 +08:00
longpanda
1ba23bcdff add image_list plugin 2020-10-21 10:23:58 +08:00
longpanda
6630ab3585 1.0.24 release 2020-10-17 15:56:54 +08:00
16 changed files with 255 additions and 37 deletions

View File

@@ -82,6 +82,8 @@ grub_uint32_t g_ventoy_cpio_size = 0;
cpio_newc_header *g_ventoy_initrd_head = NULL; cpio_newc_header *g_ventoy_initrd_head = NULL;
grub_uint8_t *g_ventoy_runtime_buf = NULL; grub_uint8_t *g_ventoy_runtime_buf = NULL;
int g_plugin_image_list = 0;
ventoy_grub_param *g_grub_param = NULL; ventoy_grub_param *g_grub_param = NULL;
ventoy_guid g_ventoy_guid = VENTOY_GUID; ventoy_guid g_ventoy_guid = VENTOY_GUID;
@@ -1247,7 +1249,16 @@ static int ventoy_colect_img_files(const char *filename, const struct grub_dirho
{ {
return 0; return 0;
} }
if (g_plugin_image_list)
{
grub_snprintf(g_img_swap_tmp_buf, sizeof(g_img_swap_tmp_buf), "%s%s", node->dir, filename);
if (ventoy_plugin_check_image_list(g_img_swap_tmp_buf) == 0)
{
return 0;
}
}
img = grub_zalloc(sizeof(img_info)); img = grub_zalloc(sizeof(img_info));
if (img) if (img)
{ {
@@ -1411,13 +1422,28 @@ static img_info * ventoy_get_min_iso(img_iterator_node *node)
img_info *minimg = NULL; img_info *minimg = NULL;
img_info *img = (img_info *)(node->firstiso); img_info *img = (img_info *)(node->firstiso);
while (img && (img_iterator_node *)(img->parent) == node) if (g_plugin_image_list)
{ {
if (img->select == 0 && (NULL == minimg || ventoy_cmp_img(img, minimg) < 0)) while (img && (img_iterator_node *)(img->parent) == node)
{ {
minimg = img; if (img->select == 0)
{
minimg = img;
break;
}
img = img->next;
}
}
else
{
while (img && (img_iterator_node *)(img->parent) == node)
{
if (img->select == 0 && (NULL == minimg || ventoy_cmp_img(img, minimg) < 0))
{
minimg = img;
}
img = img->next;
} }
img = img->next;
} }
if (minimg) if (minimg)
@@ -1433,13 +1459,28 @@ static img_iterator_node * ventoy_get_min_child(img_iterator_node *node)
img_iterator_node *Minchild = NULL; img_iterator_node *Minchild = NULL;
img_iterator_node *child = node->firstchild; img_iterator_node *child = node->firstchild;
while (child && child->parent == node) if (g_plugin_image_list)
{ {
if (child->select == 0 && (NULL == Minchild || ventoy_cmp_subdir(child->dir, Minchild->dir) < 0)) while (child && child->parent == node)
{ {
Minchild = child; if (child->select == 0)
{
Minchild = child;
break;
}
child = child->next;
}
}
else
{
while (child && child->parent == node)
{
if (child->select == 0 && (NULL == Minchild || ventoy_cmp_subdir(child->dir, Minchild->dir) < 0))
{
Minchild = child;
}
child = child->next;
} }
child = child->next;
} }
if (Minchild) if (Minchild)
@@ -1695,6 +1736,7 @@ static int ventoy_set_default_menu(void)
char *pos = NULL; char *pos = NULL;
char *end = NULL; char *end = NULL;
char *def = NULL; char *def = NULL;
const char *strdata = NULL;
img_info *cur = NULL; img_info *cur = NULL;
img_info *default_node = NULL; img_info *default_node = NULL;
const char *default_image = NULL; const char *default_image = NULL;
@@ -1732,7 +1774,22 @@ static int ventoy_set_default_menu(void)
vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos, "set default=%c", '\''); vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos, "set default=%c", '\'');
pos = def + 1; strdata = ventoy_get_env("VTOY_DEFAULT_SEARCH_ROOT");
if (strdata && strdata[0] == '/')
{
pos = def + grub_strlen(strdata);
if (*pos == '/')
{
pos++;
}
}
else
{
pos = def + 1;
}
pos = def + 1;
while ((end = grub_strchr(pos, '/')) != NULL) while ((end = grub_strchr(pos, '/')) != NULL)
{ {
*end = 0; *end = 0;
@@ -1823,7 +1880,7 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
grub_snprintf(g_iso_path, sizeof(g_iso_path), "%s", args[0]); grub_snprintf(g_iso_path, sizeof(g_iso_path), "%s", args[0]);
strdata = ventoy_get_env("VTOY_DEFAULT_SEARCH_ROOT"); strdata = ventoy_get_env("VTOY_DEFAULT_SEARCH_ROOT");
if (strdata && strdata[0] == '/') if (0 == g_plugin_image_list && strdata && strdata[0] == '/')
{ {
len = grub_snprintf(g_img_iterator_head.dir, sizeof(g_img_iterator_head.dir) - 1, "%s", strdata); len = grub_snprintf(g_img_iterator_head.dir, sizeof(g_img_iterator_head.dir) - 1, "%s", strdata);
if (g_img_iterator_head.dir[len - 1] != '/') if (g_img_iterator_head.dir[len - 1] != '/')
@@ -1867,14 +1924,17 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
node = tmp; node = tmp;
} }
/* sort image list by image name */ /* sort image list by image name if image_list is not set in ventoy.json */
for (cur = g_ventoy_img_list; cur; cur = cur->next) if (0 == g_plugin_image_list)
{ {
for (tail = cur->next; tail; tail = tail->next) for (cur = g_ventoy_img_list; cur; cur = cur->next)
{ {
if (ventoy_cmp_img(cur, tail) > 0) for (tail = cur->next; tail; tail = tail->next)
{ {
ventoy_swap_img(cur, tail); if (ventoy_cmp_img(cur, tail) > 0)
{
ventoy_swap_img(cur, tail);
}
} }
} }
} }

View File

@@ -778,6 +778,14 @@ typedef struct auto_memdisk
struct auto_memdisk *next; struct auto_memdisk *next;
}auto_memdisk; }auto_memdisk;
typedef struct image_list
{
int pathlen;
char isopath[256];
struct image_list *next;
}image_list;
extern int g_ventoy_menu_esc; extern int g_ventoy_menu_esc;
extern int g_ventoy_suppress_esc; extern int g_ventoy_suppress_esc;
extern int g_ventoy_last_entry; extern int g_ventoy_last_entry;
@@ -787,6 +795,7 @@ extern int g_ventoy_iso_uefi_drv;
extern int g_ventoy_case_insensitive; extern int g_ventoy_case_insensitive;
extern grub_uint8_t g_ventoy_chain_type; extern grub_uint8_t g_ventoy_chain_type;
extern int g_vhdboot_enable; extern int g_vhdboot_enable;
extern int g_plugin_image_list;
extern ventoy_gpt_info *g_ventoy_part_info; extern ventoy_gpt_info *g_ventoy_part_info;
#define ventoy_unix_fill_virt(new_data, new_len) \ #define ventoy_unix_fill_virt(new_data, new_len) \
@@ -819,6 +828,7 @@ const char * ventoy_plugin_get_injection(const char *isopath);
const char * ventoy_plugin_get_menu_alias(int type, const char *isopath); const char * ventoy_plugin_get_menu_alias(int type, const char *isopath);
const char * ventoy_plugin_get_menu_class(int type, const char *name); const char * ventoy_plugin_get_menu_class(int type, const char *name);
int ventoy_plugin_check_memdisk(const char *isopath); int ventoy_plugin_check_memdisk(const char *isopath);
int ventoy_plugin_check_image_list(const char *isopath);
int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start); int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
int ventoy_check_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start); int ventoy_check_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
void ventoy_plugin_dump_persistence(void); void ventoy_plugin_dump_persistence(void);

View File

@@ -46,6 +46,7 @@ static menu_alias *g_menu_alias_head = NULL;
static menu_class *g_menu_class_head = NULL; static menu_class *g_menu_class_head = NULL;
static injection_config *g_injection_head = NULL; static injection_config *g_injection_head = NULL;
static auto_memdisk *g_auto_memdisk_head = NULL; static auto_memdisk *g_auto_memdisk_head = NULL;
static image_list *g_image_list_head = NULL;
static int ventoy_plugin_control_check(VTOY_JSON *json, const char *isodisk) static int ventoy_plugin_control_check(VTOY_JSON *json, const char *isodisk)
{ {
@@ -1096,16 +1097,101 @@ static int ventoy_plugin_auto_memdisk_check(VTOY_JSON *json, const char *isodisk
return 0; return 0;
} }
static int ventoy_plugin_image_list_entry(VTOY_JSON *json, const char *isodisk)
{
VTOY_JSON *pNode = NULL;
image_list *node = NULL;
image_list *next = NULL;
(void)isodisk;
if (json->enDataType != JSON_TYPE_ARRAY)
{
debug("Not array %d\n", json->enDataType);
return 0;
}
if (g_image_list_head)
{
for (node = g_image_list_head; node; node = next)
{
next = node->next;
grub_free(node);
}
g_image_list_head = NULL;
}
g_plugin_image_list = 1;
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
{
if (pNode->enDataType == JSON_TYPE_STRING)
{
node = grub_zalloc(sizeof(image_list));
if (node)
{
node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", pNode->unData.pcStrVal);
if (g_image_list_head)
{
node->next = g_image_list_head;
}
g_image_list_head = node;
}
}
}
return 0;
}
static int ventoy_plugin_image_list_check(VTOY_JSON *json, const char *isodisk)
{
VTOY_JSON *pNode = NULL;
if (json->enDataType != JSON_TYPE_ARRAY)
{
grub_printf("Not array %d\n", json->enDataType);
return 1;
}
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
{
if (pNode->enDataType == JSON_TYPE_STRING)
{
grub_printf("<%s> ", pNode->unData.pcStrVal);
if (ventoy_check_file_exist("%s%s", isodisk, pNode->unData.pcStrVal))
{
grub_printf(" [OK]\n");
}
else
{
grub_printf(" [NOT EXIST]\n");
}
}
}
return 0;
}
static plugin_entry g_plugin_entries[] = static plugin_entry g_plugin_entries[] =
{ {
{ "control", ventoy_plugin_control_entry, ventoy_plugin_control_check }, { "control", ventoy_plugin_control_entry, ventoy_plugin_control_check },
{ "theme", ventoy_plugin_theme_entry, ventoy_plugin_theme_check }, { "theme", ventoy_plugin_theme_entry, ventoy_plugin_theme_check },
#ifdef GRUB_MACHINE_EFI
{ "theme_uefi", ventoy_plugin_theme_entry, ventoy_plugin_theme_check },
#else
{ "theme_legacy", ventoy_plugin_theme_entry, ventoy_plugin_theme_check },
#endif
{ "auto_install", ventoy_plugin_auto_install_entry, ventoy_plugin_auto_install_check }, { "auto_install", ventoy_plugin_auto_install_entry, ventoy_plugin_auto_install_check },
{ "persistence", ventoy_plugin_persistence_entry, ventoy_plugin_persistence_check }, { "persistence", ventoy_plugin_persistence_entry, ventoy_plugin_persistence_check },
{ "menu_alias", ventoy_plugin_menualias_entry, ventoy_plugin_menualias_check }, { "menu_alias", ventoy_plugin_menualias_entry, ventoy_plugin_menualias_check },
{ "menu_class", ventoy_plugin_menuclass_entry, ventoy_plugin_menuclass_check }, { "menu_class", ventoy_plugin_menuclass_entry, ventoy_plugin_menuclass_check },
{ "injection", ventoy_plugin_injection_entry, ventoy_plugin_injection_check }, { "injection", ventoy_plugin_injection_entry, ventoy_plugin_injection_check },
{ "auto_memdisk", ventoy_plugin_auto_memdisk_entry, ventoy_plugin_auto_memdisk_check }, { "auto_memdisk", ventoy_plugin_auto_memdisk_entry, ventoy_plugin_auto_memdisk_check },
{ "image_list", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check },
}; };
static int ventoy_parse_plugin_config(VTOY_JSON *json, const char *isodisk) static int ventoy_parse_plugin_config(VTOY_JSON *json, const char *isodisk)
@@ -1472,6 +1558,28 @@ int ventoy_plugin_check_memdisk(const char *isopath)
return 0; return 0;
} }
int ventoy_plugin_check_image_list(const char *isopath)
{
int len;
image_list *node = NULL;
if (!g_image_list_head)
{
return 0;
}
len = (int)grub_strlen(isopath);
for (node = g_image_list_head; node; node = node->next)
{
if (node->pathlen == len && grub_strncmp(isopath, node->isopath, len) == 0)
{
return 1;
}
}
return 0;
}
grub_err_t ventoy_cmd_plugin_check_json(grub_extcmd_context_t ctxt, int argc, char **args) grub_err_t ventoy_cmd_plugin_check_json(grub_extcmd_context_t ctxt, int argc, char **args)
{ {
int i = 0; int i = 0;

View File

@@ -33,12 +33,11 @@ if [ -e /init ] && $GREP -q '^mountroot$' /init; then
fi fi
elif [ -e "$CD_DETECT" ]; then elif [ -e "$CD_DETECT" ]; then
echo "$CD_DETECT exist, now add hook in it..." >> $VTLOG echo "$CD_DETECT exist, now add hook in it..." >> $VTLOG
$SED "1 a $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/disk_mount_hook.sh" -i "$CD_DETECT" $SED "1 a $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/disk_mount_hook.sh" -i "$CD_DETECT"
TITLE_LINE=$($GREP -m1 '^hw-detect.*detect_progress_title' "$CD_DETECT")
if [ $? -eq 0 ]; then if [ -e /bin/list-devices ]; then
echo "add $TITLE_LINE for hook" >> $VTLOG mv /bin/list-devices /bin/list-devices-bk
$SED "1 a$TITLE_LINE" -i "$CD_DETECT" cp -a /ventoy/hook/debian/list-devices /bin/list-devices
fi fi
elif [ -e /init ] && $GREP -q '/start-udev$' /init; then elif [ -e /init ] && $GREP -q '/start-udev$' /init; then
echo "Here use notify ..." >> $VTLOG echo "Here use notify ..." >> $VTLOG

View File

@@ -0,0 +1,9 @@
#! /bin/sh
if [ "$1" = "usb-partition" -a -z "$2" ]; then
if [ -f /ventoy/list-devices-usb-part ]; then
cat /ventoy/list-devices-usb-part
fi
fi
/bin/list-devices-bk $*

View File

@@ -133,15 +133,7 @@ else
vtlog "boot=, or casper, don't mount" vtlog "boot=, or casper, don't mount"
else else
vtlog "No boot param, need to mount" vtlog "No boot param, need to mount"
$BUSYBOX_PATH/mkdir /cdrom echo /dev/$1 > /ventoy/list-devices-usb-part
if [ -b $VTOY_DM_PATH ]; then
vtlog "mount $VTOY_DM_PATH ..."
$BUSYBOX_PATH/mount -t iso9660 $VTOY_DM_PATH /cdrom
else
vtlog "mount /dev/$1 ..."
$BUSYBOX_PATH/mount -t iso9660 /dev/$1 /cdrom
fi
fi fi
fi fi

Binary file not shown.

View File

@@ -19,6 +19,27 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
unset pager unset pager
} }
if [ "$grub_platform" = "pc" ]; then
menuentry 'Check legacy theme plugin configuration' --class=debug_theme_legacy {
set pager=1
vt_check_plugin_json $vt_plugin_path theme_legacy $vtoy_iso_part
echo -e "\npress ENTER to exit ..."
read vtInputKey
unset pager
}
else
menuentry 'Check uefi theme plugin configuration' --class=debug_theme_uefi {
set pager=1
vt_check_plugin_json $vt_plugin_path theme_uefi $vtoy_iso_part
echo -e "\npress ENTER to exit ..."
read vtInputKey
unset pager
}
fi
menuentry 'Check auto install plugin configuration' --class=debug_autoinstall { menuentry 'Check auto install plugin configuration' --class=debug_autoinstall {
set pager=1 set pager=1
vt_check_plugin_json $vt_plugin_path auto_install $vtoy_iso_part vt_check_plugin_json $vt_plugin_path auto_install $vtoy_iso_part
@@ -74,7 +95,16 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
echo -e "\npress ENTER to exit ..." echo -e "\npress ENTER to exit ..."
read vtInputKey read vtInputKey
unset pager unset pager
} }
menuentry 'Check image list plugin configuration' --class=debug_imagelist {
set pager=1
vt_check_plugin_json $vt_plugin_path image_list $vtoy_iso_part
echo -e "\npress ENTER to exit ..."
read vtInputKey
unset pager
}
menuentry 'Return to previous menu [Esc]' --class=vtoyret VTOY_RET { menuentry 'Return to previous menu [Esc]' --class=vtoyret VTOY_RET {
echo 'Return ...' echo 'Return ...'

View File

@@ -1044,12 +1044,12 @@ function vtoyboot_common_func {
ventoy_debug_pause ventoy_debug_pause
if [ -n "$vtoy_chain_mem_addr" ]; then if [ -n "$vtoy_chain_mem_addr" ]; then
ventoy_acpi_param ${vtoy_chain_mem_addr} 512 if [ "$grub_platform" = "pc" ]; then
vt_acpi_param ${vtoy_chain_mem_addr} 512
if [ "$grub_platform" = "pc" ]; then linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} bios80 sector512 mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} sector512 mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
boot boot
else else
ventoy_acpi_param ${vtoy_chain_mem_addr} 512
ventoy_cli_console ventoy_cli_console
chainloader ${vtoy_path}/ventoy_x64.efi sector512 env_param=${ventoy_env_param} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} chainloader ${vtoy_path}/ventoy_x64.efi sector512 env_param=${ventoy_env_param} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
boot boot
@@ -1344,7 +1344,10 @@ function img_unsupport_menuentry {
############################################################# #############################################################
############################################################# #############################################################
set VENTOY_VERSION="1.0.23" set VENTOY_VERSION="1.0.25"
#ACPI not compatible with Window7/8, so disable by default
set VTOY_PARAM_NO_ACPI=1
# Default menu display mode, you can change it as you want. # Default menu display mode, you can change it as you want.
# 0: List mode # 0: List mode

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
int g_debug = 0; int g_debug = 0;
int g_hddmode = 0; int g_hddmode = 0;
int g_bios_disk80 = 0;
char *g_cmdline_copy; char *g_cmdline_copy;
void *g_initrd_addr; void *g_initrd_addr;
size_t g_initrd_len; size_t g_initrd_len;
@@ -697,6 +698,11 @@ int ventoy_boot_vdisk(void *data)
{ {
g_hddmode = 1; g_hddmode = 1;
} }
if (strstr(g_cmdline_copy, "bios80"))
{
g_bios_disk80 = 1;
}
g_chain = (ventoy_chain_head *)g_initrd_addr; g_chain = (ventoy_chain_head *)g_initrd_addr;
g_chunk = (ventoy_img_chunk *)((char *)g_chain + g_chain->img_chunk_offset); g_chunk = (ventoy_img_chunk *)((char *)g_chain + g_chain->img_chunk_offset);

View File

@@ -1425,7 +1425,7 @@ unsigned int ventoy_int13_hook (ventoy_chain_head *chain)
if (g_hddmode) if (g_hddmode)
{ {
natural_drive = num_drives | 0x80; natural_drive = g_bios_disk80 ? 0x80 : (num_drives | 0x80);
} }
else else
{ {

View File

@@ -187,6 +187,7 @@ typedef struct ventoy_sector_flag
extern int g_debug; extern int g_debug;
extern int g_hddmode; extern int g_hddmode;
extern int g_bios_disk80;
extern char *g_cmdline_copy; extern char *g_cmdline_copy;
extern void *g_initrd_addr; extern void *g_initrd_addr;
extern size_t g_initrd_len; extern size_t g_initrd_len;