pull/396/head
longpanda 4 years ago
parent 062f816020
commit 9962775296

@ -114,11 +114,12 @@ static int ventoy_iso_open(const char *path, struct fuse_file_info *file)
return 0;
}
static int ventoy_read_iso_sector(uint32_t sector, uint32_t num, void *buf)
static int ventoy_read_iso_sector(uint32_t sector, uint32_t num, char *buf)
{
uint32_t i = 0;
uint32_t leftSec = 0;
uint32_t readSec = 0;
off_t offset = 0;
dmtable_entry *entry = NULL;
for (i = 0; i < g_disk_entry_num && num > 0; i++)
@ -127,14 +128,15 @@ static int ventoy_read_iso_sector(uint32_t sector, uint32_t num, void *buf)
if (sector >= entry->isoSector && sector < entry->isoSector + entry->sectorNum)
{
lseek(g_disk_fd, (entry->diskSector + (sector - entry->isoSector)) * 512, SEEK_SET);
offset = (entry->diskSector + (sector - entry->isoSector)) * 512;
leftSec = entry->sectorNum - (sector - entry->isoSector);
readSec = (leftSec > num) ? num : leftSec;
read(g_disk_fd, buf, readSec * 512);
pread(g_disk_fd, buf, readSec * 512, offset);
sector += readSec;
buf += readSec * 512;
num -= readSec;
}
}

Binary file not shown.

Binary file not shown.

