Skip to content

Commit

Permalink
1.0.05 release
Browse files Browse the repository at this point in the history
1. Add backup thread in vtoyjump.exe
2. New iso support
MXLinux 19.1 (Legacy + UEFI)
KNOPPIX_V8.6-2019-08-08-EN.iso (Legacy)
Puppy Linux, bionicpup64-8.0-uefi.iso (Legacy + UEFI)
tails-amd64-4.5.iso (Legacy)
slax-64bit-9.11.0.iso (Legacy)
Kaspersky Rescue Disk 18 (Legacy + UEFI)
Parted Magic 2018 Bootable ISO (Legacy + UEFI)
veket_20.iso (Legacy)
ZeroShell-3.9.3-X86.iso (Legacy)
SuperGrub2Disk rescatux-0.73.iso (Legacy + UEFI)
Some WinPE iso (Legacy + UEFI)
  • Loading branch information
ventoy committed Apr 14, 2020
1 parent 277b134 commit cd4a5fc
Show file tree
Hide file tree
Showing 17 changed files with 202 additions and 111 deletions.
2 changes: 1 addition & 1 deletion FUSEISO/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fi
export C_INCLUDE_PATH=$LIBFUSE_DIR/include

rm -f $name
gcc -O2 -D_FILE_OFFSET_BITS=64 vtoy_fuse_iso.c -o $name $LIBFUSE_DIR/lib/libfuse.a -lpthread -ldl $opt
gcc -static -O2 -D_FILE_OFFSET_BITS=64 vtoy_fuse_iso.c -o $name $LIBFUSE_DIR/lib/libfuse.a -lpthread -ldl $opt

if [ -e $name ]; then
echo -e "\n############### SUCCESS $name ##################\n"
Expand Down
1 change: 1 addition & 0 deletions GRUB2/grub-2.04/grub-core/ventoy/ventoy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,7 @@ static cmd_para ventoy_cmds[] =
{ "vt_linux_clear_initrd", ventoy_cmd_clear_initrd_list, 0, NULL, "", "", NULL },
{ "vt_linux_dump_initrd", ventoy_cmd_dump_initrd_list, 0, NULL, "", "", NULL },
{ "vt_linux_initrd_count", ventoy_cmd_initrd_count, 0, NULL, "", "", NULL },
{ "vt_linux_valid_initrd_count", ventoy_cmd_valid_initrd_count, 0, NULL, "", "", NULL },
{ "vt_linux_locate_initrd", ventoy_cmd_linux_locate_initrd, 0, NULL, "", "", NULL },
{ "vt_linux_chain_data", ventoy_cmd_linux_chain_data, 0, NULL, "", "", NULL },

Expand Down
1 change: 1 addition & 0 deletions GRUB2/grub-2.04/grub-core/ventoy/ventoy_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ int ventoy_has_efi_eltorito(grub_file_t file, grub_uint32_t sector);
grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_valid_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **args);
int ventoy_cpio_newc_fill_head(void *buf, int filesize, void *filedata, const char *name);
grub_file_t ventoy_grub_file_open(enum grub_file_type type, const char *fmt, ...);
Expand Down
40 changes: 35 additions & 5 deletions GRUB2/grub-2.04/grub-core/ventoy/ventoy_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ grub_err_t ventoy_cmd_specify_initrd_file(grub_extcmd_context_t ctxt, int argc,
grub_strncpy(img->name, args[0], sizeof(img->name));
if (ventoy_find_initrd_by_name(g_initrd_img_list, img->name))
{
debug("%s is already exist\n", args[0]);
grub_free(img);
}
else
Expand Down Expand Up @@ -738,6 +739,23 @@ grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char **
(void)argc;
(void)args;

if (argc == 1)
{
grub_snprintf(buf, sizeof(buf), "%d", g_initrd_img_count);
grub_env_set(args[0], buf);
}

VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}

