mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-09-16 17:11:13 +00:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
fb7008f49a | ||
|
463d0b2004 | ||
|
4707b76bb2 | ||
|
ff0ad76d8d | ||
|
c8b2cca7c2 | ||
|
afbeba7cf5 | ||
|
bb3789f6fc | ||
|
ea8a9e83ab | ||
|
8b9901a6a5 | ||
|
0ac83bffda |
@@ -1,20 +1,36 @@
|
||||
======== Build busybox 1.32 for aarch64 ========
|
||||
|
||||
ARCH=arm64 CROSS_COMPILE=aarch64-linux- make defconfig
|
||||
ARCH=arm64 CROSS_COMPILE=aarch64-linux- make menuconfig
|
||||
----> enable static build
|
||||
----> enable ar
|
||||
----> enable inotifyd
|
||||
|
||||
======== How to build ash/hexdump/xzcat for aarch64 ========
|
||||
#How to get ash.config/hexdump.cofig/xzcat.config
|
||||
#ARCH=arm64 CROSS_COMPILE=aarch64-linux- make allnoconfig
|
||||
#ARCH=arm64 CROSS_COMPILE=aarch64-linux- make menuconfig
|
||||
#----> enable static build
|
||||
#----> enable xzcat
|
||||
#get aarch64_xzcat.config
|
||||
|
||||
tar xf busybox-1.32.0.tar.bz2
|
||||
cd busybox-1.32.0
|
||||
copy aarch64_xzcat.config as .config
|
||||
ARCH=arm64 CROSS_COMPILE=aarch64-linux- make
|
||||
rename ./busybox to xzcat
|
||||
|
||||
|
||||
|
||||
|
||||
ARCH=arm64 CROSS_COMPILE=aarch64-linux- make allnoconfig
|
||||
======== How to build ash/hexdump/xzcat for x86_64 ==========
|
||||
#How to get ash.config/hexdump.cofig/xzcat.config
|
||||
#make allnoconfig
|
||||
#make menuconfig
|
||||
#----> enable static build
|
||||
#----> enable xzcat
|
||||
#get x86_64_xzcat.config
|
||||
|
||||
|
||||
======== use mini-native-x86_64 uclibc to build ash/hexdump/busybox for x86_64 ==========
|
||||
tar xf busybox-1.32.0.tar.bz2
|
||||
cd busybox-1.32.0
|
||||
copy x86_64_xzcat.config as .config
|
||||
modify Makefile
|
||||
CC = gcc -specs "/usr/local/musl/lib/musl-gcc.specs"
|
||||
MODFLAGS = -DMODULE -specs "/usr/local/musl/lib/musl-gcc.specs"
|
||||
make
|
||||
rename ./busybox to xzcat
|
||||
|
||||
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
DSTDIR=../../IMG/cpio/ventoy/busybox
|
||||
|
||||
rm -f vtchmod32 vtchmod64 vtchmodaa64
|
||||
rm -f vtchmod32 vtchmod64 vtchmod64_musl vtchmodaa64
|
||||
rm -f $DSTDIR/vtchmod32 $DSTDIR/vtchmod64 $DSTDIR/vtchmodaa64
|
||||
|
||||
/opt/diet32/bin/diet gcc -Os -m32 vtchmod.c -o vtchmod32
|
||||
@@ -10,12 +10,16 @@ rm -f $DSTDIR/vtchmod32 $DSTDIR/vtchmod64 $DSTDIR/vtchmodaa64
|
||||
aarch64-linux-gcc -Os -static vtchmod.c -o vtchmodaa64
|
||||
aarch64-linux-strip --strip-all vtchmodaa64
|
||||
|
||||
gcc -specs "/usr/local/musl/lib/musl-gcc.specs" -Os -static vtchmod.c -o vtchmod64_musl
|
||||
strip --strip-all vtchmod64_musl
|
||||
|
||||
chmod 777 vtchmod32
|
||||
chmod 777 vtchmod64
|
||||
chmod 777 vtchmodaa64
|
||||
chmod 777 vtchmod64_musl
|
||||
|
||||
cp -a vtchmod32 $DSTDIR/
|
||||
cp -a vtchmod64 $DSTDIR/
|
||||
cp -a vtchmodaa64 $DSTDIR/
|
||||
cp -a vtchmod64_musl $DSTDIR/
|
||||
|
||||
|
BIN
BUSYBOX/chmod/vtchmod64_musl
Normal file
BIN
BUSYBOX/chmod/vtchmod64_musl
Normal file
Binary file not shown.
@@ -36,20 +36,16 @@ build for 32bit, static linked with dietlibc
|
||||
|
||||
|
||||
======================== Build for 64bit dmsetup =========================
|
||||
https://www.uclibc.org/downloads/binaries/0.9.30.1/mini-native-x86_64.tar.bz2
|
||||
1. extract device mapper source code
|
||||
2. extract mini-native-x86_64.tar.bz2
|
||||
3. chroot to mini-native-x86_64
|
||||
3. ./configure --disable-nls --disable-selinux --disable-shared --enable-static_link
|
||||
2. ./configure --disable-nls --disable-selinux --disable-shared --enable-static_link CC='gcc -specs /usr/local/musl/lib/musl-gcc.specs'
|
||||
3. touch include/linux/limits.h include/linux/types.h
|
||||
echo '#include <sys/mount.h>' > include/linux/fs.h
|
||||
4. make
|
||||
5. strip dmsetup/dmsetup.static
|
||||
5. strip --strip-all dmsetup/dmsetup.static
|
||||
6. get dmsetup/dmsetup.static as the dmsetup64 binary file
|
||||
|
||||
|
||||
|
||||
|
||||
======================== Build for arm64 dmsetup =========================
|
||||
https://www.uclibc.org/downloads/binaries/0.9.30.1/mini-native-x86_64.tar.bz2
|
||||
1. extract device mapper source code
|
||||
2. ./configure CC=aarch64-linux-gcc --target=arm --host=x86_64-linux-gnu --disable-nls --disable-selinux --disable-shared --enable-static_link
|
||||
3. modify include/configure.h file
|
||||
|
Binary file not shown.
@@ -27,6 +27,7 @@
|
||||
2.2 Download third-part source code
|
||||
|
||||
https://www.fefe.de/dietlibc/dietlibc-0.34.tar.xz ===> /home/Ventoy-master/DOC/dietlibc-0.34.tar.xz
|
||||
https://musl.libc.org/releases/musl-1.2.1.tar.gz ===> /home/Ventoy-master/DOC/musl-1.2.1.tar.gz
|
||||
https://ftp.gnu.org/gnu/grub/grub-2.04.tar.xz ===> /home/Ventoy-master/GRUB2/grub-2.04.tar.xz
|
||||
https://codeload.github.com/tianocore/edk2/zip/edk2-stable201911 ===> /home/Ventoy-master/EDK2/edk2-edk2-stable201911.zip
|
||||
https://codeload.github.com/relan/exfat/zip/v1.3.0 ===> /home/Ventoy-master/ExFAT/exfat-1.3.0.zip
|
||||
@@ -34,6 +35,19 @@
|
||||
https://releases.linaro.org/components/toolchain/binaries/7.4-2019.02/aarch64-linux-gnu/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz ===> /opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz
|
||||
https://toolchains.bootlin.com/downloads/releases/toolchains/aarch64/tarballs/aarch64--uclibc--stable-2020.08-1.tar.bz2 ===> /opt/aarch64--uclibc--stable-2020.08-1.tar.bz2
|
||||
|
||||
2.3 Prepare third-part tools
|
||||
cd /home/Ventoy-master/DOC/
|
||||
tar xf musl-1.2.1.tar.gz
|
||||
cd musl-1.2.1
|
||||
./configure && make install
|
||||
|
||||
tar xf /opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz -C /opt
|
||||
tar xf /opt/aarch64--uclibc--stable-2020.08-1.tar.bz2 -C /opt
|
||||
|
||||
2.4 Set PATH envrioment
|
||||
export PATH=$PATH:/opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/bin:/opt/aarch64--uclibc--stable-2020.08-1/bin
|
||||
better to add this line to /root/.bashrc and relogin as root
|
||||
|
||||
|
||||
==========================================
|
||||
3. All in one script
|
||||
|
@@ -1709,6 +1709,7 @@ int ventoy_check_device_result(int ret)
|
||||
|
||||
int ventoy_check_device(grub_device_t dev)
|
||||
{
|
||||
int workaround = 0;
|
||||
grub_file_t file;
|
||||
grub_uint64_t offset;
|
||||
char devname[64];
|
||||
@@ -1726,11 +1727,29 @@ int ventoy_check_device(grub_device_t dev)
|
||||
0 == ventoy_check_file_exist("(%s,2)/grub/localboot.cfg", dev->disk->name) ||
|
||||
0 == ventoy_check_file_exist("(%s,2)/tool/mount.exfat-fuse_aarch64", dev->disk->name))
|
||||
{
|
||||
return ventoy_check_device_result(2 | 0x1000);
|
||||
#ifndef GRUB_MACHINE_EFI
|
||||
if (0 == ventoy_check_file_exist("(ventoydisk)/ventoy/ventoy.cpio", dev->disk->name) ||
|
||||
0 == ventoy_check_file_exist("(ventoydisk)/grub/localboot.cfg", dev->disk->name) ||
|
||||
0 == ventoy_check_file_exist("(ventoydisk)/tool/mount.exfat-fuse_aarch64", dev->disk->name))
|
||||
{
|
||||
return ventoy_check_device_result(2 | 0x1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
workaround = 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* We must have partition 2 */
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "(%s,2)/ventoy/ventoy.cpio", dev->disk->name);
|
||||
if (workaround)
|
||||
{
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", "(ventoydisk)/ventoy/ventoy.cpio");
|
||||
}
|
||||
else
|
||||
{
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "(%s,2)/ventoy/ventoy.cpio", dev->disk->name);
|
||||
}
|
||||
if (!file)
|
||||
{
|
||||
return ventoy_check_device_result(3 | 0x1000);
|
||||
@@ -1748,37 +1767,55 @@ int ventoy_check_device(grub_device_t dev)
|
||||
return ventoy_check_device_result(5);
|
||||
}
|
||||
|
||||
offset = partition->start + partition->len;
|
||||
partition = file->device->disk->partition;
|
||||
if ((partition->number != 1) || (partition->len != 65536) || (offset != partition->start))
|
||||
if (workaround)
|
||||
{
|
||||
grub_file_close(file);
|
||||
return ventoy_check_device_result(6);
|
||||
ventoy_part_table *PartTbl = g_ventoy_part_info->MBR.PartTbl;
|
||||
if (PartTbl[1].StartSectorId != PartTbl[0].StartSectorId + PartTbl[0].SectorCount ||
|
||||
PartTbl[1].SectorCount != 65536)
|
||||
{
|
||||
grub_file_close(file);
|
||||
return ventoy_check_device_result(6);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = partition->start + partition->len;
|
||||
partition = file->device->disk->partition;
|
||||
if ((partition->number != 1) || (partition->len != 65536) || (offset != partition->start))
|
||||
{
|
||||
grub_file_close(file);
|
||||
return ventoy_check_device_result(7);
|
||||
}
|
||||
}
|
||||
|
||||
grub_file_close(file);
|
||||
|
||||
grub_snprintf(devname, sizeof(devname), "%s,2", dev->disk->name);
|
||||
dev2 = grub_device_open(devname);
|
||||
if (!dev2)
|
||||
if (workaround == 0)
|
||||
{
|
||||
return ventoy_check_device_result(7);
|
||||
}
|
||||
grub_snprintf(devname, sizeof(devname), "%s,2", dev->disk->name);
|
||||
dev2 = grub_device_open(devname);
|
||||
if (!dev2)
|
||||
{
|
||||
return ventoy_check_device_result(8);
|
||||
}
|
||||
|
||||
fs = grub_fs_probe(dev2);
|
||||
if (!fs)
|
||||
{
|
||||
grub_device_close(dev2);
|
||||
return ventoy_check_device_result(8);
|
||||
}
|
||||
fs = grub_fs_probe(dev2);
|
||||
if (!fs)
|
||||
{
|
||||
grub_device_close(dev2);
|
||||
return ventoy_check_device_result(9);
|
||||
}
|
||||
|
||||
fs->fs_label(dev2, &label);
|
||||
if ((!label) || grub_strncmp("VTOYEFI", label, 7))
|
||||
{
|
||||
grub_device_close(dev2);
|
||||
return ventoy_check_device_result(9);
|
||||
}
|
||||
fs->fs_label(dev2, &label);
|
||||
if ((!label) || grub_strncmp("VTOYEFI", label, 7))
|
||||
{
|
||||
grub_device_close(dev2);
|
||||
return ventoy_check_device_result(10);
|
||||
}
|
||||
|
||||
grub_device_close(dev2);
|
||||
grub_device_close(dev2);
|
||||
}
|
||||
|
||||
return ventoy_check_device_result(0);
|
||||
}
|
||||
|
||||
|
@@ -47,8 +47,8 @@ if [ -e $BUSYBOX_PATH/32h ]; then
|
||||
if [ -s $BUSYBOX_PATH/busybox ]; then
|
||||
$BUSYBOX_PATH/vtchmod64 $BUSYBOX_PATH/busybox
|
||||
else
|
||||
$BUSYBOX_PATH/xzminidec64_uclibc < $BUSYBOX_PATH/busybox64.xz > $BUSYBOX_PATH/busybox
|
||||
$BUSYBOX_PATH/vtchmod64_uclibc $BUSYBOX_PATH/busybox
|
||||
$BUSYBOX_PATH/xzminidec64_musl < $BUSYBOX_PATH/busybox64.xz > $BUSYBOX_PATH/busybox
|
||||
$BUSYBOX_PATH/vtchmod64_musl $BUSYBOX_PATH/busybox
|
||||
fi
|
||||
fi
|
||||
else
|
||||
|
Binary file not shown.
BIN
IMG/cpio/ventoy/busybox/vtchmod64_musl
Normal file
BIN
IMG/cpio/ventoy/busybox/vtchmod64_musl
Normal file
Binary file not shown.
Binary file not shown.
BIN
IMG/cpio/ventoy/busybox/xzminidec64_musl
Normal file
BIN
IMG/cpio/ventoy/busybox/xzminidec64_musl
Normal file
Binary file not shown.
Binary file not shown.
48
IMG/cpio/ventoy/hook/austrumi/disk_hook.sh
Normal file
48
IMG/cpio/ventoy/hook/austrumi/disk_hook.sh
Normal file
@@ -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
|
||||
|
||||
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"
|
||||
|
||||
# blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
|
||||
# blkdev_num_mknod=$($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 blkdev_num_mknod=$blkdev_num_mknod vtDM=$vtDM"
|
||||
|
||||
# if [ -b /dev/$vtDM ]; then
|
||||
# vtlog "dev already exist ..."
|
||||
# else
|
||||
# vtlog "mknode dev ..."
|
||||
# mknod -m 660 /dev/$vtDM b $blkdev_num_mknod
|
||||
# fi
|
||||
|
||||
PATH=$VTPATH_OLD
|
24
IMG/cpio/ventoy/hook/austrumi/ventoy-hook.sh
Normal file
24
IMG/cpio/ventoy/hook/austrumi/ventoy-hook.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/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 "/^ *mdev *-s/a $BUSYBOX_PATH/sh $VTOY_PATH/hook/austrumi/disk_hook.sh" -i /init
|
||||
$SED "s/BOOT_TYPE=livecd/BOOT_TYPE=usb/g" -i /init
|
||||
|
@@ -39,7 +39,17 @@ if is_inotify_ventoy_part $3; then
|
||||
fi
|
||||
|
||||
vtlog "find ventoy partition ..."
|
||||
$BUSYBOX_PATH/sh $VTOY_PATH/hook/default/udev_disk_hook.sh $3 noreplace
|
||||
|
||||
vtReplaceOpt=noreplace
|
||||
|
||||
if $GREP -q el8 /proc/version && [ -f /etc/system-release ]; then
|
||||
vtRhel8Ver=$($SED "s#.*8\.\([0-9]*\).*#\1#" /etc/system-release)
|
||||
if [ $vtRhel8Ver -ge 3 ]; then
|
||||
vtReplaceOpt=""
|
||||
fi
|
||||
fi
|
||||
|
||||
$BUSYBOX_PATH/sh $VTOY_PATH/hook/default/udev_disk_hook.sh $3 $vtReplaceOpt
|
||||
|
||||
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})
|
||||
|
Binary file not shown.
@@ -309,6 +309,10 @@ ventoy_get_os_type() {
|
||||
echo 'primeos'; return
|
||||
fi
|
||||
|
||||
if $GREP -q 'austrumi' /proc/version; then
|
||||
echo 'austrumi'; return
|
||||
fi
|
||||
|
||||
echo "default"
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -270,6 +270,8 @@ function distro_specify_initrd_file_phase2 {
|
||||
fi
|
||||
elif [ -f (loop)/blackarch/boot/x86_64/archiso.img ]; then
|
||||
vt_linux_specify_initrd_file /blackarch/boot/x86_64/archiso.img
|
||||
elif [ -f (loop)/blackarch/boot/x86_64/initramfs-linux.img ]; then
|
||||
vt_linux_specify_initrd_file /blackarch/boot/x86_64/initramfs-linux.img
|
||||
|
||||
elif [ -f (loop)/install.amd/initrd.gz ]; then
|
||||
vt_linux_specify_initrd_file /live/initrd2.img
|
||||
@@ -277,7 +279,12 @@ function distro_specify_initrd_file_phase2 {
|
||||
vt_linux_specify_initrd_file /install.amd/gtk/initrd.gz
|
||||
elif [ -f (loop)/boot/grub/kernels.cfg ]; then
|
||||
vt_linux_parse_initrd_grub file (loop)/boot/grub/kernels.cfg
|
||||
|
||||
elif [ -f (loop)/austrumi/initrd.gz ]; then
|
||||
vt_linux_specify_initrd_file /austrumi/initrd.gz
|
||||
if [ -f (loop)/EFI/BOOT/bootx64.efi ]; then
|
||||
vt_cpio_busybox64 "64h"
|
||||
fi
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -543,6 +550,12 @@ function uefi_linux_menu_func {
|
||||
elif [ -d (loop)/blackarch ]; then
|
||||
if [ -f (loop)/blackarch/boot/x86_64/archiso.img ]; then
|
||||
vt_add_replace_file $vtindex "EFI\\archiso\\archiso.img"
|
||||
elif [ -f (loop)/blackarch/boot/x86_64/initramfs-linux.img ]; then
|
||||
vt_add_replace_file $vtindex "blackarch\\boot\\x86_64\\initramfs-linux.img"
|
||||
fi
|
||||
elif [ -d (loop)/anarchy ]; then
|
||||
if [ -f (loop)/anarchy/boot/x86_64/initramfs-linux.img ]; then
|
||||
vt_add_replace_file $vtindex "anarchy\\boot\\x86_64\\initramfs-linux.img"
|
||||
fi
|
||||
elif [ -d (loop)/parabola ]; then
|
||||
if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
|
||||
@@ -748,6 +761,8 @@ function legacy_linux_menu_func {
|
||||
if [ -d (loop)/arch/boot/syslinux ]; then
|
||||
vt_linux_parse_initrd_isolinux (loop)/arch/boot/syslinux/ /arch/
|
||||
vt_linux_parse_initrd_isolinux (loop)/arch/boot/syslinux/ /arch/boot/syslinux/
|
||||
elif [ -d (loop)/anarchy/boot/syslinux ]; then
|
||||
vt_linux_parse_initrd_isolinux (loop)/anarchy/boot/syslinux/ /anarchy/
|
||||
|
||||
#manjaro
|
||||
elif [ -d (loop)/manjaro ]; then
|
||||
@@ -1432,7 +1447,7 @@ function img_unsupport_menuentry {
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
set VENTOY_VERSION="1.0.30"
|
||||
set VENTOY_VERSION="1.0.31"
|
||||
|
||||
#ACPI not compatible with Window7/8, so disable by default
|
||||
set VTOY_PARAM_NO_ACPI=1
|
||||
|
Binary file not shown.
@@ -15,12 +15,12 @@ print_usage() {
|
||||
echo ' -r SIZE_MB preserve some space at the bottom of the disk (only for install)'
|
||||
echo ' -s/-S enable/disable secure boot support (default is disabled)'
|
||||
echo ' -g use GPT partition style, default is MBR (only for install)'
|
||||
echo ' -L Label of the 1st exfat partition (default is ventoy)'
|
||||
echo ' -L Label of the 1st exfat partition (default is Ventoy)'
|
||||
echo ''
|
||||
}
|
||||
|
||||
|
||||
VTNEW_LABEL='ventoy'
|
||||
VTNEW_LABEL='Ventoy'
|
||||
RESERVE_SIZE_MB=0
|
||||
while [ -n "$1" ]; do
|
||||
if [ "$1" = "-i" ]; then
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
LZIP/lz4cat64
Normal file
BIN
LZIP/lz4cat64
Normal file
Binary file not shown.
@@ -289,7 +289,7 @@ out:
|
||||
}
|
||||
|
||||
|
||||
static DWORD GetVentoyVolumeName(int PhyDrive, UINT32 StartSectorId, CHAR *NameBuf, UINT32 BufLen, BOOL DelSlash)
|
||||
static DWORD GetVentoyVolumeName(int PhyDrive, UINT64 StartSectorId, CHAR *NameBuf, UINT32 BufLen, BOOL DelSlash)
|
||||
{
|
||||
size_t len;
|
||||
BOOL bRet;
|
||||
@@ -304,7 +304,7 @@ static DWORD GetVentoyVolumeName(int PhyDrive, UINT32 StartSectorId, CHAR *NameB
|
||||
|
||||
PartOffset = 512ULL * StartSectorId;
|
||||
|
||||
Log("GetVentoyVolumeName PhyDrive %d SectorStart:%u PartOffset:%llu", PhyDrive, StartSectorId, (ULONGLONG)PartOffset);
|
||||
Log("GetVentoyVolumeName PhyDrive %d SectorStart:%llu PartOffset:%llu", PhyDrive, (ULONGLONG)StartSectorId, (ULONGLONG)PartOffset);
|
||||
|
||||
hVolume = FindFirstVolumeA(VolumeName, sizeof(VolumeName));
|
||||
if (hVolume == INVALID_HANDLE_VALUE)
|
||||
@@ -1401,18 +1401,18 @@ int ClearVentoyFromPhyDrive(HWND hWnd, PHY_DRIVE_INFO *pPhyDrive, char *pDrvLett
|
||||
goto End;
|
||||
}
|
||||
|
||||
// clear first and last 1MB space
|
||||
pTmpBuf = malloc(SIZE_1MB);
|
||||
// clear first and last 2MB space
|
||||
pTmpBuf = malloc(SIZE_2MB);
|
||||
if (!pTmpBuf)
|
||||
{
|
||||
Log("Failed to alloc memory.");
|
||||
rc = 1;
|
||||
goto End;
|
||||
}
|
||||
memset(pTmpBuf, 0, SIZE_1MB);
|
||||
memset(pTmpBuf, 0, SIZE_2MB);
|
||||
|
||||
SET_FILE_POS(512);
|
||||
bRet = WriteFile(hDrive, pTmpBuf, SIZE_1MB - 512, &dwSize, NULL);
|
||||
bRet = WriteFile(hDrive, pTmpBuf, SIZE_2MB - 512, &dwSize, NULL);
|
||||
Log("Write fisrt 1MB ret:%d size:%u err:%d", bRet, dwSize, LASTERR);
|
||||
if (!bRet)
|
||||
{
|
||||
@@ -1420,8 +1420,8 @@ int ClearVentoyFromPhyDrive(HWND hWnd, PHY_DRIVE_INFO *pPhyDrive, char *pDrvLett
|
||||
goto End;
|
||||
}
|
||||
|
||||
SET_FILE_POS(SIZE_1MB);
|
||||
bRet = WriteFile(hDrive, pTmpBuf, SIZE_1MB, &dwSize, NULL);
|
||||
SET_FILE_POS(pPhyDrive->SizeInBytes - SIZE_2MB);
|
||||
bRet = WriteFile(hDrive, pTmpBuf, SIZE_2MB, &dwSize, NULL);
|
||||
Log("Write 2nd 1MB ret:%d size:%u err:%d", bRet, dwSize, LASTERR);
|
||||
if (!bRet)
|
||||
{
|
||||
@@ -1430,30 +1430,71 @@ int ClearVentoyFromPhyDrive(HWND hWnd, PHY_DRIVE_INFO *pPhyDrive, char *pDrvLett
|
||||
}
|
||||
|
||||
SET_FILE_POS(0);
|
||||
bRet = ReadFile(hDrive, &MBR, sizeof(MBR), &dwSize, NULL);
|
||||
Log("Read MBR ret:%d size:%u err:%d", bRet, dwSize, LASTERR);
|
||||
if (!bRet)
|
||||
|
||||
if (pPhyDrive->SizeInBytes > 2199023255552ULL)
|
||||
{
|
||||
rc = 1;
|
||||
goto End;
|
||||
VTOY_GPT_INFO *pGptInfo;
|
||||
VTOY_GPT_HDR BackupHead;
|
||||
LARGE_INTEGER liCurrentPosition;
|
||||
|
||||
pGptInfo = (VTOY_GPT_INFO *)pTmpBuf;
|
||||
|
||||
VentoyFillWholeGpt(pPhyDrive->SizeInBytes, pGptInfo);
|
||||
|
||||
SET_FILE_POS(pPhyDrive->SizeInBytes - 512);
|
||||
VentoyFillBackupGptHead(pGptInfo, &BackupHead);
|
||||
if (!WriteFile(hDrive, &BackupHead, sizeof(VTOY_GPT_HDR), &dwSize, NULL))
|
||||
{
|
||||
rc = 1;
|
||||
Log("Write GPT Backup Head Failed, dwSize:%u (%u) ErrCode:%u", dwSize, sizeof(VTOY_GPT_INFO), GetLastError());
|
||||
goto End;
|
||||
}
|
||||
|
||||
SET_FILE_POS(pPhyDrive->SizeInBytes - 512 * 33);
|
||||
if (!WriteFile(hDrive, pGptInfo->PartTbl, sizeof(pGptInfo->PartTbl), &dwSize, NULL))
|
||||
{
|
||||
rc = 1;
|
||||
Log("Write GPT Backup Part Table Failed, dwSize:%u (%u) ErrCode:%u", dwSize, sizeof(VTOY_GPT_INFO), GetLastError());
|
||||
goto End;
|
||||
}
|
||||
|
||||
SET_FILE_POS(0);
|
||||
if (!WriteFile(hDrive, pGptInfo, sizeof(VTOY_GPT_INFO), &dwSize, NULL))
|
||||
{
|
||||
rc = 1;
|
||||
Log("Write GPT Info Failed, dwSize:%u (%u) ErrCode:%u", dwSize, sizeof(VTOY_GPT_INFO), GetLastError());
|
||||
goto End;
|
||||
}
|
||||
|
||||
Log("Write GPT Info OK ...");
|
||||
}
|
||||
|
||||
//clear boot code and partition table (reserved disk signature)
|
||||
memset(MBR.BootCode, 0, 440);
|
||||
memset(MBR.PartTbl, 0, sizeof(MBR.PartTbl));
|
||||
|
||||
VentoyFillLocation(pPhyDrive->SizeInBytes, 2048, (UINT32)(pPhyDrive->SizeInBytes / 512 - 2048), MBR.PartTbl);
|
||||
|
||||
MBR.PartTbl[0].Active = 0x00; // bootable
|
||||
MBR.PartTbl[0].FsFlag = 0x07; // exFAT/NTFS/HPFS
|
||||
|
||||
SET_FILE_POS(0);
|
||||
bRet = WriteFile(hDrive, &MBR, 512, &dwSize, NULL);
|
||||
Log("Write MBR ret:%d size:%u err:%d", bRet, dwSize, LASTERR);
|
||||
if (!bRet)
|
||||
else
|
||||
{
|
||||
rc = 1;
|
||||
goto End;
|
||||
bRet = ReadFile(hDrive, &MBR, sizeof(MBR), &dwSize, NULL);
|
||||
Log("Read MBR ret:%d size:%u err:%d", bRet, dwSize, LASTERR);
|
||||
if (!bRet)
|
||||
{
|
||||
rc = 1;
|
||||
goto End;
|
||||
}
|
||||
|
||||
//clear boot code and partition table (reserved disk signature)
|
||||
memset(MBR.BootCode, 0, 440);
|
||||
memset(MBR.PartTbl, 0, sizeof(MBR.PartTbl));
|
||||
|
||||
VentoyFillMBRLocation(pPhyDrive->SizeInBytes, 2048, (UINT32)(pPhyDrive->SizeInBytes / 512 - 2048), MBR.PartTbl);
|
||||
|
||||
MBR.PartTbl[0].Active = 0x00; // bootable
|
||||
MBR.PartTbl[0].FsFlag = 0x07; // exFAT/NTFS/HPFS
|
||||
|
||||
SET_FILE_POS(0);
|
||||
bRet = WriteFile(hDrive, &MBR, 512, &dwSize, NULL);
|
||||
Log("Write MBR ret:%d size:%u err:%d", bRet, dwSize, LASTERR);
|
||||
if (!bRet)
|
||||
{
|
||||
rc = 1;
|
||||
goto End;
|
||||
}
|
||||
}
|
||||
|
||||
Log("Clear Ventoy successfully finished");
|
||||
@@ -1490,7 +1531,7 @@ End:
|
||||
if (state != 1)
|
||||
{
|
||||
Log("need to mount ventoy part1...");
|
||||
if (0 == GetVentoyVolumeName(pPhyDrive->PhyDrive, MBR.PartTbl[0].StartSectorId, DriveLetters, sizeof(DriveLetters), FALSE))
|
||||
if (0 == GetVentoyVolumeName(pPhyDrive->PhyDrive, 2048, DriveLetters, sizeof(DriveLetters), FALSE))
|
||||
{
|
||||
DriveName[0] = MountDrive;
|
||||
bRet = SetVolumeMountPointA(DriveName, DriveLetters);
|
||||
@@ -1528,6 +1569,10 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
|
||||
CHAR DriveLetters[MAX_PATH] = { 0 };
|
||||
MBR_HEAD MBR;
|
||||
VTOY_GPT_INFO *pGptInfo = NULL;
|
||||
UINT64 Part1StartSector = 0;
|
||||
UINT64 Part1SectorCount = 0;
|
||||
UINT64 Part2StartSector = 0;
|
||||
|
||||
|
||||
Log("InstallVentoy2PhyDrive %s PhyDrive%d <<%s %s %dGB>>",
|
||||
PartStyle ? "GPT" : "MBR", pPhyDrive->PhyDrive, pPhyDrive->VendorId, pPhyDrive->ProductId,
|
||||
@@ -1541,10 +1586,19 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
|
||||
|
||||
PROGRESS_BAR_SET_POS(PT_LOCK_FOR_CLEAN);
|
||||
|
||||
VentoyFillMBR(pPhyDrive->SizeInBytes, &MBR, PartStyle);//also used to format 1st partition in GPT mode
|
||||
if (PartStyle)
|
||||
{
|
||||
VentoyFillGpt(pPhyDrive->SizeInBytes, pGptInfo);
|
||||
Part1StartSector = pGptInfo->PartTbl[0].StartLBA;
|
||||
Part1SectorCount = pGptInfo->PartTbl[0].LastLBA - Part1StartSector + 1;
|
||||
Part2StartSector = pGptInfo->PartTbl[1].StartLBA;
|
||||
}
|
||||
else
|
||||
{
|
||||
VentoyFillMBR(pPhyDrive->SizeInBytes, &MBR, PartStyle);
|
||||
Part1StartSector = MBR.PartTbl[0].StartSectorId;
|
||||
Part1SectorCount = MBR.PartTbl[0].SectorCount;
|
||||
Part2StartSector = MBR.PartTbl[1].StartSectorId;
|
||||
}
|
||||
|
||||
Log("Lock disk for clean ............................. ");
|
||||
@@ -1608,7 +1662,7 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
|
||||
//Refresh Drive Layout
|
||||
DeviceIoControl(hDrive, IOCTL_DISK_UPDATE_PROPERTIES, NULL, 0, NULL, 0, &dwSize, NULL);
|
||||
|
||||
disk_io_set_param(hDrive, MBR.PartTbl[0].StartSectorId + MBR.PartTbl[0].SectorCount);
|
||||
disk_io_set_param(hDrive, Part1StartSector + Part1SectorCount);// include the 2048 sector gap
|
||||
|
||||
PROGRESS_BAR_SET_POS(PT_FORMAT_PART1);
|
||||
|
||||
@@ -1626,9 +1680,12 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
|
||||
goto End;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PROGRESS_BAR_SET_POS(PT_FORMAT_PART2);
|
||||
Log("Writing part2 FAT img ...");
|
||||
if (0 != FormatPart2Fat(hDrive, MBR.PartTbl[1].StartSectorId))
|
||||
|
||||
if (0 != FormatPart2Fat(hDrive, Part2StartSector))
|
||||
{
|
||||
Log("FormatPart2Fat failed.");
|
||||
rc = 1;
|
||||
@@ -1679,7 +1736,7 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
|
||||
}
|
||||
|
||||
Log("Write GPT Info OK ...");
|
||||
memcpy(&(pPhyDrive->MBR), &MBR, 512);
|
||||
memcpy(&(pPhyDrive->MBR), &(pGptInfo->MBR), 512);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1728,7 +1785,8 @@ End:
|
||||
if (state != 1)
|
||||
{
|
||||
Log("need to mount ventoy part1...");
|
||||
if (0 == GetVentoyVolumeName(pPhyDrive->PhyDrive, MBR.PartTbl[0].StartSectorId, DriveLetters, sizeof(DriveLetters), FALSE))
|
||||
|
||||
if (0 == GetVentoyVolumeName(pPhyDrive->PhyDrive, Part1StartSector, DriveLetters, sizeof(DriveLetters), FALSE))
|
||||
{
|
||||
DriveName[0] = MountDrive;
|
||||
bRet = SetVolumeMountPointA(DriveName, DriveLetters);
|
||||
@@ -1872,7 +1930,7 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive)
|
||||
|
||||
Log("Lock volume for update .......................... ");
|
||||
hVolume = INVALID_HANDLE_VALUE;
|
||||
Status = GetVentoyVolumeName(pPhyDrive->PhyDrive, (UINT32)StartSector, DriveLetters, sizeof(DriveLetters), TRUE);
|
||||
Status = GetVentoyVolumeName(pPhyDrive->PhyDrive, StartSector, DriveLetters, sizeof(DriveLetters), TRUE);
|
||||
if (ERROR_SUCCESS == Status)
|
||||
{
|
||||
Log("Now lock and dismount volume <%s>", DriveLetters);
|
||||
|
@@ -382,7 +382,7 @@ BOOL IsVentoyLogicalDrive(CHAR DriveLetter)
|
||||
}
|
||||
|
||||
|
||||
int VentoyFillLocation(UINT64 DiskSizeInBytes, UINT32 StartSectorId, UINT32 SectorCount, PART_TABLE *Table)
|
||||
int VentoyFillMBRLocation(UINT64 DiskSizeInBytes, UINT32 StartSectorId, UINT32 SectorCount, PART_TABLE *Table)
|
||||
{
|
||||
BYTE Head;
|
||||
BYTE Sector;
|
||||
@@ -473,7 +473,7 @@ int VentoyFillMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR, int PartStyle)
|
||||
//Part1
|
||||
PartStartSector = VENTOY_PART1_START_SECTOR;
|
||||
PartSectorCount = DiskSectorCount - ReservedSector - VENTOY_EFI_PART_SIZE / 512 - PartStartSector;
|
||||
VentoyFillLocation(DiskSizeBytes, PartStartSector, PartSectorCount, pMBR->PartTbl);
|
||||
VentoyFillMBRLocation(DiskSizeBytes, PartStartSector, PartSectorCount, pMBR->PartTbl);
|
||||
|
||||
pMBR->PartTbl[0].Active = 0x80; // bootable
|
||||
pMBR->PartTbl[0].FsFlag = 0x07; // exFAT/NTFS/HPFS
|
||||
@@ -481,7 +481,7 @@ int VentoyFillMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR, int PartStyle)
|
||||
//Part2
|
||||
PartStartSector += PartSectorCount;
|
||||
PartSectorCount = VENTOY_EFI_PART_SIZE / 512;
|
||||
VentoyFillLocation(DiskSizeBytes, PartStartSector, PartSectorCount, pMBR->PartTbl + 1);
|
||||
VentoyFillMBRLocation(DiskSizeBytes, PartStartSector, PartSectorCount, pMBR->PartTbl + 1);
|
||||
|
||||
pMBR->PartTbl[1].Active = 0x00;
|
||||
pMBR->PartTbl[1].FsFlag = 0xEF; // EFI System Partition
|
||||
@@ -538,6 +538,45 @@ static int VentoyFillProtectMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VentoyFillWholeGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo)
|
||||
{
|
||||
UINT64 Part1SectorCount = 0;
|
||||
UINT64 DiskSectorCount = DiskSizeBytes / 512;
|
||||
VTOY_GPT_HDR *Head = &pInfo->Head;
|
||||
VTOY_GPT_PART_TBL *Table = pInfo->PartTbl;
|
||||
static GUID WindowsDataPartType = { 0xebd0a0a2, 0xb9e5, 0x4433, { 0x87, 0xc0, 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7 } };
|
||||
|
||||
VentoyFillProtectMBR(DiskSizeBytes, &pInfo->MBR);
|
||||
|
||||
Part1SectorCount = DiskSectorCount - 33 - 2048;
|
||||
|
||||
memcpy(Head->Signature, "EFI PART", 8);
|
||||
Head->Version[2] = 0x01;
|
||||
Head->Length = 92;
|
||||
Head->Crc = 0;
|
||||
Head->EfiStartLBA = 1;
|
||||
Head->EfiBackupLBA = DiskSectorCount - 1;
|
||||
Head->PartAreaStartLBA = 34;
|
||||
Head->PartAreaEndLBA = DiskSectorCount - 34;
|
||||
CoCreateGuid(&Head->DiskGuid);
|
||||
Head->PartTblStartLBA = 2;
|
||||
Head->PartTblTotNum = 128;
|
||||
Head->PartTblEntryLen = 128;
|
||||
|
||||
|
||||
memcpy(&(Table[0].PartType), &WindowsDataPartType, sizeof(GUID));
|
||||
CoCreateGuid(&(Table[0].PartGuid));
|
||||
Table[0].StartLBA = 2048;
|
||||
Table[0].LastLBA = 2048 + Part1SectorCount - 1;
|
||||
Table[0].Attr = 0;
|
||||
memcpy(Table[0].Name, L"Data", 4 * 2);
|
||||
|
||||
//Update CRC
|
||||
Head->PartTblCrc = VentoyCrc32(Table, sizeof(pInfo->PartTbl));
|
||||
Head->Crc = VentoyCrc32(Head, Head->Length);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VentoyFillGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo)
|
||||
{
|
||||
|
@@ -153,6 +153,8 @@ static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes, MBR_HEAD *pMBR, UIN
|
||||
}
|
||||
|
||||
*Part2StartSector = pGpt->PartTbl[1].StartLBA;
|
||||
|
||||
memcpy(pMBR, &(pGpt->MBR), sizeof(MBR_HEAD));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -188,9 +190,10 @@ static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes, MBR_HEAD *pMBR, UIN
|
||||
}
|
||||
|
||||
*Part2StartSector = MBR.PartTbl[1].StartSectorId;
|
||||
|
||||
memcpy(pMBR, &MBR, sizeof(MBR_HEAD));
|
||||
}
|
||||
|
||||
memcpy(pMBR, &MBR, sizeof(MBR_HEAD));
|
||||
Log("PhysicalDrive%d is ventoy disk", PhyDrive);
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#define SIZE_1MB (1024 * 1024)
|
||||
#define SIZE_2MB (2048 * 1024)
|
||||
#define VENTOY_EFI_PART_SIZE (32 * SIZE_1MB)
|
||||
#define VENTOY_PART1_START_SECTOR 2048
|
||||
|
||||
@@ -208,6 +209,7 @@ int ParseCmdLineOption(LPSTR lpCmdLine);
|
||||
int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle);
|
||||
int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive);
|
||||
int VentoyFillBackupGptHead(VTOY_GPT_INFO *pInfo, VTOY_GPT_HDR *pHead);
|
||||
int VentoyFillWholeGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo);
|
||||
void SetProgressBarPos(int Pos);
|
||||
int ReadWholeFileToBuf(const CHAR *FileName, int ExtLen, void **Bufer, int *BufLen);
|
||||
int INIT unxz(unsigned char *in, int in_size,
|
||||
@@ -219,7 +221,7 @@ void disk_io_set_param(HANDLE Handle, UINT64 SectorCount);
|
||||
INT_PTR CALLBACK PartDialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);
|
||||
int GetReservedSpaceInMB(void);
|
||||
int FindProcessOccupyDisk(HANDLE hDrive, PHY_DRIVE_INFO *pPhyDrive);
|
||||
int VentoyFillLocation(UINT64 DiskSizeInBytes, UINT32 StartSectorId, UINT32 SectorCount, PART_TABLE *Table);
|
||||
int VentoyFillMBRLocation(UINT64 DiskSizeInBytes, UINT32 StartSectorId, UINT32 SectorCount, PART_TABLE *Table);
|
||||
int ClearVentoyFromPhyDrive(HWND hWnd, PHY_DRIVE_INFO *pPhyDrive, char *pDrvLetter);
|
||||
UINT32 VentoyCrc32(void *Buffer, UINT32 Length);
|
||||
|
||||
|
@@ -475,9 +475,9 @@ static const char* const VolumeStr[FF_VOLUMES] = {FF_VOLUME_STRS}; /* Pre-define
|
||||
#endif
|
||||
|
||||
#if FF_LBA64
|
||||
#if FF_MIN_GPT > 0x100000000
|
||||
#error Wrong FF_MIN_GPT setting
|
||||
#endif
|
||||
//#if FF_MIN_GPT > 0x100000000
|
||||
//#error Wrong FF_MIN_GPT setting
|
||||
//#endif
|
||||
static const BYTE GUID_MS_Basic[16] = {0xA2,0xA0,0xD0,0xEB,0xE5,0xB9,0x33,0x44,0x87,0xC0,0x68,0xB6,0xB7,0x26,0x99,0xC7};
|
||||
#endif
|
||||
|
||||
@@ -5983,10 +5983,10 @@ FRESULT f_mkfs (
|
||||
if (sz_vol >= 0x4000000) sz_au = 256; /* >= 64Ms */
|
||||
}
|
||||
b_fat = b_vol + 32; /* FAT start at offset 32 */
|
||||
sz_fat = (DWORD)((sz_vol / sz_au + 2) * 4 + ss - 1) / ss; /* Number of FAT sectors */
|
||||
sz_fat = (DWORD)(((sz_vol / sz_au + 2) * 4 + ss - 1) / ss); /* Number of FAT sectors */
|
||||
b_data = (b_fat + sz_fat + sz_blk - 1) & ~((LBA_t)sz_blk - 1); /* Align data area to the erase block boundary */
|
||||
if (b_data - b_vol >= sz_vol / 2) LEAVE_MKFS(FR_MKFS_ABORTED); /* Too small volume? */
|
||||
n_clst = (DWORD)(sz_vol - (b_data - b_vol)) / sz_au; /* Number of clusters */
|
||||
n_clst = (DWORD)((sz_vol - (b_data - b_vol)) / sz_au); /* Number of clusters */
|
||||
if (n_clst <16) LEAVE_MKFS(FR_MKFS_ABORTED); /* Too few clusters? */
|
||||
if (n_clst > MAX_EXFAT) LEAVE_MKFS(FR_MKFS_ABORTED); /* Too many clusters? */
|
||||
|
||||
|
@@ -205,7 +205,7 @@
|
||||
/ To enable the 64-bit LBA, also exFAT needs to be enabled. (FF_FS_EXFAT == 1) */
|
||||
|
||||
|
||||
#define FF_MIN_GPT 0x100000000
|
||||
#define FF_MIN_GPT 0x10000000000000
|
||||
/* Minimum number of sectors to switch GPT format to create partition in f_mkfs and
|
||||
/ f_fdisk function. 0x100000000 max. This option has no effect when FF_LBA64 == 0. */
|
||||
|
||||
|
@@ -0,0 +1,48 @@
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
# Author: Lasse Collin <lasse.collin@tukaani.org>
|
||||
#
|
||||
# This file has been put into the public domain.
|
||||
# You can do whatever you want with this file.
|
||||
#
|
||||
|
||||
CC = gcc -specs "/usr/local/musl/lib/musl-gcc.specs" -Os -static -std=gnu89
|
||||
BCJ_CPPFLAGS = -DXZ_DEC_X86 -DXZ_DEC_POWERPC -DXZ_DEC_IA64 \
|
||||
-DXZ_DEC_ARM -DXZ_DEC_ARMTHUMB -DXZ_DEC_SPARC
|
||||
CPPFLAGS = -DXZ_USE_CRC64 -DXZ_DEC_ANY_CHECK
|
||||
CFLAGS = -ggdb3 -O2 -pedantic -Wall -Wextra
|
||||
RM = rm -f
|
||||
VPATH = ../linux/include/linux ../linux/lib/xz
|
||||
COMMON_SRCS = xz_crc32.c xz_crc64.c xz_dec_stream.c xz_dec_lzma2.c xz_dec_bcj.c
|
||||
COMMON_OBJS = $(COMMON_SRCS:.c=.o)
|
||||
XZMINIDEC_OBJS = xzminidec.o
|
||||
BYTETEST_OBJS = bytetest.o
|
||||
BUFTEST_OBJS = buftest.o
|
||||
BOOTTEST_OBJS = boottest.o
|
||||
XZ_HEADERS = xz.h xz_private.h xz_stream.h xz_lzma2.h xz_config.h
|
||||
PROGRAMS = xzminidec bytetest buftest boottest
|
||||
|
||||
ALL_CPPFLAGS = -I../linux/include/linux -I. $(BCJ_CPPFLAGS) $(CPPFLAGS)
|
||||
|
||||
all: $(PROGRAMS)
|
||||
|
||||
%.o: %.c $(XZ_HEADERS)
|
||||
$(CC) $(ALL_CPPFLAGS) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
xzminidec: $(COMMON_OBJS) $(XZMINIDEC_OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(XZMINIDEC_OBJS)
|
||||
|
||||
bytetest: $(COMMON_OBJS) $(BYTETEST_OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(BYTETEST_OBJS)
|
||||
|
||||
buftest: $(COMMON_OBJS) $(BUFTEST_OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(BUFTEST_OBJS)
|
||||
|
||||
boottest: $(BOOTTEST_OBJS) $(COMMON_SRCS)
|
||||
$(CC) $(ALL_CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(BOOTTEST_OBJS)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(RM) $(COMMON_OBJS) $(XZMINIDEC_OBJS) $(BUFTEST_OBJS) \
|
||||
$(BOOTTEST_OBJS) $(PROGRAMS)
|
@@ -0,0 +1,48 @@
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
# Author: Lasse Collin <lasse.collin@tukaani.org>
|
||||
#
|
||||
# This file has been put into the public domain.
|
||||
# You can do whatever you want with this file.
|
||||
#
|
||||
|
||||
CC = /opt/aarch64--uclibc--stable-2020.08-1/bin/aarch64-linux-gcc -Os -static -std=gnu89
|
||||
BCJ_CPPFLAGS = -DXZ_DEC_X86 -DXZ_DEC_POWERPC -DXZ_DEC_IA64 \
|
||||
-DXZ_DEC_ARM -DXZ_DEC_ARMTHUMB -DXZ_DEC_SPARC
|
||||
CPPFLAGS = -DXZ_USE_CRC64 -DXZ_DEC_ANY_CHECK
|
||||
CFLAGS = -ggdb3 -O2 -pedantic -Wall -Wextra
|
||||
RM = rm -f
|
||||
VPATH = ../linux/include/linux ../linux/lib/xz
|
||||
COMMON_SRCS = xz_crc32.c xz_crc64.c xz_dec_stream.c xz_dec_lzma2.c xz_dec_bcj.c
|
||||
COMMON_OBJS = $(COMMON_SRCS:.c=.o)
|
||||
XZMINIDEC_OBJS = xzminidec.o
|
||||
BYTETEST_OBJS = bytetest.o
|
||||
BUFTEST_OBJS = buftest.o
|
||||
BOOTTEST_OBJS = boottest.o
|
||||
XZ_HEADERS = xz.h xz_private.h xz_stream.h xz_lzma2.h xz_config.h
|
||||
PROGRAMS = xzminidec bytetest buftest boottest
|
||||
|
||||
ALL_CPPFLAGS = -I../linux/include/linux -I. $(BCJ_CPPFLAGS) $(CPPFLAGS)
|
||||
|
||||
all: $(PROGRAMS)
|
||||
|
||||
%.o: %.c $(XZ_HEADERS)
|
||||
$(CC) $(ALL_CPPFLAGS) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
xzminidec: $(COMMON_OBJS) $(XZMINIDEC_OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(XZMINIDEC_OBJS)
|
||||
|
||||
bytetest: $(COMMON_OBJS) $(BYTETEST_OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(BYTETEST_OBJS)
|
||||
|
||||
buftest: $(COMMON_OBJS) $(BUFTEST_OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(BUFTEST_OBJS)
|
||||
|
||||
boottest: $(BOOTTEST_OBJS) $(COMMON_SRCS)
|
||||
$(CC) $(ALL_CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(BOOTTEST_OBJS)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(RM) $(COMMON_OBJS) $(XZMINIDEC_OBJS) $(BUFTEST_OBJS) \
|
||||
$(BOOTTEST_OBJS) $(PROGRAMS)
|
Binary file not shown.
Reference in New Issue
Block a user