Merge branch 'ventoy:master' into master

This commit is contained in:
lev741 2025-04-15 14:22:33 +02:00 committed by GitHub
commit 1bf68c97f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
67 changed files with 603 additions and 432 deletions

@ -13,25 +13,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run docker-compose up
run: docker-compose up
- uses: actions/upload-artifact@v3
- name: Run docker compose up
run: docker compose up
- uses: actions/upload-artifact@v4
with:
name: ventoy-windows
path: INSTALL/ventoy-*windows*
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ventoy-linux
path: INSTALL/ventoy-*linux*
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ventoy-livecd
path: INSTALL/ventoy-*livecd*
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: SHA256SUM
path: INSTALL/sha256.txt
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: xxx-build-log
path: DOC/build.log

@ -1,6 +1,11 @@
FROM centos:7
RUN yum -y -q install \
RUN sed -i \
-e 's/^mirrorlist/#mirrorlist/' \
-e 's/^#baseurl/baseurl/' \
-e 's/mirror\.centos\.org/vault.centos.org/' \
/etc/yum.repos.d/*.repo && \
yum -y -q install \
libXpm net-tools bzip2 wget vim gcc gcc-c++ samba dos2unix glibc-devel glibc.i686 glibc-devel.i686 \
mpfr.i686 mpfr-devel.i686 rsync autogen autoconf automake libtool gettext* bison binutils \
flex device-mapper-devel SDL libpciaccess libusb freetype freetype-devel gnu-free-* qemu-* virt-* \

@ -128,11 +128,22 @@ insert_dir (const char *name, struct dir **root,
n->name = grub_strndup (cb, ce - cb);
if (ptr)
{
/*
* Create the substring with the trailing NUL byte
* to be included in the cpio header.
*/
char *tmp_name = grub_strndup (name, ce - name);
if (!tmp_name) {
grub_free (n->name);
grub_free (n);
return grub_errno;
}
grub_dprintf ("linux", "Creating directory %s, %s\n", name, ce);
ptr = make_header (ptr, name, ce - name,
ptr = make_header (ptr, tmp_name, ce - name + 1,
040777, 0);
grub_free (tmp_name);
}
size += ALIGN_UP ((ce - (char *) name)
size += ALIGN_UP ((ce - (char *) name + 1)
+ sizeof (struct newc_head), 4);
*head = n;
cur = n;
@ -183,7 +194,7 @@ grub_initrd_init (int argc, char *argv[],
}
initrd_ctx->size
+= ALIGN_UP (sizeof (struct newc_head)
+ grub_strlen (initrd_ctx->components[i].newc_name),
+ grub_strlen (initrd_ctx->components[i].newc_name) + 1,
4);
initrd_ctx->size += insert_dir (initrd_ctx->components[i].newc_name,
&root, 0);
@ -194,7 +205,7 @@ grub_initrd_init (int argc, char *argv[],
else if (newc)
{
initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
+ sizeof ("TRAILER!!!") - 1, 4);
+ sizeof ("TRAILER!!!"), 4);
free_dir (root);
root = 0;
newc = 0;
@ -217,7 +228,7 @@ grub_initrd_init (int argc, char *argv[],
{
initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4);
initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
+ sizeof ("TRAILER!!!") - 1, 4);
+ sizeof ("TRAILER!!!"), 4);
free_dir (root);
root = 0;
}
@ -269,14 +280,14 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
ptr += insert_dir (initrd_ctx->components[i].newc_name,
&root, ptr);
ptr = make_header (ptr, initrd_ctx->components[i].newc_name,
grub_strlen (initrd_ctx->components[i].newc_name),
grub_strlen (initrd_ctx->components[i].newc_name) + 1,
0100777,
initrd_ctx->components[i].size);
newc = 1;
}
else if (newc)
{
ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1,
ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!"),
0, 0);
free_dir (root);
root = 0;
@ -308,7 +319,7 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
{
grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
ptr += ALIGN_UP_OVERHEAD (cursize, 4);
ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0);
ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!"), 0, 0);
}
free_dir (root);
root = 0;

@ -861,7 +861,8 @@ typedef struct vhd_footer_t
grub_uint8_t savedst; // Saved state
}vhd_footer_t;
#define VDI_IMAGE_FILE_INFO "<<< Oracle VM VirtualBox Disk Image >>>\n"
#define VDI_IMAGE_FILE_INFO "<<< Oracle VM VirtualBox Disk Image >>>\n"
#define VDI_IMAGE_FILE_INFO2 "<<< Oracle VirtualBox Disk Image >>>\n"
/** Image signature. */
#define VDI_IMAGE_SIGNATURE (0xbeda107f)