grub_err_t ventoy_cmd_valid_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args)
{
char buf[32] = {0};

(void)ctxt;
(void)argc;
(void)args;

if (argc == 1)
{
grub_snprintf(buf, sizeof(buf), "%d", g_valid_initrd_count);
Expand All @@ -750,13 +768,19 @@ grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char **
static grub_err_t ventoy_linux_locate_initrd(int filt, int *filtcnt)
{
int data;
int filtbysize = 1;
int sizefilt = 0;
grub_file_t file;
initrd_info *node;

debug("ventoy_linux_locate_initrd %d\n", filt);

g_valid_initrd_count = 0;

if (grub_env_get("INITRD_NO_SIZE_FILT"))
{
filtbysize = 0;
}

for (node = g_initrd_img_list; node; node = node->next)
{
Expand All @@ -769,12 +793,18 @@ static grub_err_t ventoy_linux_locate_initrd(int filt, int *filtcnt)
debug("file <%s> size:%d\n", node->name, (int)file->size);

/* initrd file too small */
if (filt > 0 && file->size <= g_ventoy_cpio_size + 2048)
if (filtbysize
&& (NULL == grub_strstr(node->name, "minirt.gz"))
&& (NULL == grub_strstr(node->name, "initrd.xz"))
)
{
debug("file size too small %d\n", (int)g_ventoy_cpio_size);
grub_file_close(file);
sizefilt++;
continue;
if (filt > 0 && file->size <= g_ventoy_cpio_size + 2048)
{
debug("file size too small %d\n", (int)g_ventoy_cpio_size);
grub_file_close(file);
sizefilt++;
continue;
}
}

if (grub_strcmp(file->fs->name, "iso9660") == 0)
Expand Down
3 changes: 3 additions & 0 deletions IMG/cpio/ventoy/hook/debian/antix-disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ ventoy_os_install_dmsetup() {
fi
}


wait_for_usb_disk_ready

vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "ventoy disk not found"
Expand Down
27 changes: 26 additions & 1 deletion IMG/cpio/ventoy/hook/debian/ventoy-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,36 @@

DISTRO='default'

if [ -e /etc/initrd-release ]; then
if [ -d /KNOPPIX ]; then
DISTRO='knoppix'
elif [ -e /etc/initrd-release ]; then
if $EGREP -q "ID=.*antix|ID=.*mx" /etc/initrd-release; then
DISTRO='antix'
fi
fi

if [ -e /init ]; then
if $GREP -q PUPPYSFS /init; then
if $GREP -q VEKETSFS /init; then
DISTRO='veket'
else
DISTRO='puppy'
fi
fi
fi

if [ -e /etc/os-release ]; then
if $GREP -q 'Tails' /etc/os-release; then
DISTRO='tails'
fi
fi

if [ "$DISTRO"="default" ]; then
if $GREP -q 'slax/' /proc/cmdline; then
DISTRO='slax'
fi
fi


echo "##### distribution = $DISTRO ######" >> $VTLOG
. $VTOY_PATH/hook/debian/${DISTRO}-hook.sh
6 changes: 5 additions & 1 deletion IMG/cpio/ventoy/hook/gentoo/ventoy-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ if [ -d /etc/udev/rules.d ]; then
ventoy_systemd_udevd_work_around
ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k noreplace"
else
$SED "/mdev *-s/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/gentoo/disk_hook.sh" -i /init
if $GREP -q kaspersky /proc/version; then
$SED "/sysresccd_stage1_normal[^(]*$/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/gentoo/disk_hook.sh" -i /init
else
$SED "/mdev *-s/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/gentoo/disk_hook.sh" -i /init
fi
fi
2 changes: 1 addition & 1 deletion IMG/cpio/ventoy/hook/ventoy-hook-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ SED=$BUSYBOX_PATH/sed
SLEEP=$BUSYBOX_PATH/sleep
HEAD=$BUSYBOX_PATH/head
VTOY_DM_PATH=/dev/mapper/ventoy
VTOY_DEBUG_LEVEL=$($BUSYBOX_PATH/hexdump -n 1 -s 430 -e '1/1 "%02x"' $VTOY_PATH/ventoy_os_param)
VTOY_DEBUG_LEVEL=$($BUSYBOX_PATH/hexdump -n 1 -s 450 -e '1/1 "%02x"' $VTOY_PATH/ventoy_os_param)

if [ "$VTOY_DEBUG_LEVEL" = "01" ]; then
if [ -e /dev/console ]; then
Expand Down
73 changes: 47 additions & 26 deletions IMG/cpio/ventoy/init
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# Step 1 : parse kernel debug parameter #
# #
####################################################################
mkdir /proc; mount -t proc proc /proc
[ -d /proc ] || mkdir /proc; mount -t proc proc /proc
vtcmdline=$(cat /proc/cmdline)
vtkerver=$(cat /proc/version)
umount /proc; rm -rf /proc
Expand Down Expand Up @@ -71,9 +71,9 @@ ventoy_unpack_initramfs() {
if [ "${vtx:0:4}" = "${vtmagic:0:4}" ]; then
echo "vtx=$vtx" >> $VTLOG
if [ $vtskip -eq 0 ]; then
${vtx:5} $vtfile | (cpio -idm 2>>$VTLOG; cat > $vttmp)
${vtx:5} $vtfile | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
else
dd if=$vtfile skip=$vtskip iflag=skip_bytes status=none | ${vtx:5} | (cpio -idm 2>>$VTLOG; cat > $vttmp)
dd if=$vtfile skip=$vtskip iflag=skip_bytes status=none | ${vtx:5} | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
fi
break
fi
Expand All @@ -98,36 +98,57 @@ ventoy_unpack_initrd() {
# This export is for busybox cpio command
export EXTRACT_UNSAFE_SYMLINKS=1

for vtfile in $(ls /initrd*); do
#decompress first initrd
vtmagic=$(hexdump -n 2 -e '2/1 "%02X"' $vtfile)

if ventoy_is_initrd_ramdisk; then
ventoy_unpack_initrd $vtfile $vtmagic ${vtfile}_tmp
mv ${vtfile}_tmp $vtfile
break
# special process
need_xzminidec() {
testmagic=$(hexdump -n 2 -e '2/1 "%02X"' /initrd001)
if [ "FD37" = "${testmagic:0:4}" ]; then
if echo $vtkerver | grep -q 'kaspersky'; then
true
elif echo $vtkerver | grep -q 'kiosk.*Gentoo'; then
true
else
false
fi
else
ventoy_unpack_initramfs $vtfile 0 $vtmagic ${vtfile}_tmp
false
fi
}

#only for cpio,cpio,...,initrd sequence, initrd,cpio or initrd,initrd sequence is not supported
while [ -e ${vtfile}_tmp ] && [ $(stat -c '%s' ${vtfile}_tmp) -gt 512 ]; do
mv ${vtfile}_tmp $vtfile
vtdump=$(hexdump -n 512 -e '512/1 "%02X"' $vtfile)
vtmagic=$(echo $vtdump | sed 's/^\(00\)*//')
let vtoffset="(${#vtdump}-${#vtmagic})/2"

if [ -z "$vtmagic" ]; then
echo "terminate with all zero data file" >> $VTLOG
if need_xzminidec; then
echo "use xzminidec" >> $VTLOG
cat /initrd001 | xzminidec | cpio -idmu 2>>$VTLOG
rm -f /initrd001
else
for vtfile in $(ls /initrd*); do
#decompress first initrd
vtmagic=$(hexdump -n 2 -e '2/1 "%02X"' $vtfile)

if ventoy_is_initrd_ramdisk; then
ventoy_unpack_initrd $vtfile $vtmagic ${vtfile}_tmp
mv ${vtfile}_tmp $vtfile
break
else
ventoy_unpack_initramfs $vtfile 0 $vtmagic ${vtfile}_tmp
fi

#only for cpio,cpio,...,initrd sequence, initrd,cpio or initrd,initrd sequence is not supported
while [ -e ${vtfile}_tmp ] && [ $(stat -c '%s' ${vtfile}_tmp) -gt 512 ]; do
mv ${vtfile}_tmp $vtfile
vtdump=$(hexdump -n 512 -e '512/1 "%02X"' $vtfile)
vtmagic=$(echo $vtdump | sed 's/^\(00\)*//')
let vtoffset="(${#vtdump}-${#vtmagic})/2"

if [ -z "$vtmagic" ]; then
echo "terminate with all zero data file" >> $VTLOG
break
fi

ventoy_unpack_initramfs $vtfile $vtoffset ${vtmagic:0:4} ${vtfile}_tmp
done

ventoy_unpack_initramfs $vtfile $vtoffset ${vtmagic:0:4} ${vtfile}_tmp
rm -f $vtfile ${vtfile}_tmp
done

rm -f $vtfile ${vtfile}_tmp
done

fi

#break here for debug
if [ "$VTOY_BREAK_LEVEL" = "02" ] || [ "$VTOY_BREAK_LEVEL" = "12" ]; then
Expand Down
6 changes: 6 additions & 0 deletions IMG/cpio/ventoy/ventoy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ ventoy_get_os_type() {
echo 'slackware'; return
fi

if [ -e /init ]; then
if $GREP -i -q zeroshell /init; then
echo 'zeroshell'; return
fi
fi


echo "default"
}
Expand Down
Binary file modified INSTALL/EFI/BOOT/BOOTX64.EFI
Binary file not shown.
Loading

0 comments on commit cd4a5fc

Please sign in to comment.