@ -423,7 +423,6 @@ static grub_err_t
cmd_timeout (const char *line, struct syslinux_menu *menu)
{
menu->timeout = grub_strtoul (line, NULL, 0);
return GRUB_ERR_NONE;
}
@ -991,6 +990,7 @@ write_entry (struct output_buffer *outbuf,
print_string ("\n");
}
print_string ("boot\n");
}
break;
case KERNEL_CHAINLOADER:
@ -1433,6 +1433,7 @@ config_file (struct output_buffer *outbuf,
const char *fname, struct syslinux_menu *parent,
grub_syslinux_flavour_t flav)
{
const char *data;
grub_err_t err;
struct syslinux_menu menu;
struct syslinux_menuentry *curentry, *lentry;
@ -1447,6 +1448,13 @@ config_file (struct output_buffer *outbuf,
menu.filename = fname;
menu.parent = parent;
data = grub_env_get("vtdebug_flag");
if (data && data[0])
{
menu.timeout = 100;
}
err = syslinux_parse_real (&menu);
if (err)
return err;

@ -86,6 +86,9 @@ static int ventoy_debug = 0;
static int ventoy_initrd_called = 0;
static int ventoy_linux_argc = 0;
static char **ventoy_linux_args = NULL;
static int ventoy_extra_initrd_num = 0;
static char *ventoy_extra_initrd_list[256];
static grub_err_t
grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]);
@ -427,8 +430,9 @@ static void ventoy_debug_pause(void)
static int ventoy_preboot(void)
{
int i;
const char *file;
char buf[128];
char *argv[2];
if (ventoy_debug)
{
@ -449,16 +453,28 @@ static int ventoy_preboot(void)
grub_snprintf(buf, sizeof(buf), "mem:%s:size:%s", grub_env_get("ventoy_cpio_addr"), grub_env_get("ventoy_cpio_size"));
argv[0] = buf;
argv[1] = NULL;
grub_cmd_initrd(NULL, 1, argv);
ventoy_extra_initrd_list[ventoy_extra_initrd_num++] = grub_strdup(buf);
file = grub_env_get("vtoy_img_part_file");
if (file)
{
ventoy_extra_initrd_list[ventoy_extra_initrd_num++] = grub_strdup(file);
}
if (ventoy_debug)
{
grub_printf("add initrd %s\n", buf);
grub_printf("========== initrd list ==========\n");
for (i = 0; i < ventoy_extra_initrd_num; i++)
{
grub_printf("%s\n", ventoy_extra_initrd_list[i]);
}
grub_printf("=================================\n");
ventoy_debug_pause();
}
grub_cmd_initrd(NULL, ventoy_extra_initrd_num, ventoy_extra_initrd_list);
return 0;
}
@ -478,6 +494,13 @@ static int ventoy_boot_opt_filter(char *opt)
}
return 0;
}
if (grub_strncmp(opt, "init=", 5) == 0)
{
opt[0] = 'v';
opt[1] = 't';
return 0;
}
if (ventoy_debug)
{
@ -597,7 +620,7 @@ static int ventoy_bootopt_hook(int argc, char *argv[])
if (ventoy_debug)
{
ventoy_linux_args[count++] = grub_strdup("loglevel=10");
ventoy_linux_args[count++] = grub_strdup("loglevel=7");
}
ventoy_linux_argc = count;
@ -663,6 +686,72 @@ grub_cmd_unset_boot_opt (grub_command_t cmd __attribute__ ((unused)),
return 0;
}
static grub_err_t
grub_cmd_extra_initrd_append (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
int newclen = 0;
char *pos = NULL;
char *end = NULL;
char buf[256] = {0};
if (argc != 1)
{
return 1;
}
for (pos = argv[0]; *pos; pos++)
{
if (*pos == '/')
{
end = pos;
}
}
if (end)
{
/* grub2 newc bug workaround */
newclen = (int)grub_strlen(end + 1);
if ((110 + newclen) % 4 == 0)
{
grub_snprintf(buf, sizeof(buf), "newc:.%s:%s", end + 1, argv[0]);
}
else
{
grub_snprintf(buf, sizeof(buf), "newc:%s:%s", end + 1, argv[0]);
}
if (ventoy_extra_initrd_num < 256)
{
ventoy_extra_initrd_list[ventoy_extra_initrd_num++] = grub_strdup(buf);
}
}
return 0;
}
static grub_err_t
grub_cmd_extra_initrd_reset (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
int i;
(void)argc;
(void)argv;
for (i = 0; i < ventoy_extra_initrd_num; i++)
{
if (ventoy_extra_initrd_list[i])
{
grub_free(ventoy_extra_initrd_list[i]);
}
}
grub_memset(ventoy_extra_initrd_list, 0, sizeof(ventoy_extra_initrd_list));
return 0;
}
static grub_err_t
grub_linux_boot (void)
@ -1416,8 +1505,8 @@ ventoy_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
int i;
const char *file;
char buf[64];
char *newargv[32] = {NULL};
if (ventoy_debug) grub_printf("ventoy_cmd_initrd %d\n", ventoy_linux_argc);
@ -1430,19 +1519,37 @@ ventoy_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
if (ventoy_debug) grub_printf("membuf=%s\n", buf);
newargv[0] = buf;
ventoy_extra_initrd_list[ventoy_extra_initrd_num++] = grub_strdup(buf);
file = grub_env_get("vtoy_img_part_file");
if (file)
{
ventoy_extra_initrd_list[ventoy_extra_initrd_num++] = grub_strdup(file);
}
for (i = 0; i < argc; i++)
{
newargv[i + 1] = argv[i];
ventoy_extra_initrd_list[ventoy_extra_initrd_num++] = grub_strdup(argv[i]);
}
ventoy_initrd_called = 1;
if (ventoy_debug)
{
grub_printf("========== initrd list ==========\n");
for (i = 0; i < ventoy_extra_initrd_num; i++)
{
grub_printf("%s\n", ventoy_extra_initrd_list[i]);
}
grub_printf("=================================\n");
}
return grub_cmd_initrd(cmd, argc + 1, newargv);
return grub_cmd_initrd(cmd, ventoy_extra_initrd_num, ventoy_extra_initrd_list);
}
static grub_command_t cmd_linux, cmd_initrd, cmd_linuxefi, cmd_initrdefi, cmd_set_bootopt, cmd_unset_bootopt;
static grub_command_t cmd_linux, cmd_initrd, cmd_linuxefi, cmd_initrdefi;
static grub_command_t cmd_set_bootopt, cmd_unset_bootopt, cmd_extra_initrd_append, cmd_extra_initrd_reset;
GRUB_MOD_INIT(linux)
{
@ -1457,6 +1564,9 @@ GRUB_MOD_INIT(linux)
0, N_("Load initrd."));
cmd_set_bootopt = grub_register_command ("vt_set_boot_opt", grub_cmd_set_boot_opt, 0, N_("set ext boot opt"));
cmd_unset_bootopt = grub_register_command ("vt_unset_boot_opt", grub_cmd_unset_boot_opt, 0, N_("unset ext boot opt"));
cmd_extra_initrd_append = grub_register_command ("vt_img_extra_initrd_append", grub_cmd_extra_initrd_append, 0, N_(""));
cmd_extra_initrd_reset = grub_register_command ("vt_img_extra_initrd_reset", grub_cmd_extra_initrd_reset, 0, N_(""));
ventoy_linux_args = grub_zalloc(sizeof(char *) * LINUX_MAX_ARGC);