@ -536,12 +536,25 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
{
grub_file_seek(file, 0);
grub_file_read(file, &vdihdr, sizeof(vdihdr));
if (vdihdr.u32Signature == VDI_IMAGE_SIGNATURE &&
grub_strncmp(vdihdr.szFileInfo, VDI_IMAGE_FILE_INFO, grub_strlen(VDI_IMAGE_FILE_INFO)) == 0)
if (vdihdr.u32Signature == VDI_IMAGE_SIGNATURE)
{
offset = 2 * 1048576;
g_img_trim_head_secnum = offset / 512;
grub_snprintf(type, sizeof(type), "vdi");
if (grub_strncmp(vdihdr.szFileInfo, VDI_IMAGE_FILE_INFO, grub_strlen(VDI_IMAGE_FILE_INFO)) == 0)
{
offset = 2 * 1048576;
g_img_trim_head_secnum = offset / 512;
debug("VDI V1\n");
}
else if (grub_strncmp(vdihdr.szFileInfo, VDI_IMAGE_FILE_INFO2, grub_strlen(VDI_IMAGE_FILE_INFO2)) == 0)
{
offset = 2 * 1048576;
g_img_trim_head_secnum = offset / 512;
debug("VDI V2\n");
}
else
{
debug("invalid file info <%s>\n", vdihdr.szFileInfo);
}
}
else
{
@ -568,7 +581,7 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
if (gpt->MBR.Byte55 != 0x55 || gpt->MBR.ByteAA != 0xAA)
{
grub_env_set(args[1], "unknown");
debug("invalid mbr signature: 0x%x 0x%x\n", gpt->MBR.Byte55, gpt->MBR.ByteAA);
debug("invalid mbr signature: 0x%x 0x%x offset=%d\n", gpt->MBR.Byte55, gpt->MBR.ByteAA, offset);
goto end;
}

@ -0,0 +1,43 @@
#!/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"
PATH=$VTPATH_OLD
set_ventoy_hook_finish

@ -0,0 +1,21 @@
#!/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/>.
#
#************************************************************************************
$SED "/Mount.*cdrom/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/devuan-disk.sh" -i /init

@ -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/>.
#
#************************************************************************************
. /ventoy/hook/ventoy-hook-lib.sh
vtlog "mount ventoy.iso"
mkdir -p /root/cdrom >>$VTLOG 2>&1
mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso /root/cdrom >>$VTLOG 2>&1

@ -0,0 +1,52 @@
#!/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 $* ########"
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
ventoy_run_fuse() {
vtlog "ventoy_run_fuse $*"
mkdir -p $VTOY_PATH/mnt/fuse $VTOY_PATH/mnt/iso
vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_dm_table
vtoy_fuse_iso -f $VTOY_PATH/ventoy_dm_table -m $VTOY_PATH/mnt/fuse
mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso $VTOY_PATH/mnt/iso
}
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_run_fuse $vtdiskname
if [ -f /ventoy/autoinstall ]; then
sh /ventoy/hook/default/auto_install_varexp.sh /ventoy/autoinstall
fi

@ -0,0 +1,27 @@
#!/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/truenas-disk.sh" -i /init
$SED "/^mountroot$/i\\export LIVEMEDIA=/dev/mapper/ventoy" -i /init
$SED "/^mountroot$/i\\export LIVE_MEDIA=/dev/mapper/ventoy" -i /init
$SED "/^mountroot$/i\\export FROMISO=$VTOY_PATH/mnt/fuse/ventoy.iso" -i /init
$SED "/exec *run-init/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/truenas-bottom.sh" -i /init
fi

@ -110,6 +110,14 @@ ventoy_get_debian_distro() {
echo 'pyabr'; return
fi
if [ -e /devuan-logo.txt ]; then
echo 'devuan'; return
fi
if $GREP -q 'truenas' /proc/version; then
echo 'truenas'; return
fi
echo 'default'
}

@ -0,0 +1,75 @@
#!/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"
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 "blkdev_num=$blkdev_num vtDM=$vtDM ..."
while [ -n "Y" ]; do
if [ -b /dev/$vtDM ]; then
break
else
sleep 0.3
fi
done
if [ -n "$1" ]; then
vtlog "ln -s /dev/$vtDM $1"
if [ -e "$1" ]; then
vtlog "$1 already exist"
else
ln -s /dev/$vtDM "$1"
fi
else
vtLABEL=$($BUSYBOX_PATH/blkid /dev/$vtDM | $SED 's/.*LABEL="\([^"]*\)".*/\1/')
vtlog "vtLABEL is $vtLABEL"
if [ -z "$vtLABEL" ]; then
vtLABEL=$($SED "s/.*label=\([^ ]*\)/\1/" /proc/cmdline)
vtlog "vtLABEL is $vtLABEL from cmdline"
fi
if [ -e "/dev/disk/by-label/$vtLABEL" ]; then
vtlog "$1 already exist"
else
ln -s /dev/$vtDM "/dev/disk/by-label/$vtLABEL"
fi
fi
# OK finish
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/>.
#
#************************************************************************************
. $VTOY_PATH/hook/ventoy-os-lib.sh
echo "hook live.init" >> $VTLOG
$SED "1i $BUSYBOX_PATH/sh $VTOY_PATH/hook/ewe/ventoy-disk.sh" -i /lib/tinyramfs/hook.d/live/live.init

@ -26,6 +26,12 @@ if [ -f $VTOY_PATH/autoinstall ]; then
fi
fi
if $GREP -q 'rdinit=/vtoy/vtoy' /proc/cmdline; then
echo "remove rdinit param" >> $VTLOG
echo "ptoptions=+rdinit" >> /linuxrc.config
fi
if $BUSYBOX_PATH/ls $VTOY_PATH | $GREP -q 'ventoy_dud[0-9]'; then
if [ -f /linuxrc.config ]; then
vtKerVer=$($BUSYBOX_PATH/uname -r)

@ -45,8 +45,15 @@ fi
# TinyCore linux distro doesn't contain dmsetup, we use aoe here
sudo modprobe aoe aoe_iflist=lo
if [ -e /sys/module/aoe ]; then
VBLADE_BIN=$(ventoy_get_vblade_bin)
if ! [ -d /lib64 ]; then
vtlog "link lib64"
NEED_UNLIB64=1
ln -s /lib /lib64
fi
VBLADE_BIN=$(ventoy_get_vblade_bin)
sudo nohup $VBLADE_BIN -r -f $VTOY_PATH/ventoy_image_map 9 0 lo "$vtdiskname" > /dev/null &
sleep 2
@ -54,9 +61,14 @@ if [ -e /sys/module/aoe ]; then
vtlog 'Wait for /dev/etherd/e9.0 ....'
sleep 2
done
sudo cp -a /dev/etherd/e9.0 "$vPart"
if [ -n "$NEED_UNLIB64" ]; then
vtlog "unlink lib64"
unlink /lib64
fi
ventoy_find_bin_run rebuildfstab
else
vterr "aoe driver module load failed..."

@ -232,257 +232,6 @@ ventoy_check_dm_module() {
fi
}
ventoy_need_proc_ibt() {
vtKv=$($BUSYBOX_PATH/uname -r)
vtMajor=$(echo $vtKv | $AWK -F. '{print $1}')
vtMinor=$(echo $vtKv | $AWK -F. '{print $2}')
#ibt was supported since linux kernel 5.18
if [ $vtMajor -lt 5 ]; then
$BUSYBOX_PATH/false; return
elif [ $vtMajor -eq 5 ]; then
if [ $vtMajor -lt 18 ]; then
$BUSYBOX_PATH/false; return
fi
fi
if $GREP -q ' ibt=off' /proc/cmdline; then
$BUSYBOX_PATH/false; return
fi
#hardware CPU doesn't support IBT
if $VTOY_PATH/tool/vtoykmod -I; then
:
else
$BUSYBOX_PATH/false; return
fi
#dot.CONFIG not enabled
if $GREP -q ' ibt_restore$' /proc/kallsyms; then
:
else
$BUSYBOX_PATH/false; return
fi
$BUSYBOX_PATH/true
}
ventoy_need_dm_patch() {
if [ "$VTOY_LINUX_REMOUNT" != "01" ]; then
if $GREP -q 'VTOY_LINUX_REMOUNT=1' /proc/cmdline; then
:
else
$BUSYBOX_PATH/false; return
fi
fi
if $GREP -q 'device-mapper' /proc/devices; then
:
else
$BUSYBOX_PATH/false; return
fi
if $GREP -q 'dm_patch' /proc/modules; then
$BUSYBOX_PATH/false; return
fi
vtMajorVer=$($BUSYBOX_PATH/uname -r | $AWK -F. '{print $1}')
vtMinorVer=$($BUSYBOX_PATH/uname -r | $AWK -F. '{print $2}')
if [ $vtMajorVer -lt 3 ]; then
$BUSYBOX_PATH/false; return
elif [ $vtMajorVer -eq 3 -a $vtMinorVer -lt 10 ]; then
$BUSYBOX_PATH/false; return
fi
$BUSYBOX_PATH/true
}
ventoy_dm_patch() {
vtDmPatchDebug=0
vtMType=$($BUSYBOX_PATH/uname -m)
vtlog "######### ventoy_dm_patch ############"
if echo $vtMType | $EGREP -i -q "x86.64|amd64"; then
vtKoName=dm_patch_64.ko
elif echo $vtMType | $EGREP -i -q "i[3-6]86"; then
vtKoName=dm_patch_32.ko
else
vtlog "unsupported machine type $vtMType"
return
fi
if ventoy_need_proc_ibt; then
vtlog "need to proc IBT"
vtKoName=dm_patch_ibt_64.ko
vtIBT='0x8888'
else
vtlog "NO need to proc IBT"
vtIBT='0'
fi
if [ -f $VTOY_PATH/tool/$vtKoName ]; then
vtlog "/ventoy/tool/$vtKoName exist OK"
else
vtlog "/ventoy/tool/$vtKoName NOT exist"
return
fi
$CAT /proc/kallsyms | $BUSYBOX_PATH/sort > $VTOY_PATH/kallsyms
if $GREP -m1 -q 'open_table_device.isra' $VTOY_PATH/kallsyms; then
vtISRA=$($GREP -m1 'open_table_device.isra' $VTOY_PATH/kallsyms | $AWK '{print $3}')
vtLine=$($VTOY_PATH/tool/vtoyksym $vtISRA $VTOY_PATH/kallsyms)
vtlog "get $vtISRA address $vtLine"
else
vtLine=$($VTOY_PATH/tool/vtoyksym dm_get_table_device $VTOY_PATH/kallsyms)
vtlog "get dm_get_table_device address $vtLine"
fi
get_addr=$(echo $vtLine | $AWK '{print $1}')
get_size=$(echo $vtLine | $AWK '{print $2}')
vtLine=$($VTOY_PATH/tool/vtoyksym blkdev_get_by_dev $VTOY_PATH/kallsyms)
vtlog "get blkdev_get_by_dev address $vtLine"
blkdev_get_addr=$(echo $vtLine | $AWK '{print $1}')
vtLine=$($VTOY_PATH/tool/vtoyksym blkdev_put $VTOY_PATH/kallsyms)
vtlog "get blkdev_put address $vtLine"
blkdev_put_addr=$(echo $vtLine | $AWK '{print $1}')
vtLine=$($VTOY_PATH/tool/vtoyksym bdev_open_by_dev $VTOY_PATH/kallsyms)
vtlog "get bdev_open_by_dev address $vtLine"
bdev_open_addr=$(echo $vtLine | $AWK '{print $1}')
vtLine=$($VTOY_PATH/tool/vtoyksym bdev_file_open_by_dev $VTOY_PATH/kallsyms)
vtlog "get bdev_file_open_by_dev address $vtLine"
bdev_file_open_addr=$(echo $vtLine | $AWK '{print $1}')
if $GREP -m1 -q 'close_table_device.isra' $VTOY_PATH/kallsyms; then
vtLine=$($VTOY_PATH/tool/vtoyksym close_table_device.isra $VTOY_PATH/kallsyms)
vtlog "get close_table_device.isra address $vtLine"
else
vtLine=$($VTOY_PATH/tool/vtoyksym dm_put_table_device $VTOY_PATH/kallsyms)
vtlog "get dm_put_table_device address $vtLine"
fi
put_addr=$(echo $vtLine | $AWK '{print $1}')
put_size=$(echo $vtLine | $AWK '{print $2}')
ro_addr=$($GREP ' set_memory_ro$' /proc/kallsyms | $AWK '{print $1}')
rw_addr=$($GREP ' set_memory_rw$' /proc/kallsyms | $AWK '{print $1}')
kprobe_reg_addr=$($GREP ' register_kprobe$' /proc/kallsyms | $AWK '{print $1}')
kprobe_unreg_addr=$($GREP ' unregister_kprobe$' /proc/kallsyms | $AWK '{print $1}')
if [ "$VTOY_DEBUG_LEVEL" = "01" ]; then
vtDmPatchDebug=1
fi
if $GREP -q 'dmpatch_debug' /proc/cmdline; then
vtDmPatchDebug=1
fi
if [ $vtDmPatchDebug -eq 1 ]; then
printk_addr=$($GREP ' printk$' /proc/kallsyms | $AWK '{print $1}')
if [ -z "$printk_addr" ]; then
printk_addr=$($GREP ' _printk$' /proc/kallsyms | $AWK '{print $1}')
fi
vtDebug="-v"
else
printk_addr=0
fi
#printk_addr=$($GREP ' printk$' /proc/kallsyms | $AWK '{print $1}')
#vtDebug="-v"
vtlog get_addr=$get_addr get_size=$get_size
vtlog put_addr=$put_addr put_size=$put_size
vtlog blkdev_get_addr=$blkdev_get_addr blkdev_put_addr=$blkdev_put_addr
vtlog kprobe_reg_addr=$kprobe_reg_addr kprobe_unreg_addr=$kprobe_unreg_addr
vtlog ro_addr=$ro_addr rw_addr=$rw_addr printk_addr=$printk_addr bdev_open_addr=$bdev_open_addr bdev_file_open_addr=$bdev_file_open_addr
if [ "$get_addr" = "0" -o "$put_addr" = "0" ]; then
vtlog "Invalid symbol address"
return
fi
if [ "$ro_addr" = "0" -o "$rw_addr" = "0" ]; then
vtlog "Invalid symbol address"
return
fi
vtKv=$($BUSYBOX_PATH/uname -r)
vtKVMajor=$(echo $vtKv | $AWK -F. '{print $1}')
vtKVMinor=$(echo $vtKv | $AWK -F. '{print $2}')
vtKVSubMinor=$(echo $vtKv | $AWK -F. '{print $3}')
if [ ! -d /lib/modules/$vtKv ]; then
vtlog "No modules directory found"
return
elif [ -d /lib/modules/$vtKv/kernel/fs ]; then
vtModPath=$($FIND /lib/modules/$vtKv/kernel/fs/ -name "*.ko*" | $HEAD -n1)
elif [ -d /lib/modules/$vtKv/kernel ]; then
vtModPath=$($FIND /lib/modules/$vtKv/kernel/ -name "xfs.ko*" | $HEAD -n1)
elif [ -d /lib/modules/$vtKv/initrd ]; then
vtModPath=$($FIND /lib/modules/$vtKv/initrd/ -name "xfs.ko*" | $HEAD -n1)
fi
if [ -z "$vtModPath" ]; then
vtModPath=$($FIND /lib/modules/$vtKv/ -name "*.ko*" | $HEAD -n1)
fi
vtModName=$($BUSYBOX_PATH/basename $vtModPath)
vtlog "template module is $vtModPath $vtModName"
if [ -z "$vtModPath" ]; then
vtlog "No template module found"
return
elif echo $vtModPath | $GREP -q "[.]ko$"; then
$BUSYBOX_PATH/cp -a $vtModPath $VTOY_PATH/$vtModName
elif echo $vtModPath | $GREP -q "[.]ko[.]xz$"; then
$BUSYBOX_PATH/xzcat $vtModPath > $VTOY_PATH/$vtModName
elif echo $vtModPath | $GREP -q "[.]ko[.]gz$"; then
$BUSYBOX_PATH/zcat $vtModPath > $VTOY_PATH/$vtModName
elif echo $vtModPath | $GREP -q "[.]ko[.]zst$"; then
$VTOY_PATH/tool/zstdcat $vtModPath > $VTOY_PATH/$vtModName
else
vtlog "unsupport module type"
return
fi
#step1: modify vermagic/mod crc/relocation
vtlog "$VTOY_PATH/tool/vtoykmod -u $vtKVMajor $vtKVMinor $VTOY_PATH/tool/$vtKoName $VTOY_PATH/$vtModName $vtDebug"
$VTOY_PATH/tool/vtoykmod -u $vtKVMajor $vtKVMinor $VTOY_PATH/tool/$vtKoName $VTOY_PATH/$vtModName $vtDebug >>$VTLOG 2>&1
#step2: fill parameters
vtPgsize=$($VTOY_PATH/tool/vtoyksym -p)
vtPrams="$VTOY_PATH/tool/$vtKoName $vtPgsize 0x$printk_addr 0x$ro_addr 0x$rw_addr $get_addr $get_size $put_addr $put_size 0x$kprobe_reg_addr 0x$kprobe_unreg_addr $vtKVMajor $vtIBT $vtKVMinor $blkdev_get_addr $blkdev_put_addr $vtKVSubMinor $bdev_open_addr $bdev_file_open_addr $vtDebug"
vtlog "$VTOY_PATH/tool/vtoykmod -f $vtPrams"
$VTOY_PATH/tool/vtoykmod -f $vtPrams >>$VTLOG 2>&1
vtlog "insmod $VTOY_PATH/tool/$vtKoName"
$BUSYBOX_PATH/insmod $VTOY_PATH/tool/$vtKoName >>$VTLOG 2>&1
if $GREP -q 'dm_patch' /proc/modules; then
vtlog "dm_patch module OK"
echo "done" > $VTOY_PATH/dm_patch_done
else
vtlog "dm_patch module FAILED"
fi
}
create_ventoy_device_mapper() {
vtlog "create_ventoy_device_mapper $*"
@ -502,28 +251,16 @@ create_ventoy_device_mapper() {
fi
$VTOY_PATH/tool/vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_dm_table
vtLevel1=$($CAT /proc/sys/kernel/printk | $AWK '{print $1}')
vtLevel2=$($CAT /proc/sys/kernel/printk | $AWK '{print $2}')
vtLevel3=$($CAT /proc/sys/kernel/printk | $AWK '{print $3}')
vtLevel4=$($CAT /proc/sys/kernel/printk | $AWK '{print $4}')
if ventoy_need_dm_patch; then
ventoy_dm_patch
#suppress printk message
echo 0 $vtLevel2 0 $vtLevel4 > /proc/sys/kernel/printk
fi
$VTOY_PATH/tool/vtoydm -r -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_raw_table
if [ -z "$2" ]; then
$VT_DM_BIN create ventoy $VTOY_PATH/ventoy_dm_table >>$VTLOG 2>&1
else
$VT_DM_BIN "$2" create ventoy $VTOY_PATH/ventoy_dm_table >>$VTLOG 2>&1
fi
if ventoy_need_dm_patch; then
#recover printk level
echo $vtLevel1 $vtLevel2 $vtLevel3 $vtLevel4 > /proc/sys/kernel/printk
fi
RAWDISKNAME=$($HEAD -n1 $VTOY_PATH/ventoy_raw_table | $AWK '{print $4}')
$VT_DM_BIN create ${RAWDISKNAME#/dev/} $VTOY_PATH/ventoy_raw_table >>$VTLOG 2>&1
}
create_persistent_device_mapper() {
@ -543,24 +280,8 @@ create_persistent_device_mapper() {
vterr "Error: no dm module avaliable"
fi
$VTOY_PATH/tool/vtoydm -p -f $VTOY_PATH/ventoy_persistent_map -d $1 > $VTOY_PATH/persistent_dm_table
vtLevel1=$($CAT /proc/sys/kernel/printk | $AWK '{print $1}')
vtLevel2=$($CAT /proc/sys/kernel/printk | $AWK '{print $2}')
vtLevel3=$($CAT /proc/sys/kernel/printk | $AWK '{print $3}')
vtLevel4=$($CAT /proc/sys/kernel/printk | $AWK '{print $4}')
if [ -f $VTOY_PATH/dm_patch_done ]; then
#suppress printk message
echo 0 $vtLevel2 0 $vtLevel4 > /proc/sys/kernel/printk
fi
$VT_DM_BIN create vtoy_persistent $VTOY_PATH/persistent_dm_table >>$VTLOG 2>&1
if [ -f $VTOY_PATH/dm_patch_done ]; then
#recover printk level
echo $vtLevel1 $vtLevel2 $vtLevel3 $vtLevel4 > /proc/sys/kernel/printk
fi
$VTOY_PATH/tool/vtoydm -p -f $VTOY_PATH/ventoy_persistent_map -d $1 > $VTOY_PATH/persistent_dm_table
$VT_DM_BIN create vtoy_persistent $VTOY_PATH/persistent_dm_table >>$VTLOG 2>&1
}
@ -853,12 +574,7 @@ ventoy_udev_disk_common_hook() {
if [ -f $VTOY_PATH/ventoy_persistent_map ]; then
create_persistent_device_mapper "/dev/$VTDISK"
ventoy_create_persistent_link
fi
if $GREP -q 'dm_patch' /proc/modules; then
vtlog "remove dm_patch module."
$BUSYBOX_PATH/rmmod dm_patch
fi
fi
}
ventoy_create_dev_ventoy_part() {
@ -866,17 +582,7 @@ ventoy_create_dev_ventoy_part() {
$BUSYBOX_PATH/mknod -m 0666 /dev/ventoy b $blkdev_num
if [ -e /vtoy_dm_table ]; then
vtPartid=1
vtLevel1=$($CAT /proc/sys/kernel/printk | $AWK '{print $1}')
vtLevel2=$($CAT /proc/sys/kernel/printk | $AWK '{print $2}')
vtLevel3=$($CAT /proc/sys/kernel/printk | $AWK '{print $3}')
vtLevel4=$($CAT /proc/sys/kernel/printk | $AWK '{print $4}')
if [ -f $VTOY_PATH/dm_patch_done ]; then
#suppress printk message
echo 0 $vtLevel2 0 $vtLevel4 > /proc/sys/kernel/printk
fi
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}
@ -886,11 +592,6 @@ ventoy_create_dev_ventoy_part() {
vtPartid=$(expr $vtPartid + 1)
done
if [ -f $VTOY_PATH/dm_patch_done ]; then
#recover printk level
echo $vtLevel1 $vtLevel2 $vtLevel3 $vtLevel4 > /proc/sys/kernel/printk
fi
fi
}

@ -72,27 +72,29 @@ ventoy_unpack_initramfs() {
for vtx in '1F8B zcat' '1F9E zcat' '425A bzcat' '5D00 lzcat' 'FD37 xzcat' '894C lzopcat' '0221 lz4cat' '28B5 zstdcat' '3037 cat' '4C5A lunzip -c'; do
if [ "${vtx:0:4}" = "${vtmagic:0:4}" ]; then
echo "vtx=$vtx" >> $VTLOG
if [ $vtskip -eq 0 ]; then
if [ "${vtx:5}" = "xzcat" ]; then
rm -f $VTOY_PATH/xzlog
${vtx:5} $vtfile 2> $VTOY_PATH/xzlog | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
if grep -q 'corrupted data' $VTOY_PATH/xzlog; then
echo 'xzcat failed, now try xzminidec...' >> $VTLOG
rm -f $VTOY_PATH/xzlog
cat $vtfile | xzminidec 2> $VTOY_PATH/xzlog | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
echo "vtx=$vtx" >> $VTLOG
if [ $vtskip -ne 0 ]; then
dd if=$vtfile skip=$vtskip iflag=skip_bytes status=none > ${vtfile}.skip
rm -f $vtfile
mv ${vtfile}.skip $vtfile
fi
if grep -q 'limit' $VTOY_PATH/xzlog; then
echo 'xzminidec failed, now try xzcat_musl ...' >> $VTLOG
xzcat_musl $vtfile | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
fi
if [ "${vtx:5}" = "xzcat" ]; then
rm -f $VTOY_PATH/xzlog
${vtx:5} $vtfile 2> $VTOY_PATH/xzlog | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
if grep -q 'corrupted data' $VTOY_PATH/xzlog; then
echo 'xzcat failed, now try xzminidec...' >> $VTLOG
rm -f $VTOY_PATH/xzlog
cat $vtfile | xzminidec 2> $VTOY_PATH/xzlog | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
if grep -q 'limit' $VTOY_PATH/xzlog; then
echo 'xzminidec failed, now try xzcat_musl ...' >> $VTLOG
xzcat_musl $vtfile | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
fi
else
${vtx:5} $vtfile | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
fi
else
dd if=$vtfile skip=$vtskip iflag=skip_bytes status=none | ${vtx:5} | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
fi
${vtx:5} $vtfile | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
fi
break
fi
done

@ -39,35 +39,6 @@ fi
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
ventoy_create_dev_ventoy_part
if ventoy_need_dm_patch; then
vtlog "extract a ko file"
mkdir -p /ventoy/tmpmnt1 /ventoy/tmpmnt2
mount /dev/ventoy1 /ventoy/tmpmnt1
mount /ventoy/tmpmnt1/boot/batocera /ventoy/tmpmnt2
vtKV=$(uname -r)
mkdir -p /lib/modules/$vtKV/kernel/
vtKO=$(find "/ventoy/tmpmnt2/lib/modules/$vtKV/kernel/fs/" -name "*.ko*" | head -n1)
cp -a $vtKO /lib/modules/$vtKV/kernel/
vtlog "vtKV=$vtKV vtKO=$vtKO"
umount /ventoy/tmpmnt2
umount /ventoy/tmpmnt1
vtPartid=1
cat /vtoy_dm_table | while read vtline; do
dmsetup remove ventoy$vtPartid
vtPartid=$(expr $vtPartid + 1)
done
dmsetup remove ventoy
vtlog "Recreate device-mapper"
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
ventoy_create_dev_ventoy_part
fi
PATH=$VTPATH_OLD

@ -384,6 +384,12 @@ ventoy_get_os_type() {
fi
fi
if [ -f /etc/tinyramfs/config ]; then
if $GREP -q 'EWE_ISO' /etc/tinyramfs/config; then
echo "ewe"; return
fi
fi
echo "default"
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -19,16 +19,7 @@ submenu "$VTLANG_CTRL_TEMP_SET" --class=debug_temp_set --class=F5tool {
else
set VTOY_WIN11_BYPASS_NRO=0
fi
}
menuentry "[ $VTOY_LINUX_REMOUNT ] $VTLANG_LINUX_REMOUNT" --class=debug_temp_linux_remount --class=debug_temp_set --class=F5tool \
VTOY_RUN_SET2 {
if [ "$VTOY_LINUX_REMOUNT" = "0" ]; then
set VTOY_LINUX_REMOUNT=1
else
set VTOY_LINUX_REMOUNT=0
fi
}
}
menuentry "[ $VTOY_SECONDARY_BOOT_MENU ] $VTLANG_SECONDARY_BOOT_MENU" --class=debug_temp_second_menu --class=debug_temp_set --class=F5tool \
VTOY_RUN_SET3 {

@ -33,6 +33,21 @@ function ventoy_debug_pause {
fi
}
function ventoy_max_resolution {
#Skip this for VirtualBox
smbios -t 1 -s 0x05 --set=system_product;
if vt_str_casebegin "$system_product" "VirtualBox"; then
return
fi
vt_enum_video_mode
vt_get_video_mode 0 vtCurMode
terminal_output console
set gfxmode=$vtCurMode
terminal_output gfxterm
}
function ventoy_cli_console {
if [ -z "$vtoy_display_mode" ]; then
terminal_output console
@ -403,10 +418,14 @@ function distro_specify_initrd_file_phase2 {
vt_linux_specify_initrd_file /images/pxeboot/initrd.img
elif [ -f (loop)/live/initrd ]; then
vt_linux_specify_initrd_file /live/initrd
elif [ -f (loop)/initramfs-linux.img ]; then
vt_linux_specify_initrd_file /initramfs-linux.img
elif [ -f (loop)/boot/isolinux/initrd.gz ]; then
vt_linux_specify_initrd_file /boot/isolinux/initrd.gz
fi
}
function ventoy_get_ghostbsd_ver {
# fallback to parse version from elf /boot/kernel/kernel
set vt_freebsd_ver=xx
@ -514,6 +533,13 @@ function ventoy_freebsd_proc {
fi
fi
if [ "$vt_freebsd_ver" = "14.x" ]; then
if [ -e (loop)/boot/lua/brand-pfSense.lua ]; then
set vtFreeBsdDistro=pfSense
fi
fi
if [ -n "${vtdebug_flag}" ]; then
echo "This is $vtFreeBsdDistro $vt_freebsd_ver ${vt_freebsd_bit}bit"
fi
@ -620,7 +646,7 @@ function uefi_windows_menu_func {
if [ -n "$vtoy_chain_mem_addr" ]; then
ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
ventoy_cli_console
ventoy_max_resolution
chainloader ${vtoy_path}/ventoy_${VTOY_EFI_ARCH}.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} iso_${ventoy_fs_probe} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
boot
else
@ -662,7 +688,7 @@ function uefi_linux_menu_func {
if [ -d (loop)/pmagic ]; then
vt_linux_specify_initrd_file /pmagic/initrd.img
else
for file in "boot/grub/grub.cfg" "EFI/BOOT/grub.cfg" "EFI/boot/grub.cfg" "efi/boot/grub.cfg" "EFI/BOOT/BOOTX64.conf" "/grub/grub.cfg"; do
for file in "boot/grub/grub.cfg" "EFI/BOOT/grub.cfg" "EFI/boot/grub.cfg" "efi/boot/grub.cfg" "EFI/BOOT/BOOTX64.conf" "/grub/grub.cfg" "EFI/BOOT/grub/grub.cfg"; do
if [ -e (loop)/$file ]; then
vt_linux_parse_initrd_grub file (loop)/$file
fi
@ -2399,7 +2425,7 @@ function mimg_common_menuentry {
#############################################################
#############################################################
set VENTOY_VERSION="1.0.99"
set VENTOY_VERSION="1.1.05"
#ACPI not compatible with Window7/8, so disable by default
set VTOY_PARAM_NO_ACPI=1

@ -626,6 +626,14 @@ else
vtoycli partresize -s $DISK $part2_start
fi
if [ "$PART1_TYPE" = "EE" ]; then
vtinfo "update esp partition attribute"
vtoycli gpt -f $DISK
sync
fi
echo ""
vtinfo "Update Ventoy on $DISK successfully finished."
echo ""

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -19,5 +19,34 @@
"condition": "equal",
"expression": "ukui",
"gui": "gtk3"
},
{
"type": "env",
"name": "DESKTOP_SESSION",
"condition": "equal",
"expression": "cinnamon",
"gui": "gtk3"
},
{
"type": "env",
"name": "DESKTOP_SESSION",
"condition": "equal",
"expression": "gnome",
"gui": "gtk3"
},
{
"type": "env",
"name": "DESKTOP_SESSION",
"condition": "equal",
"expression": "plasma",
"gui": "qt5"
},
{
"type": "env",
"name": "DESKTOP_SESSION",
"condition": "equal",
"expression": "xfce",
"gui": "gtk3"
}
]

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -449,7 +449,6 @@ format_ventoy_disk_gpt() {
mkpart Ventoy ntfs $part1_start_sector $part1_end_sector \
mkpart VTOYEFI fat16 $part2_start_sector $part2_end_sector \
$vt_set_efi_type \
set 2 hidden on \
quit
sync

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -442,7 +442,7 @@ int ventoy_fill_gpt(uint64_t size, uint64_t reserve, int align4k, VTOY_GPT_INFO
ventoy_gen_preudo_uuid(&(Table[1].PartGuid));
Table[1].StartLBA = Table[0].LastLBA + 1;
Table[1].LastLBA = Table[1].StartLBA + VTOYEFI_PART_BYTES / 512 - 1;
Table[1].Attr = 0xC000000000000001ULL;
Table[1].Attr = 0x8000000000000000ULL;
ventoy_fill_gpt_partname(Table[1].Name, "VTOYEFI");
#if 0

@ -727,6 +727,7 @@ static void * ventoy_update_thread(void *data)
MBR_HEAD MBR;
ventoy_disk *disk = NULL;
ventoy_thread_data *thread = (ventoy_thread_data *)data;
VTOY_GPT_INFO *pstGPT = NULL;
vdebug("ventoy_update_thread run ...\n");
@ -790,6 +791,36 @@ static void * ventoy_update_thread(void *data)
vlog("No need to update MBR\n");
}
if (disk->vtoydata.partition_style)
{
pstGPT = (VTOY_GPT_INFO *)malloc(sizeof(VTOY_GPT_INFO));
memset(pstGPT, 0, sizeof(VTOY_GPT_INFO));
offset = lseek(fd, 0, SEEK_SET);
len = read(fd, pstGPT, sizeof(VTOY_GPT_INFO));
vlog("Read GPT table offset:%llu len:%llu ...\n", (_ull)offset, (_ull)len);
if (pstGPT->PartTbl[1].Attr != 0x8000000000000000ULL)
{
vlog("Update EFI part attr from 0x%016llx to 0x%016llx\n",
pstGPT->PartTbl[1].Attr, 0x8000000000000000ULL);
pstGPT->PartTbl[1].Attr = 0x8000000000000000ULL;
pstGPT->Head.PartTblCrc = ventoy_crc32(pstGPT->PartTbl, sizeof(pstGPT->PartTbl));
pstGPT->Head.Crc = 0;
pstGPT->Head.Crc = ventoy_crc32(&(pstGPT->Head), pstGPT->Head.Length);
ventoy_write_gpt_part_table(fd, disk->size_in_byte, pstGPT);
}
else
{
vlog("No need to update EFI part attr\n");
}
free(pstGPT);
}
g_current_progress = PT_SYNC_DATA1;
vlog("fsync data1...\n");

@ -2520,7 +2520,7 @@ int PartitionResizeForVentoy(PHY_DRIVE_INFO *pPhyDrive)
pGPT->PartTbl[1].StartLBA = pGPT->PartTbl[0].LastLBA + 1;
pGPT->PartTbl[1].LastLBA = pGPT->PartTbl[1].StartLBA + VENTOY_EFI_PART_SIZE / 512 - 1;
pGPT->PartTbl[1].Attr = 0xC000000000000001ULL;
pGPT->PartTbl[1].Attr = VENTOY_EFI_PART_ATTR;
memcpy(pGPT->PartTbl[1].Name, L"VTOYEFI", 7 * 2);
//Update CRC
@ -2797,6 +2797,7 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int TryId)
BOOL CleanDisk = FALSE;
BOOL DelEFI = FALSE;
BOOL bWriteBack = TRUE;
BOOL bUpdateEFIAttr = FALSE;
HANDLE hVolume;
HANDLE hDrive;
DWORD Status;
@ -2904,7 +2905,13 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int TryId)
if (pPhyDrive->PartStyle == 1)
{
Log("TryId=%d EFI GPT partition type is 0x%llx", TryId, pPhyDrive->Part2GPTAttr);
PROGRESS_BAR_SET_POS(PT_DEL_ALL_PART);
PROGRESS_BAR_SET_POS(PT_DEL_ALL_PART);
if (pGptInfo->PartTbl[1].Attr != VENTOY_EFI_PART_ATTR)
{
bUpdateEFIAttr = TRUE;
}
if (TryId == 1)
{
@ -2917,8 +2924,8 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int TryId)
}
else if (TryId == 2)
{
Log("Change GPT partition attribute");
if (DISK_ChangeVtoyEFIAttr(pPhyDrive->PhyDrive, StartSector * 512ULL, 0x8000000000000001))
Log("Try2 Change GPT partition attribute to 0x%016llx", VENTOY_EFI_PART_ATTR & 0xFFFFFFFFFFFFFFFEULL);
if (DISK_ChangeVtoyEFIAttr(pPhyDrive->PhyDrive, StartSector * 512ULL, VENTOY_EFI_PART_ATTR & 0xFFFFFFFFFFFFFFFEULL))
{
ChangeAttr = TRUE;
Sleep(2000);
@ -3253,15 +3260,16 @@ End:
DISK_ChangeVtoyEFI2Basic(pPhyDrive->PhyDrive, StartSector * 512);
}
if (pPhyDrive->PartStyle == 1)
{
if (ChangeAttr || ((pPhyDrive->Part2GPTAttr >> 56) != 0xC0))
if (ChangeAttr || bUpdateEFIAttr)
{
Log("Change EFI partition attr %u <0x%llx> to <0x%llx>", ChangeAttr, pPhyDrive->Part2GPTAttr, 0xC000000000000001ULL);
if (DISK_ChangeVtoyEFIAttr(pPhyDrive->PhyDrive, StartSector * 512ULL, 0xC000000000000001ULL))
Log("Change EFI partition attr %u <0x%llx> to <0x%llx>", ChangeAttr, pGptInfo->PartTbl[1].Attr, VENTOY_EFI_PART_ATTR);
if (DISK_ChangeVtoyEFIAttr(pPhyDrive->PhyDrive, StartSector * 512ULL, VENTOY_EFI_PART_ATTR))
{
Log("Change EFI partition attr success");
pPhyDrive->Part2GPTAttr = 0xC000000000000001ULL;
pPhyDrive->Part2GPTAttr = VENTOY_EFI_PART_ATTR;
}
else
{

@ -982,7 +982,7 @@ int VentoyFillGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo)
CoCreateGuid(&(Table[1].PartGuid));
Table[1].StartLBA = Table[0].LastLBA + 1;
Table[1].LastLBA = Table[1].StartLBA + VENTOY_EFI_PART_SIZE / 512 - 1;
Table[1].Attr = 0xC000000000000001ULL;
Table[1].Attr = VENTOY_EFI_PART_ATTR;
memcpy(Table[1].Name, L"VTOYEFI", 7 * 2);
#if 0

@ -34,6 +34,9 @@ typedef enum VTOY_FS
#define FAT32_MAX_LIMIT (32 * 1073741824ULL)
#define VENTOY_EFI_PART_ATTR 0x8000000000000000ULL
#define SIZE_1KB (1024)
#define SIZE_1GB (1024 * 1024 * 1024)
#define SIZE_1TB (1024ULL * 1024ULL * 1024ULL * 1024ULL)

@ -68,6 +68,7 @@ static int verbose = 0;
#define CMD_DUMP_ISO_INFO 3
#define CMD_EXTRACT_ISO_FILE 4
#define CMD_PRINT_EXTRACT_ISO_FILE 5
#define CMD_PRINT_RAW_TABLE 6
static uint64_t g_iso_file_size;
static char g_disk_name[128];
@ -578,6 +579,45 @@ static uint64_t vtoydm_get_part_start(const char *diskname, int part)
return size;
}
static uint64_t vtoydm_get_part_secnum(const char *diskname, int part)
{
int fd;
unsigned long long size = 0;
char diskpath[256] = {0};
char sizebuf[64] = {0};
diskname += 5; /* skip /dev/ */
if (strstr(diskname, "nvme") || strstr(diskname, "mmc") || strstr(diskname, "nbd"))
{
snprintf(diskpath, sizeof(diskpath) - 1, "/sys/class/block/%sp%d/size", diskname, part);
}
else
{
snprintf(diskpath, sizeof(diskpath) - 1, "/sys/class/block/%s%d/size", diskname, part);
}
if (access(diskpath, F_OK) >= 0)
{
debug("get part size from sysfs for %s %d\n", diskname, part);
fd = open(diskpath, O_RDONLY | O_BINARY);
if (fd >= 0)
{
read(fd, sizebuf, sizeof(sizebuf));
size = strtoull(sizebuf, NULL, 10);
close(fd);
return size;
}
}
else
{
debug("%s not exist \n", diskpath);
}
return size;
}
static int vtoydm_vlnk_convert(char *disk, int len, int *part, uint64_t *offset)
{
int rc = 1;
@ -627,6 +667,24 @@ end:
return rc;
}
static int vtoydm_print_raw_linear_table(const char *img_map_file, const char *diskname, int part)
{
uint64_t disk_sector_num;
disk_sector_num = vtoydm_get_part_secnum(diskname, part);
if (strstr(diskname, "nvme") || strstr(diskname, "mmc") || strstr(diskname, "nbd"))
{
printf("0 %lu linear %sp%d 0\n", (unsigned long)disk_sector_num, diskname, part);
}
else
{
printf("0 %lu linear %s%d 0\n", (unsigned long)disk_sector_num, diskname, part);
}
return 0;
}
int vtoydm_main(int argc, char **argv)
{
int ch;
@ -639,7 +697,7 @@ int vtoydm_main(int argc, char **argv)
char filepath[300] = {0};
char outfile[300] = {0};
while ((ch = getopt(argc, argv, "s:l:o:d:f:v::i::p::c::h::e::E::")) != -1)
while ((ch = getopt(argc, argv, "s:l:o:d:f:v::i::p::r::c::h::e::E::")) != -1)
{
if (ch == 'd')
{
@ -653,6 +711,10 @@ int vtoydm_main(int argc, char **argv)
{
cmd = CMD_PRINT_TABLE;
}
else if (ch == 'r')
{
cmd = CMD_PRINT_RAW_TABLE;
}
else if (ch == 'c')
{
cmd = CMD_CREATE_DM;
@ -713,6 +775,10 @@ int vtoydm_main(int argc, char **argv)
{
return vtoydm_print_linear_table(filepath, diskname, part, offset);
}
case CMD_PRINT_RAW_TABLE:
{
return vtoydm_print_raw_linear_table(filepath, diskname, part);
}
case CMD_CREATE_DM:
{
break;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -599,7 +599,7 @@ static int update_part_table(char *disk, UINT64 part2start)
PartTbl[1].StartLBA = PartTbl[0].LastLBA + 1;
PartTbl[1].LastLBA = PartTbl[1].StartLBA + VENTOY_EFI_PART_SIZE / 512 - 1;
PartTbl[1].Attr = 0xC000000000000001ULL;
PartTbl[1].Attr = VENTOY_EFI_PART_ATTR;
PartTbl[1].Name[0] = 'V';
PartTbl[1].Name[1] = 'T';
PartTbl[1].Name[2] = 'O';

@ -21,7 +21,7 @@
#ifndef __VTOYCLI_H__
#define __VTOYCLI_H__
#define VENTOY_EFI_PART_ATTR 0xC000000000000001ULL
#define VENTOY_EFI_PART_ATTR 0x8000000000000000ULL
#define SIZE_1MB (1024 * 1024)
#define VENTOY_EFI_PART_SIZE (32 * SIZE_1MB)

@ -191,23 +191,26 @@ int vtoygpt_main(int argc, char **argv)
Name = pMainGptInfo->PartTbl[1].Name;
if (Name[0] == 'V' && Name[1] == 'T' && Name[2] == 'O' && Name[3] == 'Y')
{
pMainGptInfo->PartTbl[1].Attr = VENTOY_EFI_PART_ATTR;
pMainGptInfo->Head.PartTblCrc = VtoyCrc32(pMainGptInfo->PartTbl, sizeof(pMainGptInfo->PartTbl));
pMainGptInfo->Head.Crc = 0;
pMainGptInfo->Head.Crc = VtoyCrc32(&pMainGptInfo->Head, pMainGptInfo->Head.Length);
if (pMainGptInfo->PartTbl[1].Attr != VENTOY_EFI_PART_ATTR)
{
pMainGptInfo->PartTbl[1].Attr = VENTOY_EFI_PART_ATTR;
pMainGptInfo->Head.PartTblCrc = VtoyCrc32(pMainGptInfo->PartTbl, sizeof(pMainGptInfo->PartTbl));
pMainGptInfo->Head.Crc = 0;
pMainGptInfo->Head.Crc = VtoyCrc32(&pMainGptInfo->Head, pMainGptInfo->Head.Length);
pBackGptInfo->PartTbl[1].Attr = VENTOY_EFI_PART_ATTR;
pBackGptInfo->Head.PartTblCrc = VtoyCrc32(pBackGptInfo->PartTbl, sizeof(pBackGptInfo->PartTbl));
pBackGptInfo->Head.Crc = 0;
pBackGptInfo->Head.Crc = VtoyCrc32(&pBackGptInfo->Head, pBackGptInfo->Head.Length);
pBackGptInfo->PartTbl[1].Attr = VENTOY_EFI_PART_ATTR;
pBackGptInfo->Head.PartTblCrc = VtoyCrc32(pBackGptInfo->PartTbl, sizeof(pBackGptInfo->PartTbl));
pBackGptInfo->Head.Crc = 0;
pBackGptInfo->Head.Crc = VtoyCrc32(&pBackGptInfo->Head, pBackGptInfo->Head.Length);
lseek(fd, 512, SEEK_SET);
write(fd, (UINT8 *)pMainGptInfo + 512, sizeof(VTOY_GPT_INFO) - 512);
lseek(fd, 512, SEEK_SET);
write(fd, (UINT8 *)pMainGptInfo + 512, sizeof(VTOY_GPT_INFO) - 512);
lseek(fd, DiskSize - 33 * 512, SEEK_SET);
write(fd, pBackGptInfo, sizeof(VTOY_BK_GPT_INFO));
lseek(fd, DiskSize - 33 * 512, SEEK_SET);
write(fd, pBackGptInfo, sizeof(VTOY_BK_GPT_INFO));
fsync(fd);
fsync(fd);
}
}
}

@ -244,7 +244,7 @@ int DumpGptInfo(VTOY_GPT_INFO *pGptInfo)
return 0;
}
#define VENTOY_EFI_PART_ATTR 0xC000000000000001ULL
#define VENTOY_EFI_PART_ATTR 0x8000000000000000ULL
int main(int argc, const char **argv)
{
@ -291,23 +291,26 @@ int main(int argc, const char **argv)
Name = pMainGptInfo->PartTbl[1].Name;
if (Name[0] == 'V' && Name[1] == 'T' && Name[2] == 'O' && Name[3] == 'Y')
{
pMainGptInfo->PartTbl[1].Attr = VENTOY_EFI_PART_ATTR;
pMainGptInfo->Head.PartTblCrc = VtoyCrc32(pMainGptInfo->PartTbl, sizeof(pMainGptInfo->PartTbl));
pMainGptInfo->Head.Crc = 0;
pMainGptInfo->Head.Crc = VtoyCrc32(&pMainGptInfo->Head, pMainGptInfo->Head.Length);
if (pMainGptInfo->PartTbl[1].Attr != VENTOY_EFI_PART_ATTR)
{
pMainGptInfo->PartTbl[1].Attr = VENTOY_EFI_PART_ATTR;
pMainGptInfo->Head.PartTblCrc = VtoyCrc32(pMainGptInfo->PartTbl, sizeof(pMainGptInfo->PartTbl));
pMainGptInfo->Head.Crc = 0;
pMainGptInfo->Head.Crc = VtoyCrc32(&pMainGptInfo->Head, pMainGptInfo->Head.Length);
pBackGptInfo->PartTbl[1].Attr = VENTOY_EFI_PART_ATTR;
pBackGptInfo->Head.PartTblCrc = VtoyCrc32(pBackGptInfo->PartTbl, sizeof(pBackGptInfo->PartTbl));
pBackGptInfo->Head.Crc = 0;
pBackGptInfo->Head.Crc = VtoyCrc32(&pBackGptInfo->Head, pBackGptInfo->Head.Length);
pBackGptInfo->PartTbl[1].Attr = VENTOY_EFI_PART_ATTR;
pBackGptInfo->Head.PartTblCrc = VtoyCrc32(pBackGptInfo->PartTbl, sizeof(pBackGptInfo->PartTbl));
pBackGptInfo->Head.Crc = 0;
pBackGptInfo->Head.Crc = VtoyCrc32(&pBackGptInfo->Head, pBackGptInfo->Head.Length);
lseek(fd, 512, SEEK_SET);
write(fd, (UINT8 *)pMainGptInfo + 512, sizeof(VTOY_GPT_INFO) - 512);
lseek(fd, 512, SEEK_SET);
write(fd, (UINT8 *)pMainGptInfo + 512, sizeof(VTOY_GPT_INFO) - 512);
lseek(fd, DiskSize - 33 * 512, SEEK_SET);
write(fd, pBackGptInfo, sizeof(VTOY_BK_GPT_INFO));
lseek(fd, DiskSize - 33 * 512, SEEK_SET);
write(fd, pBackGptInfo, sizeof(VTOY_BK_GPT_INFO));
fsync(fd);
fsync(fd);
}
}
}