@ -54,6 +54,7 @@ int g_valid_initrd_count = 0;
int g_default_menu_mode = 0;
int g_filt_dot_underscore_file = 0;
static grub_file_t g_old_file;
static int g_ventoy_last_entry_back;
char g_iso_path[256];
char g_img_swap_tmp_buf[1024];
@ -92,6 +93,9 @@ static int g_tree_script_pos = 0;
static char *g_list_script_buf = NULL;
static int g_list_script_pos = 0;
static char *g_part_list_buf = NULL;
static int g_part_list_pos = 0;
static const char *g_menu_class[] =
{
"vtoyiso", "vtoywim", "vtoyefi", "vtoyimg"
@ -1812,6 +1816,7 @@ int ventoy_check_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist,
int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start)
{
int fs_type;
int len;
grub_uint32_t i = 0;
grub_uint32_t sector = 0;
grub_uint32_t count = 0;
@ -1856,6 +1861,27 @@ int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, gr
}
}
len = (int)grub_strlen(file->name);
if (grub_strncasecmp(file->name + len - 4, ".img", 4) == 0)
{
for (i = 0; i < chunklist->cur_chunk; i++)
{
count = chunklist->chunk[i].disk_end_sector + 1 - chunklist->chunk[i].disk_start_sector;
if (count < 4)
{
count = 1;
}
else
{
count >>= 2;
}
chunklist->chunk[i].img_start_sector = sector;
chunklist->chunk[i].img_end_sector = sector + count - 1;
sector += count;
}
}
return 0;
}
@ -2498,6 +2524,62 @@ end:
return 0;
}
static int ventoy_img_partition_callback (struct grub_disk *disk, const grub_partition_t partition, void *data)
{
(void)disk;
(void)data;
g_part_list_pos += grub_snprintf(g_part_list_buf + g_part_list_pos, VTOY_MAX_SCRIPT_BUF - g_part_list_pos,
"0 %llu linear /dev/ventoy %llu\n",
(ulonglong)partition->len, (ulonglong)partition->start);
return 0;
}
static grub_err_t ventoy_cmd_img_part_info(grub_extcmd_context_t ctxt, int argc, char **args)
{
char *device_name = NULL;
grub_device_t dev = NULL;
char buf[64];
(void)ctxt;
g_part_list_pos = 0;
grub_env_unset("vtoy_img_part_file");
if (argc != 1)
{
return 1;
}
device_name = grub_file_get_device_name(args[0]);
if (!device_name)
{
debug("ventoy_cmd_img_part_info failed, %s\n", args[0]);
goto end;
}
dev = grub_device_open(device_name);
if (!dev)
{
debug("grub_device_open failed, %s\n", device_name);
goto end;
}
grub_partition_iterate(dev->disk, ventoy_img_partition_callback, NULL);
grub_snprintf(buf, sizeof(buf), "newc:vtoy_dm_table:mem:0x%llx:size:%d", (ulonglong)(ulong)g_part_list_buf, g_part_list_pos);
grub_env_set("vtoy_img_part_file", buf);
end:
check_free(device_name, grub_free);
check_free(dev, grub_device_close);
return 0;
}
static grub_err_t ventoy_cmd_file_strstr(grub_extcmd_context_t ctxt, int argc, char **args)
{
int rc = 1;
@ -2645,6 +2727,108 @@ static grub_err_t ventoy_cmd_img_unhook_root(grub_extcmd_context_t ctxt, int arg
return 0;
}
static grub_err_t ventoy_cmd_push_last_entry(grub_extcmd_context_t ctxt, int argc, char **args)
{
(void)ctxt;
(void)argc;
(void)args;
g_ventoy_last_entry_back = g_ventoy_last_entry;
g_ventoy_last_entry = -1;
return 0;
}
static grub_err_t ventoy_cmd_pop_last_entry(grub_extcmd_context_t ctxt, int argc, char **args)
{
(void)ctxt;
(void)argc;
(void)args;
g_ventoy_last_entry = g_ventoy_last_entry_back;
return 0;
}
static int ventoy_lib_module_callback(const char *filename, const struct grub_dirhook_info *info, void *data)
{
const char *pos = filename + 1;
if (info->dir)
{
while (*pos)
{
if (*pos == '.')
{
if ((*(pos - 1) >= '0' && *(pos - 1) <= '9') && (*(pos + 1) >= '0' && *(pos + 1) <= '9'))
{
grub_strncpy((char *)data, filename, 128);
return 1;
}
}
pos++;
}
}
return 0;
}
static grub_err_t ventoy_cmd_lib_module_ver(grub_extcmd_context_t ctxt, int argc, char **args)
{
int rc = 1;
char *device_name = NULL;
grub_device_t dev = NULL;
grub_fs_t fs = NULL;
char buf[128] = {0};
(void)ctxt;
if (argc != 3)
{
debug("ventoy_cmd_lib_module_ver, invalid param num %d\n", argc);
return 1;
}
debug("ventoy_cmd_lib_module_ver %s %s %s\n", args[0], args[1], args[2]);
device_name = grub_file_get_device_name(args[0]);
if (!device_name)
{
debug("grub_file_get_device_name failed, %s\n", args[0]);
goto end;
}
dev = grub_device_open(device_name);
if (!dev)
{
debug("grub_device_open failed, %s\n", device_name);
goto end;
}
fs = grub_fs_probe(dev);
if (!fs)
{
debug("grub_fs_probe failed, %s\n", device_name);
goto end;
}
fs->fs_dir(dev, args[1], ventoy_lib_module_callback, buf);
if (buf[0])
{
ventoy_set_env(args[2], buf);
}
rc = 0;
end:
check_free(device_name, grub_free);
check_free(dev, grub_device_close);
return rc;
}
grub_uint64_t ventoy_grub_get_file_size(const char *fmt, ...)
{
grub_uint64_t size = 0;
@ -2747,6 +2931,7 @@ static int ventoy_env_init(void)
grub_env_set("vtdebug_flag", "");
g_part_list_buf = grub_malloc(VTOY_PART_BUF_LEN);
g_tree_script_buf = grub_malloc(VTOY_MAX_SCRIPT_BUF);
g_list_script_buf = grub_malloc(VTOY_MAX_SCRIPT_BUF);
@ -2785,6 +2970,9 @@ static cmd_para ventoy_cmds[] =
{ "vt_load_cpio", ventoy_cmd_load_cpio, 0, NULL, "", "", NULL },
{ "vt_trailer_cpio", ventoy_cmd_trailer_cpio, 0, NULL, "", "", NULL },
{ "vt_push_last_entry", ventoy_cmd_push_last_entry, 0, NULL, "", "", NULL },
{ "vt_pop_last_entry", ventoy_cmd_pop_last_entry, 0, NULL, "", "", NULL },
{ "vt_get_lib_module_ver", ventoy_cmd_lib_module_ver, 0, NULL, "", "", NULL },
{ "vt_find_first_bootable_hd", ventoy_cmd_find_bootable_hdd, 0, NULL, "", "", NULL },
{ "vt_dump_menu", ventoy_cmd_dump_menu, 0, NULL, "", "", NULL },
@ -2834,6 +3022,7 @@ static cmd_para ventoy_cmds[] =
{ "vt_1st_line", ventoy_cmd_read_1st_line, 0, NULL, "", "", NULL },
{ "vt_file_strstr", ventoy_cmd_file_strstr, 0, NULL, "", "", NULL },
{ "vt_img_part_info", ventoy_cmd_img_part_info, 0, NULL, "", "", NULL },
{ "vt_parse_iso_volume", ventoy_cmd_parse_volume, 0, NULL, "", "", NULL },

@ -23,6 +23,8 @@
#define VTOY_MAX_SCRIPT_BUF (4 * 1024 * 1024)
#define VTOY_PART_BUF_LEN (128 * 1024)
#define VTOY_FILT_MIN_FILE_SIZE 32768
#define VTOY_SIZE_1GB 1073741824

@ -12,10 +12,10 @@ make install
PATH=$PATH:$VT_DIR/GRUB2/INSTALL/bin/:$VT_DIR/GRUB2/INSTALL/sbin/
net_modules_legacy="net tftp http"
all_modules_legacy="date drivemap blocklist 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"
all_modules_legacy="date drivemap blocklist 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="blocklist ventoy test 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="blocklist ventoy test 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"
if [ "$1" = "uefi" ]; then
all_modules="$net_modules_uefi $all_modules_uefi "

@ -43,6 +43,12 @@ ventoy_os_install_dmsetup() {
# install md-modules
LINE=$($GREP ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list)
if [ $? -eq 0 ]; then
LINTCNT=$($GREP -c ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list)
if [ $LINTCNT -gt 1 ]; then
vtlog "more than one pkgs, need to filter..."
VER=$($BUSYBOX_PATH/uname -r)
LINE=$($GREP ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list | $GREP $VER)
fi
install_udeb_from_line "$LINE" ${vt_usb_disk}
fi
@ -83,6 +89,8 @@ if is_ventoy_hook_finished || not_ventoy_disk "${1:0:-1}"; then
exit 0
fi
vtlog "==== $0 $* ===="
dmsetup_path=$(ventoy_find_bin_path dmsetup)
if [ -z "$dmsetup_path" ]; then
ventoy_os_install_dmsetup "/dev/${1:0:-1}"

@ -64,6 +64,10 @@ ventoy_get_debian_distro() {
echo 'linuxconsole'; return
fi
if $GREP -q 'vyos' /proc/version; then
echo 'vyos'; return
fi
echo 'default'
}

@ -0,0 +1,49 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. /ventoy/hook/ventoy-hook-lib.sh
if is_ventoy_hook_finished; then
exit 0
fi
vtlog "####### $0 $* ########"
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
wait_for_usb_disk_ready
vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "ventoy disk not found"
PATH=$VTPATH_OLD
exit 0
fi
mkdir -p /live/vtoyfuse /live/vtoyiso
modprobe fuse
vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $vtdiskname > $VTOY_PATH/ventoy_dm_table
vtoy_fuse_iso -f $VTOY_PATH/ventoy_dm_table -m /live/vtoyfuse
mount -t iso9660 /live/vtoyfuse/ventoy.iso /live/vtoyiso
PATH=$VTPATH_OLD
set_ventoy_hook_finish

@ -0,0 +1,25 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
if [ -e /init ] && $GREP -q '^mountroot$' /init; then
echo "Here before mountroot ..." >> $VTLOG
$SED "/^mountroot$/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/vyos-disk.sh" -i /init
$SED "/^mountroot$/i\\export LIVE_MEDIA=/live/vtoyiso" -i /init
#$SED "/^mountroot$/i\\exec /ventoy/busybox/sh" -i /init
fi

@ -0,0 +1,48 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. /ventoy/hook/ventoy-hook-lib.sh
vtlog "######### $0 $* ############"
if is_ventoy_hook_finished; then
exit 0
fi
wait_for_usb_disk_ready
vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "ventoy disk not found"
exit 0
fi
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
if [ -n "$1" ]; then
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
vtDM=$(ventoy_find_dm_id ${blkdev_num})
vtlog "ln -s /dev/$vtDM $1"
ln -s /dev/$vtDM "$1"
fi
# OK finish
set_ventoy_hook_finish

@ -0,0 +1,44 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. $VTOY_PATH/hook/ventoy-os-lib.sh
if $GREP -q '^"$mount_handler"' /init; then
echo 'use mount_handler ...' >> $VTLOG
$SED "/^\"\$mount_handler\"/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/hyperbola/ventoy-disk.sh \"\$hyperisodevice\"" -i /init
if [ -f /hooks/parabolaiso ]; then
$SED '/while ! poll_device "${dev}"/a\ if /ventoy/busybox/sh /ventoy/hook/hyperbola/ventoy-timeout.sh ${dev}; then break; fi' -i /hooks/hyperiso
fi
else
# some archlinux initramfs doesn't contain device-mapper udev rules file
ARCH_UDEV_DIR=$(ventoy_get_udev_conf_dir)
if [ -s "$ARCH_UDEV_DIR/13-dm-disk.rules" ]; then
echo 'dm-disk rule exist' >> $VTLOG
else
echo 'Copy dm-disk rule file' >> $VTLOG
$CAT $VTOY_PATH/hook/default/13-dm-disk.rules > "$ARCH_UDEV_DIR/13-dm-disk.rules"
fi
# use default proc
ventoy_systemd_udevd_work_around
ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k"
fi

@ -0,0 +1,36 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. /ventoy/hook/ventoy-hook-lib.sh
vtlog "######### $0 $* ############"
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
vtDM=$(ventoy_find_dm_id ${blkdev_num})
if [ -b /dev/$vtDM ]; then
vtlog "ln -s /dev/$vtDM $1"
ln -s /dev/$vtDM "$1"
exit 0
else
vtlog "Device-mapper not found"
exit 1
fi

@ -436,8 +436,14 @@ ventoy_udev_disk_common_hook() {
VTDISK="${1:0:-1}"
if [ -e /vtoy/vtoy ]; then
VTRWMOD=""
else
VTRWMOD="--readonly"
fi
# create device mapper for iso image file
if create_ventoy_device_mapper "/dev/$VTDISK" --readonly; then
if create_ventoy_device_mapper "/dev/$VTDISK" $VTRWMOD; then
vtlog "==== create ventoy device mapper success ===="
else
vtlog "==== create ventoy device mapper failed ===="
@ -453,7 +459,7 @@ ventoy_udev_disk_common_hook() {
done
fi
if create_ventoy_device_mapper "/dev/$VTDISK" --readonly; then
if create_ventoy_device_mapper "/dev/$VTDISK" $VTRWMOD; then
vtlog "==== create ventoy device mapper success after retry ===="
else
vtlog "==== create ventoy device mapper failed after retry ===="
@ -473,6 +479,24 @@ ventoy_udev_disk_common_hook() {
fi
}
ventoy_create_dev_ventoy_part() {
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | $GREP ventoy | $SED 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
$BUSYBOX_PATH/mknod -m 0666 /dev/ventoy b $blkdev_num
if [ -e /vtoy_dm_table ]; then
vtPartid=1
$CAT /vtoy_dm_table | while read vtline; do
echo $vtline > /ventoy/dm_table_part${vtPartid}
$VTOY_PATH/tool/dmsetup create ventoy${vtPartid} /ventoy/dm_table_part${vtPartid}
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | $GREP ventoy${vtPartid} | $SED 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
$BUSYBOX_PATH/mknod -m 0666 /dev/ventoy${vtPartid} b $blkdev_num
vtPartid=$(expr $vtPartid + 1)
done
fi
}
is_inotify_ventoy_part() {
if echo $1 | $GREP -q "2$"; then

@ -0,0 +1,53 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. /ventoy/hook/ventoy-hook-lib.sh
if is_ventoy_hook_finished; then
exit 0
fi
vtlog "####### $0 $* ########"
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
$BUSYBOX_PATH/insmod $VTOY_PATH/modules/dax.ko
$BUSYBOX_PATH/insmod $VTOY_PATH/modules/dm-mod.ko
wait_for_usb_disk_ready
vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "ventoy disk not found"
PATH=$VTPATH_OLD
exit 0
fi
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
vtDM=$(ventoy_find_dm_id ${blkdev_num})
echo -n $vtDM > /ventoy/vtDM
ventoy_create_dev_ventoy_part
mdev -s
PATH=$VTPATH_OLD
set_ventoy_hook_finish

@ -0,0 +1,32 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. $VTOY_PATH/hook/ventoy-os-lib.sh
$SED "/find drives/i $BUSYBOX_PATH/sh $VTOY_PATH/loop/easyos/ventoy-disk.sh; vtDM=\$(cat /ventoy/vtDM)" -i /init
$SED "1a boot_dev=ventoy1;wkg_dev=ventoy2" -i /init
#check for ssd will read /sys/block/ventoy, will no exist, need a workaround
$SED "s#/sys/block/\${WKG_DRV}/#/sys/block/\$vtDM/#g" -i /init
#skip the resizing process, can't resizing partition
$SED "s#640M#0M#g" -i /init

@ -0,0 +1,50 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. /ventoy/hook/ventoy-hook-lib.sh
if is_ventoy_hook_finished; then
exit 0
fi
vtlog "####### $0 $* ########"
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
wait_for_usb_disk_ready
vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "ventoy disk not found"
PATH=$VTPATH_OLD
exit 0
fi
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
vtDM=$(ventoy_find_dm_id ${blkdev_num})
echo -n $vtDM > /ventoy/vtDM
ventoy_create_dev_ventoy_part
mdev -s
PATH=$VTPATH_OLD
set_ventoy_hook_finish

@ -0,0 +1,30 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. $VTOY_PATH/hook/ventoy-os-lib.sh
$BUSYBOX_PATH/mkdir /sys
$BUSYBOX_PATH/mount -t proc proc /proc
$BUSYBOX_PATH/mount -t sysfs sys /sys
$BUSYBOX_PATH/mdev -s
#$BUSYBOX_PATH/sh $VTOY_PATH/loop/openwrt/ventoy-disk.sh
exec $BUSYBOX_PATH/sh

@ -0,0 +1,46 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. /ventoy/hook/ventoy-hook-lib.sh
if is_ventoy_hook_finished; then
exit 0
fi
vtlog "####### $0 $* ########"
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
wait_for_usb_disk_ready
vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "ventoy disk not found"
PATH=$VTPATH_OLD
exit 0
fi
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
ventoy_create_dev_ventoy_part
mdev -s
PATH=$VTPATH_OLD
set_ventoy_hook_finish

@ -0,0 +1,28 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. $VTOY_PATH/hook/ventoy-os-lib.sh
$SED "/^CMDLINE=/i $BUSYBOX_PATH/sh $VTOY_PATH/loop/volumio/ventoy-disk.sh" -i /init
#skip the resizing process
$SED "/^FREESIZE=/a FREESIZE=0" -i /init
$SED "/exec.*switch_root/i $SED 's@\\\\(.*/boot \\\\)@#\\\\1@' -i /mnt/ext/union/etc/fstab" -i /init

@ -227,6 +227,10 @@ ventoy_get_os_type() {
echo 'vine'; return
fi
if $GREP -q 'hyperbola' /proc/cmdline; then
echo 'hyperbola'; return
fi
echo "default"
}

@ -37,10 +37,30 @@ for i in $vtcmdline; do
fi
done
####################################################################
# #
# Step 2 : Process ko #
# #
####################################################################
$BUSYBOX_PATH/mkdir -p /ventoy/modules
$BUSYBOX_PATH/ls -1a / | $EGREP '\.ko$|\.ko.[gx]z$' | while read vtline; do
if [ "${vtline:0:1}" = "." ]; then
$BUSYBOX_PATH/mv /${vtline} /ventoy/modules/${vtline:1}
else
$BUSYBOX_PATH/mv /${vtline} /ventoy/modules/
fi
done
if [ -e /vtloopex.tar.xz ]; then
echo "extract vtloopex ..." >> $VTLOG
$BUSYBOX_PATH/tar -xJf /vtloopex.tar.xz -C $VTOY_PATH/
$BUSYBOX_PATH/rm -f /vtloopex.tar.xz
fi
####################################################################
# #
# Step 2 : Do OS specific hook #
# Step 3 : Do OS specific hook #
# #
####################################################################
ventoy_get_os_type() {
@ -56,6 +76,22 @@ ventoy_get_os_type() {
echo 'endless'; return
fi
if $GREP -q 'OpenWrt' /proc/version; then
echo 'openwrt'; return
fi
if [ -e /BOOT_SPECS ]; then
if $GREP -q 'easyos' /BOOT_SPECS; then
echo 'easyos'; return
fi
fi
if [ -e /etc/os-release ]; then
if $GREP -q 'volumio' /etc/os-release; then
echo 'volumio'; return
fi
fi
echo "default"
}
@ -68,7 +104,7 @@ fi
####################################################################
# #
# Step 3 : Check for debug break #
# Step 4 : Check for debug break #
# #
####################################################################
if [ "$VTOY_BREAK_LEVEL" = "03" ] || [ "$VTOY_BREAK_LEVEL" = "13" ]; then
@ -85,7 +121,7 @@ fi
####################################################################
# #
# Step 3 : Hand over to real init #
# Step 5 : Hand over to real init #
# #
####################################################################
$BUSYBOX_PATH/umount /proc

@ -0,0 +1,27 @@
#!/bin/bash
VENTOY_PATH=$PWD/../
rm -f vtloopex.cpio
cp -a vtloopex vtloopex_tmp
cd vtloopex_tmp
for dir in $(ls); do
cd $dir
tar -cJf vtloopex.tar.xz vtloopex
rm -rf vtloopex
cd ..
done
find . | cpio -o -H newc>../vtloopex.cpio
cd ..
rm -rf vtloopex_tmp
rm -f $VENTOY_PATH/INSTALL/ventoy/vtloopex.cpio
cp -a vtloopex.cpio $VENTOY_PATH/INSTALL/ventoy/
echo '======== SUCCESS ============='

@ -206,6 +206,11 @@ function distro_specify_initrd_file_phase2 {
if [ -f (loop)/parabola/boot/i686/parabolaiso.img ]; then
vt_linux_specify_initrd_file /parabola/boot/i686/parabolaiso.img
fi
elif [ -f (loop)/hyperbola/boot/x86_64/hyperiso.img ]; then
vt_linux_specify_initrd_file /hyperbola/boot/x86_64/hyperiso.img
if [ -f (loop)/hyperbola/boot/i686/hyperiso.img ]; then
vt_linux_specify_initrd_file /hyperbola/boot/i686/hyperiso.img
fi
elif [ -f (loop)/EFI/BOOT/initrd.img ]; then
#Qubes
vt_linux_specify_initrd_file /EFI/BOOT/initrd.img
@ -230,6 +235,14 @@ function ventoy_get_ghostbsd_ver {
set vt_freebsd_ver=12.x
}
function ventoy_get_furybsd_ver {
if regexp "13\.[0-9]" "$2"; then
set vt_freebsd_ver=13.x
else
set vt_freebsd_ver=12.x
fi
}
function ventoy_get_freenas_ver {
set vt_freebsd_ver=11.x
@ -250,6 +263,8 @@ function ventoy_freebsd_proc {
ventoy_get_ghostbsd_ver $1 ${chosen_path}
elif vt_strstr "$vt_volume_id" "FREENAS"; then
ventoy_get_freenas_ver $1 ${chosen_path}
elif vt_strstr "$vt_volume_id" "FURYBSD"; then
ventoy_get_furybsd_ver $1 ${chosen_path}
elif regexp "^13_[0-9]" "$vt_volume_id"; then
set vt_freebsd_ver=13.x
elif regexp "^12_[0-9]" "$vt_volume_id"; then
@ -307,7 +322,7 @@ function ventoy_freebsd_proc {
fi
unset vt_unix_mod_path
for file in "/COPYRIGHT" "/FreeNAS-MANIFEST" "/version"; do
for file in "/COPYRIGHT" "/FreeNAS-MANIFEST" "/version" "/etc/fstab"; do
if [ -e (loop)${file} ]; then
set vt_unix_mod_path=${file}
break
@ -442,6 +457,8 @@ function uefi_linux_menu_func {
elif [ -d (loop)/EFI/boot/entries ]; then
if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img"
elif [ -f (loop)/hyperbola/boot/x86_64/hyperiso.img ]; then
vt_add_replace_file 0 "EFI\\hyperiso\\hyperiso.img"
fi
elif [ -e (loop)/syslinux/alt0/full.cz ]; then
vt_add_replace_file 0 "EFI\\BOOT\\full.cz"
@ -833,20 +850,125 @@ function efi_unsupport_menuentry {
common_unsupport_menuentry
}
#
#============================================================#
# IMG file boot process #
#============================================================#
#
function ventoy_img_busybox_ver {
set ventoy_busybox_ver=32
function ventoy_img_easyos {
vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
if [ -e (vtimghd,2)/etc/openwrt_release ]; then
if vt_file_strstr (vtimghd,2)/etc/openwrt_release x86_64; then
set ventoy_busybox_ver=64
fi
fi
loopback easysfs (vtimghd,1)/easy.sfs
vt_get_lib_module_ver (easysfs) /lib/modules/ vt_module_ver
if [ -n "$vt_module_ver" ]; then
for mod in "kernel/drivers/md/dm-mod.ko" "kernel/drivers/dax/dax.ko"; do
vt_img_extra_initrd_append (easysfs)/lib/modules/$vt_module_ver/$mod
done
fi
ventoy_debug_pause
#boot image file
vt_set_boot_opt rdinit=/vtoy/vtoy
vt_img_hook_root
syslinux_configfile (vtimghd,1)/syslinux.cfg
vt_img_unhook_root
vt_unset_boot_opt
loopback -d easysfs
}
function ventoy_img_volumio {
vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
ventoy_debug_pause
#boot image file
vt_set_boot_opt rdinit=/vtoy/vtoy imgpart=/dev/ventoy2 bootpart=/dev/ventoy1
vt_img_hook_root
syslinux_configfile (vtimghd,1)/syslinux.cfg
vt_img_unhook_root
vt_unset_boot_opt
}
function ventoy_img_fydeos {
set ventoy_busybox_ver=64
vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
# loopback easysfs (vtimghd,1)/easy.sfs
# vt_get_lib_module_ver (easysfs) /lib/modules/ vt_module_ver
# if [ -n "$vt_module_ver" ]; then
# for mod in "kernel/drivers/md/dm-mod.ko" "kernel/drivers/dax/dax.ko"; do
# vt_img_extra_initrd_append (easysfs)/lib/modules/$vt_module_ver/$mod
# done
# fi
ventoy_debug_pause
#boot image file
vt_set_boot_opt rdinit=/vtoy/vtoy
vt_img_hook_root
set root=(vtimghd,12)
configfile (vtimghd,12)/efi/boot/grub.cfg
#syslinux_configfile (vtimghd,12)/syslinux/syslinux.cfg
vt_img_unhook_root
vt_unset_boot_opt
}
function img_common_menuentry {
set ventoy_busybox_ver=32
vt_chosen_img_path vt_chosen_path vt_chosen_size
if [ -d (vtimghd)/ ]; then
loopback -d vtimghd
fi
loopback vtimghd ${vtoy_iso_part}${vt_chosen_path}
vt_img_sector ${vtoy_iso_part}${vt_chosen_path}
vt_img_part_info (vtimghd)
set vtback_root=$root
ventoy_cli_console
vt_push_last_entry
echo "To be implement"
vt_img_extra_initrd_reset
if [ -e (vtimghd,1)/easy.sfs ]; then
ventoy_img_easyos
elif [ -e (vtimghd,1)/volumio.initrd ]; then
ventoy_img_volumio
elif [ -e (vtimghd,3)/etc/os-release ]; then
if vt_file_strstr (vtimghd,3)/etc/os-release FydeOS; then
ventoy_img_fydeos
fi
else
echo -e "\n This IMG file is NOT supported now. \n"
echo -e " 当前不支持启动此 IMG 文件 \n"
echo -e "\npress ENTER to exit (请按 回车 键返回) ..."
read vtInputKey
fi
set root=$vtback_root
vt_pop_last_entry
ventoy_gui_console
}
function img_unsupport_menuentry {

@ -116,7 +116,7 @@ if [ "$MODE" = "install" ]; then
if parted -v > /dev/null 2>&1; then
PARTTOOL='parted'
else
vterr "parted is not found in the sysstem, Ventoy can't create new partition."
vterr "parted is not found in the system, Ventoy can't create new partition."
exit 1
fi
else
@ -125,7 +125,7 @@ if [ "$MODE" = "install" ]; then
elif fdisk -v >/dev/null 2>&1; then
PARTTOOL='fdisk'
else
vterr "Both parted and fdisk are not found in the sysstem, Ventoy can't create new partition."
vterr "Both parted and fdisk are not found in the system, Ventoy can't create new partition."
exit 1
fi
fi
@ -144,7 +144,7 @@ if [ "$MODE" = "install" ]; then
disk_sector_num=$(cat /sys/block/${DISK#/dev/}/size)
disk_size_gb=$(expr $disk_sector_num / 2097152)
if [ $disk_sector_num -gt 4294967296 ] && [ -z $VTGPT ]; then
if [ $disk_sector_num -gt 4294967296 ] && [ -z "$VTGPT" ]; then
vterr "$DISK is over 2TB size, MBR will not work on it."
exit 1
fi

Binary file not shown.

Binary file not shown.

@ -486,8 +486,8 @@ static int vtoydm_print_linear_table(const char *img_map_file, const char *diskn
{
int i;
int len;
uint32_t disk_sector_num;
uint32_t sector_start;
uint32_t sector_num;
ventoy_img_chunk *chunk = NULL;
chunk = vtoydm_get_img_map_data(img_map_file, &len);
@ -499,16 +499,16 @@ static int vtoydm_print_linear_table(const char *img_map_file, const char *diskn
for (i = 0; i < len / sizeof(ventoy_img_chunk); i++)
{
sector_start = chunk[i].img_start_sector;
sector_num = chunk[i].img_end_sector - chunk[i].img_start_sector + 1;
disk_sector_num = (uint32_t)(chunk[i].disk_end_sector + 1 - chunk[i].disk_start_sector);
/* TBD: to be more flexible */
#if 0
printf("%u %u linear %s %llu\n",
(sector_start << 2), (sector_num << 2),
(sector_start << 2), disk_sector_num,
diskname, (unsigned long long)chunk[i].disk_start_sector);
#else
printf("%u %u linear %s1 %llu\n",
(sector_start << 2), (sector_num << 2),
(sector_start << 2), disk_sector_num,
diskname, (unsigned long long)chunk[i].disk_start_sector - 2048);
#endif
}

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save