Compare commits

...
46 Commits
Author SHA1 Message Date
longpanda 6116894ab8 1.1.18 release
Ventoy CI / build (push) Canceled after 0s
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Canceled after 0s
2026-10-09 12:03:06 +08:00
ca92070fac Plugson: cap Boot Conf Replace at 2 entries per mode (#3727)
Ventoy only supports replacing up to 2 config files per mode, but
Plugson's Boot Conf Replace page let users add unlimited entries with
no indication that anything past the 2nd is silently ignored. Block
the add action once 2 entries exist for the current tab and show a
warning instead.

Fixes #3593

Co-authored-by: Raj <raj@Rajs-MacBook-Pro.local>
2026-10-09 11:33:26 +08:00
Maison da SilvaandGitHub 2af829d020 Fixes accentuation and formatting in the Portuguese help text. (#3746)
* Fixes accentuation and formatting in the Portuguese help text.

Fixes accentuation and formatting in the Portuguese help text.

* Fix typos in Portuguese help text for GRUB

* Fix typo in help text for compatibility mode

* Fix Brazilian Portuguese translations in pt_BR.json

Updated Brazilian Portuguese translations for various menu strings in the GRUB configuration.
2026-10-09 11:31:50 +08:00
argothielandGitHub 2b38972540 doc: Update dependencies links (#3725)
Replace dead links.
Replace arrows with actual commands, for easier copying.
2026-10-09 11:29:24 +08:00
longpanda 85440c00a1 Add a bat for VS build 2026-10-09 10:05:18 +08:00
longpanda ab684ca049 Improve ISO partition auto mount for different Linux distros. 2026-10-09 10:04:53 +08:00
longpanda 96f3210bd0 Make the ISO partition mountable for CloneZilla. (#3274)
Ventoy CI / build (push) Canceled after 0s
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Canceled after 0s
2026-10-08 18:45:50 +08:00
longpanda 490ed6ce0f 1. Improve the Linux remount feature to make the ISO partition mountable out of the box on mainstream desktop distros.
Ventoy CI / build (push) Canceled after 0s
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Canceled after 0s
2. Change the ISO partition dm name to stable /dev/mapper/VentoyPart
2026-10-08 11:10:13 +08:00
longpanda 432152813e VtoyTool add cmds. 2026-10-08 11:04:39 +08:00
longpanda 2c4e686293 Optimize udev process 2026-10-05 23:28:56 +08:00
longpanda a2f6e4e31f Optimize udev process 2026-10-05 23:28:02 +08:00
longpanda 029a0a9d16 Experimental support for SteamOS recovery images. (#3712 #2875 #1815)
Ventoy CI / build (push) Canceled after 0s
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Canceled after 0s
2026-09-30 19:20:12 +08:00
longpanda a67151f859 Make vt_img_extra_initrd_append cmd auto process suffix.
Different Linux distros use different kernel module file format (e.g. .ko/.ko.xz/.ko.zst ...)
Add auto detect feature to vt_img_extra_initrd_append.
2026-09-30 19:10:49 +08:00
longpanda a9331a749c Improvement for latest LinuxConsole release. (#3745)
Ventoy CI / build (push) Canceled after 0s
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Canceled after 0s
2026-09-29 15:35:07 +08:00
longpanda b327e92a34 Add support for custom Syslinux-based ISO (#3760) 2026-09-29 14:32:50 +08:00
longpanda f9669af70c Fix the boot issue for Grml 2026.09 (#3751)
Ventoy CI / build (push) Canceled after 0s
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Canceled after 0s
2026-09-29 09:48:31 +08:00
longpanda ca552e14c0 Change hard coded dracut hooks directory to variable. (#3753)
Ventoy CI / build (push) Canceled after 0s
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Canceled after 0s
Some distros (e.g.  Fedora 45) change dracut hooks directory from /lib/dracut/hooks to /var/lib/dracut/hooks
2026-09-28 20:56:47 +08:00
longpanda 6568972abc Fix Persistence intermittently fails on Ubuntu 24.04 (#3718)
Ventoy CI / build (push) Canceled after 0s
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Canceled after 0s
2026-08-06 12:51:19 +08:00
longpanda 021c237920 Fix the Windows/WinPE secure boot version check failed issue.
Conditions:
1. Secure boot is enabled.
2. Select ByPass policy in Ventoy.
3. With BIOS update to latest. (Windows CA2011 revocated)

Error message is like follows:
Security Error: Secure boot version check failed.
Your system security may be compromised!

Current version: 1.0 - Minimum allowed version: xx.0
Visit https://aka.ms/secure-boot-version-violation for more information.

The system will shutdown in 10 seconds.

......
2026-08-06 11:13:37 +08:00
longpanda 7cbdc5cf69 1.1.17 release
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-07-24 20:56:41 +08:00
longpanda 5903c8bf52 Fix the issue that proxmox-ve can not boot after install in grub2 mode. 2026-07-24 20:53:12 +08:00
Tiago Augusto PimentaandGitHub 40895a09f6 Fix fdisk detection on BusyBox systems (#3614)
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
On BusyBox, fdisk -v exists but returns a non-zero exit code,
causing the script to incorrectly conclude fdisk is not available.
Use POSIX command -v instead to reliably check for fdisk.
2026-07-24 18:26:25 +08:00
HYB1022andGitHub ddc8e53156 [ko_KR] Improve Korean translation (natural phrasing & context fixes) (#3694)
* edit context, Language refinement (korean)

* Update languages.json
2026-07-24 17:31:58 +08:00
longpanda e352b76731 Fix the PATH broken in Ventoy2Disk.sh (#3615) 2026-07-24 17:21:49 +08:00
longpanda 5ebef5af77 Fix the boot issue for latest GhostBSD (#3664) 2026-07-24 16:56:59 +08:00
longpanda 9be9c7adb8 Add support for Athena OS (#3689) 2026-07-24 15:26:59 +08:00
longpanda 3751a47513 Add log for live injection process. 2026-07-24 14:14:12 +08:00
longpanda 6dd3ed3ce3 Fix the disk_write logic error (#3693)
This is indeed a logic error, but actually it does not take effect so it does not cause any install/update failure.
2026-07-24 12:25:35 +08:00
longpanda ac300d7464 Add support for some EulerOS release. 2026-07-24 11:52:45 +08:00
longpanda 0963c1d396 Fix the boot issue for some UOS release. 2026-07-24 11:49:59 +08:00
longpanda a3995a0267 Optimization for secure boot process.
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-06-29 13:46:17 +08:00
longpanda ba87af540b Update hwinfo
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-06-28 23:06:50 +08:00
longpanda 3d0d6c3147 Optimization for secure boot process.
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-06-28 21:48:32 +08:00
longpanda 2915e197e9 Optimization for secure boot process.
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-06-28 00:24:59 +08:00
longpanda 9bf8393cdf Optimization for secure boot process.
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-06-26 18:08:39 +08:00
longpanda 05d10437b0 Remove grub.cfg max resolution script function.
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-06-25 22:37:03 +08:00
longpanda 083e5f72ea Optimization for Secure Boot process. 2026-06-25 22:36:33 +08:00
longpanda 2f66a309e4 1.1.16 release.
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-06-25 19:46:14 +08:00
longpanda aa75cdac7d VtoyShim build script update. 2026-06-25 19:39:15 +08:00
longpanda ccf4f7234a Fix the issue that VTOY_WIN_UEFI_RES_LOCK option reset when enter VentoyPlugson. 2026-06-25 19:38:47 +08:00
longpanda c1cad99584 Merge branch 'master' of https://github.com/Ventoy/Ventoy 2026-06-25 19:31:39 +08:00
VenusGirl❤andGitHub d9cab1cb33 Update Korean (#3649) 2026-06-25 19:31:22 +08:00
independent-argandGitHub 18f4c8afcc i18n: Update and optimize Spanish translation for grub and language JSON (#3648)
* i18n: Update Spanish translation

- Fixed grammatical inconsistencies (unified verbs to infinitive).
- Corrected missing accents and typos (árbol, gráfico, depuración).
- Standardized UI terminology to match original English text (GUI Mode).

* i18n: Update and fix typos in Spanish (Latinoamérica) translation

* docs(i18n): comprehensive Spanish localization updates

* update Spanish translations for Ventoy strings
2026-06-25 19:31:07 +08:00
Roope YrjöläandGitHub aeb46cd3c8 modified: LANGUAGES/languages.json (#3645)
Modified the finnis language translation.
2026-06-25 19:30:54 +08:00
longpanda 475de1dada Fix the boot issue with old UEFI version firmware when secure boot is disabled. 2026-06-25 19:23:48 +08:00
longpanda 31648a0d4b Fix the latest Kicksecure boot issue. (#3651) 2026-06-25 19:16:48 +08:00
100 changed files with 3895 additions and 1019 deletions
+13 -14
View File
@@ -25,22 +25,21 @@
Next I assume that you have unzipped the code into the /home directory (check /home/Ventoy-master/README.md file for the directory layout).
2.2 Download third-party source code and tool
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
https://codeload.github.com/libfuse/libfuse/zip/fuse-2.9.9 ===> /home/Ventoy-master/ExFAT/libfuse-fuse-2.9.9.zip
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
https://github.com/ventoy/vtoytoolchain/releases/download/1.0/mips-loongson-gcc7.3-2019.06-29-linux-gnu.tar.gz ===> /opt/mips-loongson-gcc7.3-2019.06-29-linux-gnu.tar.gz
https://github.com/ventoy/musl-cross-make/releases/download/latest/output.tar.bz2 ===> /opt/output.tar.bz2
wget https://github.com/ventoy/vtoytoolchain/releases/download/1.0/dietlibc-0.34.tar.xz -O /home/Ventoy-master/DOC/dietlibc-0.34.tar.xz
wget https://musl.libc.org/releases/musl-1.2.1.tar.gz -O /home/Ventoy-master/DOC/musl-1.2.1.tar.gz
wget https://ftp.gnu.org/gnu/grub/grub-2.04.tar.xz -O /home/Ventoy-master/GRUB2/grub-2.04.tar.xz
wget https://codeload.github.com/tianocore/edk2/zip/edk2-stable201911 -O /home/Ventoy-master/EDK2/edk2-edk2-stable201911.zip
wget https://codeload.github.com/relan/exfat/zip/v1.3.0 -O /home/Ventoy-master/ExFAT/exfat-1.3.0.zip
wget https://codeload.github.com/libfuse/libfuse/zip/fuse-2.9.9 -O /home/Ventoy-master/ExFAT/libfuse-fuse-2.9.9.zip
wget https://github.com/ventoy/vtoytoolchain/releases/download/1.0/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz -O /opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz
wget https://toolchains.bootlin.com/downloads/releases/toolchains/aarch64/tarballs/aarch64--uclibc--stable-2020.08-1.tar.bz2 -O /opt/aarch64--uclibc--stable-2020.08-1.tar.bz2
wget https://github.com/ventoy/vtoytoolchain/releases/download/1.0/mips-loongson-gcc7.3-2019.06-29-linux-gnu.tar.gz -O /opt/mips-loongson-gcc7.3-2019.06-29-linux-gnu.tar.gz
wget https://github.com/ventoy/musl-cross-make/releases/download/latest/output.tar.bz2 -O /opt/output.tar.bz2
http://www.tinycorelinux.net/11.x/x86_64/release/distribution_files/vmlinuz64 ===> /home/Ventoy-master/LiveCD/ISO/EFI/boot/vmlinuz64
http://www.tinycorelinux.net/11.x/x86_64/release/distribution_files/corepure64.gz ===> /home/Ventoy-master/LiveCD/ISO/EFI/boot/corepure64.gz
http://www.tinycorelinux.net/11.x/x86_64/release/distribution_files/modules64.gz ===> /home/Ventoy-master/LiveCD/ISO/EFI/boot/modules64.gz
wget http://www.tinycorelinux.net/11.x/x86_64/release/distribution_files/vmlinuz64 -O /home/Ventoy-master/LiveCD/ISO/EFI/boot/vmlinuz64
wget http://www.tinycorelinux.net/11.x/x86_64/release/distribution_files/corepure64.gz -O /home/Ventoy-master/LiveCD/ISO/EFI/boot/corepure64.gz
wget http://www.tinycorelinux.net/11.x/x86_64/release/distribution_files/modules64.gz -O /home/Ventoy-master/LiveCD/ISO/EFI/boot/modules64.gz
2.3 Prepare third-party tools
cd /home/Ventoy-master/DOC/
+60 -2
View File
@@ -37,12 +37,70 @@ else
fi
if [ -e $VTEFI_PATH ]; then
objdump -h "$VTEFI_PATH"
echo ""
objcopy \
--add-section .sbat="MdeModulePkg/Application/VtoyShim/sbat.csv" \
--set-section-flags .sbat=alloc,load,readonly,data \
"$VTEFI_PATH" "$DST_PATH"
objcopy --adjust-section-vma .sbat=0x1000 "$DST_PATH"
#find the right sbat section VMA
tmpfile=$(mktemp)
cnt1=$(objdump -h "$DST_PATH" | grep -P '^\s*[0-9][0-9]* \.' | wc -l)
cnt2=$(objdump -h "$DST_PATH" | grep -P 'ALLOC' | wc -l)
if [ $cnt1 -ne $cnt2 ]; then
echo "Section count mismatch $cnt1 $cnt2"
objdump -h "$DST_PATH"
exit 1
fi
objdump -h "$DST_PATH" | grep -P '^\s*[0-9][0-9]* \.' > $tmpfile
sbat_size=$(stat -c '%s' MdeModulePkg/Application/VtoyShim/sbat.csv)
sbat_size_hex=$(printf '0x%08x' $sbat_size)
lmax='0000000000000000'
lsize='0000000000000000'
while read line; do
echo $line
lbase=$(echo $line | awk '{print $4}')
if expr "$lmax" \< "$lbase" > /dev/null; then
lmax=$lbase
lsize=$(echo $line | awk '{print $3}')
fi
echo "max=$lmax size=$lsize"
done < $tmpfile
rm -f $tmpfile
lvma=$((0x${lsize}+0x${lmax}))
lvma_align=`printf '0x%08x' $(( (lvma + 4095) / 4096 * 4096 ))`
echo "sbat section lvma_align=$lvma_align"
objcopy --adjust-section-vma .sbat=$lvma_align "$DST_PATH"
img_base=$(objdump -p "$DST_PATH" | grep ImageBase | awk '{print $2}')
size_img=0x$(objdump -p "$DST_PATH" | grep SizeOfImage | awk '{print $2}')
sbat_end=`printf '0x%08x' $(($lvma_align+$sbat_size_hex))`
if [ "$img_base" != "0000000000000000" ]; then
echo "#### ImageBase is not 0 $img_base"
exit 1
fi
echo "size_img=$size_img sbat_size=$sbat_size_hex sbat_range $lvma_align - $sbat_end"
if expr "$size_img" \< "$sbat_end" > /dev/null; then
echo "SizeOfImage $size_img less than sbat section addr $sbat_end"
exit 1
else
echo "SizeOfImage $size_img >= $sbat_end is OK"
fi
objdump -h "$DST_PATH"
echo -e '\n\n====================== SUCCESS ========================\n\n'
@@ -1231,32 +1231,6 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
return EFI_SUCCESS;
}
#if defined (MDE_CPU_X64)
STATIC BOOLEAN EFIAPI CheckVtoyShim(VOID)
{
UINT8 SecureBoot = 0;
UINTN DataSize;
EFI_STATUS Status;
EFI_GUID Guid = VTOY_SHIM_POLICY_GUID;
VOID *Prot = NULL;
DataSize = sizeof(SecureBoot);
Status = gST->RuntimeServices->GetVariable(L"SecureBoot", &gEfiGlobalVariableGuid, NULL,
&DataSize, &SecureBoot);
if (!EFI_ERROR(Status) && SecureBoot)
{
Status = gBS->LocateProtocol(&Guid, NULL, (VOID**)&Prot);
if (EFI_ERROR(Status))
{
VtoyDebug("Failed to locate Vtoy Shim Protocol %lx\r\n", Status);
return FALSE;
}
}
return TRUE;
}
#endif
EFI_STATUS EFIAPI VentoyEfiMain
(
IN EFI_HANDLE ImageHandle,
@@ -1266,15 +1240,6 @@ EFI_STATUS EFIAPI VentoyEfiMain
EFI_STATUS Status = EFI_SUCCESS;
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *Protocol;
#if defined (MDE_CPU_X64)
/* check that Ventoy Shim must exist */
if (!CheckVtoyShim())
{
sleep(5);
return EFI_NOT_FOUND;
}
#endif
g_sector_flag_num = 512; /* initial value */
g_sector_flag = AllocatePool(g_sector_flag_num * sizeof(ventoy_sector_flag));
@@ -21,6 +21,7 @@
#include <Protocol/LoadedImage.h>
#include <Guid/FileInfo.h>
#include <Guid/FileSystemInfo.h>
#include <Guid/ImageAuthentication.h>
#include <Protocol/BlockIo.h>
#include <Protocol/RamDisk.h>
#include <Protocol/SimpleFileSystem.h>
@@ -34,15 +35,30 @@
#define CUR_SBAT_VER 1
STATIC EFI_GUID gVtoySbatGUID = { 0xf755068a, 0xe04f, 0x452b, { 0x9d, 0x6d, 0x7c, 0x55, 0x96, 0xb3, 0xc0, 0x7d }};
STATIC EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *gDpToText = NULL;
STATIC EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *gTextToDp = NULL;
STATIC UINT8 gVtoyGrubSha256Hash[32] __attribute__((aligned(32))) = {
0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,
0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,
0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,
0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26
};
STATIC BOOLEAN gGrubLaunched = FALSE;
STATIC EFI_GUID gShimLockGUID = SHIM_LOCK_GUID;
STATIC EFI_GUID gMsftDBXSVNOwnerGUID = MSFT_DBX_SVN_OWN_GUID;
STATIC EFI_GUID gBootMgrDBXSVNGUID = EFI_BOOTMGR_DBXSVN_GUID;
STATIC EFI_SECURITY_FILE_AUTHENTICATION_STATE gSysSecFileAuth = NULL;
STATIC EFI_SECURITY2_FILE_AUTHENTICATION gSysSec2FileAuth = NULL;
STATIC BOOLEAN gVtoyByPassSB = FALSE; /* must be FALSE by default for revoke */
STATIC VTOY_SHIM gVtoyShimProtocol;
STATIC EFI_HANDLE gVtoyShimProtHandle;
STATIC SHIM_LOCK *gShimLock = NULL;
STATIC SHIM_LOCK gShimLock;
STATIC EFI_EXIT_BOOT_SERVICES gSysExitBootServices = NULL;
STATIC EFI_GET_VARIABLE gSysGetVariable = NULL;
STATIC VOID EFIAPI HookSystemService(VOID);
STATIC VOID EFIAPI UnHookSystemService(VOID);
STATIC VOID EFIAPI VtoyLog(CONST CHAR16 *Format, ...)
{
@@ -66,11 +82,15 @@ STATIC VOID EFIAPI DumpDevicePath(const EFI_DEVICE_PATH_PROTOCOL *DevicePath)
{
CHAR16 *DPStr = NULL;
DPStr = gDpToText->ConvertDevicePathToText(DevicePath, TRUE, TRUE);
if (DevicePath)
{
DPStr = ConvertDevicePathToText(DevicePath, TRUE, TRUE);
}
if (DPStr)
{
vLog(L"%s", DPStr);
gBS->FreePool(DPStr);
FreePool(DPStr);
}
else
{
@@ -78,31 +98,19 @@ STATIC VOID EFIAPI DumpDevicePath(const EFI_DEVICE_PATH_PROTOCOL *DevicePath)
}
}
STATIC VOID EFIAPI ShowSBWarning(BOOLEAN Reboot, const EFI_DEVICE_PATH_PROTOCOL *DevicePath)
STATIC VOID EFIAPI ShowSBWarning(const EFI_DEVICE_PATH_PROTOCOL *DevicePath)
{
UINTN Index = 0;
vLog(L"\r\n=======================================================");
vLog(L"=======================================================\r\n");
DumpDevicePath(DevicePath);
vLog(L"\r\n####### Security Boot Violation ##########\r\n");
vLog(L"\r\n####### Ventoy Security Boot Violation ##########\r\n");
vLog(L"=======================================================");
vLog(L"=======================================================");
if (Reboot)
{
vLog(L"\r\n###### Press Enter to reboot... ######");
gST->ConIn->Reset(gST->ConIn, FALSE);
gBS->WaitForEvent(1, &gST->ConIn->WaitForKey, &Index);
gRT->ResetSystem(EfiResetWarm, EFI_SECURITY_VIOLATION, 0, NULL);
}
else
{
VtoySleep(5);
}
VtoySleep(5);
}
@@ -129,7 +137,6 @@ STATIC VOID * EFIAPI FindShimFuncAddr(UINT64 FuncOffset)
}
}
EFI_STATUS EFIAPI LaunchRealGrub(EFI_HANDLE ImageHandle, CONST CHAR16 *FileName)
{
EFI_STATUS Status;
@@ -156,7 +163,7 @@ EFI_STATUS EFIAPI LaunchRealGrub(EFI_HANDLE ImageHandle, CONST CHAR16 *FileName)
goto END;
}
DevDpStr = gDpToText->ConvertDevicePathToText(DeviceDP, FALSE, TRUE);
DevDpStr = ConvertDevicePathToText(DeviceDP, FALSE, TRUE);
if (!DevDpStr)
{
vLog(L"Failed to convert device path to text");
@@ -175,7 +182,7 @@ EFI_STATUS EFIAPI LaunchRealGrub(EFI_HANDLE ImageHandle, CONST CHAR16 *FileName)
UnicodeSPrint(NewDpStr, BufferSize, L"%s/EFI/BOOT/%s", DevDpStr, FileName);
TargetDp = gTextToDp->ConvertTextToDevicePath(NewDpStr);
TargetDp = ConvertTextToDevicePath(NewDpStr);
if (!TargetDp)
{
vLog(L"Failed to convert new text <%s> to device path", NewDpStr);
@@ -200,152 +207,39 @@ EFI_STATUS EFIAPI LaunchRealGrub(EFI_HANDLE ImageHandle, CONST CHAR16 *FileName)
END:
CheckBSFreePool(DevDpStr);
CheckFreePool(DevDpStr);
CheckFreePool(NewDpStr);
CheckBSFreePool(TargetDp);
CheckFreePool(TargetDp);
return Status;
}
STATIC EFI_STATUS EFIAPI ReadAuthFile
STATIC EFI_STATUS EFIAPI CheckVtoyGrub
(
const EFI_DEVICE_PATH_PROTOCOL *DevicePathConst,
VOID **Buffer,
UINT32 *Size
VOID *FileBuffer,
UINTN FileSize
)
{
EFI_STATUS Status;
UINTN TmpSize = 0;
CHAR16 *DpStr = NULL;
EFI_HANDLE Handle = NULL;
EFI_DEVICE_PATH *DevPath = NULL;
EFI_DEVICE_PATH *TmpPath = NULL;
EFI_FILE_IO_INTERFACE *FileIO = NULL;
EFI_FILE *File = NULL;
EFI_FILE *Root = NULL;
UINT8 *FileData = NULL;
EFI_FILE_INFO *FInfo = NULL;
UINT8 Buf[1024];
UINT8 Sha256Hash[64];
DevPath = TmpPath = DuplicateDevicePath(DevicePathConst);
if (!DevPath)
if (!FileBuffer || FileSize < sizeof(EFI_IMAGE_DOS_HEADER))
{
Status = EFI_OUT_OF_RESOURCES;
goto END;
vErr(L"Invalid FileBuffer:%p or size:%ld", FileBuffer, FileSize);
return EFI_SECURITY_VIOLATION;
}
Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid, &DevPath, &Handle);
if (EFI_ERROR(Status))
ZeroMem(Sha256Hash, sizeof(Sha256Hash));
calc_sha256(FileBuffer, (UINT64)FileSize, Sha256Hash);
if (CompareMem(Sha256Hash, gVtoyGrubSha256Hash, 32) != 0)
{
vLog(L"Failed to locate simple file protocol %lx", Status);
goto END;
vErr(L"Ventoy hash check failed.");
gRT->ResetSystem(EfiResetWarm, EFI_SECURITY_VIOLATION, 0, NULL);
return EFI_SECURITY_VIOLATION;
}
DpStr = gDpToText->ConvertDevicePathToText(DevPath, FALSE, TRUE);
if (!DpStr)
{
Status = EFI_OUT_OF_RESOURCES;
goto END;
}
Status = gBS->HandleProtocol(Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&FileIO);
if (EFI_ERROR(Status))
{
vLog(L"Failed to handle simple file protocol %lx", Status);
goto END;
}
Status = FileIO->OpenVolume(Handle, &Root);
if (EFI_ERROR(Status))
{
vLog(L"Failed to open drive volume (%lx)\n", Status);
goto END;
}
Status = Root->Open(Root, &File, DpStr, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR(Status))
{
vLog(L"Failed to open file (%s) (%lx)\n", DpStr, Status);
goto END;
}
FInfo = (EFI_FILE_INFO *)Buf;
TmpSize = sizeof(Buf);
ZeroMem(FInfo, sizeof(EFI_FILE_INFO));
Status = File->GetInfo(File, &gEfiFileInfoGuid, &TmpSize, FInfo);
if (EFI_ERROR(Status) || FInfo->FileSize == 0 || FInfo->FileSize >= 0xFFFFFFFFUL)
{
vLog(L"Failed to open file (%s) (%lx) Size(%ld)\n", DpStr, Status, (UINTN)FInfo->FileSize);
goto END;
}
FileData = AllocatePool(FInfo->FileSize);
if (!FileData)
{
Status = EFI_OUT_OF_RESOURCES;
goto END;
}
TmpSize = FInfo->FileSize;
Status = File->Read(File, &TmpSize, FileData);
if (EFI_ERROR(Status) || TmpSize != (UINTN)FInfo->FileSize)
{
vLog(L"Failed to read file (%lx) Read:%ld Size:%ld\n", Status, TmpSize, (UINTN)FInfo->FileSize);
goto END;
}
END:
if (File)
{
File->Close(File);
}
if (Root)
{
Root->Close(Root);
}
CheckFreePool(TmpPath);
CheckBSFreePool(DpStr);
if (EFI_ERROR(Status))
{
CheckFreePool(FileData);
}
else
{
*Buffer = FileData;
*Size = (UINT32)FInfo->FileSize;
}
return Status;
}
STATIC BOOLEAN VtoyCheckRevoke(VOID *Buffer, UINTN Size)
{
UINT32 uiVer = 0;
EFI_IMAGE_DOS_HEADER *DosHead = (EFI_IMAGE_DOS_HEADER *)Buffer;
if (Size > sizeof(EFI_IMAGE_DOS_HEADER))
{
if (CompareMem(DosHead->e_res2, &gVtoySbatGUID, 16) == 0)
{
CopyMem(&uiVer, DosHead->e_res2 + 8, 4);
if (uiVer < CUR_SBAT_VER)
{
vLog(L"Ventoy EFI file revoke (%u < %u)", uiVer, CUR_SBAT_VER);
return FALSE;
}
}
}
return TRUE;
return EFI_SUCCESS;
}
STATIC EFI_STATUS EFIAPI SecurityPolicyAuth
@@ -355,59 +249,17 @@ STATIC EFI_STATUS EFIAPI SecurityPolicyAuth
const EFI_DEVICE_PATH_PROTOCOL *DevicePathConst
)
{
EFI_STATUS Status;
BOOLEAN bRevokeChkOK = TRUE;
UINT32 Size = 0;
VOID *Buffer = NULL;
/* Just return OK if the user choose to bypass SB */
if (gVtoyByPassSB)
{
return EFI_SUCCESS;
}
/*
* Step 1:
* Use original UEFI firmware auth API.
* If it's OK, it may be signed with Microsoft UEFI CA. (e.g. bootmgr/shim/...)
* Some old UEFI firmware (without Security2 protocol) will hang when run OpenVolume.
* So finally I decide not to support such UEFI firmware.
* It means that for UEFI firmware before 2.5 (about 2015) Ventoy only supports Bypass policy.
*
*/
if (gSysSecFileAuth)
{
Status = gSysSecFileAuth(This, AuthenticationStatus, DevicePathConst);
if (!EFI_ERROR(Status))
{
return EFI_SUCCESS;
}
}
/*
* Step 2:
* Use shim verify API.
* If it's OK, it may be signed with a MOK key. (e.g. Ventoy EFI files)
*/
if (gShimLock && gShimLock->Verify)
{
Status = ReadAuthFile(DevicePathConst, &Buffer, &Size);
if (!EFI_ERROR(Status))
{
Status = gShimLock->Verify(Buffer, Size);
if (!EFI_ERROR(Status))
{
bRevokeChkOK = VtoyCheckRevoke(Buffer, Size);
if (bRevokeChkOK)
{
FreePool(Buffer);
return EFI_SUCCESS;
}
}
FreePool(Buffer);
}
}
ShowSBWarning(!bRevokeChkOK, DevicePathConst);
return EFI_SECURITY_VIOLATION;
(VOID)This;
(VOID)AuthenticationStatus;
(VOID)DevicePathConst;
return EFI_SUCCESS;
}
STATIC EFI_STATUS EFIAPI Security2PolicyAuth
@@ -420,7 +272,6 @@ STATIC EFI_STATUS EFIAPI Security2PolicyAuth
)
{
EFI_STATUS Status;
BOOLEAN bRevokeChkOK = TRUE;
/* Just return OK if the user choose to bypass SB */
if (gVtoyByPassSB)
@@ -428,6 +279,11 @@ STATIC EFI_STATUS EFIAPI Security2PolicyAuth
return EFI_SUCCESS;
}
if (!gGrubLaunched)
{
return CheckVtoyGrub(FileBuffer, FileSize);
}
/*
* Step 1:
* Use original UEFI firmware auth API.
@@ -448,23 +304,19 @@ STATIC EFI_STATUS EFIAPI Security2PolicyAuth
* Use shim verify API.
* If it's OK, it may be signed with a MOK key. (e.g. Ventoy EFI files)
*/
if (gShimLock && gShimLock->Verify)
if (gShimLock.Verify)
{
if (FileBuffer && FileSize > 0 && FileSize < 0xFFFFFFFFUL)
{
Status = gShimLock->Verify(FileBuffer, (UINT32)FileSize);
Status = gShimLock.Verify(FileBuffer, (UINT32)FileSize);
if (!EFI_ERROR(Status))
{
bRevokeChkOK = VtoyCheckRevoke(FileBuffer, FileSize);
if (bRevokeChkOK)
{
return EFI_SUCCESS;
}
return EFI_SUCCESS;
}
}
}
ShowSBWarning(!bRevokeChkOK, DevicePath);
ShowSBWarning(DevicePath);
return EFI_SECURITY_VIOLATION;
}
@@ -522,13 +374,13 @@ STATIC VOID EFIAPI UnHookSecurityPolicy(VOID)
return;
}
if (Security2 && gSysSec2FileAuth)
if (Security2 && gSysSec2FileAuth && Security2->FileAuthentication == Security2PolicyAuth)
{
Security2->FileAuthentication = gSysSec2FileAuth;
gSysSec2FileAuth = NULL;
}
if (Security && gSysSecFileAuth)
if (Security && gSysSecFileAuth && Security->FileAuthenticationState == SecurityPolicyAuth)
{
Security->FileAuthenticationState = gSysSecFileAuth;
gSysSecFileAuth = NULL;
@@ -545,6 +397,11 @@ STATIC VOID EFIAPI VtoyCheckSB(VOID)
gVtoyByPassSB = FALSE;
}
STATIC VOID EFIAPI VtoyLaunched(VOID)
{
gGrubLaunched = TRUE;
}
STATIC VOID EFIAPI UnInstallVtoyShimProtocol(VOID)
{
EFI_GUID Guid = VTOY_SHIM_POLICY_GUID;
@@ -564,6 +421,7 @@ STATIC EFI_STATUS EFIAPI InstallVtoyShimProtocol(VOID)
gVtoyShimProtocol.ByPassSB = VtoyByPassSB;
gVtoyShimProtocol.CheckSB = VtoyCheckSB;
gVtoyShimProtocol.Launched = VtoyLaunched;
Status = gBS->LocateProtocol(&Guid, NULL, (VOID**)&Prot);
if (!EFI_ERROR(Status))
@@ -599,63 +457,46 @@ STATIC BOOLEAN EFIAPI IsSecureBootEnabled(VOID)
return SecureBoot ? TRUE : FALSE;
}
STATIC EFI_STATUS EFIAPI EnvInit(VOID)
STATIC BOOLEAN EFIAPI IsSetupMode(VOID)
{
EFI_STATUS Status;
UINT8 SetupMode = 0;
UINTN DataSize;
EFI_STATUS Status;
Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID**)&gDpToText);
if (EFI_ERROR(Status) || !gDpToText || !gDpToText->ConvertDevicePathToText)
DataSize = sizeof(SetupMode);
Status = gST->RuntimeServices->GetVariable(L"SetupMode", &gEfiGlobalVariableGuid, NULL,
&DataSize, &SetupMode);
if (EFI_ERROR(Status))
{
vLog(L"Failed to locate PathToText Protocol %lx", Status);
return Status;
return FALSE;
}
Status = gBS->LocateProtocol(&gEfiDevicePathFromTextProtocolGuid, NULL, (VOID**)&gTextToDp);
if (EFI_ERROR(Status) || !gTextToDp || !gTextToDp->ConvertTextToDevicePath)
{
vLog(L"Failed to locate PathFromText Protocol %lx", Status);
return Status;
}
return EFI_SUCCESS;
return SetupMode ? TRUE : FALSE;
}
EFI_STATUS EFIAPI VtoyShimEfiMain
STATIC EFI_STATUS EFIAPI ShimEfiMain
(
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_GUID Guid = SHIM_LOCK_GUID;
unhook_system_services_pf Func = NULL;
SHIM_LOCK *ShimLock = NULL;
shim_void_func_pf Func1 = NULL;
shim_void_func_pf Func2 = NULL;
Status = EnvInit();
if (EFI_ERROR(Status))
{
vErr(L"Failed to prepare env");
return Status;
}
/* If secure boot is not enabled, nothing needed, just launch Ventoy grub */
if (!IsSecureBootEnabled())
{
Status = LaunchRealGrub(ImageHandle, REAL_GRUB_FILE);
if (EFI_ERROR(Status))
{
vErr(L"Failed to launch %s", REAL_GRUB_FILE);
}
return Status;
}
Status = gBS->LocateProtocol(&Guid, NULL, (VOID**)&gShimLock);
if (EFI_ERROR(Status) || !gShimLock)
/* We must be launched by shim */
Status = gBS->LocateProtocol(&gShimLockGUID, NULL, (VOID**)&ShimLock);
if (EFI_ERROR(Status) || !ShimLock)
{
vErr(L"Failed to locate SHIM LOCK Protocol %lx", Status);
return Status;
}
/* Backup shim Lock because we will remove it later */
gShimLock.Verify = ShimLock->Verify;
gShimLock.Hash = ShimLock->Hash;
gShimLock.Context = ShimLock->Context;
Status = InstallVtoyShimProtocol();
if (EFI_ERROR(Status))
@@ -679,16 +520,19 @@ EFI_STATUS EFIAPI VtoyShimEfiMain
* It may break in future versions of shim, and a better approach may exist.
*
*/
Func = FindShimFuncAddr(NM_UNHOOK_SYSTEM_SERVICES_OFFSET);
if (!Func)
Func1 = FindShimFuncAddr(NM_UNHOOK_SYSTEM_SERVICES_OFFSET);
Func2 = FindShimFuncAddr(NM_UNINSTALL_SHIM_PROTOCOLS_OFFSET);
if (!Func1 || !Func2)
{
vErr(L"Can not find shim unhook_system_services");
vErr(L"Can not find shim func %p %p", Func1, Func2);
Status = EFI_NOT_FOUND;
goto END;
}
Func(); /* call shim unhook_system_services() */
Func1(); /* call shim unhook_system_services() */
Func2(); /* call shim uninstall_shim_protocols() */
HookSystemService();
/* Hook the system security policy */
Status = HookSecurityPolicy();
@@ -698,6 +542,7 @@ EFI_STATUS EFIAPI VtoyShimEfiMain
goto END;
}
/* Finally launch Ventoy grub */
Status = LaunchRealGrub(ImageHandle, REAL_GRUB_FILE);
if (EFI_ERROR(Status))
@@ -713,6 +558,182 @@ END:
UnInstallVtoyShimProtocol();
UnHookSystemService();
return Status;
}
STATIC EFI_STATUS EFIAPI VtoyHookDBX(UINTN DataSize, VOID *Data)
{
UINT32 i = 0;
UINT32 Count = 0;
UINTN Offset = 0;
EFI_SIGNATURE_LIST *pstCurSig = NULL;
EFI_SIGNATURE_DATA *pstSigData = NULL;
for (Offset = 0; Offset + sizeof(EFI_SIGNATURE_LIST) <= DataSize; Offset += pstCurSig->SignatureListSize)
{
pstCurSig = (EFI_SIGNATURE_LIST *)((UINT8 *)Data + Offset);
if (pstCurSig->SignatureSize == 0 || pstCurSig->SignatureListSize == 0 ||
Offset + pstCurSig->SignatureListSize > DataSize ||
pstCurSig->SignatureListSize < sizeof(EFI_SIGNATURE_LIST) + pstCurSig->SignatureHeaderSize)
{
break;
}
if (!CompareGuid(&pstCurSig->SignatureType, &gEfiCertSha256Guid))
{
continue;
}
pstSigData = (EFI_SIGNATURE_DATA *)((UINT8 *)pstCurSig + sizeof(EFI_SIGNATURE_LIST) + pstCurSig->SignatureHeaderSize);
Count = (pstCurSig->SignatureListSize - sizeof(EFI_SIGNATURE_LIST) - pstCurSig->SignatureHeaderSize) / pstCurSig->SignatureSize;
#if 0
if (Count > 0 && pstCurSig->SignatureSize == 48)
{
vDbg(L"Make a fake SVN signature for test");
CopyMem(&pstSigData->SignatureOwner, &gMsftDBXSVNOwnerGUID, sizeof(EFI_GUID));
ZeroMem(pstSigData->SignatureData, pstCurSig->SignatureSize);
CopyMem(&pstSigData->SignatureData + 1, &gBootMgrDBXSVNGUID, sizeof(EFI_GUID));
pstSigData->SignatureData[0] = 1;
DBX_SVN_SET(pstSigData->SignatureData, 100);
break;
}
#endif
for (i = 0; i < Count; i++)
{
if (CompareGuid(&pstSigData->SignatureOwner, &gMsftDBXSVNOwnerGUID) &&
CompareGuid((CONST EFI_GUID *)(pstSigData->SignatureData + 1), &gBootMgrDBXSVNGUID))
{
DBX_SVN_SET(pstSigData->SignatureData, 1);
return EFI_SUCCESS;
}
pstSigData = (EFI_SIGNATURE_DATA *)((UINT8 *)pstSigData + pstCurSig->SignatureSize);
}
}
return EFI_SUCCESS;
}
EFI_STATUS EFIAPI VtoyGetVariable
(
IN CHAR16 *VariableName,
IN EFI_GUID *VendorGuid,
OUT UINT32 *Attributes, OPTIONAL
IN OUT UINTN *DataSize,
OUT VOID *Data OPTIONAL
)
{
BOOLEAN bChk = FALSE;
EFI_STATUS Status;
if (gVtoyByPassSB && VariableName && VendorGuid && DataSize && Data)
{
bChk = TRUE;
}
Status = gSysGetVariable(VariableName, VendorGuid, Attributes, DataSize, Data);
if (bChk && EFI_SUCCESS == Status)
{
if (EFI_VAR_MATCH(&gShimLockGUID, L"MokSBState"))
{
*(UINT8 *)Data = 1;
}
else if (EFI_VAR_MATCH(&gEfiImageSecurityDatabaseGuid, L"dbx"))
{
VtoyHookDBX(*DataSize, Data);
}
}
return Status;
}
STATIC VOID EFIAPI UnHookSystemService(VOID)
{
UINT32 uiNewCRC = 0;
EFI_TABLE_HEADER *Hdr = &gST->RuntimeServices->Hdr;
if (gSysExitBootServices)
{
gBS->ExitBootServices = gSysExitBootServices;
gSysExitBootServices = NULL;
}
if (gSysGetVariable)
{
gST->RuntimeServices->GetVariable = gSysGetVariable;
gSysGetVariable = NULL;
Hdr->CRC32 = 0;
gBS->CalculateCrc32(Hdr, Hdr->HeaderSize, &uiNewCRC);
Hdr->CRC32 = uiNewCRC;
}
}
STATIC EFI_STATUS EFIAPI VtoyExitBootServices
(
IN EFI_HANDLE ImageHandle,
IN UINTN MapKey
)
{
EFI_EXIT_BOOT_SERVICES SysExitBS;
/* UnHookSystemService will set gSysExitBootServices NULL */
SysExitBS = gSysExitBootServices;
UnHookSecurityPolicy();
UnInstallVtoyShimProtocol();
UnHookSystemService();
return SysExitBS(ImageHandle, MapKey);
}
STATIC VOID EFIAPI HookSystemService(VOID)
{
UINT32 uiNewCRC = 0;
EFI_TABLE_HEADER *Hdr = &gST->RuntimeServices->Hdr;
gSysExitBootServices = gBS->ExitBootServices;
gBS->ExitBootServices = VtoyExitBootServices;
gSysGetVariable = gST->RuntimeServices->GetVariable;
gST->RuntimeServices->GetVariable = VtoyGetVariable;
Hdr->CRC32 = 0;
gBS->CalculateCrc32(Hdr, Hdr->HeaderSize, &uiNewCRC);
Hdr->CRC32 = uiNewCRC;
}
EFI_STATUS EFIAPI VtoyShimEfiMain
(
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
BOOLEAN IsSetup = FALSE;
BOOLEAN IsSecureBoot = FALSE;
EFI_STATUS Status;
IsSetup = IsSetupMode();
IsSecureBoot = IsSecureBootEnabled();
if (!IsSecureBoot || IsSetup)
{
/* If secure boot is not enabled or in SetupMode, nothing needed, just launch Ventoy grub */
Status = LaunchRealGrub(ImageHandle, REAL_GRUB_FILE);
if (EFI_ERROR(Status))
{
vErr(L"Failed to launch %s", REAL_GRUB_FILE);
}
}
else
{
Status = ShimEfiMain(ImageHandle, SystemTable);
}
return Status;
}
@@ -22,7 +22,23 @@
/* The following definations are copied from shim source code */
#define SHIM_LOCK_GUID {0x605dab50, 0xe046, 0x4300, {0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23 } };
#define SHIM_LOCK_GUID {0x605dab50, 0xe046, 0x4300, {0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23 } }
#define MSFT_DBX_SVN_OWN_GUID { 0x9d132b6c, 0x59d5, 0x4388, {0xab, 0x1c, 0x18, 0x5c, 0xfc, 0xb2, 0xeb, 0x92}}
#define EFI_BOOTMGR_DBXSVN_GUID { 0x9d132b61, 0x59d5, 0x4388, {0xab, 0x1c, 0x18, 0x5c, 0x3c, 0xb2, 0xeb, 0x92}}
#define EFI_VAR_MATCH(pguid, name) \
(CompareMem((pguid), VendorGuid, 16) == 0 && StrCmp(VariableName, (name)) == 0)
#define DBX_SVN_SET(SigData, SVN) \
do { \
SigData[17] = 0; \
SigData[18] = 0; \
SigData[19] = (SVN); \
SigData[20] = 0; \
} while (0)
typedef
EFI_STATUS
@@ -66,19 +82,21 @@ typedef struct _SHIM_IMAGE_LOADER {
EFI_IMAGE_UNLOAD UnloadImage;
} SHIM_IMAGE_LOADER;
typedef VOID (*unhook_system_services_pf)(VOID);
typedef VOID (*shim_void_func_pf)(VOID);
/*
* The two offset here are extract from the shim file which used in Ventoy.
* nm BOOTX64.EFI | grep shim_load_image
* nm BOOTX64.EFI | grep unhook_system_services
* nm BOOTX64.EFI | grep uninstall_shim_protocols
*
* It means that they must be updated every time Ventoy update the shim file.
*
*/
#define NM_SHIM_LOAD_IMAGE_OFFSET 0x2dc12
#define NM_UNHOOK_SYSTEM_SERVICES_OFFSET 0x2e278
#define NM_UNINSTALL_SHIM_PROTOCOLS_OFFSET 0x26264
@@ -86,6 +104,7 @@ typedef VOID (*unhook_system_services_pf)(VOID);
#define VtoySleep(sec) gBS->Stall(1000000 * (sec))
#define vLog(fmt, ...) VtoyLog(fmt "\r\n", ##__VA_ARGS__)
#define vErr(fmt, ...) VtoyLog(fmt "\r\n", ##__VA_ARGS__); VtoySleep(5)
#define vDbg(fmt, ...) VtoyLog(fmt "\r\n", ##__VA_ARGS__); VtoySleep(1)
#define CheckFreePool(p) \
do { \
@@ -95,27 +114,19 @@ do { \
}\
} while (0)
#define CheckBSFreePool(p) \
do { \
if (p) { \
gBS->FreePool(p); \
(p) = NULL; \
}\
} while (0)
#define VTOY_SHIM_POLICY_GUID {0x90a29d14, 0x3968, 0x48fe, { 0x85, 0x81, 0x6b, 0x7f, 0x7d, 0xc4, 0x70, 0x55 }};
typedef VOID (EFIAPI *VTOY_BYPASS_SB)(VOID);
typedef VOID (EFIAPI *VTOY_CHECK_SB)(VOID);
typedef VOID (EFIAPI *VTOY_LAUNCHED)(VOID);
typedef struct _VTOY_SHIM{
VTOY_BYPASS_SB ByPassSB;
VTOY_BYPASS_SB CheckSB;
VTOY_LAUNCHED Launched;
} VTOY_SHIM;
CONST UINT8 * ventoy_get_der_data(UINT32 *Len);
void calc_sha256(const void *data, UINT64 len, void *output);
#endif
@@ -31,6 +31,7 @@
[Sources]
VtoyShim.h
VtoyShim.c
sha256.c
[Packages]
MdePkg/MdePkg.dec
@@ -45,6 +46,8 @@
[Guids]
gEfiGlobalVariableGuid
gEfiImageSecurityDatabaseGuid
gEfiCertSha256Guid
gShellVariableGuid
gEfiVirtualCdGuid
gEfiFileInfoGuid
@@ -0,0 +1,170 @@
/******************************************************************************
* VtoyShim.c
*
* Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
* SPDX-License-Identifier: BSD-2-Clause-Patent
*
*/
#include <Uefi.h>
#include <Library/DebugLib.h>
#include <Library/PrintLib.h>
#include <Library/UefiLib.h>
#include <Library/BaseMemoryLib.h>
static const UINT32 sha256_initial_h[8]
= { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 };
static const UINT32 sha256_round_k[64]
= { 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,
0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,
0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 };
static void sha256_endian_reverse64(UINT64 input, UINT8 *output) {
output[7] = (input >> 0) & 0xff;
output[6] = (input >> 8) & 0xff;
output[5] = (input >> 16) & 0xff;
output[4] = (input >> 24) & 0xff;
output[3] = (input >> 32) & 0xff;
output[2] = (input >> 40) & 0xff;
output[1] = (input >> 48) & 0xff;
output[0] = (input >> 56) & 0xff;
}
static UINT32 sha256_endian_read32(UINT8 *input) {
UINT32 output = 0;
output |= (input[0] << 24);
output |= (input[1] << 16);
output |= (input[2] << 8);
output |= (input[3] << 0);
return output;
}
static void sha256_endian_reverse32(UINT32 input, UINT8 *output) {
output[3] = (input >> 0) & 0xff;
output[2] = (input >> 8) & 0xff;
output[1] = (input >> 16) & 0xff;
output[0] = (input >> 24) & 0xff;
}
static UINT32 sha256_ror(UINT32 input, UINT32 by) {
return (input >> by) | (((input & ((1 << by) - 1))) << (32 - by));
}
void calc_sha256(const void *data, UINT64 len, void *output)
{
int i = 0;
int j = 0;
UINT8 padding[80];
UINT64 current = (len + 1) % 64;
// want to be == 56 % 64.
UINT64 needed = (64 + 56 - current) % 64;
UINT64 extra = needed + 9;
UINT64 total = len + extra;
UINT32 v[8];
UINT64 cursor = 0;
for(i = 1; i < 80; i++)
{
padding[i] = 0;
}
padding[0] = 0x80;
sha256_endian_reverse64(len * 8, padding + total - len - 8);
for(i = 0; i < 8; i++)
{
v[i] = sha256_initial_h[i];
}
for(cursor = 0; cursor * 64 < total; cursor++)
{
UINT32 t[8];
UINT32 w[64];
for(i = 0; i < 8; i++)
{
t[i] = v[i];
}
if(cursor * 64 + 64 <= len)
{
for(j = 0; j < 16; j++)
{
w[j] = sha256_endian_read32((UINT8 *)data + cursor * 64 + j * 4);
}
}
else
{
if(cursor * 64 < len)
{
UINT64 size = len - cursor * 64;
if(size > 0)
{
CopyMem(w, (UINT8 *)data + cursor * 64, size);
}
CopyMem((UINT8 *)w + size, padding, 64 - size);
}
else
{
UINT64 off = (cursor * 64 - len) % 64;
CopyMem((UINT8 *)w, padding + off, 64);
}
for(j = 0; j < 16; j++)
{
w[j] = sha256_endian_read32((UINT8 *)&w[j]);
}
}
for(j = 16; j < 64; j++)
{
UINT32 s1 = sha256_ror(w[j - 2], 17) ^ sha256_ror(w[j - 2], 19) ^ (w[j - 2] >> 10);
UINT32 s0 = sha256_ror(w[j - 15], 7) ^ sha256_ror(w[j - 15], 18) ^ (w[j - 15] >> 3);
w[j] = s1 + w[j - 7] + s0 + w[j - 16];
}
for(j = 0; j < 64; j++)
{
UINT32 ch = (t[4] & t[5]) ^ (~t[4] & t[6]);
UINT32 maj = (t[0] & t[1]) ^ (t[0] & t[2]) ^ (t[1] & t[2]);
UINT32 S0 = sha256_ror(t[0], 2) ^ sha256_ror(t[0], 13) ^ sha256_ror(t[0], 22);
UINT32 S1 = sha256_ror(t[4], 6) ^ sha256_ror(t[4], 11) ^ sha256_ror(t[4], 25);
UINT32 t1 = t[7] + S1 + ch + sha256_round_k[j] + w[j];
UINT32 t2 = S0 + maj;
t[7] = t[6];
t[6] = t[5];
t[5] = t[4];
t[4] = t[3] + t1;
t[3] = t[2];
t[2] = t[1];
t[1] = t[0];
t[0] = t1 + t2;
}
for(i = 0; i < 8; i++)
{
v[i] += t[i];
}
}
for(i = 0; i < 8; i++)
{
sha256_endian_reverse32(v[i], (UINT8 *)output + i * 4);
}
}
@@ -145,32 +145,6 @@ STATIC EFI_STATUS ParseCmdline(IN EFI_HANDLE ImageHandle)
return EFI_SUCCESS;
}
#if defined (MDE_CPU_X64)
STATIC BOOLEAN EFIAPI CheckVtoyShim(VOID)
{
UINT8 SecureBoot = 0;
UINTN DataSize;
EFI_STATUS Status;
EFI_GUID Guid = VTOY_SHIM_POLICY_GUID;
VOID *Prot = NULL;
DataSize = sizeof(SecureBoot);
Status = gST->RuntimeServices->GetVariable(L"SecureBoot", &gEfiGlobalVariableGuid, NULL,
&DataSize, &SecureBoot);
if (!EFI_ERROR(Status) && SecureBoot)
{
Status = gBS->LocateProtocol(&Guid, NULL, (VOID**)&Prot);
if (EFI_ERROR(Status))
{
gST->ConOut->OutputString(gST->ConOut, L"Can not locate Vtoy Shim\r\n");
return FALSE;
}
}
return TRUE;
}
#endif
EFI_STATUS EFIAPI VtoyUtilEfiMain
(
IN EFI_HANDLE ImageHandle,
@@ -180,15 +154,6 @@ EFI_STATUS EFIAPI VtoyUtilEfiMain
UINTN i;
UINTN Len;
#if defined (MDE_CPU_X64)
/* check that Ventoy Shim must exist */
if (!CheckVtoyShim())
{
gBS->Stall(5 * 1000000);
return EFI_NOT_FOUND;
}
#endif
ParseCmdline(ImageHandle);
for (i = 0; gCurFeature && i < ARRAY_SIZE(gFeatureList); i++)
@@ -0,0 +1,98 @@
/* fwsetup.c - Reboot into firmware setup menu. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2012 Free Software Foundation, Inc.
*
* GRUB 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.
*
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/types.h>
#include <grub/mm.h>
#include <grub/misc.h>
#include <grub/efi/api.h>
#include <grub/efi/efi.h>
#include <grub/command.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+");
static grub_efi_boolean_t efifwsetup_is_supported (void);
static grub_err_t
grub_cmd_fwsetup (grub_command_t cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
grub_efi_uint64_t *old_os_indications;
grub_efi_uint64_t os_indications = GRUB_EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
grub_err_t status;
grub_size_t oi_size;
grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
if (argc >= 1 && grub_strcmp(args[0], "--is-supported") == 0)
return !efifwsetup_is_supported ();
if (!efifwsetup_is_supported ())
return grub_error (GRUB_ERR_INVALID_COMMAND,
N_("reboot to firmware setup is not supported by the current firmware"));
old_os_indications = grub_efi_get_variable ("OsIndications", &global,
&oi_size);
if (old_os_indications != NULL && oi_size == sizeof (os_indications))
os_indications |= *old_os_indications;
status = grub_efi_set_variable ("OsIndications", &global, &os_indications,
sizeof (os_indications));
if (status != GRUB_ERR_NONE)
return status;
grub_reboot ();
return GRUB_ERR_BUG;
}
static grub_command_t cmd = NULL;
static grub_efi_boolean_t
efifwsetup_is_supported (void)
{
grub_efi_uint64_t *os_indications_supported = NULL;
grub_size_t oi_size = 0;
grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
os_indications_supported = grub_efi_get_variable ("OsIndicationsSupported",
&global, &oi_size);
if (!os_indications_supported)
return 0;
if (*os_indications_supported & GRUB_EFI_OS_INDICATIONS_BOOT_TO_FW_UI)
return 1;
return 0;
}
GRUB_MOD_INIT (efifwsetup)
{
cmd = grub_register_command ("fwsetup", grub_cmd_fwsetup, NULL,
N_("Reboot into firmware setup menu."));
}
GRUB_MOD_FINI (efifwsetup)
{
if (cmd)
grub_unregister_command (cmd);
}
@@ -0,0 +1,313 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009,2010 Free Software Foundation, Inc.
*
* GRUB 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.
*
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/mm.h>
#include <grub/dl.h>
#include <grub/command.h>
#include <grub/term.h>
#include <grub/i18n.h>
#include <grub/misc.h>
GRUB_MOD_LICENSE ("GPLv3+");
static grub_uint8_t g_terminal_lock = 0;
struct grub_term_autoload *grub_term_input_autoload = NULL;
struct grub_term_autoload *grub_term_output_autoload = NULL;
struct abstract_terminal
{
struct abstract_terminal *next;
struct abstract_terminal *prev;
const char *name;
grub_err_t (*init) (struct abstract_terminal *term);
grub_err_t (*fini) (struct abstract_terminal *term);
};
static grub_err_t
handle_command (int argc, char **args, struct abstract_terminal **enabled,
struct abstract_terminal **disabled,
struct grub_term_autoload *autoloads,
const char *active_str,
const char *available_str)
{
int i;
struct abstract_terminal *term;
struct grub_term_autoload *aut;
if (argc == 0)
{
grub_puts_ (active_str);
for (term = *enabled; term; term = term->next)
grub_printf ("%s ", term->name);
grub_printf ("\n");
grub_puts_ (available_str);
for (term = *disabled; term; term = term->next)
grub_printf ("%s ", term->name);
/* This is quadratic but we don't expect mode than 30 terminal
modules ever. */
for (aut = autoloads; aut; aut = aut->next)
{
for (term = *disabled; term; term = term->next)
if (grub_strcmp (term->name, aut->name) == 0
|| (aut->name[0] && aut->name[grub_strlen (aut->name) - 1] == '*'
&& grub_memcmp (term->name, aut->name,
grub_strlen (aut->name) - 1) == 0))
break;
if (!term)
for (term = *enabled; term; term = term->next)
if (grub_strcmp (term->name, aut->name) == 0
|| (aut->name[0] && aut->name[grub_strlen (aut->name) - 1] == '*'
&& grub_memcmp (term->name, aut->name,
grub_strlen (aut->name) - 1) == 0))
break;
if (!term)
grub_printf ("%s ", aut->name);
}
grub_printf ("\n");
return GRUB_ERR_NONE;
}
i = 0;
if (grub_strcmp (args[0], "--append") == 0
|| grub_strcmp (args[0], "--remove") == 0)
i++;
if (i == argc)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_ ("no terminal specified"));
for (; i < argc; i++)
{
int again = 0;
while (1)
{
for (term = *disabled; term; term = term->next)
if (grub_strcmp (args[i], term->name) == 0
|| (grub_strcmp (args[i], "ofconsole") == 0
&& grub_strcmp ("console", term->name) == 0))
break;
if (term == 0)
for (term = *enabled; term; term = term->next)
if (grub_strcmp (args[i], term->name) == 0
|| (grub_strcmp (args[i], "ofconsole") == 0
&& grub_strcmp ("console", term->name) == 0))
break;
if (term)
break;
if (again)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
N_("terminal `%s' isn't found"),
args[i]);
for (aut = autoloads; aut; aut = aut->next)
if (grub_strcmp (args[i], aut->name) == 0
|| (grub_strcmp (args[i], "ofconsole") == 0
&& grub_strcmp ("console", aut->name) == 0)
|| (aut->name[0] && aut->name[grub_strlen (aut->name) - 1] == '*'
&& grub_memcmp (args[i], aut->name,
grub_strlen (aut->name) - 1) == 0))
{
grub_dl_t mod;
mod = grub_dl_load (aut->modname);
if (mod)
grub_dl_ref (mod);
grub_errno = GRUB_ERR_NONE;
break;
}
if (grub_memcmp (args[i], "serial_usb",
sizeof ("serial_usb") - 1) == 0
&& grub_term_poll_usb)
{
grub_term_poll_usb (1);
again = 1;
continue;
}
if (!aut)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
N_("terminal `%s' isn't found"),
args[i]);
again = 1;
}
}
if (grub_strcmp (args[0], "--append") == 0)
{
for (i = 1; i < argc; i++)
{
for (term = *disabled; term; term = term->next)
if (grub_strcmp (args[i], term->name) == 0
|| (grub_strcmp (args[i], "ofconsole") == 0
&& grub_strcmp ("console", term->name) == 0))
break;
if (term)
{
if (term->init && term->init (term) != GRUB_ERR_NONE)
return grub_errno;
grub_list_remove (GRUB_AS_LIST (term));
grub_list_push (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
}
}
return GRUB_ERR_NONE;
}
if (grub_strcmp (args[0], "--remove") == 0)
{
for (i = 1; i < argc; i++)
{
for (term = *enabled; term; term = term->next)
if (grub_strcmp (args[i], term->name) == 0
|| (grub_strcmp (args[i], "ofconsole") == 0
&& grub_strcmp ("console", term->name) == 0))
break;
if (term)
{
if (!term->next && term == *enabled)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"can't remove the last terminal");
grub_list_remove (GRUB_AS_LIST (term));
if (term->fini)
term->fini (term);
grub_list_push (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
}
}
return GRUB_ERR_NONE;
}
for (i = 0; i < argc; i++)
{
for (term = *disabled; term; term = term->next)
if (grub_strcmp (args[i], term->name) == 0
|| (grub_strcmp (args[i], "ofconsole") == 0
&& grub_strcmp ("console", term->name) == 0))
break;
if (term)
{
if (term->init && term->init (term) != GRUB_ERR_NONE)
return grub_errno;
grub_list_remove (GRUB_AS_LIST (term));
grub_list_push (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
}
}
{
struct abstract_terminal *next;
for (term = *enabled; term; term = next)
{
next = term->next;
for (i = 0; i < argc; i++)
if (grub_strcmp (args[i], term->name) == 0
|| (grub_strcmp (args[i], "ofconsole") == 0
&& grub_strcmp ("console", term->name) == 0))
break;
if (i == argc)
{
if (!term->next && term == *enabled)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"can't remove the last terminal");
grub_list_remove (GRUB_AS_LIST (term));
if (term->fini)
term->fini (term);
grub_list_push (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
}
}
}
return GRUB_ERR_NONE;
}
static grub_err_t
grub_cmd_terminal_lock (grub_command_t cmd __attribute__ ((unused)),
int argc, char **args)
{
(void)argc;
(void)args;
if (args[0] && args[0][0] == '1')
g_terminal_lock = 1;
else
g_terminal_lock = 0;
return 0;
}
static grub_err_t
grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)),
int argc, char **args)
{
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, next);
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, prev);
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, name);
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, init);
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, fini);
if (g_terminal_lock) return 0;
return handle_command (argc, args,
(struct abstract_terminal **) (void *) &grub_term_inputs,
(struct abstract_terminal **) (void *) &grub_term_inputs_disabled,
grub_term_input_autoload,
N_ ("Active input terminals:"),
N_ ("Available input terminals:"));
}
static grub_err_t
grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)),
int argc, char **args)
{
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, next);
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, prev);
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, name);
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, init);
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, fini);
if (g_terminal_lock) return 0;
return handle_command (argc, args,
(struct abstract_terminal **) (void *) &grub_term_outputs,
(struct abstract_terminal **) (void *) &grub_term_outputs_disabled,
grub_term_output_autoload,
N_ ("Active output terminals:"),
N_ ("Available output terminals:"));
}
static grub_command_t cmd_terminal_input, cmd_terminal_output, cmd_lock_terminal;
GRUB_MOD_INIT(terminal)
{
cmd_lock_terminal =
grub_register_command ("terminal_lock", grub_cmd_terminal_lock,
0, N_("lock terminal."));
cmd_terminal_input =
grub_register_command ("terminal_input", grub_cmd_terminal_input,
N_("[--append|--remove] "
"[TERMINAL1] [TERMINAL2] ..."),
N_("List or select an input terminal."));
cmd_terminal_output =
grub_register_command ("terminal_output", grub_cmd_terminal_output,
N_("[--append|--remove] "
"[TERMINAL1] [TERMINAL2] ..."),
N_("List or select an output terminal."));
}
GRUB_MOD_FINI(terminal)
{
grub_unregister_command (cmd_lock_terminal);
grub_unregister_command (cmd_terminal_input);
grub_unregister_command (cmd_terminal_output);
}
@@ -0,0 +1,117 @@
/* font_cmd.c - Font command definition. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
*
* GRUB 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.
*
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/font.h>
#include <grub/dl.h>
#include <grub/misc.h>
#include <grub/command.h>
#include <grub/i18n.h>
static grub_uint8_t g_font_lock = 0;
static grub_err_t
loadfont_command (grub_command_t cmd __attribute__ ((unused)),
int argc,
char **args)
{
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
if (g_font_lock) return 0;
while (argc--)
if (grub_font_load (*args++) == 0)
{
if (!grub_errno)
return grub_error (GRUB_ERR_BAD_FONT, "invalid font");
return grub_errno;
}
return GRUB_ERR_NONE;
}
static grub_err_t
lsfonts_command (grub_command_t cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
struct grub_font_node *node;
grub_puts_ (N_("Loaded fonts:"));
for (node = grub_font_list; node; node = node->next)
{
grub_font_t font = node->value;
grub_printf ("%s\n", grub_font_get_name (font));
}
return GRUB_ERR_NONE;
}
static grub_err_t
lockfont_command (grub_command_t cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
if (args[0] && args[0][0] == '1')
{
g_font_lock = 1;
}
else
{
g_font_lock = 0;
}
return GRUB_ERR_NONE;
}
static grub_command_t cmd_loadfont, cmd_lsfonts, cmd_lockfont;
#if defined (GRUB_MACHINE_MIPS_LOONGSON) || defined (GRUB_MACHINE_COREBOOT)
void grub_font_init (void)
#else
GRUB_MOD_INIT(font)
#endif
{
grub_font_loader_init ();
cmd_loadfont =
grub_register_command ("loadfont", loadfont_command,
N_("FILE..."),
N_("Specify one or more font files to load."));
cmd_lsfonts =
grub_register_command ("lsfonts", lsfonts_command,
0, N_("List the loaded fonts."));
cmd_lockfont =
grub_register_command ("lockfont", lockfont_command,
0, N_("Lock fonts."));
}
#if defined (GRUB_MACHINE_MIPS_LOONGSON) || defined (GRUB_MACHINE_COREBOOT)
void grub_font_fini (void)
#else
GRUB_MOD_FINI(font)
#endif
{
/* TODO: Determine way to free allocated resources.
Warning: possible pointer references could be in use. */
grub_unregister_command (cmd_loadfont);
grub_unregister_command (cmd_lsfonts);
grub_unregister_command (cmd_lockfont);
}
@@ -84,6 +84,11 @@ grub_core_cmd_insmod (struct grub_command *cmd __attribute__ ((unused)),
return grub_error (GRUB_ERR_BAD_SIGNATURE, "Cannot insmod when SecureBoot is enabled and Policy is check.");
}
if (grub_strcmp(argv[0], "steamenv") == 0) {
grub_printf("Ventoy skip module steamenv ...\n");
return 0;
}
if (argv[0][0] == '/' || argv[0][0] == '(' || argv[0][0] == '+')
mod = grub_dl_load_file (argv[0]);
else
@@ -51,8 +51,8 @@ struct syslinux_menuentry
char hotkey;
int make_default;
struct syslinux_say *say;
enum { KERNEL_NO_KERNEL, KERNEL_LINUX, KERNEL_CHAINLOADER,
enum { KERNEL_NO_KERNEL, KERNEL_LINUX, KERNEL_CHAINLOADER,
KERNEL_BIN, KERNEL_PXE, KERNEL_CHAINLOADER_BPB,
KERNEL_COM32, KERNEL_COM, KERNEL_IMG, KERNEL_CONFIG, LOCALBOOT }
entry_type;
@@ -170,7 +170,7 @@ print_num (struct output_buffer *outbuf, int n)
{
char buf[20];
grub_snprintf (buf, sizeof (buf), "%d", n);
return print (outbuf, buf, grub_strlen (buf));
return print (outbuf, buf, grub_strlen (buf));
}
static grub_err_t
@@ -233,7 +233,7 @@ kernel (const char *line, struct syslinux_menu *menu)
if (end - line >= 4 && grub_strcasecmp (end - 4, ".img") == 0)
menu->entries->entry_type = KERNEL_IMG;
return GRUB_ERR_NONE;
}
@@ -247,7 +247,7 @@ cmd_linux (const char *line, struct syslinux_menu *menu)
if (!menu->entries->kernel_file)
return grub_errno;
menu->entries->entry_type = KERNEL_LINUX;
return GRUB_ERR_NONE;
}
@@ -261,7 +261,7 @@ cmd_boot (const char *line, struct syslinux_menu *menu)
if (!menu->entries->kernel_file)
return grub_errno;
menu->entries->entry_type = KERNEL_CHAINLOADER;
return GRUB_ERR_NONE;
}
@@ -275,7 +275,7 @@ cmd_bss (const char *line, struct syslinux_menu *menu)
if (!menu->entries->kernel_file)
return grub_errno;
menu->entries->entry_type = KERNEL_CHAINLOADER_BPB;
return GRUB_ERR_NONE;
}
@@ -289,7 +289,7 @@ cmd_pxe (const char *line, struct syslinux_menu *menu)
if (!menu->entries->kernel_file)
return grub_errno;
menu->entries->entry_type = KERNEL_PXE;
return GRUB_ERR_NONE;
}
@@ -303,7 +303,7 @@ cmd_fdimage (const char *line, struct syslinux_menu *menu)
if (!menu->entries->kernel_file)
return grub_errno;
menu->entries->entry_type = KERNEL_IMG;
return GRUB_ERR_NONE;
}
@@ -317,7 +317,7 @@ cmd_comboot (const char *line, struct syslinux_menu *menu)
if (!menu->entries->kernel_file)
return grub_errno;
menu->entries->entry_type = KERNEL_COM;
return GRUB_ERR_NONE;
}
@@ -331,7 +331,7 @@ cmd_com32 (const char *line, struct syslinux_menu *menu)
if (!menu->entries->kernel_file)
return grub_errno;
menu->entries->entry_type = KERNEL_COM32;
return GRUB_ERR_NONE;
}
@@ -354,7 +354,7 @@ cmd_config (const char *line, struct syslinux_menu *menu)
return grub_errno;
}
menu->entries->entry_type = KERNEL_CONFIG;
return GRUB_ERR_NONE;
}
@@ -368,7 +368,7 @@ cmd_append (const char *line, struct syslinux_menu *menu)
menu->entries->append = grub_strdup (line);
if (!menu->entries->append)
return grub_errno;
return GRUB_ERR_NONE;
}
@@ -377,6 +377,8 @@ cmd_initrd (const char *line, struct syslinux_menu *menu)
{
struct initrd_list *ninitrd;
const char *comma;
char *pcPos;
if (!menu->entries)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "kernel without label");
@@ -393,6 +395,14 @@ cmd_initrd (const char *line, struct syslinux_menu *menu)
grub_free (ninitrd);
return grub_errno;
}
pcPos = grub_strstr(ninitrd->file, " quiet");
if (pcPos)
{
*pcPos = 0;
}
ninitrd->next = NULL;
if (menu->entries->initrds_last)
menu->entries->initrds_last->next = ninitrd;
@@ -406,7 +416,7 @@ cmd_initrd (const char *line, struct syslinux_menu *menu)
while (*line == ',')
line++;
}
return GRUB_ERR_NONE;
}
@@ -416,7 +426,7 @@ cmd_default (const char *line, struct syslinux_menu *menu)
menu->def = grub_strdup (line);
if (!menu->def)
return grub_errno;
return GRUB_ERR_NONE;
}
@@ -434,7 +444,7 @@ cmd_menudefault (const char *line __attribute__ ((unused)),
if (!menu->entries)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "kernel without label");
menu->entries->make_default = 1;
menu->entries->make_default = 1;
return GRUB_ERR_NONE;
}
@@ -457,7 +467,7 @@ cmd_localboot (const char *line,
if (!menu->entries->kernel_file)
return grub_errno;
menu->entries->entry_type = LOCALBOOT;
return GRUB_ERR_NONE;
}
@@ -485,7 +495,7 @@ cmd_extlabel (const char *line, struct syslinux_menu *menu)
*out++ = *in++;
}
*out = 0;
return GRUB_ERR_NONE;
}
@@ -548,7 +558,7 @@ syslinux_parse (const char *filename,
ret = syslinux_parse_real (menu);
if (ret == GRUB_ERR_FILE_NOT_FOUND
|| ret == GRUB_ERR_BAD_FILENAME)
{
{
grub_errno = ret = GRUB_ERR_NONE;
add_comment (menu, "# File ", 0);
add_comment (menu, nf, 0);
@@ -761,7 +771,7 @@ syslinux_parse_real (struct syslinux_menu *menu)
}
static grub_err_t
print_escaped (struct output_buffer *outbuf,
print_escaped (struct output_buffer *outbuf,
const char *from, const char *to)
{
const char *ptr;
@@ -1037,7 +1047,7 @@ write_entry (struct output_buffer *outbuf,
case KERNEL_COM:
{
char *basename = NULL;
{
char *ptr;
for (ptr = curentry->kernel_file; *ptr; ptr++)
@@ -1244,8 +1254,8 @@ write_entry (struct output_buffer *outbuf,
if (grub_strcasecmp (basename, "whichsys.c32") == 0)
{
grub_syslinux_flavour_t flavour = GRUB_SYSLINUX_ISOLINUX;
const char *flav[] =
{
const char *flav[] =
{
[GRUB_SYSLINUX_ISOLINUX] = "iso",
[GRUB_SYSLINUX_PXELINUX] = "pxe",
[GRUB_SYSLINUX_SYSLINUX] = "sys"
@@ -1416,7 +1426,7 @@ free_menu (struct syslinux_menu *menu)
grub_free (initrd->file);
grub_free (initrd);
}
grub_free (entry->comments);
grub_free (entry->kernel_file);
grub_free (entry->label);
@@ -1455,7 +1465,7 @@ config_file (struct output_buffer *outbuf,
{
menu.timeout = 100;
}
err = syslinux_parse_real (&menu);
if (err)
return err;
@@ -1512,7 +1522,7 @@ config_file (struct output_buffer *outbuf,
print_string ("\n");
}
for (curentry = lentry; curentry; curentry = curentry->prev)
{
{
print_string ("menuentry ");
err = print_escaped (outbuf,
curentry->extlabel ? : curentry->label, NULL);
@@ -185,11 +185,11 @@ static void ventoy_debug_pause(void)
{
char key;
if (0 == ventoy_debug)
if (0 == ventoy_debug)
{
return;
}
grub_printf("press Enter to continue ......\n");
while (1)
{
@@ -198,7 +198,7 @@ static void ventoy_debug_pause(void)
{
break;
}
}
}
}
static int ventoy_preboot(void)
@@ -207,7 +207,7 @@ static int ventoy_preboot(void)
const char *file;
char buf[128];
if (ventoy_debug)
if (ventoy_debug)
{
grub_printf("ventoy_preboot %d %d\n", ventoy_linux_argc, ventoy_initrd_called);
ventoy_debug_pause();
@@ -234,7 +234,7 @@ static int ventoy_preboot(void)
ventoy_extra_initrd_list[ventoy_extra_initrd_num++] = grub_strdup(file);
}
if (ventoy_debug)
if (ventoy_debug)
{
grub_printf("========== initrd list ==========\n");
for (i = 0; i < ventoy_extra_initrd_num; i++)
@@ -242,7 +242,7 @@ static int ventoy_preboot(void)
grub_printf("%s\n", ventoy_extra_initrd_list[i]);
}
grub_printf("=================================\n");
ventoy_debug_pause();
}
@@ -272,14 +272,14 @@ static int ventoy_boot_opt_filter(char *opt)
}
return 0;
}
if (grub_strncmp(opt, "init=", 5) == 0)
{
opt[0] = 'v';
opt[1] = 't';
return 0;
}
if (grub_strncmp(opt, "dm=", 3) == 0)
{
opt[0] = 'D';
@@ -293,12 +293,12 @@ static int ventoy_boot_opt_filter(char *opt)
{
return 1;
}
if (grub_strncmp(opt, "loglevel=", 9) == 0)
{
return 1;
}
if (grub_strcmp(opt, "splash") == 0)
{
return 1;
@@ -345,7 +345,7 @@ static int ventoy_bootopt_hook(int argc, char *argv[])
{
ventoy_linux_args[count] = ventoy_linux_args[i + (LINUX_MAX_ARGC / 2)];
ventoy_linux_args[i + (LINUX_MAX_ARGC / 2)] = NULL;
if (ventoy_linux_args[count][0] == '@')
{
env = grub_env_get(ventoy_linux_args[count] + 1);
@@ -391,7 +391,7 @@ static int ventoy_bootopt_hook(int argc, char *argv[])
{
if (0 == ventoy_boot_opt_filter(last))
{
ventoy_linux_args[count++] = grub_strdup(last);
ventoy_linux_args[count++] = grub_strdup(last);
}
break;
}
@@ -406,7 +406,7 @@ static int ventoy_bootopt_hook(int argc, char *argv[])
}
else
{
count++;
count++;
}
}
@@ -434,10 +434,10 @@ static int ventoy_bootopt_hook(int argc, char *argv[])
for (i = 0; i < count; i++)
{
grub_printf("%s ", ventoy_linux_args[i]);
}
}
grub_printf("\n================================\n");
}
return 0;
}
@@ -470,7 +470,7 @@ grub_cmd_unset_boot_opt (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
int i;
(void)argc;
(void)argv;
@@ -493,16 +493,44 @@ static grub_err_t
grub_cmd_extra_initrd_append (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
grub_uint32_t i;
int newclen = 0;
char *pos = NULL;
char *end = NULL;
char buf[256] = {0};
const char *suffix = NULL;
const char *check_suffix[] = { ".ko", ".ko.zst", ".ko.xz", ".ko.gz" };
if (argc != 1)
{
return 1;
}
if (grub_strstr(argv[0], ".ko"))
{
if (ventoy_check_file_exist("%s", argv[0]))
{
suffix = "";
}
}
else
{
for (i = 0; i < sizeof(check_suffix) / sizeof(check_suffix[0]); i++)
{
if (ventoy_check_file_exist("%s%s", argv[0], check_suffix[i]))
{
suffix = check_suffix[i];
break;
}
}
}
if (!suffix)
{
grub_printf("ko file <%s> not exist\n", argv[0]);
return 0;
}
for (pos = argv[0]; *pos; pos++)
{
if (*pos == '/')
@@ -517,28 +545,29 @@ grub_cmd_extra_initrd_append (grub_command_t cmd __attribute__ ((unused)),
newclen = (int)grub_strlen(end + 1);
if ((110 + newclen) % 4 == 0)
{
grub_snprintf(buf, sizeof(buf), "newc:.%s:%s", end + 1, argv[0]);
grub_snprintf(buf, sizeof(buf), "newc:.%s%s:%s%s", end + 1, suffix, argv[0], suffix);
}
else
{
grub_snprintf(buf, sizeof(buf), "newc:%s:%s", end + 1, argv[0]);
grub_snprintf(buf, sizeof(buf), "newc:%s%s:%s%s", end + 1, suffix, argv[0], suffix);
}
if (ventoy_extra_initrd_num < 256)
{
ventoy_extra_initrd_list[ventoy_extra_initrd_num++] = grub_strdup(buf);
ventoy_extra_initrd_list[ventoy_extra_initrd_num++] = grub_strdup(buf);
}
}
return 0;
}
static grub_err_t
grub_cmd_extra_initrd_reset (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
int i;
(void)argc;
(void)argv;
@@ -741,7 +770,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
cmdline_size,
GRUB_VERIFY_KERNEL_CMDLINE); }
else
{
{
err = grub_create_loader_cmdline (argc, argv,
linux_args + sizeof (LINUX_IMAGE) - 1,
cmdline_size,
@@ -789,7 +818,7 @@ ventoy_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
if (ventoy_linux_argc == 0)
{
return grub_cmd_initrd(cmd, argc, argv);
return grub_cmd_initrd(cmd, argc, argv);
}
grub_snprintf(buf, sizeof(buf), "mem:%s:size:%s", grub_env_get("ventoy_cpio_addr"), grub_env_get("ventoy_cpio_size"));
@@ -820,7 +849,7 @@ ventoy_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
}
grub_printf("=================================\n");
}
return grub_cmd_initrd(cmd, ventoy_extra_initrd_num, ventoy_extra_initrd_list);
}
@@ -843,12 +872,12 @@ GRUB_MOD_INIT (linux)
cmd_set_bootopt = grub_register_command ("vt_set_boot_opt", grub_cmd_set_boot_opt, 0, N_("set ext boot opt"));
cmd_unset_bootopt = grub_register_command ("vt_unset_boot_opt", grub_cmd_unset_boot_opt, 0, N_("unset ext boot opt"));
cmd_extra_initrd_append = grub_register_command ("vt_img_extra_initrd_append", grub_cmd_extra_initrd_append, 0, N_(""));
cmd_extra_initrd_reset = grub_register_command ("vt_img_extra_initrd_reset", grub_cmd_extra_initrd_reset, 0, N_(""));
ventoy_linux_args = grub_zalloc(sizeof(char *) * LINUX_MAX_ARGC);
my_mod = mod;
}
@@ -675,16 +675,44 @@ static grub_err_t
grub_cmd_extra_initrd_append (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
grub_uint32_t i;
int newclen = 0;
char *pos = NULL;
char *end = NULL;
char buf[256] = {0};
const char *suffix = NULL;
const char *check_suffix[] = { ".ko", ".ko.zst", ".ko.xz", ".ko.gz" };
if (argc != 1)
{
return 1;
}
if (grub_strstr(argv[0], ".ko"))
{
if (ventoy_check_file_exist("%s", argv[0]))
{
suffix = "";
}
}
else
{
for (i = 0; i < sizeof(check_suffix) / sizeof(check_suffix[0]); i++)
{
if (ventoy_check_file_exist("%s%s", argv[0], check_suffix[i]))
{
suffix = check_suffix[i];
break;
}
}
}
if (!suffix)
{
grub_printf("ko file <%s> not exist\n", argv[0]);
return 0;
}
for (pos = argv[0]; *pos; pos++)
{
if (*pos == '/')
@@ -699,11 +727,11 @@ grub_cmd_extra_initrd_append (grub_command_t cmd __attribute__ ((unused)),
newclen = (int)grub_strlen(end + 1);
if ((110 + newclen) % 4 == 0)
{
grub_snprintf(buf, sizeof(buf), "newc:.%s:%s", end + 1, argv[0]);
grub_snprintf(buf, sizeof(buf), "newc:.%s%s:%s%s", end + 1, suffix, argv[0], suffix);
}
else
{
grub_snprintf(buf, sizeof(buf), "newc:%s:%s", end + 1, argv[0]);
grub_snprintf(buf, sizeof(buf), "newc:%s%s:%s%s", end + 1, suffix, argv[0], suffix);
}
if (ventoy_extra_initrd_num < 256)
@@ -715,6 +743,7 @@ grub_cmd_extra_initrd_append (grub_command_t cmd __attribute__ ((unused)),
return 0;
}
static grub_err_t
grub_cmd_extra_initrd_reset (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
@@ -64,7 +64,7 @@ grub_uint64_t tempMemsize = 0;
grub_uint32_t free_index = 0;
grub_uint32_t reserve_index = 0;
grub_uint32_t acpi_table_index = 0;
grub_uint32_t acpi_nvs_index = 0;
grub_uint32_t acpi_nvs_index = 0;
#define LINUX_MAX_ARGC 1024
static int ventoy_debug = 0;
@@ -133,11 +133,11 @@ static void ventoy_debug_pause(void)
{
char key;
if (0 == ventoy_debug)
if (0 == ventoy_debug)
{
return;
}
grub_printf("press Enter to continue ......\n");
while (1)
{
@@ -146,7 +146,7 @@ static void ventoy_debug_pause(void)
{
break;
}
}
}
}
static int ventoy_preboot(void)
@@ -155,7 +155,7 @@ static int ventoy_preboot(void)
const char *file;
char buf[128];
if (ventoy_debug)
if (ventoy_debug)
{
grub_printf("ventoy_preboot %d %d\n", ventoy_linux_argc, ventoy_initrd_called);
ventoy_debug_pause();
@@ -182,7 +182,7 @@ static int ventoy_preboot(void)
ventoy_extra_initrd_list[ventoy_extra_initrd_num++] = grub_strdup(file);
}
if (ventoy_debug)
if (ventoy_debug)
{
grub_printf("========== initrd list ==========\n");
for (i = 0; i < ventoy_extra_initrd_num; i++)
@@ -190,7 +190,7 @@ static int ventoy_preboot(void)
grub_printf("%s\n", ventoy_extra_initrd_list[i]);
}
grub_printf("=================================\n");
ventoy_debug_pause();
}
@@ -220,7 +220,7 @@ static int ventoy_boot_opt_filter(char *opt)
}
return 0;
}
if (grub_strncmp(opt, "init=", 5) == 0)
{
opt[0] = 'v';
@@ -241,12 +241,12 @@ static int ventoy_boot_opt_filter(char *opt)
{
return 1;
}
if (grub_strncmp(opt, "loglevel=", 9) == 0)
{
return 1;
}
if (grub_strcmp(opt, "splash") == 0)
{
return 1;
@@ -293,7 +293,7 @@ static int ventoy_bootopt_hook(int argc, char *argv[])
{
ventoy_linux_args[count] = ventoy_linux_args[i + (LINUX_MAX_ARGC / 2)];
ventoy_linux_args[i + (LINUX_MAX_ARGC / 2)] = NULL;
if (ventoy_linux_args[count][0] == '@')
{
env = grub_env_get(ventoy_linux_args[count] + 1);
@@ -339,7 +339,7 @@ static int ventoy_bootopt_hook(int argc, char *argv[])
{
if (0 == ventoy_boot_opt_filter(last))
{
ventoy_linux_args[count++] = grub_strdup(last);
ventoy_linux_args[count++] = grub_strdup(last);
}
break;
}
@@ -354,7 +354,7 @@ static int ventoy_bootopt_hook(int argc, char *argv[])
}
else
{
count++;
count++;
}
}
@@ -382,10 +382,10 @@ static int ventoy_bootopt_hook(int argc, char *argv[])
for (i = 0; i < count; i++)
{
grub_printf("%s ", ventoy_linux_args[i]);
}
}
grub_printf("\n================================\n");
}
return 0;
}
@@ -418,7 +418,7 @@ grub_cmd_unset_boot_opt (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
int i;
(void)argc;
(void)argv;
@@ -441,16 +441,44 @@ static grub_err_t
grub_cmd_extra_initrd_append (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
grub_uint32_t i;
int newclen = 0;
char *pos = NULL;
char *end = NULL;
char buf[256] = {0};
const char *suffix = NULL;
const char *check_suffix[] = { ".ko", ".ko.zst", ".ko.xz", ".ko.gz" };
if (argc != 1)
{
return 1;
}
if (grub_strstr(argv[0], ".ko"))
{
if (ventoy_check_file_exist("%s", argv[0]))
{
suffix = "";
}
}
else
{
for (i = 0; i < sizeof(check_suffix) / sizeof(check_suffix[0]); i++)
{
if (ventoy_check_file_exist("%s%s", argv[0], check_suffix[i]))
{
suffix = check_suffix[i];
break;
}
}
}
if (!suffix)
{
grub_printf("ko file <%s> not exist\n", argv[0]);
return 0;
}
for (pos = argv[0]; *pos; pos++)
{
if (*pos == '/')
@@ -465,16 +493,16 @@ grub_cmd_extra_initrd_append (grub_command_t cmd __attribute__ ((unused)),
newclen = (int)grub_strlen(end + 1);
if ((110 + newclen) % 4 == 0)
{
grub_snprintf(buf, sizeof(buf), "newc:.%s:%s", end + 1, argv[0]);
grub_snprintf(buf, sizeof(buf), "newc:.%s%s:%s%s", end + 1, suffix, argv[0], suffix);
}
else
{
grub_snprintf(buf, sizeof(buf), "newc:%s:%s", end + 1, argv[0]);
grub_snprintf(buf, sizeof(buf), "newc:%s%s:%s%s", end + 1, suffix, argv[0], suffix);
}
if (ventoy_extra_initrd_num < 256)
{
ventoy_extra_initrd_list[ventoy_extra_initrd_num++] = grub_strdup(buf);
ventoy_extra_initrd_list[ventoy_extra_initrd_num++] = grub_strdup(buf);
}
}
@@ -486,7 +514,7 @@ grub_cmd_extra_initrd_reset (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
int i;
(void)argc;
(void)argv;
@@ -539,7 +567,7 @@ grub_linux_boot (void)
struct memmap free_mem[GRUB_EFI_LOONGSON_MMAP_MAX];
struct memmap acpi_table_mem[GRUB_EFI_LOONGSON_MMAP_MAX];
struct memmap acpi_nvs_mem[GRUB_EFI_LOONGSON_MMAP_MAX];
grub_memset(reserve_mem, 0, sizeof(struct memmap) * GRUB_EFI_LOONGSON_MMAP_MAX);
grub_memset(free_mem, 0, sizeof(struct memmap) * GRUB_EFI_LOONGSON_MMAP_MAX);
grub_memset(acpi_table_mem, 0, sizeof(struct memmap) * GRUB_EFI_LOONGSON_MMAP_MAX);
@@ -573,7 +601,7 @@ grub_linux_boot (void)
}else{
new_interface_flag = 0;
grub_dprintf("loongson", "get old parameter interface\n");
}
state.gpr[6] = (grub_uint64_t)tmp_boot_params;
grub_dprintf("loongson", "boot_params is 0x%llx\n", (_ull)state.gpr[6]);
@@ -600,7 +628,7 @@ grub_linux_boot (void)
/*
According to UEFI SPEC,mmap_buf is the accurate Memory Map array \
now we can fill platform specific memory structure.
now we can fill platform specific memory structure.
*/
for(lsdesc = mmap_buf; lsdesc < (grub_efi_memory_descriptor_t *)((char *)mmap_buf + mmap_size); lsdesc = (grub_efi_memory_descriptor_t *)((char *)lsdesc + desc_size))
{
@@ -610,7 +638,7 @@ grub_linux_boot (void)
(lsdesc->type != GRUB_EFI_RUNTIME_SERVICES_DATA) && \
(lsdesc->type != GRUB_EFI_RUNTIME_SERVICES_CODE) && \
(lsdesc->type != GRUB_EFI_RESERVED_MEMORY_TYPE) && \
(lsdesc->type != GRUB_EFI_PAL_CODE))
(lsdesc->type != GRUB_EFI_PAL_CODE))
{
free_mem[free_index].memtype = GRUB_EFI_LOONGSON_SYSTEM_RAM_LOW;
@@ -631,7 +659,7 @@ grub_linux_boot (void)
acpi_nvs_index++;
/* Reserve */
}else{
}else{
reserve_mem[reserve_index].memtype = GRUB_EFI_LOONGSON_MEMORY_RESERVED;
reserve_mem[reserve_index].memstart = (lsdesc->physical_start) & 0xffffffffffff;
reserve_mem[reserve_index].memsize = lsdesc->num_pages * 4096;
@@ -645,12 +673,12 @@ grub_linux_boot (void)
tempMemsize = free_mem[j].memsize;
for(t = j + 1; t < free_index; t++)
{
if((free_mem[j].memstart + tempMemsize == free_mem[t].memstart) && (free_mem[j].memtype == free_mem[t].memtype))
if((free_mem[j].memstart + tempMemsize == free_mem[t].memstart) && (free_mem[j].memtype == free_mem[t].memtype))
{
tempMemsize += free_mem[t].memsize;
}else{
}else{
break;
}
}
}
if(free_mem[j].memstart >= 0x10000000) /*HIGH MEM*/
new_interface_mem->map[tmp_index].memtype = GRUB_EFI_LOONGSON_SYSTEM_RAM_HIGH;
@@ -978,7 +1006,7 @@ ventoy_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
if (ventoy_linux_argc == 0)
{
return grub_cmd_initrd(cmd, argc, argv);
return grub_cmd_initrd(cmd, argc, argv);
}
grub_snprintf(buf, sizeof(buf), "mem:%s:size:%s", grub_env_get("ventoy_cpio_addr"), grub_env_get("ventoy_cpio_size"));
@@ -1009,10 +1037,10 @@ ventoy_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
}
grub_printf("=================================\n");
}
return grub_cmd_initrd(cmd, ventoy_extra_initrd_num, ventoy_extra_initrd_list);
}
static grub_command_t cmd_linux, cmd_initrd;
static grub_command_t cmd_set_bootopt, cmd_unset_bootopt, cmd_extra_initrd_append, cmd_extra_initrd_reset;
@@ -1025,7 +1053,7 @@ GRUB_MOD_INIT(linux)
cmd_set_bootopt = grub_register_command ("vt_set_boot_opt", grub_cmd_set_boot_opt, 0, N_("set ext boot opt"));
cmd_unset_bootopt = grub_register_command ("vt_unset_boot_opt", grub_cmd_unset_boot_opt, 0, N_("unset ext boot opt"));
cmd_extra_initrd_append = grub_register_command ("vt_img_extra_initrd_append", grub_cmd_extra_initrd_append, 0, N_(""));
cmd_extra_initrd_reset = grub_register_command ("vt_img_extra_initrd_reset", grub_cmd_extra_initrd_reset, 0, N_(""));
@@ -49,6 +49,10 @@ int g_ventoy_debug = 0;
static int g_efi_os = 0xFF;
grub_uint32_t g_ventoy_plat_data;
static grub_uint8_t g_timeout_lock = 0;
static grub_uint8_t g_theme_lock = 0;
static char *g_lock_theme = NULL;
#ifdef GRUB_MACHINE_EFI
static VTOY_SHIM *g_vtoy_shim = NULL;
#endif
@@ -236,6 +240,29 @@ int ventoy_strncmp (const char *pattern, const char *str, grub_size_t n)
return (int)(grub_uint8_t)*pattern - (int)(grub_uint8_t)*str;
}
void ventoy_timeout_lock(int lock)
{
g_timeout_lock = lock ? 1 : 0;
}
void ventoy_theme_lock(int lock)
{
const char *env = NULL;
g_theme_lock = 0;
grub_check_free(g_lock_theme);
if (lock)
{
env = grub_env_get("theme");
if (env)
{
g_lock_theme = grub_strdup(env);
g_theme_lock = 1;
}
}
}
grub_err_t ventoy_env_int_set(const char *name, int value)
{
char buf[16];
@@ -314,6 +341,25 @@ static void ventoy_get_uefi_version(char *str, grub_size_t len)
grub_snprintf(str, len, "%s.%d", str, uefi_minor_2);
}
static void ventoy_get_pi_version(char *str, grub_size_t len)
{
grub_uint32_t data = 0;
grub_efi_uintn_t i = 0;
grub_efi_guid_t dxest =
{ 0x05ad34ba, 0x6f02, 0x4214, {0x95, 0x2e, 0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9 } };
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
{
if (grub_memcmp(&dxest, &grub_efi_system_table->configuration_table[i].vendor_guid, 16) == 0)
{
grub_memcpy(&data, (char *)grub_efi_system_table->configuration_table[i].vendor_table + 8, 4);
break;
}
}
grub_snprintf(str, len, "%d.%d", (data >> 16) & 0xFFFF, (data & 0xFFFF) / 10);
}
int ventoy_set_sb_policy(void)
{
const char *env = NULL;
@@ -359,12 +405,27 @@ int ventoy_set_sb_policy(void)
static void ventoy_get_uefi_sb(void)
{
grub_uint8_t secure_boot = 0;
grub_uint8_t setup_mode = 0;
grub_uint8_t *var = NULL;
grub_size_t size = 0;
grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
var = grub_efi_get_variable("SecureBoot", &global, &size);
if (var && size == 1 && *var == 1)
{
secure_boot = 1;
}
grub_check_free(var);
size = 0;
var = grub_efi_get_variable("SetupMode", &global, &size);
if (var && size == 1 && *var == 1)
{
setup_mode = 1;
}
if (secure_boot == 1 && setup_mode == 0)
{
g_sys_sb = 1;
}
@@ -384,24 +445,23 @@ static int ventoy_secure_boot_init(void)
}
/*
* When SecureBoot enabled, Ventoy grub must be launched by Ventoy Shim.
* Currently only x86_64 support this feature.
*/
if (g_ventoy_plat_data == VTOY_PLAT_X86_64_UEFI)
{
g_vtoy_shim = grub_efi_locate_protocol(&ProtGuid, NULL);
if (g_vtoy_shim == NULL || g_vtoy_shim->ByPassSB == NULL || g_vtoy_shim->CheckSB == NULL)
if (g_vtoy_shim == NULL || g_vtoy_shim->ByPassSB == NULL ||
g_vtoy_shim->CheckSB == NULL || g_vtoy_shim->Launched == NULL)
{
grub_cls();
grub_printf(VTOY_WARNING"\n");
grub_printf(VTOY_WARNING"\n");
grub_printf(VTOY_WARNING"\n\n\n");
grub_printf("Ventoy grub is not launched by Ventoy shim.\n\n");
grub_refresh();
ventoy_prompt_end();
/*
* Generally when SecureBoot enabled, Ventoy grub must be launched by Ventoy Shim.
* But there are some exceptions:
* 1. Ventoy key was enrolled directly to the UEFI DB
* 2. Some UEFI firmware (MSI) has Image Execution Policy as Always Execute which
* means Secure Boot is effectively disabled.
*/
}
else
{
g_vtoy_shim->Launched();
}
}
@@ -468,8 +528,12 @@ static int ventoy_hwinfo_init(void)
#ifdef GRUB_MACHINE_EFI
ventoy_get_uefi_version(str, sizeof(str));
ventoy_env_export("grub_uefi_version", str);
ventoy_get_pi_version(str, sizeof(str));
ventoy_env_export("grub_pi_version", str);
#else
ventoy_env_export("grub_uefi_version", "NA");
ventoy_env_export("grub_pi_version", "NA");
#endif
return 0;
@@ -516,6 +580,19 @@ static char * ventoy_global_var_write_hook(struct grub_env_var *var, const char
return grub_strdup(val);
}
static char * ventoy_timeout_write_hook(struct grub_env_var *var, const char *val)
{
(void)var;
return grub_strdup(g_timeout_lock ? "-1" : val);
}
static char * ventoy_theme_write_hook(struct grub_env_var *var, const char *val)
{
(void)var;
return grub_strdup(g_theme_lock ? g_lock_theme : val);
}
int ventoy_global_var_init(void)
{
int i;
@@ -527,6 +604,9 @@ int ventoy_global_var_init(void)
grub_register_variable_hook(g_global_vars[i].name, ventoy_global_var_read_hook, ventoy_global_var_write_hook);
}
grub_register_variable_hook("timeout", NULL, ventoy_timeout_write_hook);
grub_register_variable_hook("theme", NULL, ventoy_theme_write_hook);
return 0;
}
@@ -896,6 +896,36 @@ static grub_err_t ventoy_cmd_strstr(grub_extcmd_context_t ctxt, int argc, char *
return (grub_strstr(args[0], args[1])) ? 0 : 1;
}
static grub_err_t ventoy_cmd_istrstr(grub_extcmd_context_t ctxt, int argc, char **args)
{
grub_err_t ret = 1;
char *s1 = NULL;
char *s2 = NULL;
(void)ctxt;
if (argc != 2)
{
return 1;
}
s1 = grub_strdup(args[0]);
s2 = grub_strdup(args[1]);
if (s1 == NULL || s2 == NULL)
{
goto end;
}
ventoy_str_toupper(s1);
ventoy_str_toupper(s2);
ret = (grub_strstr(s1, s2)) ? 0 : 1;
end:
grub_check_free(s1);
grub_check_free(s2);
return ret;
}
static grub_err_t ventoy_cmd_strbegin(grub_extcmd_context_t ctxt, int argc, char **args)
{
char *c0, *c1;
@@ -4258,6 +4288,11 @@ static grub_err_t ventoy_cmd_check_mode(grub_extcmd_context_t ctxt, int argc, ch
}
else if (args[0][0] == '1')
{
if (argc == 2 && ventoy_check_mode_by_name(args[1], "vtcompat"))
{
return 0;
}
return g_ventoy_iso_raw ? 0 : 1;
}
else if (args[0][0] == '2')
@@ -4722,23 +4757,10 @@ static grub_err_t ventoy_cmd_img_unhook_root(grub_extcmd_context_t ctxt, int arg
#ifdef GRUB_MACHINE_EFI
static grub_err_t ventoy_cmd_check_secureboot_var(grub_extcmd_context_t ctxt, int argc, char **args)
{
int ret = 1;
grub_uint8_t *var = NULL;
grub_size_t size;
grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
(void)ctxt;
(void)argc;
(void)args;
var = grub_efi_get_variable("SecureBoot", &global, &size);
if (var && *var == 1)
{
grub_free(var);
return 0;
}
return ret;
return g_sys_sb ? 0 : 1;
}
#else
static grub_err_t ventoy_cmd_check_secureboot_var(grub_extcmd_context_t ctxt, int argc, char **args)
@@ -6232,7 +6254,8 @@ static grub_err_t ventoy_cmd_need_secondary_menu(grub_extcmd_context_t ctxt, int
if (ventoy_check_mode_by_name(args[0], "vtgrub2") ||
ventoy_check_mode_by_name(args[0], "vtwimboot") ||
ventoy_check_mode_by_name(args[0], "vtmemdisk") ||
ventoy_check_mode_by_name(args[0], "vtnormal")
ventoy_check_mode_by_name(args[0], "vtnormal") ||
ventoy_check_mode_by_name(args[0], "vtcompat")
)
{
return 1;
@@ -6426,6 +6449,40 @@ static grub_err_t ventoy_cmd_update_sb_policy(grub_extcmd_context_t ctxt, int ar
VENTOY_CMD_RETURN(0);
}
static grub_err_t ventoy_cmd_timeout_lock(grub_extcmd_context_t ctxt, int argc, char **args)
{
(void)ctxt;
(void)argc;
if (args[0] && args[0][0] == '1')
{
ventoy_timeout_lock(1);
}
else
{
ventoy_timeout_lock(0);
}
VENTOY_CMD_RETURN(0);
}
static grub_err_t ventoy_cmd_theme_lock(grub_extcmd_context_t ctxt, int argc, char **args)
{
(void)ctxt;
(void)argc;
if (args[0] && args[0][0] == '1')
{
ventoy_theme_lock(1);
}
else
{
ventoy_theme_lock(0);
}
VENTOY_CMD_RETURN(0);
}
static grub_err_t ventoy_cmd_sb_info(grub_extcmd_context_t ctxt, int argc, char **args)
{
(void)ctxt;
@@ -6434,6 +6491,10 @@ static grub_err_t ventoy_cmd_sb_info(grub_extcmd_context_t ctxt, int argc, char
#ifdef GRUB_MACHINE_EFI
const char *policy = NULL;
grub_efi_guid_t security =
{ 0xA46423E3, 0x4617, 0x49f1, {0xB9, 0xFF, 0xD1, 0xBF, 0xA9, 0x11, 0x58, 0x39 } };
grub_efi_guid_t security2 =
{ 0x94ab2f58, 0x1438, 0x4ef1, {0x91, 0x52, 0x18, 0x94, 0x1a, 0x3a, 0x0e, 0x68 } };
if (g_sb_policy == VTOY_SB_POLICY_BYPASS)
{
@@ -6448,8 +6509,10 @@ static grub_err_t ventoy_cmd_sb_info(grub_extcmd_context_t ctxt, int argc, char
policy = "XXX";
}
grub_printf("UEFI Firmware Secure Boot: %s\n", g_sys_sb ? "Enable" : "Disable");
grub_printf("Ventoy Secure Boot Policy: %s\n", policy);
grub_printf("UEFI Security %s\n", grub_efi_locate_protocol(&security, NULL) ? "Yes" : "No");
grub_printf("UEFI Security2 %s\n", grub_efi_locate_protocol(&security2, NULL) ? "Yes" : "No");
grub_printf("Ventoy Secure Policy %s\n", policy);
#else
grub_printf("Non EFI mode!\n");
#endif
@@ -6944,6 +7007,7 @@ static cmd_para ventoy_cmds[] =
{ "vt_incr", ventoy_cmd_incr, 0, NULL, "{Var} {INT}", "Increase integer variable", NULL },
{ "vt_mod", ventoy_cmd_mod, 0, NULL, "{Int} {Int} {Var}", "mod integer variable", NULL },
{ "vt_strstr", ventoy_cmd_strstr, 0, NULL, "", "", NULL },
{ "vt_istrstr", ventoy_cmd_istrstr, 0, NULL, "", "", NULL },
{ "vt_str_begin", ventoy_cmd_strbegin, 0, NULL, "", "", NULL },
{ "vt_str_casebegin", ventoy_cmd_strcasebegin, 0, NULL, "", "", NULL },
{ "vt_debug", ventoy_cmd_debug, 0, NULL, "{on|off}", "turn debug on/off", NULL },
@@ -7110,6 +7174,9 @@ static cmd_para ventoy_cmds[] =
{ "vt_sbinfo", ventoy_cmd_sb_info, 0, NULL, "", "", NULL },
{ "vt_update_sb_policy", ventoy_cmd_update_sb_policy, 0, NULL, "", "", NULL },
{ "vt_timeout_lock", ventoy_cmd_timeout_lock, 0, NULL, "", "", NULL },
{ "vt_theme_lock", ventoy_cmd_theme_lock, 0, NULL, "", "", NULL },
};
int ventoy_register_all_cmd(void)
@@ -199,9 +199,11 @@ typedef struct cpio_newc_header
typedef void (*VTOY_BYPASS_SB)(void);
typedef void (*VTOY_CHECK_SB)(void);
typedef void (*VTOY_LAUNCHED)(void);
typedef struct _VTOY_SHIM{
VTOY_BYPASS_SB ByPassSB;
VTOY_CHECK_SB CheckSB;
VTOY_LAUNCHED Launched;
} VTOY_SHIM;
@@ -659,6 +661,8 @@ int ventoy_str_all_digit(const char *str);
int ventoy_str_all_alnum(const char *str);
int ventoy_str_len_alnum(const char *str, int len);
char * ventoy_str_basename(char *path);
void ventoy_timeout_lock(int lock);
void ventoy_theme_lock(int lock);
grub_err_t ventoy_env_int_set(const char *name, int value);
int ventoy_str_chrcnt(const char *str, char c);
int ventoy_strcmp(const char *pattern, const char *str);
@@ -1,5 +1,5 @@
/******************************************************************************
* ventoy_unix.c
* ventoy_unix.c
*
* Copyright (c) 2020, longpanda <admin@ventoy.net>
*
@@ -7,12 +7,12 @@
* 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/>.
*
@@ -69,9 +69,9 @@ static int ventoy_get_file_override(const char *filename, grub_uint64_t *offset)
}
*offset = grub_iso9660_get_last_file_dirent_pos(file) + 2;
grub_file_close(file);
return 0;
}
@@ -83,12 +83,12 @@ static grub_uint32_t ventoy_unix_get_override_chunk_count(void)
{
count++;
}
if (g_mod_new_len > 0)
{
count++;
}
if (g_ko_fillmap_len > 0)
{
count += (g_ko_fillmap_len / 512);
@@ -109,7 +109,7 @@ static grub_uint32_t ventoy_unix_get_virt_chunk_count(void)
{
count++;
}
if (g_mod_new_len > 0)
{
count++;
@@ -127,7 +127,7 @@ static grub_uint32_t ventoy_unix_get_virt_chunk_size(void)
{
size += ventoy_align_2k(g_conf_new_len);
}
if (g_mod_new_len > 0)
{
size += ventoy_align_2k(g_mod_new_len);
@@ -141,9 +141,9 @@ static void ventoy_unix_fill_map_data(ventoy_chain_head *chain, struct g_ventoy_
grub_uint32_t i;
ventoy_img_chunk *chunk = NULL;
debug("Fill unix map data: <%llu> <%u> %p\n",
debug("Fill unix map data: <%llu> <%u> %p\n",
(unsigned long long)chain->os_param.vtoy_disk_size, g_img_chunk_list.cur_chunk, map);
map->magic1[0] = map->magic2[0] = VENTOY_UNIX_SEG_MAGIC0;
map->magic1[1] = map->magic2[1] = VENTOY_UNIX_SEG_MAGIC1;
map->magic1[2] = map->magic2[2] = VENTOY_UNIX_SEG_MAGIC2;
@@ -158,12 +158,12 @@ static void ventoy_unix_fill_map_data(ventoy_chain_head *chain, struct g_ventoy_
debug("####[FAIL] Too many segments for the ISO file %u\n", g_img_chunk_list.cur_chunk);
map->segnum = VENTOY_UNIX_MAX_SEGNUM;
}
for (i = 0; i < (grub_uint32_t)(map->segnum); i++)
{
chunk = g_img_chunk_list.chunk + i;
map->seglist[i].seg_start_bytes = chunk->disk_start_sector * 512ULL;
map->seglist[i].seg_end_bytes = (chunk->disk_end_sector + 1) * 512ULL;
map->seglist[i].seg_end_bytes = (chunk->disk_end_sector + 1) * 512ULL;
}
}
@@ -176,7 +176,7 @@ static void ventoy_unix_fill_override_data( grub_uint64_t isosize, ventoy_cha
grub_uint64_t sector;
ventoy_override_chunk *cur;
ventoy_iso9660_override *dirent;
sector = (isosize + 2047) / 2048;
cur = (ventoy_override_chunk *)((char *)chain + chain->override_chunk_offset);
@@ -215,7 +215,7 @@ static void ventoy_unix_fill_override_data( grub_uint64_t isosize, ventoy_cha
offset = g_mod_override_offset;
ventoy_unix_fill_map_data(chain, (struct g_ventoy_map *)data);
for (i = 0; i < g_ko_fillmap_len / 512; i++)
{
cur->img_offset = offset;
@@ -252,7 +252,7 @@ static void ventoy_unix_fill_virt_data( grub_uint64_t isosize, ventoy_chain_h
override = (char *)chain + chain->virt_chunk_offset;
cur = (ventoy_virt_chunk *)override;
sector = (isosize + 2047) / 2048;
offset = 2 * sizeof(ventoy_virt_chunk);
@@ -267,10 +267,10 @@ static void ventoy_unix_fill_virt_data( grub_uint64_t isosize, ventoy_chain_h
{
ventoy_unix_fill_map_data(chain, (struct g_ventoy_map *)(g_mod_new_data + g_mod_search_magic));
}
ventoy_unix_fill_virt(g_mod_new_data, g_mod_new_len);
}
return;
}
@@ -287,7 +287,7 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath, const char
grub_uint8_t disk_guid[16];
debug("ventoy_freebsd_append_conf %s\n", isopath);
isofile = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", isopath);
if (!isofile)
{
@@ -296,7 +296,7 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath, const char
vtoy_ssprintf(buf, pos, "ventoy_load=\"%s\"\n", "YES");
vtoy_ssprintf(buf, pos, "ventoy_name=\"%s\"\n", g_ko_mod_path);
if (alias)
{
vtoy_ssprintf(buf, pos, "hint.ventoy.0.alias=\"%s\"\n", alias);
@@ -320,7 +320,7 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath, const char
}
debug("Fill hint.ventoy info\n");
disk = isofile->device->disk;
ventoy_get_disk_guid(isofile->name, disk_guid, disk_sig);
@@ -338,7 +338,7 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath, const char
for (i = 0; i < g_img_chunk_list.cur_chunk; i++)
{
chunk = g_img_chunk_list.chunk + i;
vtoy_ssprintf(buf, pos, "hint.ventoy.%u.seg=\"0x%llx@0x%llx\"\n",
vtoy_ssprintf(buf, pos, "hint.ventoy.%u.seg=\"0x%llx@0x%llx\"\n",
i, (ulonglong)(chunk->disk_start_sector * 512),
(ulonglong)((chunk->disk_end_sector + 1) * 512));
}
@@ -368,7 +368,7 @@ grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **ar
(void)ctxt;
(void)argc;
(void)args;
g_unix_vlnk_boot = 0;
g_mod_search_magic = 0;
g_conf_new_len = 0;
@@ -411,7 +411,7 @@ grub_err_t ventoy_cmd_parse_freenas_ver(grub_extcmd_context_t ctxt, int argc, ch
const char *ver = NULL;
char *buf = NULL;
VTOY_JSON *json = NULL;
(void)ctxt;
(void)argc;
@@ -472,7 +472,7 @@ grub_err_t ventoy_cmd_unix_freebsd_ver(grub_extcmd_context_t ctxt, int argc, cha
char *buf;
char *start = NULL;
char *nextline = NULL;
(void)ctxt;
(void)argc;
(void)args;
@@ -502,7 +502,7 @@ grub_err_t ventoy_cmd_unix_freebsd_ver(grub_extcmd_context_t ctxt, int argc, cha
nextline++;
}
*nextline = 0;
*nextline = 0;
break;
}
nextline = ventoy_get_line(start);
@@ -521,25 +521,162 @@ grub_err_t ventoy_cmd_unix_freebsd_ver(grub_extcmd_context_t ctxt, int argc, cha
grub_free(buf);
grub_file_close(file);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
static int ventoy_freebsd_ver_elf(int bit64, grub_elf_t elf, const char *section, const char *env, char *data)
{
int j = 0;
int k = 0;
int ret = 1;
char *str = NULL;
void *hdr = NULL;
grub_off_t offset = 0;
grub_uint32_t len = 0;
char ver[64] = {0};
if (bit64)
{
Elf64_Ehdr *e = &(elf->ehdr.ehdr64);
Elf64_Shdr *h;
Elf64_Shdr *s;
Elf64_Shdr *t;
Elf64_Half i;
h = hdr = grub_zalloc(e->e_shnum * e->e_shentsize);
if (!h)
{
goto out;
}
debug("read section header %u %u %u\n", e->e_shnum, e->e_shentsize, e->e_shstrndx);
grub_file_seek(elf->file, e->e_shoff);
grub_file_read(elf->file, h, e->e_shnum * e->e_shentsize);
s = (Elf64_Shdr *)((char *)h + e->e_shstrndx * e->e_shentsize);
str = grub_malloc(s->sh_size + 1);
if (!str)
{
goto out;
}
str[s->sh_size] = 0;
debug("read string table %u %u\n", (grub_uint32_t)s->sh_offset, (grub_uint32_t)s->sh_size);
grub_file_seek(elf->file, s->sh_offset);
grub_file_read(elf->file, str, s->sh_size);
for (t = h, i = 0; i < e->e_shnum; i++)
{
if (grub_strcmp(str + t->sh_name, section) == 0)
{
offset = t->sh_offset;
len = t->sh_size;
debug("find %s section at %u %u\n", section, (grub_uint32_t)offset, len);
break;
}
t = (Elf64_Shdr *)((char *)t + e->e_shentsize);
}
}
else
{
Elf32_Ehdr *e = &(elf->ehdr.ehdr32);
Elf32_Shdr *h;
Elf32_Shdr *s;
Elf32_Shdr *t;
Elf32_Half i;
h = hdr = grub_zalloc(e->e_shnum * e->e_shentsize);
if (!h)
{
goto out;
}
debug("read section header %u %u %u\n", e->e_shnum, e->e_shentsize, e->e_shstrndx);
grub_file_seek(elf->file, e->e_shoff);
grub_file_read(elf->file, h, e->e_shnum * e->e_shentsize);
s = (Elf32_Shdr *)((char *)h + e->e_shstrndx * e->e_shentsize);
str = grub_malloc(s->sh_size + 1);
if (!str)
{
goto out;
}
str[s->sh_size] = 0;
debug("read string table %u %u\n", (grub_uint32_t)s->sh_offset, (grub_uint32_t)s->sh_size);
grub_file_seek(elf->file, s->sh_offset);
grub_file_read(elf->file, str, s->sh_size);
for (t = h, i = 0; i < e->e_shnum; i++)
{
if (grub_strcmp(str + t->sh_name, section) == 0)
{
offset = t->sh_offset;
len = t->sh_size;
debug("find %s section at %u %u\n", section, (grub_uint32_t)offset, len);
break;
}
t = (Elf32_Shdr *)((char *)t + e->e_shentsize);
}
}
if (offset == 0 || len == 0)
{
debug("%s section not found\n", section);
goto out;
}
grub_file_seek(elf->file, offset + len - 8192);
grub_file_read(elf->file, data, 8192);
for (j = 0; j < 8192 - 12; j++)
{
if (grub_strncmp(data + j, "@(#)FreeBSD ", 12) == 0)
{
for (k = j + 12; k < 8192; k++)
{
if (0 == grub_isdigit(data[k]) && data[k] != '.')
{
data[k] = 0;
break;
}
}
grub_snprintf(ver, sizeof(ver), "%s", data + j + 12);
break;
}
}
if (ver[0])
{
k = (int)grub_strtoul(ver, NULL, 10);
debug("%s freebsd version:<%s> <%d.x>\n", section, ver, k);
grub_snprintf(ver, sizeof(ver), "%d.x", k);
ventoy_set_env(env, ver);
ret = 0;
}
else
{
debug("%s freebsd version:<%s>\n", section, "NOT FOUND");
ret = 1;
}
out:
grub_check_free(str);
grub_check_free(hdr);
return ret;
}
grub_err_t ventoy_cmd_unix_freebsd_ver_elf(grub_extcmd_context_t ctxt, int argc, char **args)
{
int j;
int k;
grub_elf_t elf = NULL;
grub_off_t offset = 0;
grub_uint32_t len = 0;
char *str = NULL;
int ret = 0;
int bit64 = 0;
char *data = NULL;
void *hdr = NULL;
char ver[64] = {0};
grub_elf_t elf = NULL;
(void)ctxt;
(void)argc;
(void)args;
if (argc != 3)
{
@@ -560,136 +697,18 @@ grub_err_t ventoy_cmd_unix_freebsd_ver_elf(grub_extcmd_context_t ctxt, int argc,
goto out;
}
if (args[1][0] == '6')
bit64 = (args[1][0] == '6') ? 1 : 0;
ret = ventoy_freebsd_ver_elf(bit64, elf, ".data", args[2], data);
if (ret != 0)
{
Elf64_Ehdr *e = &(elf->ehdr.ehdr64);
Elf64_Shdr *h;
Elf64_Shdr *s;
Elf64_Shdr *t;
Elf64_Half i;
h = hdr = grub_zalloc(e->e_shnum * e->e_shentsize);
if (!h)
{
goto out;
}
debug("read section header %u %u %u\n", e->e_shnum, e->e_shentsize, e->e_shstrndx);
grub_file_seek(elf->file, e->e_shoff);
grub_file_read(elf->file, h, e->e_shnum * e->e_shentsize);
s = (Elf64_Shdr *)((char *)h + e->e_shstrndx * e->e_shentsize);
str = grub_malloc(s->sh_size + 1);
if (!str)
{
goto out;
}
str[s->sh_size] = 0;
debug("read string table %u %u\n", (grub_uint32_t)s->sh_offset, (grub_uint32_t)s->sh_size);
grub_file_seek(elf->file, s->sh_offset);
grub_file_read(elf->file, str, s->sh_size);
for (t = h, i = 0; i < e->e_shnum; i++)
{
if (grub_strcmp(str + t->sh_name, ".data") == 0)
{
offset = t->sh_offset;
len = t->sh_size;
debug("find .data section at %u %u\n", (grub_uint32_t)offset, len);
break;
}
t = (Elf64_Shdr *)((char *)t + e->e_shentsize);
}
}
else
{
Elf32_Ehdr *e = &(elf->ehdr.ehdr32);
Elf32_Shdr *h;
Elf32_Shdr *s;
Elf32_Shdr *t;
Elf32_Half i;
h = hdr = grub_zalloc(e->e_shnum * e->e_shentsize);
if (!h)
{
goto out;
}
debug("read section header %u %u %u\n", e->e_shnum, e->e_shentsize, e->e_shstrndx);
grub_file_seek(elf->file, e->e_shoff);
grub_file_read(elf->file, h, e->e_shnum * e->e_shentsize);
s = (Elf32_Shdr *)((char *)h + e->e_shstrndx * e->e_shentsize);
str = grub_malloc(s->sh_size + 1);
if (!str)
{
goto out;
}
str[s->sh_size] = 0;
debug("read string table %u %u\n", (grub_uint32_t)s->sh_offset, (grub_uint32_t)s->sh_size);
grub_file_seek(elf->file, s->sh_offset);
grub_file_read(elf->file, str, s->sh_size);
for (t = h, i = 0; i < e->e_shnum; i++)
{
if (grub_strcmp(str + t->sh_name, ".data") == 0)
{
offset = t->sh_offset;
len = t->sh_size;
debug("find .data section at %u %u\n", (grub_uint32_t)offset, len);
break;
}
t = (Elf32_Shdr *)((char *)t + e->e_shentsize);
}
}
if (offset == 0 || len == 0)
{
debug(".data section not found %s\n", args[0]);
goto out;
}
grub_file_seek(elf->file, offset + len - 8192);
grub_file_read(elf->file, data, 8192);
for (j = 0; j < 8192 - 12; j++)
{
if (grub_strncmp(data + j, "@(#)FreeBSD ", 12) == 0)
{
for (k = j + 12; k < 8192; k++)
{
if (0 == grub_isdigit(data[k]) && data[k] != '.')
{
data[k] = 0;
break;
}
}
grub_snprintf(ver, sizeof(ver), "%s", data + j + 12);
break;
}
}
if (ver[0])
{
k = (int)grub_strtoul(ver, NULL, 10);
debug("freebsd version:<%s> <%d.x>\n", ver, k);
grub_snprintf(ver, sizeof(ver), "%d.x", k);
ventoy_set_env(args[2], ver);
}
else
{
debug("freebsd version:<%s>\n", "NOT FOUND");
ret = ventoy_freebsd_ver_elf(bit64, elf, ".rodata", args[2], data);
}
out:
grub_check_free(str);
grub_check_free(hdr);
grub_check_free(data);
check_free(elf, grub_elf_close);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
@@ -704,7 +723,7 @@ grub_err_t ventoy_cmd_unix_replace_grub_conf(grub_extcmd_context_t ctxt, int arg
grub_file_t file;
char extcfg[512];
const char *confile = NULL;
const char * loader_conf[] =
const char * loader_conf[] =
{
"/boot/grub/grub.cfg",
};
@@ -716,7 +735,7 @@ grub_err_t ventoy_cmd_unix_replace_grub_conf(grub_extcmd_context_t ctxt, int arg
debug("Replace conf invalid argc %d\n", argc);
return 1;
}
for (i = 0; i < sizeof(loader_conf) / sizeof(loader_conf[0]); i++)
{
if (ventoy_get_file_override(loader_conf[i], &offset) == 0)
@@ -728,7 +747,7 @@ grub_err_t ventoy_cmd_unix_replace_grub_conf(grub_extcmd_context_t ctxt, int arg
}
if (confile == NULL)
{
{
debug("Can't find grub.cfg file from %u locations\n", i);
return 1;
}
@@ -745,13 +764,13 @@ grub_err_t ventoy_cmd_unix_replace_grub_conf(grub_extcmd_context_t ctxt, int arg
data = grub_malloc(VTOY_MAX_SCRIPT_BUF);
if (!data)
{
grub_file_close(file);
grub_file_close(file);
return 1;
}
grub_file_read(file, data, file->size);
grub_file_close(file);
g_conf_new_data = data;
g_conf_new_len = (int)file->size;
@@ -783,7 +802,7 @@ grub_err_t ventoy_cmd_unix_replace_grub_conf(grub_extcmd_context_t ctxt, int arg
{
vtoy_ssprintf(extcfg, len, ";set kFreeBSD.hint.ventoy.0.remount=%d", 1);
}
grub_memmove(pos + len, pos, (int)(file->size - (pos - data)));
grub_memcpy(pos, extcfg, len);
g_conf_new_len += len;
@@ -792,7 +811,7 @@ grub_err_t ventoy_cmd_unix_replace_grub_conf(grub_extcmd_context_t ctxt, int arg
{
debug("no kfreebsd found\n");
}
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
@@ -803,7 +822,7 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
grub_uint64_t offset;
grub_file_t file;
const char *confile = NULL;
const char * loader_conf[] =
const char * loader_conf[] =
{
"/boot/loader.conf",
"/boot/defaults/loader.conf",
@@ -816,7 +835,7 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
debug("Replace conf invalid argc %d\n", argc);
return 1;
}
for (i = 0; i < sizeof(loader_conf) / sizeof(loader_conf[0]); i++)
{
if (ventoy_get_file_override(loader_conf[i], &offset) == 0)
@@ -828,7 +847,7 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
}
if (confile == NULL)
{
{
debug("Can't find loader.conf file from %u locations\n", i);
return 1;
}
@@ -845,13 +864,13 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
data = grub_malloc(VTOY_MAX_SCRIPT_BUF);
if (!data)
{
grub_file_close(file);
grub_file_close(file);
return 1;
}
grub_file_read(file, data, file->size);
grub_file_close(file);
g_conf_new_data = data;
g_conf_new_len = (int)file->size;
@@ -863,19 +882,19 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
{
g_conf_new_len += ventoy_dragonfly_append_conf(data + file->size, args[1]);
}
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
static int ventoy_unix_search_magic(char *data, int len)
{
int i;
grub_uint32_t *magic = NULL;
grub_uint32_t *magic = NULL;
for (i = 0; i < len; i += 4096)
{
magic = (grub_uint32_t *)(data + i);
if (magic[0] == VENTOY_UNIX_SEG_MAGIC0 && magic[1] == VENTOY_UNIX_SEG_MAGIC1 &&
if (magic[0] == VENTOY_UNIX_SEG_MAGIC0 && magic[1] == VENTOY_UNIX_SEG_MAGIC1 &&
magic[2] == VENTOY_UNIX_SEG_MAGIC2 && magic[3] == VENTOY_UNIX_SEG_MAGIC3)
{
debug("unix find search magic at 0x%x loop:%d\n", i, (i >> 12));
@@ -910,7 +929,7 @@ grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char
g_mod_override_offset = offset;
}
else
{
{
debug("Can't find replace ko file from %s\n", args[0]);
return 1;
}
@@ -928,18 +947,18 @@ grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char
if (!data)
{
debug("Failed to alloc memory for new ko %d\n", (int)file->size);
grub_file_close(file);
grub_file_close(file);
return 1;
}
grub_file_read(file, data, file->size);
grub_file_close(file);
g_mod_new_data = data;
g_mod_new_len = (int)file->size;
ventoy_unix_search_magic(g_mod_new_data, g_mod_new_len);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
@@ -967,7 +986,7 @@ grub_err_t ventoy_cmd_unix_ko_fillmap(grub_extcmd_context_t ctxt, int argc, char
g_mod_override_offset = grub_iso9660_get_last_read_pos(file);
}
else
{
{
debug("Can't find replace ko file from %s\n", args[0]);
return 1;
}
@@ -977,8 +996,8 @@ grub_err_t ventoy_cmd_unix_ko_fillmap(grub_extcmd_context_t ctxt, int argc, char
magic[0] = 0;
grub_file_seek(file, i);
grub_file_read(file, magic, sizeof(magic));
if (magic[0] == VENTOY_UNIX_SEG_MAGIC0 && magic[1] == VENTOY_UNIX_SEG_MAGIC1 &&
if (magic[0] == VENTOY_UNIX_SEG_MAGIC0 && magic[1] == VENTOY_UNIX_SEG_MAGIC1 &&
magic[2] == VENTOY_UNIX_SEG_MAGIC2 && magic[3] == VENTOY_UNIX_SEG_MAGIC3)
{
debug("unix find search magic at 0x%x loop:%d\n", i, (i >> 16));
@@ -987,7 +1006,7 @@ grub_err_t ventoy_cmd_unix_ko_fillmap(grub_extcmd_context_t ctxt, int argc, char
}
}
len = (grub_uint32_t)OFFSET_OF(struct g_ventoy_map, seglist) +
len = (grub_uint32_t)OFFSET_OF(struct g_ventoy_map, seglist) +
(sizeof(struct g_ventoy_seg) * g_img_chunk_list.cur_chunk);
g_ko_fillmap_len = (int)len;
@@ -1034,7 +1053,7 @@ grub_err_t ventoy_cmd_unix_fill_image_desc(grub_extcmd_context_t ctxt, int argc,
if (grub_memcmp(flag, byte + i, 32) == 0)
{
debug("Find position flag at %d(0x%x)\n", i, i);
break;
break;
}
}
}
@@ -1118,7 +1137,7 @@ grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char
const char *pLastChain = NULL;
const char *compatible;
ventoy_chain_head *chain;
(void)ctxt;
(void)argc;
@@ -1161,9 +1180,9 @@ grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char
return grub_error(GRUB_ERR_BAD_ARGUMENT, "File %s is not bootable", args[0]);
}
}
img_chunk_size = g_img_chunk_list.cur_chunk * sizeof(ventoy_img_chunk);
if (ventoy_compatible)
{
size = sizeof(ventoy_chain_head) + img_chunk_size;
@@ -1172,11 +1191,11 @@ grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char
{
override_count = ventoy_unix_get_override_chunk_count();
override_size = override_count * sizeof(ventoy_override_chunk);
virt_chunk_size = ventoy_unix_get_virt_chunk_size();
size = sizeof(ventoy_chain_head) + img_chunk_size + override_size + virt_chunk_size;
}
pLastChain = grub_env_get("vtoy_chain_mem_addr");
if (pLastChain)
{
@@ -1239,7 +1258,7 @@ grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char
ventoy_unix_fill_virt_data(isosize, chain);
grub_file_close(file);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
@@ -0,0 +1,9 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
vtlog "####### $0 $* ########"
ventoy_copy_udev_auto_rules
@@ -0,0 +1,19 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
vtlog "####### $0 $* ########"
vtoy_udev_auto_hook() {
if grep -q 'break.*=.*postmount' /init; then
vtlog "udev auto before postmount"
sed "/break.*=.*postmount/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/manjaro/ventoy-uauto-exec.sh" -i /init
elif [ -d $VT_DRACUT_HOOKS/pre-pivot ]; then
vtlog "dracut distro"
ventoy_dracut_pivot_udev_rule
fi
}
vtoy_udev_auto_hook
@@ -20,6 +20,6 @@
. $VTOY_PATH/hook/ventoy-os-lib.sh
ventoy_set_inotify_script blackPanther/ventoy-inotifyd-hook.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/blackPanther/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/00-ventoy-inotifyd-start.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/blackPanther/ventoy-inotifyd-start.sh $VT_DRACUT_HOOKS/pre-udev/00-ventoy-inotifyd-start.sh
$SED "s#printf\(.*\)\$CMDLINE#printf\1 root=/dev/ventoy \$CMDLINE root=/dev/ventoy#" -i /lib/dracut-lib.sh
@@ -0,0 +1,16 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
vtlog "####### $0 $* ########"
vtoy_udev_auto_hook() {
if [ -d $VT_DRACUT_HOOKS/pre-pivot ]; then
vtlog "dracut distro"
ventoy_dracut_pivot_udev_rule
fi
}
vtoy_udev_auto_hook
@@ -0,0 +1,19 @@
find_cow_device() {
tgt_pers_label="${1}"
vt_pers_label=""
vt_pers_dev=""
if [ -f /ventoy/ventoy_persistent_label -a -f /ventoy/ventoy_persistent_dev ]; then
vt_pers_label=$(cat /ventoy/ventoy_persistent_label)
vt_pers_dev=$(cat /ventoy/ventoy_persistent_dev)
fi
if [ "$tgt_pers_label" = "$vt_pers_label" ]; then
echo "$vt_pers_dev"
else
find_cow_device_back "$@"
fi
}
find_cow_device_back() {
@@ -31,6 +31,19 @@ if [ -e /init ] && $GREP -q '^mountroot$' /init; then
$SED "s#^ *LIVEMEDIA=.*#LIVEMEDIA=/dev/mapper/ventoy#" -i /scripts/casper
fi
fi
#workaround for issue #3718
if [ -f $VTOY_PATH/ventoy_persistent_map -a -f /scripts/casper-helpers ]; then
echo 'fix casper cow udev issue' >> $VTLOG
if $GREP -q '^find_cow_device\(\).*{' /scripts/casper-helpers; then
VTINS_LINE=$($GREP -n '^find_cow_device\(\).*{' /scripts/casper-helpers | $AWK -F':' '{print $1}')
$AWK "NR < $VTINS_LINE" /scripts/casper-helpers > /ventoy/casper-helpers-tmp
$CAT $VTOY_PATH/hook/debian/casper-perst-wa.sh >> /ventoy/casper-helpers-tmp
$AWK "NR > $VTINS_LINE" /scripts/casper-helpers >> /ventoy/casper-helpers-tmp
$CAT /ventoy/casper-helpers-tmp > /scripts/casper-helpers
fi
fi
elif [ -e "$CD_DETECT" ]; then
echo "$CD_DETECT exist, now add hook in it..." >> $VTLOG
$SED "1 a $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/disk_mount_hook.sh" -i "$CD_DETECT"
@@ -36,19 +36,24 @@ if [ "$vtdiskname" = "unknown" ]; then
exit 0
fi
if grep -q 'device-mapper' /proc/devices; then
vtlog "dm-mod already loaded"
else
vtlog "dm-mod not loaded, get from squashfs"
vtoydm -i -f $VTOY_PATH/ventoy_image_map -d $vtdiskname > $VTOY_PATH/iso_file_list
vtoydm -i -f $VTOY_PATH/ventoy_image_map -d $vtdiskname > $VTOY_PATH/iso_file_list
vtline=$(grep '[-][-] drivers-.*\.squashfs' $VTOY_PATH/iso_file_list)
sector=$(echo $vtline | awk '{print $(NF-1)}')
length=$(echo $vtline | awk '{print $NF}')
vtline=$(grep '[-][-] drivers-.*\.squashfs' $VTOY_PATH/iso_file_list)
sector=$(echo $vtline | awk '{print $(NF-1)}')
length=$(echo $vtline | awk '{print $NF}')
vtoydm -e -f $VTOY_PATH/ventoy_image_map -d $vtdiskname -s $sector -l $length -o $VTOY_PATH/driver.squashfs
mount -t squashfs $VTOY_PATH/driver.squashfs /lib/modules
modprobe dm-mod
vtoydm -e -f $VTOY_PATH/ventoy_image_map -d $vtdiskname -s $sector -l $length -o $VTOY_PATH/driver.squashfs
mount -t squashfs $VTOY_PATH/driver.squashfs /lib/modules
modprobe dm-mod
umount /lib/modules
rm -f $VTOY_PATH/driver.squashfs
umount /lib/modules
rm -f $VTOY_PATH/driver.squashfs
fi
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
+5
View File
@@ -17,5 +17,10 @@
#
#************************************************************************************
if $GREP -q 'rdinit=/vtoy/vtoy' /proc/cmdline; then
echo "fix rdinit" >> $VTLOG
$SED "/switch_root.*\/mnt\/.installer-mp/i\ sh $VTOY_PATH/hook/debian/pve-wa.sh /mnt/.installer-mp/sbin/unconfigured.sh" -i /init
fi
$SED "/\/sys\/block\/hd\*/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/pve-disk.sh" -i /init
$SED "s#/sys/block/hd\*#/sys/block/dm* /sys/block/hd*#" -i /init
+20
View File
@@ -0,0 +1,20 @@
#!/bin/sh
script=$1
tmpscript=${script}.tmp
LINE=$(grep -n 'proc.*proc.*proc' $script | awk -F':' '{print $1}')
sed -n "1,${LINE}p" $script >> $tmpscript
echo "if grep -q 'rdinit=/vtoy/vtoy' /proc/cmdline; then" >> $tmpscript
echo " sed 's#rdinit=/vtoy/vtoy##g' /proc/cmdline > /etc/cmdline" >> $tmpscript
echo " mount --bind /etc/cmdline /proc/cmdline" >> $tmpscript
echo "fi" >> $tmpscript
let LINE++
sed -n "${LINE},\$p" $script >> $tmpscript
cat $tmpscript > $script
@@ -0,0 +1,11 @@
[Unit]
Description=Ventoy CloneZilla Device Cheat
After=systemd-udevd.service
[Service]
Type=oneshot
ExecStart=mv /dev/VTISOPART /dev/bk_VTISOPART
ExecStart=cp -a /dev/DMXXX /dev/VTISOPART
[Install]
WantedBy=sysinit.target
@@ -0,0 +1,3 @@
[Unit]
Wants=ventoy-curtin-wa.service
After=ventoy-curtin-wa.service
@@ -0,0 +1,8 @@
[Unit]
Description=Ventoy subiquity curtin Workaround
[Service]
Type=oneshot
ExecStart=/etc/ventoy/ventoy-curtin-wa.sh
PrivateMounts=no
ProtectSystem=no
@@ -0,0 +1,27 @@
#!/bin/bash
exec >> /var/log/ventoy-curtin-wa.log 2>&1
set -x
if [ -e /tmp/ventoy_storage_config.py ]; then
echo "no need to patch again"
elif [ -d /snap/ubuntu-desktop-bootstrap/current/lib ]; then
PyVer=$(ls -1 /snap/ubuntu-desktop-bootstrap/current/lib | grep -m1 python)
echo "Python Path: $PyVer"
OldFile=/snap/ubuntu-desktop-bootstrap/current/lib/$PyVer/site-packages/curtin/storage_config.py
NewFile=/tmp/ventoy_storage_config.py
if [ -e $OldFile ]; then
echo "Patch curtin storage config script"
cp -a $OldFile $NewFile
#skip Ventoy dm device
sed 's#\(if *\(.*\)\[.MAJOR.\] *in *\["11", *"2"\]\)#\1 or re.match(r"[vV]entoy.*|vtoy.*", \2.get("DM_NAME") or "")#g' -i $NewFile
mount --bind $NewFile $OldFile
else
echo "curin file not exist"
fi
else
echo "curin snap dir not exit"
fi
@@ -0,0 +1,48 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
vtlog "####### $0 $* ########"
subiquity_curtin_workaround() {
mkdir -p /root/etc/ventoy
ventoy_copy_file /ventoy/hook/debian/ventoy-curtin-wa.sh /root/etc/ventoy/ventoy-curtin-wa.sh 0755
ventoy_copy_file /ventoy/hook/debian/ventoy-curtin-wa.conf /root/etc/ventoy/ventoy-curtin-wa.conf 0644
ventoy_copy_file /ventoy/hook/debian/ventoy-curtin-wa.service /root/etc/ventoy/ventoy-curtin-wa.service 0644
ln -sf /etc/ventoy/ventoy-curtin-wa.service /root/etc/systemd/system/ventoy-curtin-wa.service
vtDepDir=/root/etc/systemd/system/snap.ubuntu-desktop-bootstrap.subiquity-server.service.d
mkdir -p $vtDepDir
ln -sf /etc/ventoy/ventoy-curtin-wa.conf $vtDepDir/10-ventoy-curtin-wa.conf
}
vroot=$(ventoy_new_root_dir)
if [ -z "$vroot" ]; then
vtlog "new sysroot not found"
else
ventoy_copy_udev_auto_rules
if ls $vroot/etc/udev/rules.d | grep -q 'snap.*desktop'; then
subiquity_curtin_workaround
else
vtlog "no snap desktop detected"
fi
fi
if [ -d $vroot/usr/share/clonezilla ]; then
vtlog "add cheat service for clonezilla"
vtDM=$($VTOY_PATH/tool/dmsetup info VentoyPart | grep Major | sed "s/.*[^0-9]\([0-9][0-9]*\)$/\1/")
vtRAWDISKNAME=$(head -n1 $VTOY_PATH/ventoy_raw_table | awk '{print $4}')
cp -a /ventoy/hook/debian/ventoy-clonezilla-cheat.service /ventoy/udevtmp.service
sed "s/DMXXX/dm-${vtDM}/g" -i /ventoy/udevtmp.service
sed "s/VTISOPART/${vtRAWDISKNAME#/dev/}/g" -i /ventoy/udevtmp.service
ventoy_copy_file /ventoy/udevtmp.service $vroot/etc/systemd/system/ventoy-clonezilla-cheat.service 0644
echo 'enable ventoy-clonezilla-cheat.service' > $vroot/etc/systemd/system-preset/90-ventoy-clonezilla.preset
ln -sf /etc/systemd/system/ventoy-clonezilla-cheat.service $vroot/etc/systemd/system/sysinit.target.wants/ventoy-clonezilla-cheat.service
fi
@@ -0,0 +1,36 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
vtlog "####### $0 $* ########"
vtoy_udev_auto_hook() {
if [ -e /etc/os-release ]; then
if grep -q 'ID=ubuntu' /etc/os-release; then
if egrep -q 'VERSION_ID=\"2[2-9]\.|VERSION_ID=\"3[0-9]\.' /etc/os-release; then
vtlog "ubuntu distro"
sed "/^mountroot$/a\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/ventoy-uauto-exec.sh" -i /init
return
fi
fi
fi
if [ -e /init ]; then
if $GREP -q '^mountroot$' /init; then
vtlog "mountroot distro"
sed "/^mountroot$/a\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/ventoy-uauto-exec.sh" -i /init
return
fi
if $GREP -q '^ *exec.*switch_root' /init; then
vtlog "switch_root distro"
sed "/^ *exec.*switch_root/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/ventoy-uauto-exec.sh" -i /init
return
fi
fi
}
vtoy_udev_auto_hook
+7 -3
View File
@@ -17,19 +17,23 @@
#
#************************************************************************************
$CAT /proc/cmdline > /ventoy/cmdline
$SED 's#live-media=[^ ]*#live-media=/dev/mapper/ventoy#g' -i /ventoy/cmdline
if [ -e /init ] && $GREP -q '^mountroot$' /init; then
echo "Here before mountroot ..." >> $VTLOG
$SED "/^mountroot$/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/deepin/disk_mount_hook.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 LIVE_MEDIA=/dev/mapper/ventoy" -i /init
$SED "/mount *[-]t *proc/a\\mount --bind /ventoy/cmdline /proc/cmdline" -i /init
if $GREP -q 'live-media=' /proc/cmdline; then
if [ -f /scripts/casper ] && $GREP -q '^ *LIVEMEDIA=' /scripts/casper; then
$SED "s#^ *LIVEMEDIA=.*#LIVEMEDIA=/dev/mapper/ventoy#" -i /scripts/casper
fi
fi
fi
fi
else
echo "Here use udev hook ..." >> $VTLOG
ventoy_systemd_udevd_work_around
@@ -0,0 +1,10 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
vtlog "####### $0 $* ########"
ventoy_copy_udev_auto_rules
@@ -0,0 +1,25 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
vtlog "####### $0 $* ########"
vtoy_udev_auto_hook() {
if [ -e /init ]; then
if $GREP -q '^mountroot$' /init; then
vtlog "mountroot distro"
sed "/^mountroot$/a\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/deepin/ventoy-uauto-exec.sh" -i /init
return
fi
if $GREP -q '^ *exec.*switch_root' /init; then
vtlog "switch_root distro"
sed "/^ *exec.*switch_root/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/deepin/ventoy-uauto-exec.sh" -i /init
return
fi
fi
}
vtoy_udev_auto_hook
@@ -0,0 +1,12 @@
ACTION=="add|change", SUBSYSTEM=="block", KERNEL=="dm-*", \
ENV{DM_NAME}=="[vV]entoy*", \
ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}="", \
ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="", \
ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=""
ACTION=="add|change", SUBSYSTEM=="block", KERNEL=="dm-*", \
ENV{DM_NAME}=="vtoy*", \
ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}="", \
ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="", \
ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=""
@@ -0,0 +1,5 @@
ACTION=="add|change", KERNEL=="dm-[0-9]*", ENV{DM_NAME}=="ventoy[0-9]*", \
ENV{DM_UDEV_DISABLE_SYBSYSTEM_RULES_FLAG}="", \
ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="", \
ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="", \
IMPORT{program}="/ventoy/hook/default/ventoy-udev.sh $env{DM_NAME}"
@@ -0,0 +1,12 @@
ACTION=="add|change", SUBSYSTEM=="block", KERNEL=="DMXXX", \
ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}="", \
ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="", \
ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="", \
ENV{UDISKS_SYSTEM}="0", \
ENV{UDISKS_REMOVABLE}="1", \
ENV{UDISKS_AUTO}="1", \
ENV{UDISKS_AUTOMOUNTABLE}="1"
KERNEL=="yyy", SUBSYSTEM=="block", ENV{UDISKS_IGNORE}="1"
@@ -0,0 +1,14 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
vtlog "####### $0 $* ########"
for vroot in sysroot newroot root; do
if [ -e $vroot/etc/selinux/config ]; then
$SED "s/SELINUX=enforcing/SELINUX=permissive/g" -i $vroot/etc/selinux/config
break
fi
done
$BUSYBOX_PATH/true
@@ -0,0 +1,9 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
vtlog "####### $0 $* ########"
ventoy_copy_udev_auto_rules
$BUSYBOX_PATH/true
@@ -0,0 +1,16 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
vtlog "####### $0 $* ########"
vtoy_udev_auto_hook() {
if [ -d $VT_DRACUT_HOOKS/pre-pivot ]; then
vtlog "dracut distro"
ventoy_dracut_pivot_udev_rule
fi
}
vtoy_udev_auto_hook
@@ -0,0 +1,9 @@
#!/bin/sh
for i in 0 1 2 3 4 5 6 7 8 9; do
[ -b /dev/DMXXX ] && break
sleep 1
done
udevadm trigger --subsystem-match=block --sysname-match=DMXXX
udevadm settle
@@ -0,0 +1,11 @@
[Unit]
Description=Ventoy DM device udev attributes
After=systemd-udevd.service
[Service]
Type=oneshot
ExecStart=-udevadm trigger --subsystem-match=block --sysname-match=DMXXX
ExecStart=udevadm settle
[Install]
WantedBy=sysinit.target
@@ -0,0 +1,22 @@
#!/bin/sh
PATH=$PATH:/ventoy/busybox:/ventoy/tool
echo "$@" >> /ventoy/log
VT_DMNAME=$1
VT_PART_NUM="${VT_DMNAME#*ventoy}"
VT_PARENT_DEV="/dev/mapper/ventoy"
VT_PARTUUID=
[ -b "$VT_PARENT_DEV" ] || exit 0
VT_PARTUUID=$(/ventoy/tool/vtoygpt $VT_PARENT_DEV $VT_PART_NUM | awk '{print $2}')
echo "$VT_DMNAME PARTUUID=$VT_PARTUUID" >> /ventoy/log
if [ -n "$VT_PARTUUID" ]; then
echo "ID_PART_ENTRY_UUID=$VT_PARTUUID"
echo "ID_PART_ENTRY_NUMBER=$VT_PART_NUM"
echo "ID_PART_ENTRY_SCHEME=gpt"
fi
@@ -0,0 +1,24 @@
#!/ventoy/busybox/sh
. /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
vtlog "vtdiskname=$vtdiskname"
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
# OK finish
set_ventoy_hook_finish
@@ -0,0 +1,7 @@
function ft_mountCdromDir()
{
/ventoy/busybox/sh /ventoy/hook/euleros/disk_mount_hook.sh
ft_mountCdromDirXX "$@"
}
@@ -0,0 +1,42 @@
#!/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
TRANSFILE=/usr/Euler/project/load/filetransfer.sh
LINE=$($GREP -n 'function ft_mountCdromDir' $TRANSFILE | $AWK -F':' '{print $1}')
echo "LINE=$LINE" >> $VTLOG
$SED 's#FT_SR_DEV=.*#FT_SR_DEV=/dev/mapper/ventoy#g' -i $TRANSFILE
$SED 's/function ft_mountCdromDir/function ft_mountCdromDirXX/' -i $TRANSFILE
let LINE--
$SED -n "1,${LINE}p" $TRANSFILE >> /ventoy/filetransfer.sh
$CAT $VTOY_PATH/hook/euleros/hook_func.sh >> /ventoy/filetransfer.sh
let LINE++
$SED -n "${LINE},\$p" $TRANSFILE >> /ventoy/filetransfer.sh
$BUSYBOX_PATH/mv /ventoy/filetransfer.sh $TRANSFILE
#fix the euler os shell script
$SED 's/-z ${harddisk_disk_list}/-z "${harddisk_disk_list}"/' -i /usr/Euler/project/disk/disk_tool.sh
+32
View File
@@ -0,0 +1,32 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
for i in 0 1 2 3 4 5 6 7 8 9; do
vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "wait for disk ..."
$SLEEP 2
else
break
fi
done
echo '############ Copy ISO file to memory ... ###############'
vtoydm -C -f $VTOY_PATH/ventoy_image_map -d $vtdiskname -o $VTOY_PATH/dump.iso
[ -d /ventoy/tmpmnt ] || mkdir /ventoy/tmpmnt
mount /ventoy/dump.iso /ventoy/tmpmnt
cp -a /ventoy/tmpmnt/* $1/
umount /ventoy/tmpmnt
rm -f /ventoy/dump.iso
echo '############ Copy ISO file to memory finished OK ###############'
sleep 2
PATH=$VTPATH_OLD
@@ -30,6 +30,9 @@ elif $GREP -q 'setting up the root filesystem' /init; then
elif [ -d /etc/udev/rules.d ] || [ -d /lib/udev/rules.d ]; then
ventoy_systemd_udevd_work_around
ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k noreplace"
elif $GREP -q 'NVIDIA CORPORATION' /init; then
$SED "s/while true; do/while false; do/" -i /init
$SED "/^FOUNDDEV=/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/gentoo/mats-hook.sh \"\${ROOTFS}/\${MNTNV}\"" -i /init
else
$SED "/mdev *-s/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/gentoo/disk_hook.sh" -i /init
fi
+1 -1
View File
@@ -23,4 +23,4 @@ $SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE root=live:/dev/mapper/ventoy#" -
ventoy_set_inotify_script gobo/ventoy-inotifyd-hook.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/gobo/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/01-ventoy-inotifyd-start.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/gobo/ventoy-inotifyd-start.sh $VT_DRACUT_HOOKS/pre-udev/01-ventoy-inotifyd-start.sh
@@ -0,0 +1,16 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
vtlog "####### $0 $* ########"
vtoy_udev_auto_hook() {
if [ -d $VT_DRACUT_HOOKS/pre-pivot ]; then
vtlog "dracut distro"
ventoy_dracut_pivot_udev_rule
fi
}
vtoy_udev_auto_hook
@@ -0,0 +1,9 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
vtlog "####### $0 $* ########"
ventoy_copy_udev_auto_rules
@@ -0,0 +1,19 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
vtlog "####### $0 $* ########"
vtoy_udev_auto_hook() {
if grep -q 'break.*=.*postmount' /init; then
vtlog "udev auto before postmount"
sed "/break.*=.*postmount/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/hyperbola/ventoy-uauto-exec.sh" -i /init
elif [ -d $VT_DRACUT_HOOKS/pre-pivot ]; then
vtlog "dracut distro"
ventoy_dracut_pivot_udev_rule
fi
}
vtoy_udev_auto_hook
@@ -0,0 +1,9 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
vtlog "####### $0 $* ########"
ventoy_copy_udev_auto_rules
@@ -0,0 +1,25 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
vtlog "####### $0 $* ########"
vtoy_udev_auto_hook() {
if [ -e /init ]; then
if $GREP -q '^mountroot$' /init; then
vtlog "mountroot distro"
sed "/^mountroot$/a\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/kaos/ventoy-uauto-exec.sh" -i /init
return
fi
if $GREP -q '^ *exec.*switch_root' /init; then
vtlog "switch_root distro"
sed "/^ *exec.*switch_root/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/kaos/ventoy-uauto-exec.sh" -i /init
return
fi
fi
}
vtoy_udev_auto_hook
+1 -1
View File
@@ -24,4 +24,4 @@ $SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE root=/dev/ventoy#" -i /lib/dracu
$BUSYBOX_PATH/rm -f /usr/lib/systemd/system-generators/systemd-fstab-generator /lib/systemd/system-generators/systemd-fstab-generator
ventoy_set_inotify_script lunar/ventoy-inotifyd-hook.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/lunar/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/01-ventoy-inotifyd-start.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/lunar/ventoy-inotifyd-start.sh $VT_DRACUT_HOOKS/pre-udev/01-ventoy-inotifyd-start.sh
+1 -1
View File
@@ -23,7 +23,7 @@
#ventoy_add_udev_rule "$VTOY_PATH/hook/mageia/udev_disk_hook.sh %k noreplace"
ventoy_set_inotify_script mageia/ventoy-inotifyd-hook.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/mageia/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/99-ventoy-inotifyd-start.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/mageia/ventoy-inotifyd-start.sh $VT_DRACUT_HOOKS/pre-udev/99-ventoy-inotifyd-start.sh
@@ -0,0 +1,9 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
vtlog "####### $0 $* ########"
ventoy_copy_udev_auto_rules
@@ -0,0 +1,16 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
vtlog "####### $0 $* ########"
vtoy_udev_auto_hook() {
if grep -q 'break.*=.*postmount' /init; then
vtlog "udev auto before postmount"
sed "/break.*=.*postmount/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/manjaro/ventoy-uauto-exec.sh" -i /init
fi
}
vtoy_udev_auto_hook
@@ -93,9 +93,9 @@ else
vtPriority=01
fi
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/openEuler/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/${vtPriority}-ventoy-inotifyd-start.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/openEuler/ventoy-timeout.sh /lib/dracut/hooks/initqueue/timeout/${vtPriority}-ventoy-timeout.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/openEuler/ventoy-repo.sh /lib/dracut/hooks/pre-pivot/99-ventoy-repo.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/openEuler/ventoy-inotifyd-start.sh $VT_DRACUT_HOOKS/pre-udev/${vtPriority}-ventoy-inotifyd-start.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/openEuler/ventoy-timeout.sh $VT_DRACUT_HOOKS/initqueue/timeout/${vtPriority}-ventoy-timeout.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/openEuler/ventoy-repo.sh $VT_DRACUT_HOOKS/pre-pivot/99-ventoy-repo.sh
if [ -f /sbin/dmsquash-live-root ]; then
echo "patch /sbin/dmsquash-live-root ..." >> $VTLOG
@@ -109,5 +109,5 @@ fi
if [ -f $VTOY_PATH/autoinstall ]; then
cp -a $VTOY_PATH/hook/openEuler/ventoy-autoexp.sh /lib/dracut/hooks/pre-mount/99-ventoy-autoexp.sh
cp -a $VTOY_PATH/hook/openEuler/ventoy-autoexp.sh $VT_DRACUT_HOOKS/pre-mount/99-ventoy-autoexp.sh
fi
@@ -0,0 +1,16 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
vtlog "####### $0 $* ########"
vtoy_udev_auto_hook() {
if [ -d $VT_DRACUT_HOOKS/pre-pivot ]; then
vtlog "dracut distro"
ventoy_dracut_pivot_udev_rule
fi
}
vtoy_udev_auto_hook
+5 -5
View File
@@ -24,7 +24,7 @@
if [ -f $VTOY_PATH/autoinstall ]; then
VTKS="inst.ks=file:$VTOY_PATH/autoinstall"
cp -a $VTOY_PATH/hook/rhel7/ventoy-autoexp.sh /lib/dracut/hooks/pre-mount/99-ventoy-autoexp.sh
cp -a $VTOY_PATH/hook/rhel7/ventoy-autoexp.sh $VT_DRACUT_HOOKS/pre-mount/99-ventoy-autoexp.sh
else
for vtParam in $($CAT /proc/cmdline); do
if echo $vtParam | $GREP -q 'ks=file:/'; then
@@ -119,7 +119,7 @@ fi
echo "vtNeedRepo=$vtNeedRepo" >> $VTLOG
if [ "$vtNeedRepo" = "yes" ]; then
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-repo.sh /lib/dracut/hooks/pre-pivot/99-ventoy-repo.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-repo.sh $VT_DRACUT_HOOKS/pre-pivot/99-ventoy-repo.sh
fi
@@ -161,8 +161,8 @@ else
vtPriority=01
fi
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/${vtPriority}-ventoy-inotifyd-start.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-timeout.sh /lib/dracut/hooks/initqueue/timeout/${vtPriority}-ventoy-timeout.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-inotifyd-start.sh $VT_DRACUT_HOOKS/pre-udev/${vtPriority}-ventoy-inotifyd-start.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-timeout.sh $VT_DRACUT_HOOKS/initqueue/timeout/${vtPriority}-ventoy-timeout.sh
if [ -e /sbin/dmsquash-live-root ]; then
@@ -178,7 +178,7 @@ fi
#For Fedora CoreOS
if $GREP -i -q 'fedora.*coreos' /etc/os-release; then
$SED "s#isosrc=.*#isosrc=/dev/mapper/ventoy#" -i /lib/systemd/system-generators/live-generator
cp -a $VTOY_PATH/hook/rhel7/ventoy-make-link.sh /lib/dracut/hooks/pre-mount/99-ventoy-premount-mklink.sh
cp -a $VTOY_PATH/hook/rhel7/ventoy-make-link.sh $VT_DRACUT_HOOKS/pre-mount/99-ventoy-premount-mklink.sh
fi
@@ -34,7 +34,7 @@ if is_inotify_ventoy_part $3; then
vtlog "find ventoy partition ..."
vtReplaceOpt=noreplace
if [ -f /lib/dracut/hooks/pre-pivot/99-ventoy-repo.sh ]; then
if [ -f $VT_DRACUT_HOOKS/pre-pivot/99-ventoy-repo.sh ]; then
vtReplaceOpt=""
fi
@@ -30,5 +30,5 @@ else
#don't call it too early issue 2225
#$BUSYBOX_PATH/sh $vtHook n /dev "${vtdisk#/dev/}2"
cp -a $VTOY_PATH/hook/rhel7/ventoy-inotifyd-call.sh /lib/dracut/hooks/initqueue/settled/90-ventoy-inotifyd-call.sh
cp -a $VTOY_PATH/hook/rhel7/ventoy-inotifyd-call.sh $VT_DRACUT_HOOKS/initqueue/settled/90-ventoy-inotifyd-call.sh
fi
@@ -0,0 +1,27 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
vtlog "####### $0 $* ########"
vtoy_udev_auto_hook() {
if [ -e /etc/os-release ]; then
if grep -q 'ID=fedora' /etc/os-release; then
if grep -q 'VERSION_ID=[3-9][0-9]' /etc/os-release; then
vtlog "fedora distro"
ventoy_dracut_pivot_udev_rule
ventoy_dracut_pivot_selinux_off
return
fi
fi
fi
if [ -d $VT_DRACUT_HOOKS/pre-pivot ]; then
vtlog "dracut distro"
ventoy_dracut_pivot_udev_rule
fi
}
vtoy_udev_auto_hook
@@ -0,0 +1,16 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
vtlog "####### $0 $* ########"
vtoy_udev_auto_hook() {
if [ -d $VT_DRACUT_HOOKS/pre-pivot ]; then
vtlog "dracut distro"
ventoy_dracut_pivot_udev_rule
fi
}
vtoy_udev_auto_hook
+371 -6
View File
@@ -32,6 +32,11 @@ VTOY_DM_PATH=/dev/mapper/ventoy
VTOY_DEBUG_LEVEL=$($BUSYBOX_PATH/hexdump -n 1 -s 450 -e '1/1 "%02x"' $VTOY_PATH/ventoy_os_param)
VTOY_LINUX_REMOUNT=$($BUSYBOX_PATH/hexdump -n 1 -s 454 -e '1/1 "%02x"' $VTOY_PATH/ventoy_os_param)
VTOY_VLNK_BOOT=$($BUSYBOX_PATH/hexdump -n 1 -s 455 -e '1/1 "%02x"' $VTOY_PATH/ventoy_os_param)
if [ -d /var/lib/dracut/hooks ]; then
VT_DRACUT_HOOKS=/var/lib/dracut/hooks
else
VT_DRACUT_HOOKS=/lib/dracut/hooks
fi
if [ "$VTOY_DEBUG_LEVEL" = "01" ]; then
if [ -e /dev/console ]; then
@@ -39,6 +44,7 @@ if [ "$VTOY_DEBUG_LEVEL" = "01" ]; then
fi
fi
vtlog() {
if [ "$VTLOG" = "$VTOY_PATH/log" ]; then
echo "$*" >>$VTLOG
@@ -58,6 +64,14 @@ vterr() {
}
ventoy_copy_file() {
cp -a "$1" "$2"
if [ -n "$3" ]; then
chmod $3 "$2"
fi
}
is_ventoy_hook_finished() {
[ -e $VTOY_PATH/hook_finish ]
}
@@ -71,7 +85,7 @@ set_ventoy_hook_finish() {
echo "### iso part dm cmd" >> $VTLOG
$CAT /ventoy/ventoy_iso_part_dm_cmd >> $VTLOG
$BUSYBOX_PATH/sh /ventoy/ventoy_iso_part_dm_cmd >>$VTLOG 2>&1
#$BUSYBOX_PATH/rm -f /ventoy/ventoy_iso_part_dm_cmd
$BUSYBOX_PATH/mv /ventoy/ventoy_iso_part_dm_cmd /ventoy/ventoy_iso_part_dm_cmd_bk
fi
}
@@ -267,11 +281,68 @@ create_ventoy_device_mapper() {
else
$VT_DM_BIN "$2" create ventoy $VTOY_PATH/ventoy_dm_table >>$VTLOG 2>&1
fi
RAWDISKNAME=$($HEAD -n1 $VTOY_PATH/ventoy_raw_table | $AWK '{print $4}')
echo "$VT_DM_BIN create ${RAWDISKNAME#/dev/} $VTOY_PATH/ventoy_raw_table" > /ventoy/ventoy_iso_part_dm_cmd
#echo "$VT_DM_BIN mknodes ${RAWDISKNAME#/dev/}" >> /ventoy/ventoy_iso_part_dm_cmd
#echo "$VT_DM_BIN ls" >> /ventoy/ventoy_iso_part_dm_cmd
echo "$VT_DM_BIN create VentoyPart $VTOY_PATH/ventoy_raw_table" > /ventoy/ventoy_iso_part_dm_cmd
echo "echo 1 > $VTOY_PATH/ventoy_raw_dm_done" >> /ventoy/ventoy_iso_part_dm_cmd
}
create_ventoy_loop_device_mapper() {
vtLoop1=${1#/dev/}
vtLoop2=${2#/dev/}
vtlog "create_ventoy_loop_device_mapper $*"
VT_DM_BIN=$(ventoy_find_bin_path dmsetup)
if [ -z "$VT_DM_BIN" ]; then
vtlog "no dmsetup avaliable, lastly try inbox dmsetup"
VT_DM_BIN=$VTOY_PATH/tool/dmsetup
fi
vtlog "dmsetup avaliable in system $VT_DM_BIN"
if ventoy_check_dm_module; then
vtlog "device-mapper module check success"
else
vterr "Error: no dm module avaliable"
fi
vtLoop2Size=$(cat /sys/block/$vtLoop2/size)
echo "0 65 linear $1 0" > $VTOY_PATH/ventoy_dm_table
echo "65 $vtLoop2Size linear $2 0" >> $VTOY_PATH/ventoy_dm_table
$VT_DM_BIN "--readonly" create ventoy $VTOY_PATH/ventoy_dm_table >>$VTLOG 2>&1
}
create_ventoy_wrapper_device_mapper() {
vtlog "create_ventoy_wrapper_device_mapper $*"
VT_DM_BIN=$(ventoy_find_bin_path dmsetup)
if [ -z "$VT_DM_BIN" ]; then
vtlog "no dmsetup avaliable, lastly try inbox dmsetup"
VT_DM_BIN=$VTOY_PATH/tool/dmsetup
fi
vtlog "dmsetup avaliable in system $VT_DM_BIN"
if ventoy_check_dm_module "$1"; then
vtlog "device-mapper module check success"
else
vterr "Error: no dm module avaliable"
fi
$VTOY_PATH/tool/vtoydm -w -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_dm_table
VT_LOOP_DEV=$(losetup -f)
losetup $VT_LOOP_DEV /ventoy/dmwrapper.bin
$SED "s#/dev/loop0#$VT_LOOP_DEV#" -i $VTOY_PATH/ventoy_dm_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
}
create_persistent_device_mapper() {
@@ -512,6 +583,9 @@ ventoy_create_persistent_link() {
VTLABEL=casper-rw
fi
echo "$VTLABEL" > $VTOY_PATH/ventoy_persistent_label
echo "/dev/$vtDM" > $VTOY_PATH/ventoy_persistent_dev
vtlog "Persistent Label: ##${VTLABEL}##"
if ! [ -e /dev/disk/by-label/$VTLABEL ]; then
@@ -581,13 +655,64 @@ ventoy_udev_disk_common_hook() {
else
ventoy_copy_device_mapper "/dev/$1"
fi
if [ -f $VTOY_PATH/ventoy_persistent_map ]; then
create_persistent_device_mapper "/dev/$VTDISK"
ventoy_create_persistent_link
fi
}
ventoy_create_wrapper_dm() {
if echo $1 | $EGREP -q "nvme.*p[0-9]$|mmc.*p[0-9]$|nbd.*p[0-9]$"; then
VTDISK="${1:0:-2}"
else
VTDISK="${1:0:-1}"
fi
if [ -e /vtoy/vtoy ]; then
VTRWMOD=""
else
VTRWMOD="--readonly"
fi
# create device mapper for iso image file
if create_ventoy_wrapper_device_mapper "/dev/$VTDISK" $VTRWMOD; then
vtlog "==== create wrapper ventoy device mapper success ===="
else
vtlog "==== create wrapper ventoy device mapper failed ===="
$SLEEP 3
if $GREP -q "/dev/$VTDISK" /proc/mounts; then
$GREP "/dev/$VTDISK" /proc/mounts | while read vtLine; do
vtPart=$(echo $vtLine | $AWK '{print $1}')
vtMnt=$(echo $vtLine | $AWK '{print $2}')
vtlog "$vtPart is mounted on $vtMnt now umount it ..."
$BUSYBOX_PATH/umount $vtMnt
done
fi
if create_ventoy_wrapper_device_mapper "/dev/$VTDISK" $VTRWMOD; then
vtlog "==== create wrapper ventoy device mapper success after retry ===="
else
vtlog "==== create wrapper ventoy device mapper failed after retry ===="
return
fi
fi
if [ "$2" = "noreplace" ]; then
vtlog "no need to replace block device"
else
ventoy_copy_device_mapper "/dev/$1"
fi
if [ -f $VTOY_PATH/ventoy_persistent_map ]; then
create_persistent_device_mapper "/dev/$VTDISK"
ventoy_create_persistent_link
fi
}
ventoy_create_dev_ventoy_part() {
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | $GREP ventoy | $SED 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
$BUSYBOX_PATH/mknod -m 0666 /dev/ventoy b $blkdev_num
@@ -607,6 +732,37 @@ ventoy_create_dev_ventoy_part() {
}
ventoy_remove_all_dm() {
if [ -e /vtoy_dm_table ]; then
vtPartid=1
$CAT /vtoy_dm_table | while read vtline; do
vtlog "dmsetup remove ventoy${vtPartid}"
$VTOY_PATH/tool/dmsetup remove ventoy${vtPartid}
vtPartid=$(expr $vtPartid + 1)
done
fi
vtlog "dmsetup remove ventoy"
$VTOY_PATH/tool/dmsetup remove ventoy >> $VTLOG 2>&1
rm -f /dev/ventoy*
if [ -e $VTOY_PATH/ventoy_raw_dm_done ]; then
vtlog "dmsetup remove VentoyPart"
$VTOY_PATH/tool/dmsetup remove VentoyPart
rm -f $VTOY_PATH/ventoy_iso_part_dm_cmd
fi
if [ -e $VTOY_PATH/persistent_dm_table ]; then
if $VTOY_PATH/tool/dmsetup ls | $GREP -qw vtoy_persistent; then
vtlog "dmsetup remove vtoy_persistent"
$VTOY_PATH/tool/dmsetup remove vtoy_persistent
else
vtlog "no need to remove DM vtoy_persistent"
fi
fi
}
ventoy_create_chromeos_ventoy_part() {
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | $GREP ventoy | $SED 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
$BUSYBOX_PATH/mknod -m 0666 /dev/ventoy b $blkdev_num
@@ -724,3 +880,212 @@ ventoy_wait_dir() {
fi
done
}
ventoy_load_iso_part_fs_ko() {
vtFS=$($VTOY_PATH/tool/vtoydump -s /ventoy/ventoy_os_param)
vtlog "ISO part FS is $vtFS"
for vtModProbe in /usr/sbin/modprobe /sbin/modprobe /bin/modprobe $BUSYBOX_PATH/modprobe; do
if [ -e $vtModProbe ]; then
break
fi
done
vtlog "modprobe is $vtModProbe"
if [ "$vtFS" = "ext" ]; then
vtlog "modprobe ext2/3/4"
$vtModProbe ext2 >> $VTLOG 2>&1
$vtModProbe ext3 >> $VTLOG 2>&1
$vtModProbe ext4 >> $VTLOG 2>&1
elif [ "$vtFS" = "ntfs" ]; then
vtlog "modprobe ntfs3"
$vtModProbe ntfs3 >> $VTLOG 2>&1
elif [ "$vtFS" = "fat" ]; then
vtlog "modprobe vfat"
$vtModProbe vfat >> $VTLOG 2>&1
else
vtlog "modprobe $vtFS"
$vtModProbe $vtFS >> $VTLOG 2>&1
fi
}
ventoy_iso_part_fs_supported() {
vtFS=$($VTOY_PATH/tool/vtoydump -s /ventoy/ventoy_os_param)
if [ "$vtFS" = "ext" ]; then
vtPattern='ext[2-4]'
elif [ "$vtFS" = "fat" ]; then
vtPattern='vfat'
elif [ "$vtFS" = "ntfs" ]; then
vtPattern='ntfs3'
else
vtPattern="$vtFS"
fi
vtlog "vtFS=$vtFS Pattern=$vtPattern"
if $EGREP -q "$vtPattern" /proc/filesystems; then
vtlog "ISO part FS supported OK"
$BUSYBOX_PATH/true
else
vtlog "ISO part FS is NOT supported"
$BUSYBOX_PATH/false
fi
}
ventoy_mount_iso_part() {
vtDisk=$1
vtMnt=$2
vtlog "mount iso partition $vtDisk"
if [ -z "$vtMnt" ]; then
vtMnt=$VTOY_PATH/tmpmnt
fi
mkdir -p $vtMnt
if echo $vtDisk | $EGREP -q "nvme|mmc|nbd"; then
vtpart1=${vtDisk}p1
else
vtpart1=${vtDisk}1
fi
vtFS=$($VTOY_PATH/tool/vtoydump -s /ventoy/ventoy_os_param)
if [ "$vtFS" = "ntfs" ]; then
vtlog "mount -t ntfs3 $vtpart1 $vtMnt"
mount -t ntfs3 $vtpart1 $vtMnt >> $VTLOG 2>&1
elif [ "$vtFS" = "fat" ]; then
vtlog "mount -t vfat $vtpart1 $vtMnt"
mount -t vfat $vtpart1 $vtMnt >> $VTLOG 2>&1
else
vtlog "mount $vtpart1 $vtMnt"
mount $vtpart1 $vtMnt >> $VTLOG 2>&1
fi
}
ventoy_losetup_iso() {
vtMnt=$1
if [ -z "$vtMnt" ]; then
vtMnt=$VTOY_PATH/tmpmnt
fi
for vtLosetup in /usr/sbin/losetup /sbin/losetup /bin/losetup $BUSYBOX_PATH/losetup; do
if [ -e $vtLosetup ]; then
break
fi
done
vtisoname=$(get_ventoy_iso_name)
dd if=/dev/zero of=/ventoy/isoheader.bin bs=512 count=1 >/dev/null 2>&1
dd if="${vtMnt}${vtisoname}" bs=512 skip=1 count=64 >>/ventoy/isoheader.bin 2>>/dev/null
vtfreeloop1=$($vtLosetup -f)
if $vtLosetup -r $vtfreeloop1 /ventoy/isoheader.bin >> $VTLOG 2>&1; then
vtfreeloop2=$($vtLosetup -f)
if $vtLosetup -r --offset=33280 $vtfreeloop2 "${vtMnt}${vtisoname}" >> $VTLOG 2>&1; then
echo -n "$vtfreeloop1 $vtfreeloop2" > /ventoy/vtoy_dm_loop_dev
fi
fi
}
ventoy_mount_iso() {
if [ "$1" = "ko" ]; then
shift
ventoy_load_iso_part_fs_ko
fi
if ventoy_iso_part_fs_supported; then
if ventoy_mount_iso_part $1; then
if ventoy_losetup_iso; then
create_ventoy_loop_device_mapper $($CAT /ventoy/vtoy_dm_loop_dev)
return
else
vtlog "losetup ISO file FAILED"
fi
else
vtlog "mount iso partition FAILED"
fi
fi
$BUSYBOX_PATH/false
}
ventoy_init_udev_auto_rules() {
ventoy_copy_file /ventoy/hook/default/11-ventoy-dm.rules /etc/udev/rules.d/11-ventoy-dm.rules 0644
}
ventoy_new_root_dir() {
for vroot in sysroot newroot new_root root live/aufs pup_new; do
if [ -d $vroot/etc/udev/rules.d ]; then
echo "$vroot"
return
fi
done
echo ''
}
ventoy_copy_udev_auto_rules() {
if ! [ -e $VTOY_PATH/ventoy_raw_dm_done ]; then
vtlog "ventoy_raw_dm_done not exist, no need for udev auto rule"
return
fi
vtlog "==== Copy udev auto rules ===="
vroot=$(ventoy_new_root_dir)
if [ -z "$vroot" ]; then
vtlog "no new root found"
return
else
vtlog "new root is $vroot"
fi
cp -a /ventoy/hook/default/90-ventoy-auto.rules /ventoy/udevtmp.rules
vtDM=$($VTOY_PATH/tool/dmsetup info VentoyPart | $GREP Major | $SED "s/.*[^0-9]\([0-9][0-9]*\)$/\1/")
$SED "s/DMXXX/dm-${vtDM}/g" -i /ventoy/udevtmp.rules
vtRAWDISKNAME=$($HEAD -n1 $VTOY_PATH/ventoy_raw_table | $AWK '{print $4}')
$SED "s/yyy/${vtRAWDISKNAME#/dev/}/g" -i /ventoy/udevtmp.rules
vtlog "VentoyPart is /dev/dm-${vtDM} map to $vtRAWDISKNAME NewRoot is $vroot"
ventoy_copy_file /ventoy/udevtmp.rules $vroot/etc/udev/rules.d/90-ventoy-auto.rules 0644
ventoy_copy_file /ventoy/udevtmp.rules $vroot/etc/udev/rules.d/11-ventoy-auto.rules 0644
if $GREP -q 'init=.*sysvinit' /proc/cmdline; then
vtlog "copy sysvinit udev trigger script"
cp -a /ventoy/hook/default/ventoy-udev-trigger.rc /ventoy/udevtmp.rc
$SED "s/DMXXX/dm-${vtDM}/g" -i /ventoy/udevtmp.rc
mkdir -p $vroot/etc/boot.d
ventoy_copy_file /ventoy/udevtmp.rc $vroot/etc/boot.d/S01-ventoy-udev-trigger 0755
elif [ -d $vroot/etc/systemd/system ]; then
vtlog "copy systemd udev trigger service"
mkdir -p $vroot/etc/systemd/system/sysinit.target.wants
cp -a /ventoy/hook/default/ventoy-udev-trigger.service /ventoy/udevtmp.service
$SED "s/DMXXX/dm-${vtDM}/g" -i /ventoy/udevtmp.service
ventoy_copy_file /ventoy/udevtmp.service $vroot/etc/systemd/system/ventoy-udev-trigger.service 0644
mkdir -p $vroot/etc/systemd/system-preset
echo 'enable ventoy-udev-trigger.service' > $vroot/etc/systemd/system-preset/80-ventoy-udev.preset
$BUSYBOX_PATH/ln -sf /etc/systemd/system/ventoy-udev-trigger.service $vroot/etc/systemd/system/sysinit.target.wants/ventoy-udev-trigger.service
else
vtlog "sysinit wants dir not exist"
fi
}
ventoy_dracut_pivot_udev_rule() {
echo "#!/bin/sh" > $VT_DRACUT_HOOKS/pre-pivot/99-ventoy-udev-rules.sh
echo "/ventoy/busybox/sh $VTOY_PATH/hook/default/ventoy-pivot-udev-rule.sh" >> $VT_DRACUT_HOOKS/pre-pivot/99-ventoy-udev-rules.sh
}
ventoy_dracut_pivot_selinux_off() {
echo "#!/bin/sh" > $VT_DRACUT_HOOKS/pre-pivot/99-ventoy-selinux-off.sh
echo "/ventoy/busybox/sh $VTOY_PATH/hook/default/ventoy-pivot-selinux-off.sh" >> $VT_DRACUT_HOOKS/pre-pivot/99-ventoy-selinux-off.sh
}
+20
View File
@@ -22,6 +22,13 @@ VT_PRINTK_LEVEL=0
VT_UDEV_RULE_FILE_NAME="99-ventoy.rules"
VT_UDEV_RULE_PREFIX="ACTION==\"add\", SUBSYSTEM==\"block\","
if [ -d /var/lib/dracut/hooks ]; then
VT_DRACUT_HOOKS=/var/lib/dracut/hooks
else
VT_DRACUT_HOOKS=/lib/dracut/hooks
fi
ventoy_close_printk() {
VT_PRINTK_LEVEL=$($CAT /proc/sys/kernel/printk | $AWK '{print $1}')
if [ -e /proc/sys/kernel/printk ]; then
@@ -56,6 +63,14 @@ ventoy_get_udev_conf_path() {
echo "$VT_RULE_DIR/$VT_UDEV_RULE_FILE_NAME"
}
ventoy_add_udev_auto_rule() {
VT_RULE_DIR=$(ventoy_get_udev_conf_dir)
cp -a $VTOY_PATH/hook/default/90-ventoy-auto.rules $VT_RULE_DIR/11-ventoy-auto.rules
cp -a $VTOY_PATH/hook/default/90-ventoy-auto.rules $VT_RULE_DIR/90-ventoy-auto.rules
chmod 0644 $VT_RULE_DIR/*ventoy*
}
ventoy_add_kernel_udev_rule() {
VT_UDEV_RULE_PATH=$(ventoy_get_udev_conf_path)
echo "KERNEL==\"$1\", $VT_UDEV_RULE_PREFIX RUN+=\"$2\"" >> $VT_UDEV_RULE_PATH
@@ -171,3 +186,8 @@ ventoy_iso_scan_check() {
[ $vtCheckOk -eq 1 ]
}
ventoy_wrapper_dracut_hook() {
echo "#/bin/sh" > $2
echo "$BUSYBOX_PATH/sh $1" >> $2
}
+119
View File
@@ -0,0 +1,119 @@
#!/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"
exit 0
fi
/usr/bin/insmod $VTOY_PATH/modules/dm-mod.ko*
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
ventoy_create_dev_ventoy_part
mkdir -p /ventoy/tmpmnt
mount /dev/ventoy3 /ventoy/tmpmnt
mount --bind /ventoy/tmpmnt/lib/modules /lib/modules
for mod in loop iso9660 ntfs ntfs3 exfat ext2 ext3 ext4 xfs btrfs; do
vtlog "modprobe $mod"
/usr/bin/modprobe $mod >> $VTLOG 2>&1
done
umount /lib/modules
umount /ventoy/tmpmnt
ventoy_remove_all_dm
vtimgname=$(get_ventoy_iso_name)
if [ "$vtimgname" = "unknown" -o -z "$vtimgname" ]; then
vterr "image file path not found"
exit 0
fi
if echo "$vtdiskname" | $EGREP -q "nvme|mmc|nbd"; then
vtdatapart=${vtdiskname}p1
else
vtdatapart=${vtdiskname}1
fi
# rw: the holo hook mounts the image rootfs rw
mkdir -p /run/ventoy-media
if mount "$vtdatapart" /run/ventoy-media >>$VTLOG 2>&1; then
vtlog "mounted $vtdatapart at /run/ventoy-media OK"
mount | grep ventoy >>$VTLOG 2>&1
else
vtlog "mounted $vtdatapart at /run/ventoy-media failed"
exit 0
fi
vtimgfile="/run/ventoy-media${vtimgname}"
if ! [ -f "$vtimgfile" ]; then
vterr "$vtimgfile not found on data partition"
umount /run/ventoy-media >>$VTLOG 2>&1
exit 0
fi
vtloopdev=$(losetup -f)
if [ -z "$vtloopdev" ]; then
vterr "no free loop device"
exit 0
fi
if ! losetup -P "$vtloopdev" "$vtimgfile" >>$VTLOG 2>&1; then
vterr "losetup $vtloopdev $vtimgfile failed"
exit 0
fi
vtlog "attached $vtimgfile to $vtloopdev"
vtloop=0
while ! [ -e "${vtloopdev}p2" ]; do
let vtloop=vtloop+1
if [ $vtloop -gt 10 ]; then
break
fi
$SLEEP 0.3
done
# exact /dev path avoids PARTLABEL/LABEL/UUID collisions with an installed SteamOS
if [ -e "${vtloopdev}p2" ]; then
ln -s "${vtloopdev}p2" /dev/steamos-media-efi
vtlog "/dev/steamos-media-efi -> ${vtloopdev}p2"
else
vterr "${vtloopdev}p2 not created, partition scan failed"
fi
@@ -0,0 +1,33 @@
#!/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
# inject the disk hook before the run_hook phase of the stock mkinitcpio /init
# if $GREP -q "run_hookfunctions 'run_hook' 'hook'" /init; then
# echo "insert ventoy-disk.sh before run_hook" >> $VTLOG
# $SED "/run_hookfunctions 'run_hook' 'hook'/i\\$BUSYBOX_PATH/sh $VTOY_PATH/loop/steamos/ventoy-disk-new.sh" -i /init
# else
# echo "run_hook anchor not found in /init" >> $VTLOG
# fi
$SED "s/udev /udev ventoy /g" -i /config
cp -a $VTOY_PATH/loop/steamos/ventoy.hook /hooks/ventoy
+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/ash
run_earlyhook() {
:
}
run_hook() {
msg ":: Ventoy hook..."
/ventoy/busybox/sh /ventoy/loop/steamos/ventoy-disk.sh
}
run_cleanuphook() {
:
}
# vim: set ft=sh ts=4 sw=4 et:
+17 -3
View File
@@ -100,7 +100,11 @@ ventoy_get_os_type() {
echo 'rhel7'; return
elif $GREP -q 'euleros' /proc/version; then
echo 'rhel7'; return
if [ -d /usr/Euler/project/init ]; then
echo 'euleros'; return
else
echo 'rhel7'; return
fi
# SUSE
elif $GREP -q 'SUSE' /proc/version; then
@@ -402,7 +406,10 @@ ventoy_get_os_type() {
fi
fi
if [ -f /scripts/casper ]; then
echo "debian"; return
fi
echo "default"
}
@@ -411,6 +418,9 @@ echo "OS=###${VTOS}###" >>$VTLOG
if [ -e "$VTOY_PATH/hook/$VTOS/ventoy-hook.sh" ]; then
$BUSYBOX_PATH/sh "$VTOY_PATH/hook/$VTOS/ventoy-hook.sh"
fi
if [ -e "$VTOY_PATH/hook/$VTOS/ventoy-uauto-hook.sh" ]; then
$BUSYBOX_PATH/sh "$VTOY_PATH/hook/$VTOS/ventoy-uauto-hook.sh"
fi
@@ -436,7 +446,11 @@ fi
# #
####################################################################
if [ -f "/live_injection_7ed136ec_7a61_4b54_adc3_ae494d5106ea/hook.sh" ]; then
$BUSYBOX_PATH/sh "/live_injection_7ed136ec_7a61_4b54_adc3_ae494d5106ea/hook.sh" $VTOS
echo "==== Begin Call live injection hook.sh $VTOS" >> $VTLOG
$BUSYBOX_PATH/sh "/live_injection_7ed136ec_7a61_4b54_adc3_ae494d5106ea/hook.sh" $VTOS >>$VTLOG 2>&1
echo "==== Finish Call live injection hook.sh $VTOS" >> $VTLOG
else
echo "No live injection" >> $VTLOG
fi
+1 -1
View File
@@ -43,7 +43,7 @@ done
# #
####################################################################
$BUSYBOX_PATH/mkdir -p /ventoy/modules
$BUSYBOX_PATH/ls -1a / | $EGREP '\.ko$|\.ko.[gx]z$' | while read vtline; do
$BUSYBOX_PATH/ls -1a / | $EGREP '\.ko$|\.ko.[gx]z$|\.ko.zst$' | while read vtline; do
if [ "${vtline:0:1}" = "." ]; then
$BUSYBOX_PATH/mv /${vtline} /ventoy/modules/${vtline:1}
else
+1 -10
View File
@@ -1,7 +1,5 @@
#!/bin/sh
OLDDIR=$(pwd)
if ! [ -f ./tool/ventoy_lib.sh ]; then
if [ -f ${0%Ventoy2Disk.sh}/tool/ventoy_lib.sh ]; then
cd ${0%Ventoy2Disk.sh}
@@ -21,7 +19,7 @@ elif uname -m | grep -E -q 'mips64'; then
else
export TOOLDIR=i386
fi
export PATH="$OLDDIR/tool/$TOOLDIR:$PATH"
export PATH="$(pwd)/tool/$TOOLDIR:$PATH"
echo ''
@@ -88,10 +86,3 @@ if [ -f /bin/bash ]; then
else
ash ./tool/VentoyWorker.sh $*
fi
if [ -n "$OLDDIR" ]; then
CURDIR=$(pwd)
if [ "$CURDIR" != "$OLDDIR" ]; then
cd "$OLDDIR"
fi
fi
+74 -25
View File
@@ -34,20 +34,6 @@ function ventoy_debug_pause {
}
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
@@ -64,6 +50,13 @@ function ventoy_gui_console {
fi
}
function ventoy_cfg_theme_lock {
vt_timeout_lock $1
vt_theme_lock $1
terminal_lock $1
lockfont $1
}
function ventoy_acpi_param {
if [ "$VTOY_PARAM_NO_ACPI" != "1" ]; then
vt_acpi_param "$1" "$2"
@@ -304,7 +297,8 @@ function distro_specify_initrd_file {
vt_linux_specify_initrd_file /boot/isolinux/initramfs_data64.cpio.gz
elif [ -f (loop)/boot/initrd.img ]; then
vt_linux_specify_initrd_file /boot/initrd.img
elif [ -f (loop)/boot/grmlfullamd64/initrd.img ]; then
vt_linux_specify_initrd_file /boot/grmlfullamd64/initrd.img
fi
if [ -f (loop)/isolinux/initrd.gz ]; then
@@ -427,7 +421,9 @@ function distro_specify_initrd_file_phase2 {
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
vt_linux_specify_initrd_file /boot/isolinux/initrd.gz
elif [ -f (loop)/tiny/initrd ]; then
vt_linux_specify_initrd_file /tiny/initrd
elif vt_str_begin "$vt_volume_id" "AERYNOS"; then
vt_vcfg_pre_proc
@@ -503,20 +499,20 @@ function ventoy_freebsd_proc {
ventoy_get_truenas_ver "$1" "${chosen_path}"
elif vt_strstr "$vt_volume_id" "FURYBSD"; then
ventoy_get_furybsd_ver "$1" "${chosen_path}"
elif regexp --set 1:vtBsdVerNum "^(15|14|13|12|11|10|9)_[0-9]" "$vt_volume_id"; then
elif regexp --set 1:vtBsdVerNum "^(1[0-9]|9)_[0-9]" "$vt_volume_id"; then
set vt_freebsd_ver=${vtBsdVerNum}.x
elif [ -d (loop)/usr/midnightbsd-dist ]; then
ventoy_get_midnightbsd_ver "$1" "${chosen_path}"
set vtFreeBsdDistro=MidnightBSD
elif [ -e (loop)/bin/freebsd-version ]; then
vt_unix_parse_freebsd_ver (loop)/bin/freebsd-version vt_userland_ver
if regexp --set 1:vtBsdVerNum "\"(15|14|13|12|11|10|9)\.[0-9]-" "$vt_userland_ver"; then
if regexp --set 1:vtBsdVerNum "\"(1[0-9]|9)\.[0-9]-" "$vt_userland_ver"; then
set vt_freebsd_ver=${vtBsdVerNum}.x
fi
fi
elif [ -e (loop)/README.TXT ]; then
vt_1st_line (loop)/README.TXT vt_freebsd_line1
if regexp --set 1:vtBsdVerNum "FreeBSD (15|14|13|12|11|10|9)\.[0-9]-" "$vt_freebsd_line1"; then
set vt_freebsd_ver=${vtBsdVerNum}.x
if regexp --set 1:vtBsdVerNum "FreeBSD (1[0-9]|9)\.[0-9]-" "$vt_freebsd_line1"; then
set vt_freebsd_ver=${vtBsdVerNum}.x
fi
elif vt_strstr "${chosen_path}" "MidnightBSD"; then
set vt_freebsd_ver=9.x
@@ -545,7 +541,7 @@ function ventoy_freebsd_proc {
fi
if [ "$vt_freebsd_ver" = "xx" ]; then
set vt_freebsd_ver=14.x
set vt_freebsd_ver=15.x
fi
fi
@@ -662,7 +658,6 @@ function uefi_windows_menu_func {
if [ -n "$vtoy_chain_mem_addr" ]; then
ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
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
@@ -747,6 +742,8 @@ function uefi_linux_menu_func {
vt_add_replace_file $vtindex "arch\\boot\\x86_64\\initramfs-linux.img"
elif [ -f (loop)/boot/initramfs_x86_64.img ]; then
vt_add_replace_file $vtindex "boot\\initramfs_x86_64.img"
elif [ -f (loop)/arch/boot/x86_64/initramfs-linux-aegis-offensive.img ]; then
vt_add_replace_file $vtindex "arch\\boot\\x86_64\\initramfs-linux-aegis-offensive.img"
fi
elif [ -d (loop)/blackarch ]; then
if [ -f (loop)/blackarch/boot/x86_64/archiso.img ]; then
@@ -873,6 +870,9 @@ function uefi_linux_menu_func {
elif [ -f (loop)/boot/syslinux/porteus.cfg ]; then
syslinux_configfile (loop)/boot/syslinux/porteus.cfg
set vtback_cfg_find=1
elif [ -f (loop)/syslinux.cfg ]; then
syslinux_configfile (loop)/syslinux.cfg
set vtback_cfg_find=1
fi
fi
@@ -1327,6 +1327,9 @@ function legacy_linux_menu_func {
elif [ -f (loop)/boot/syslinux/porteus.cfg ]; then
syslinux_configfile (loop)/boot/syslinux/porteus.cfg
set vtback_cfg_find=1
elif [ -f (loop)/syslinux.cfg ]; then
syslinux_configfile (loop)/syslinux.cfg
set vtback_cfg_find=1
fi
fi
@@ -1457,7 +1460,10 @@ function ventoy_iso_busybox_ver {
set ventoy_busybox_ver=64
elif vt_strstr "$vt_volume_id" "x86_64"; then
set ventoy_busybox_ver=64
elif vt_istrstr "${vt_chosen_path}" "x86_64"; then
set ventoy_busybox_ver=64
elif vt_istrstr "${vt_chosen_path}" "amd64"; then
set ventoy_busybox_ver=64
fi
fi
}
@@ -1998,6 +2004,47 @@ function ventoy_img_freedombox {
vt_unset_boot_opt
}
function steamenv_init {
echo "dummy steamenv_boot"
}
function steamenv_boot {
if [ -n "${vtdebug_flag}" ]; then
$1 $2 loglevel=7
else
$@
fi
}
function ventoy_img_steamos {
vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
vt_get_lib_module_ver (vtimghd,3) /lib/modules/ vt_module_ver
if [ -n "$vt_module_ver" ]; then
vt_img_extra_initrd_append (vtimghd,3)/lib/modules/$vt_module_ver/kernel/drivers/md/dm-mod
fi
ventoy_debug_pause
#boot image file
vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=steamos steamos.efi=/dev/steamos-media-efi
vt_img_hook_root
set theme=$vtback_theme
ventoy_gui_console
ventoy_cfg_theme_lock 1
configfile (vtimghd,2)/EFI/steamos/grub.cfg
ventoy_cfg_theme_lock 0
vt_img_unhook_root
vt_unset_boot_opt
}
function ventoy_img_paldo {
vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
@@ -2377,6 +2424,8 @@ function img_common_menuentry {
ventoy_img_recalbox
elif [ "$vtImgHd1Label" = "ESYSRESCUE" ]; then
ventoy_img_esysrescue
elif [ -e (vtimghd,1)/SteamOS ]; then
ventoy_img_steamos
elif [ -e (vtimghd,1)/easy.sfs ]; then
ventoy_img_easyos
elif [ -d (vtimghd,2)/easyos ]; then
@@ -2449,7 +2498,7 @@ function mimg_common_menuentry {
#############################################################
#############################################################
set VENTOY_VERSION="1.1.15"
set VENTOY_VERSION="1.1.18"
#ACPI not compatible with Window7/8, so disable by default
set VTOY_PARAM_NO_ACPI=1
+10 -10
View File
@@ -1,18 +1,18 @@
L - Seleccionar lenguaje
L - Seleccionar idioma
F1 - Mostrar información de ayuda
F2 - Navegar y arranca archivos en el disco local
F3 - Cambiar modo de menú entre vista de árbol <-> vista de lista
F4 - arrancar Windows/Linux en el disco local
F2 - Navegar y arrancar archivos en el disco local
F3 - Cambiar modo de menú entre Vista de árbol <-> Vista de lista
F4 - Arrancar Windows/Linux en el disco local
F5 - Utilidades
F6 - Cargar menú de Grub2 personalizado
F7 - Cambiar entre modo grafico <-> modo texto
F7 - Cambiar entre Modo GUI <-> Modo texto
m/Ctrl+m - Suma de comprobación de archivos de imagen (md5/sha1/sha256/sha512)
d/Ctrl+d - Modo Memdisk (solo para WinPE/LiveCD ISO/IMG pequeños)
w/Ctrl+w - Modo WIMBOOT (Solo para archivos Windows/WinPE ISO)
r/Ctrl+r - Modo Grub2 (Solo para algunas distribuciones de Linux)
i/Ctrl+i - Modo compatible (Solo para depuración)
u/Ctrl+u - Cargar controlador ISO EFI (Solo para depuración, no se puede usar oficialmente)
d/Ctrl+d - Modo Memdisk (Sólo para WinPE/LiveCD ISO/IMG pequeños)
w/Ctrl+w - Modo WIMBOOT (Sólo para archivos Windows/WinPE ISO)
r/Ctrl+r - Modo Grub2 (Sólo para algunas distros de Linux)
i/Ctrl+i - Modo compatible (Sólo para depuración)
u/Ctrl+u - Cargar controlador ISO EFI (Sólo para depuración, uso no oficial)
+9 -9
View File
@@ -1,18 +1,18 @@
L - Seleção de Idiomas
F1 - Exibir informações de ajuda
L - Selecao de Idiomas
F1 - Exibir informacoes de ajuda
F2 - Explorar e inicializar os arquivos no disco local
F3 - Trocar o modo do menu entre Visualização em Árvore <-> Visualização em Lista
F3 - Trocar o modo do menu entre Visualizacao em Arvore <-> Visualizacao em Lista
F4 - Inicializar o Windows/Linux no disco local
F5 - Utilitários
F5 - Utilitarios
F6 - Carregar o Menu Personalizado do Grub2
F7 - Trocar entre o Modo GUI <-> Modo TEXTO
m/Ctrl+m - Checksum dos arquivos de imagem (md5/sha1/sha256/sha512)
d/Ctrl+d - Modo Memdisk (Só pros pequenos WinPE/LiveCD ISO/IMG)
w/Ctrl+w - Modo WIMBOOT (Só pra arquivos ISO do Windows/WinPE)
r/Ctrl+r - Modo Grub2 (Só pra algumas distros do Linux)
i/Ctrl+i - Modo Compatível (Só pra debugging)
u/Ctrl+u - Carregar o driver EFI da ISO (Só pra debugging, não pode ser usado oficialmente)
d/Ctrl+d - Modo Memdisk (So pros pequenos WinPE/LiveCD ISO/IMG)
w/Ctrl+w - Modo WIMBOOT (So pra arquivos ISO do Windows/WinPE)
r/Ctrl+r - Modo Grub2 (So pra algumas distros do Linux)
i/Ctrl+i - Modo Compativel (So pra debugging)
u/Ctrl+u - Carregar o driver EFI da ISO (So pra debugging, nao pode ser usado oficialmente)
+6 -3
View File
@@ -24,17 +24,20 @@ menuentry "$VTLANG_HWINFO" --class=debug_hwinfo --class=F5tool {
set bios_size="-";
smbios -t 0 -b 0x09 --set=bios_size;
echo "Platform $grub_cpu-$grub_platform"
if [ "$grub_platform" != "pc" ]; then
echo "UEFI Version $grub_uefi_version"
echo "PI Version $grub_pi_version"
if vt_check_secureboot_var; then
echo "Secure Boot Enabled"
else
echo "Secure Boot Disabled"
fi
fi
vt_sbinfo
fi
echo ""
echo "CPU Model $cpu_brand"
echo "Physical RAM $grub_total_ram MB"
+35 -35
View File
@@ -1,10 +1,10 @@
{
"VTLANG_LANGUAGE_NAME": "Spanish (Español)",
"VTLANG_STR_HOTKEY_LIST": "L:Lenguaje F1:Ayuda F2:Navegar F3:Vista de lista F4:Arranque local F5:Herramientas F6:Extensión de menú",
"VTLANG_STR_HOTKEY_TREE": "L:Lenguaje F1:Ayuda F2:Navegar F3:Vista de árbol F4:Arranque local F5:Herramientas F6:Extensión de menú",
"VTLANG_RETURN_PREVIOUS": "Regresar al menú previo [Esc]",
"VTLANG_RETURN_PRV_NOESC": "Regresar al menú previo",
"VTLANG_STR_HOTKEY_LIST": "L:Idioma F1:Ayuda F2:Navegar F3:Vista de lista F4:Arranque local F5:Herramientas F6:Menú ext.",
"VTLANG_STR_HOTKEY_TREE": "L:Idioma F1:Ayuda F2:Navegar F3:Vista de árbol F4:Arranque local F5:Herramientas F6:Menú ext.",
"VTLANG_RETURN_PREVIOUS": "Regresar al menú anterior [Esc]",
"VTLANG_RETURN_PRV_NOESC": "Regresar al menú anterior",
"VTLANG_MENU_LANG": "Selección de idioma del menú",
@@ -28,13 +28,13 @@
"VTLANG_CHKSUM_SHA256_CALC_CHK": "Calcular y comprobar sha256sum",
"VTLANG_CHKSUM_SHA512_CALC_CHK": "Calcular y comprobar sha512sum",
"VTLANG_POWER": "Poder",
"VTLANG_POWER": "Energía",
"VTLANG_POWER_REBOOT": "Reiniciar",
"VTLANG_POWER_HALT": "Detener",
"VTLANG_POWER_BOOT_EFIFW": "Reiniciar a configuración EFI",
"VTLANG_POWER_HALT": "Apagar",
"VTLANG_POWER_BOOT_EFIFW": "Reiniciar a la configuración EFI",
"VTLANG_KEYBRD_LAYOUT": "Distribuciones de teclado",
"VTLANG_HWINFO": "Información de Hardware",
"VTLANG_HWINFO": "Información de hardware",
"VTLANG_RESOLUTION_CFG": "Configuración de resolución",
"VTLANG_SCREEN_MODE": "Modo de visualización de pantalla",
@@ -45,23 +45,23 @@
"VTLANG_UEFI_UTIL": "Utilidades UEFI de Ventoy",
"VTLANG_UTIL_SHOW_EFI_DRV": "Mostrar controladores EFI",
"VTLANG_UTIL_FIX_BLINIT_FAIL": "Reparar la falla de BinitializeLibrary de Windows",
"VTLANG_UTIL_FIX_BLINIT_FAIL": "Reparar error BlinitializeLibrary de Windows",
"VTLANG_JSON_CHK_JSON": "Comprobar configuración de complemento de json (ventoy.json)",
"VTLANG_JSON_CHK_CONTROL": "Comprobar configuración de complemento de control global",
"VTLANG_JSON_CHK_THEME": "Comprobar configuración de complemento de tema",
"VTLANG_JSON_CHK_AUTOINS": "Comprobar configuración de complemento de auto instalación",
"VTLANG_JSON_CHK_PERSIST": "Comprobar configuración de complemento de persistencia",
"VTLANG_JSON_CHK_MENU_ALIAS": "Comprobar configuración de complemento de alias de menú",
"VTLANG_JSON_CHK_MENU_TIP": "Comprobar configuración de complemento de consejo de menú",
"VTLANG_JSON_CHK_MENU_CLASS": "Comprobar configuración de complemento de clase de menú",
"VTLANG_JSON_CHK_INJECTION": "Comprobar configuración de complemento de inyección",
"VTLANG_JSON_CHK_AUTO_MEMDISK": "Comprobar configuración de complemento de auto memdisk",
"VTLANG_JSON_CHK_IMG_LIST": "Comprobar configuración de complemento de lista de imágenes",
"VTLANG_JSON_CHK_IMG_BLIST": "Comprobar configuración de complemento de lista negra de imágenes",
"VTLANG_JSON_CHK_CONF_REPLACE": "Comprobar configuración de complemento de reemplazo de configuración de arranque",
"VTLANG_JSON_CHK_DUD": "Comprobar configuración de complemento de dud",
"VTLANG_JSON_CHK_PASSWORD": "Comprobar configuración de complemento de contraseñas",
"VTLANG_JSON_CHK_JSON": "Comprobar configuración del complemento de json (ventoy.json)",
"VTLANG_JSON_CHK_CONTROL": "Comprobar configuración del complemento de control global",
"VTLANG_JSON_CHK_THEME": "Comprobar configuración del complemento de tema",
"VTLANG_JSON_CHK_AUTOINS": "Comprobar configuración del complemento de autoinstalación",
"VTLANG_JSON_CHK_PERSIST": "Comprobar configuración del complemento de persistencia",
"VTLANG_JSON_CHK_MENU_ALIAS": "Comprobar configuración del complemento de alias de menú",
"VTLANG_JSON_CHK_MENU_TIP": "Comprobar configuración del complemento de consejo de menú",
"VTLANG_JSON_CHK_MENU_CLASS": "Comprobar configuración del complemento de clases de menú",
"VTLANG_JSON_CHK_INJECTION": "Comprobar configuración del complemento de inyección",
"VTLANG_JSON_CHK_AUTO_MEMDISK": "Comprobar configuración del complemento auto memdisk",
"VTLANG_JSON_CHK_IMG_LIST": "Comprobar configuración del complemento de lista de imágenes",
"VTLANG_JSON_CHK_IMG_BLIST": "Comprobar configuración del complemento de lista negra de imágenes",
"VTLANG_JSON_CHK_CONF_REPLACE": "Comprobar configuración del complemento de reemplazo de configuración de arranque",
"VTLANG_JSON_CHK_DUD": "Comprobar configuración del complemento dud",
"VTLANG_JSON_CHK_PASSWORD": "Comprobar configuración del complemento de contraseñas",
"VTLANG_NORMAL_MODE": "Arrancar en modo normal",
"VTLANG_WIMBOOT_MODE": "Arrancar en modo wimboot",
@@ -71,7 +71,7 @@
"VTLANG_RET_TO_LISTVIEW": "Regresar a vista de lista",
"VTLANG_RET_TO_TREEVIEW": "regresar a vista de árbol",
"VTLANG_NO_AUTOINS_SCRIPT": "Arrancar sin plantilla de auto instalación",
"VTLANG_NO_AUTOINS_SCRIPT": "Arrancar sin plantilla de autoinstalación",
"VTLANG_AUTOINS_USE": "Arrancar con",
"VTLANG_NO_PERSIST": "Arrancar sin persistencia",
@@ -79,20 +79,20 @@
"VTLANG_BROWER_RETURN": "Regresar",
"VTLANG_ENTER_EXIT": "presiona tecla Entrar para salir",
"VTLANG_ENTER_REBOOT": "presiona tecla Entrar para reiniciar",
"VTLANG_ENTER_CONTINUE": "presiona tecla Entrar para continuar",
"VTLANG_ENTER_EXIT": "Presiona la tecla Entrar para salir",
"VTLANG_ENTER_REBOOT": "Presiona la tecla Entrar para reiniciar",
"VTLANG_ENTER_CONTINUE": "Presiona la tecla Entrar para continuar",
"VTLANG_CTRL_TEMP_SET": "Ajustes de control temporales",
"VTLANG_WIN11_BYPASS_CHECK": "Saltar comprobación de CPU/TPM/Arranque Seguro al instalar Windows 11",
"VTLANG_WIN11_BYPASS_NRO": "Saltar requerimiento de cuenta en linea al instalar Windows 11",
"VTLANG_WIN11_BYPASS_CHECK": "Omitir comprobación de CPU/TPM/SecureBoot al instalar Windows 11",
"VTLANG_WIN11_BYPASS_NRO": "Omitir requisito de cuenta en línea al instalar Windows 11",
"VTLANG_LINUX_REMOUNT": "Montar partición de Ventoy después de arrancar Linux",
"VTLANG_SECONDARY_BOOT_MENU": "Mostrar menú de arranque secundario",
"VTLANG_WIN_UEFI_RES_LOCK": "Lock the resolution when UEFI boot Windows/WinPE",
"VTLANG_UEFI_RES_LOCK_NONE": "None",
"VTLANG_UEFI_RES_LOCK_MAX": "Highest",
"VTLANG_UEFI_RES_LOCK_1024_768": "Fixed 1024 x 768",
"VTLANG_UEFI_RES_LOCK_BE1024_768": "At least 1024 x 768",
"VTLANG_WIN_UEFI_RES_LOCK": "Bloquear la resolución al arrancar Windows/WinPE en modo UEFI",
"VTLANG_UEFI_RES_LOCK_NONE": "Ninguno",
"VTLANG_UEFI_RES_LOCK_MAX": "La más alta",
"VTLANG_UEFI_RES_LOCK_1024_768": "Fija 1024 x 768",
"VTLANG_UEFI_RES_LOCK_BE1024_768": "Al menos 1024 x 768",
"MENU_STR_XXX": ""
+5 -5
View File
@@ -88,11 +88,11 @@
"VTLANG_WIN11_BYPASS_NRO": "Windows 11 설치 시 온라인 계정 요구 사항 무시",
"VTLANG_LINUX_REMOUNT": "Linux 부팅 후 Ventoy 파티션 마운트",
"VTLANG_SECONDARY_BOOT_MENU": "보조 부팅 메뉴 표시",
"VTLANG_WIN_UEFI_RES_LOCK": "Lock the resolution when UEFI boot Windows/WinPE",
"VTLANG_UEFI_RES_LOCK_NONE": "None",
"VTLANG_UEFI_RES_LOCK_MAX": "Highest",
"VTLANG_UEFI_RES_LOCK_1024_768": "Fixed 1024 x 768",
"VTLANG_UEFI_RES_LOCK_BE1024_768": "At least 1024 x 768",
"VTLANG_WIN_UEFI_RES_LOCK": "UEFI 부팅 시 Windows/WinPE 해상도 고정",
"VTLANG_UEFI_RES_LOCK_NONE": "고정 안 함",
"VTLANG_UEFI_RES_LOCK_MAX": "최고 해상도로 고정",
"VTLANG_UEFI_RES_LOCK_1024_768": "1024 x 768로 고정",
"VTLANG_UEFI_RES_LOCK_BE1024_768": "1024 x 768 이상으로 고정",
"MENU_STR_XXX": ""
+43 -44
View File
@@ -1,18 +1,18 @@
{
"VTLANG_LANGUAGE_NAME": "Brazilian Portuguese (Português Brasileiro)",
"VTLANG_LANGUAGE_NAME": "Brazilian Portuguese (Portugues Brasileiro)",
"VTLANG_STR_HOTKEY_LIST": "L:Idioma F1:Ajuda F2:Explorar F3:Visualização em Lista F4:Inicialização Local F5:Ferramentas F6:Sair",
"VTLANG_STR_HOTKEY_TREE": "L:Idioma F1:Ajuda F2:Explorar F3:Visualização em Árvore F4:Inicialização Local F5:Ferramentas F6:Sair",
"VTLANG_STR_HOTKEY_LIST": "L:Idioma F1:Ajuda F2:Explorar F3:Visualizacao em Lista F4:Inicializacao Local F5:Ferramentas F6:Sair",
"VTLANG_STR_HOTKEY_TREE": "L:Idioma F1:Ajuda F2:Explorar F3:Visualizacao em Arvore F4:Inicializacao Local F5:Ferramentas F6:Sair",
"VTLANG_RETURN_PREVIOUS": "Retornar ao menu anterior [Esc]",
"VTLANG_RETURN_PRV_NOESC": "Retornar ao menu anterior",
"VTLANG_MENU_LANG": "Menu de Seleção dos Idiomas",
"VTLANG_MENU_LANG": "Menu de Selecao dos Idiomas",
"VTLANG_LB_SBOOT_WINDOWS": "Procurar e iniciar o Windows",
"VTLANG_LB_SBOOT_G4D": "Procurar e iniciar o Grub4dos",
"VTLANG_LB_SBOOT_HDD1": "Iniciar o 1º disco local",
"VTLANG_LB_SBOOT_HDD2": "Iniciar o 2º disco local",
"VTLANG_LB_SBOOT_HDD3": "Iniciar o 3º disco local",
"VTLANG_LB_SBOOT_HDD1": "Iniciar o 1 disco local",
"VTLANG_LB_SBOOT_HDD2": "Iniciar o 2 disco local",
"VTLANG_LB_SBOOT_HDD3": "Iniciar o 3 disco local",
"VTLANG_LB_SBOOT_X64EFI": "Procurar e iniciar o BOOTX64.EFI",
"VTLANG_LB_SBOOT_IA32EFI": "Procurar e iniciar o BOOTIA32.EFI",
"VTLANG_LB_SBOOT_AA64EFI": "Procurar e iniciar o BOOTAA64.EFI",
@@ -31,50 +31,50 @@
"VTLANG_POWER": "Energia",
"VTLANG_POWER_REBOOT": "Reiniciar",
"VTLANG_POWER_HALT": "Desligar",
"VTLANG_POWER_BOOT_EFIFW": "Reiniciar com a configuração do EFI",
"VTLANG_POWER_BOOT_EFIFW": "Reiniciar com a configuracao do EFI",
"VTLANG_KEYBRD_LAYOUT": "Esquemas do Teclado",
"VTLANG_HWINFO": "Informações do Hardware",
"VTLANG_HWINFO": "Informacoes do Hardware",
"VTLANG_RESOLUTION_CFG": "Configuração da Resolução",
"VTLANG_SCREEN_MODE": "Modo de Exibição da Tela",
"VTLANG_SCREEN_TEXT_MODE": "Forçar o Modo Texto",
"VTLANG_SCREEN_GUI_MODE": "Forçar o Modo Gráfico",
"VTLANG_RESOLUTION_CFG": "Configuracao da Resolucao",
"VTLANG_SCREEN_MODE": "Modo de Exibicao da Tela",
"VTLANG_SCREEN_TEXT_MODE": "Forcar o Modo Texto",
"VTLANG_SCREEN_GUI_MODE": "Forcar o Modo Grafico",
"VTLANG_THEME_SELECT": "Seleção de Tema",
"VTLANG_THEME_SELECT": "Selecao de Tema",
"VTLANG_UEFI_UTIL": "Utilitários UEFI do Ventoy",
"VTLANG_UEFI_UTIL": "Utilitarios UEFI do Ventoy",
"VTLANG_UTIL_SHOW_EFI_DRV": "Mostrar os Drivers EFI",
"VTLANG_UTIL_FIX_BLINIT_FAIL": "Consertar a Falha BlinitializeLibrary do Windows",
"VTLANG_JSON_CHK_JSON": "Verificar a configuração do plugin json (ventoy.json)",
"VTLANG_JSON_CHK_CONTROL": "Verificar a configuração do plugin de controle global",
"VTLANG_JSON_CHK_THEME": "Verificar a configuração do plugin dos temas",
"VTLANG_JSON_CHK_AUTOINS": "Verificar a configuração do plugin de instalação automática",
"VTLANG_JSON_CHK_PERSIST": "Verificar a configuração do plugin de persistência",
"VTLANG_JSON_CHK_MENU_ALIAS": "Verificar a configuração do plugin do menu alias",
"VTLANG_JSON_CHK_MENU_TIP": "Verificar a configuração do plugin do menu das dicas",
"VTLANG_JSON_CHK_MENU_CLASS": "Verificar a configuração do plugin do menu classe",
"VTLANG_JSON_CHK_INJECTION": "Verificar a configuração do plugin de injeção",
"VTLANG_JSON_CHK_AUTO_MEMDISK": "Verificar a configuração do plugin automático do memdisk",
"VTLANG_JSON_CHK_IMG_LIST": "Verificar a configuração do plugin da lista de imagens",
"VTLANG_JSON_CHK_IMG_BLIST": "Verificar a configuração do plugin da lista negra de imagens",
"VTLANG_JSON_CHK_CONF_REPLACE": "Verificar a configuração do plugin de substituição da configuração de inicialização",
"VTLANG_JSON_CHK_DUD": "Verificar a configuração do plugin dud",
"VTLANG_JSON_CHK_PASSWORD": "Verificar a configuração do plugin das senhas",
"VTLANG_JSON_CHK_JSON": "Verificar a configuracao do plugin json (ventoy.json)",
"VTLANG_JSON_CHK_CONTROL": "Verificar a configuracao do plugin de controle global",
"VTLANG_JSON_CHK_THEME": "Verificar a configuracao do plugin dos temas",
"VTLANG_JSON_CHK_AUTOINS": "Verificar a configuracao do plugin de instalacao automatica",
"VTLANG_JSON_CHK_PERSIST": "Verificar a configuracao do plugin de persistencia",
"VTLANG_JSON_CHK_MENU_ALIAS": "Verificar a configuracao do plugin do menu alias",
"VTLANG_JSON_CHK_MENU_TIP": "Verificar a configuracao do plugin do menu das dicas",
"VTLANG_JSON_CHK_MENU_CLASS": "Verificar a configuracao do plugin do menu classe",
"VTLANG_JSON_CHK_INJECTION": "Verificar a configuracao do plugin de injecao",
"VTLANG_JSON_CHK_AUTO_MEMDISK": "Verificar a configuracao do plugin automatico do memdisk",
"VTLANG_JSON_CHK_IMG_LIST": "Verificar a configuracao do plugin da lista de imagens",
"VTLANG_JSON_CHK_IMG_BLIST": "Verificar a configuracao do plugin da lista negra de imagens",
"VTLANG_JSON_CHK_CONF_REPLACE": "Verificar a configuracao do plugin de substituicao da configuracao de inicializacao",
"VTLANG_JSON_CHK_DUD": "Verificar a configuracao do plugin dud",
"VTLANG_JSON_CHK_PASSWORD": "Verificar a configuracao do plugin das senhas",
"VTLANG_NORMAL_MODE": "Iniciar no modo normal",
"VTLANG_WIMBOOT_MODE": "Iniciar no modo wimboot",
"VTLANG_GRUB2_MODE": "Iniciar no modo grub2",
"VTLANG_MEMDISK_MODE": "Iniciar no modo memdisk",
"VTLANG_RET_TO_LISTVIEW": "Retornar pra Visualização em Lista",
"VTLANG_RET_TO_TREEVIEW": "Retornar para Visualização em Árvore",
"VTLANG_RET_TO_LISTVIEW": "Retornar pra Visualizacao em Lista",
"VTLANG_RET_TO_TREEVIEW": "Retornar para Visualizacao em Arvore",
"VTLANG_NO_AUTOINS_SCRIPT": "Iniciar sem modelo de instalação automática",
"VTLANG_NO_AUTOINS_SCRIPT": "Iniciar sem modelo de instalacao automatica",
"VTLANG_AUTOINS_USE": "Iniciar com",
"VTLANG_NO_PERSIST": "Iniciar sem persistência",
"VTLANG_NO_PERSIST": "Iniciar sem persistencia",
"VTLANG_PERSIST_USE": "Iniciar com",
"VTLANG_BROWER_RETURN": "Retornar",
@@ -83,17 +83,16 @@
"VTLANG_ENTER_REBOOT": "Pressione a tecla Enter pra reiniciar",
"VTLANG_ENTER_CONTINUE": "Pressione a tecla Enter pra continuar",
"VTLANG_CTRL_TEMP_SET": "Configurações do Controle Temporário",
"VTLANG_WIN11_BYPASS_CHECK": "Ignorar a verificação da CPU/TPM/SecureBoot quando instalar o Windows 11",
"VTLANG_CTRL_TEMP_SET": "Configuracoes do Controle Temporario",
"VTLANG_WIN11_BYPASS_CHECK": "Ignorar a verificacao da CPU/TPM/SecureBoot quando instalar o Windows 11",
"VTLANG_WIN11_BYPASS_NRO": "Ignorar o requerimento de conta online quanto instalar o Windows 11",
"VTLANG_LINUX_REMOUNT": "Montar a partição do Ventoy após iniciar o Linux",
"VTLANG_SECONDARY_BOOT_MENU": "Mostrar o menu secundário da inicialização",
"VTLANG_WIN_UEFI_RES_LOCK": "Lock the resolution when UEFI boot Windows/WinPE",
"VTLANG_UEFI_RES_LOCK_NONE": "None",
"VTLANG_UEFI_RES_LOCK_MAX": "Highest",
"VTLANG_UEFI_RES_LOCK_1024_768": "Fixed 1024 x 768",
"VTLANG_UEFI_RES_LOCK_BE1024_768": "At least 1024 x 768",
"VTLANG_LINUX_REMOUNT": "Montar a particao do Ventoy apos iniciar o Linux",
"VTLANG_SECONDARY_BOOT_MENU": "Mostrar o menu secundario da inicializacao",
"VTLANG_WIN_UEFI_RES_LOCK": "Bloquear a resolucao ao iniciar o Windows/WinPE via UEFI",
"VTLANG_UEFI_RES_LOCK_NONE": "Nenhuma",
"VTLANG_UEFI_RES_LOCK_MAX": "Mais alta",
"VTLANG_UEFI_RES_LOCK_1024_768": "Fixa em 1024 x 768",
"VTLANG_UEFI_RES_LOCK_BE1024_768": "No minimo 1024 x 768",
"MENU_STR_XXX": ""
}
+1 -1
View File
@@ -186,7 +186,7 @@ if [ "$MODE" = "install" -a -z "$NONDESTRUCTIVE" ]; then
else
if parted -v > /dev/null 2>&1; then
PARTTOOL='parted'
elif fdisk -v >/dev/null 2>&1; then
elif command -v fdisk > /dev/null 2>&1; then
PARTTOOL='fdisk'
else
vterr "Both parted and fdisk are not found in the system, Ventoy can't create new partitions."
+3 -3
View File
@@ -14,8 +14,8 @@ if dmsetup -h > /dev/null 2>&1; then
for t in *; do
if grep -q "^${VPART_MAJOR_MINOR}$" $t/dev; then
VPART=$t
echo 0 $(cat /sys/class/block/$VPART/size) linear /dev/$VPART 0 | dmsetup create $VPART
dmsetup mknodes "$VPART" > /dev/null 2>&1
echo 0 $(cat /sys/class/block/$VPART/size) linear /dev/$VPART 0 | dmsetup create VentoyPart
dmsetup mknodes "VentoyPart" > /dev/null 2>&1
break
fi
done
@@ -30,7 +30,7 @@ if dmsetup -h > /dev/null 2>&1; then
udevadm trigger --type=devices --action=add > /dev/null 2>&1
udevadm settle > /dev/null 2>&1
fi
echo "Create /dev/mapper/$VPART success"
echo "Create /dev/mapper/VentoyPart success"
fi
else
echo "dmsetup program not avaliable"
+18 -7
View File
@@ -12,7 +12,6 @@ if [ "$VENTOY_CERT_PASS" = "YES" ]; then
fi
fi
SBAT_VER=1
sign_efi() {
efi=$1
@@ -32,10 +31,6 @@ sign_efi() {
mv ${efi}.unxz ${efi}
fi
sbstr=$(printf "%08x" $SBAT_VER)
echo -en "\x8a\x06\x55\xf7\x4f\xe0\x2b\x45\x9d\x6d\x7c\x55\x96\xb3\xc0\x7d\x${sbstr:6:2}\x${sbstr:4:2}\x${sbstr:2:2}\x${sbstr:0:2}" | \
dd bs=1 count=20 of=${efi} seek=40 conv=notrunc status=none
rm -f "${efi}.signed"
if [ "$VENTOY_CERT_PASS" = "YES" ]; then
expect -f ./sign_with_pass.exp "$KEY_PASS" "$VENTOY_CERT_KEY" "$VENTOY_CERT_PEM" "${efi}" "${efi}.signed" >/dev/null 2>&1
@@ -52,7 +47,7 @@ sign_efi() {
mv "${efi}.signed" "$efi"
fi
else
echo "### %-64s failed\n" "$efi"
printf "### %-64s failed\n" "$efi"
exit 1
fi
@@ -191,7 +186,6 @@ cp -a ./tool/create_ventoy_iso_part_dm.sh $tmpmnt/tool/
rm -f $tmpmnt/grub/i386-pc/*.img
sign_efi $tmpmnt/EFI/BOOT/fbx64.efi
sign_efi $tmpmnt/EFI/BOOT/fbia32.efi
sign_efi $tmpmnt/EFI/BOOT/fbaa64.efi
sign_efi $tmpmnt/EFI/BOOT/grubx64_real.efi
@@ -211,6 +205,23 @@ sign_efi $tmpmnt/ventoy/vtoyutil_aa64.efi
sign_efi $tmpmnt/ventoy/wimboot.i386.efi.xz
sign_efi $tmpmnt/ventoy/wimboot.x86_64.xz
#inject Ventoy Grub sign sha256 value into VtoyShim
grub_sha256=$(sha256sum $tmpmnt/EFI/BOOT/grubx64_real.efi | awk '{print $1}')
magic_cnt=$(hexdump -C $tmpmnt/EFI/BOOT/fbx64.efi | grep '26 26 26 26 26 26 26 26' | wc -l)
if [ $magic_cnt -ne 1 ]; then
echo "hash magic duplicate"
exit 1
fi
magic_off_hex=$(hexdump -C $tmpmnt/EFI/BOOT/fbx64.efi | grep '26 26 26 26 26 26 26 26' | awk '{print $1}')
magic_off=$(printf '%u' "0x${magic_off_hex}")
echo_cmd=$(echo $grub_sha256 | sed 's/\(..\)/\\x\1/g')
echo Ventoy Grub hash $grub_sha256
echo -en "$echo_cmd" | dd bs=1 count=32 of=$tmpmnt/EFI/BOOT/fbx64.efi seek=$magic_off conv=notrunc status=none
sign_efi $tmpmnt/EFI/BOOT/fbx64.efi
umount $tmpmnt && rm -rf $tmpmnt
+36 -36
View File
@@ -198,13 +198,13 @@
"name":"Korean (한국어)",
"FontFamily":"Courier New",
"FontSize":16,
"Author":"VenusGirl",
"Author":"VenusGirl, HYB1022",
"STR_ERROR":"오류",
"STR_WARNING":"경고",
"STR_INFO":"정보",
"STR_INCORRECT_DIR":"올바른 디렉터리에서 실행하십시오!",
"STR_INCORRECT_TREE_DIR":"여기서 프로그램 (INSTALL 디렉터리)을 실행하지 말고 설치 패키지를 다운로드하여 압축을 푼 후 그곳에서 실행해 주십시오.",
"STR_INCORRECT_DIR":"올바른 파일 경로에서 실행하십시오!",
"STR_INCORRECT_TREE_DIR":"여기(INSTALL 경로)서 프로그램을 실행하지 말고 설치 패키지를 다운로드하여 압축을 푼 후 그곳에서 실행해 주십시오.",
"STR_DEVICE":"장치",
"STR_LOCAL_VER":"패키지의 Ventoy 버전",
"STR_DISK_VER":"장치 내부의 Ventoy 버전",
@@ -216,10 +216,10 @@
"STR_INSTALL_TIP2":"디스크가 포맷되고 모든 데이터가 손실됩니다.#@계속하시겠습니까? (다시 확인)",
"STR_INSTALL_SUCCESS":"축하합니다!#@Ventoy가 장치에 성공적으로 설치되었습니다.",
"STR_INSTALL_FAILED":"설치 중 오류가 발생했습니다. USB를 다시 삽입하고 다시 시도할 수 있습니다. 자세한 내용은 log.txt를 확인하십시오.",
"STR_UPDATE_SUCCESS":"축하합니다!#@Ventoy가 장치에 성공적으로 업데이트되었습니다.",
"STR_UPDATE_SUCCESS":"축하합니다! 장치에 설치된#@Ventoy가 성공적으로 업데이트되었습니다.",
"STR_UPDATE_FAILED":"업데이트 중에 오류가 발생했습니다. USB를 다시 삽입하고 다시 시도할 수 있습니다. 자세한 내용은 log.txt를 확인하십시오.",
"STR_WAIT_PROCESS":"현재 작업이 실행 중입니다. 기다려 주십시오...",
"STR_MENU_OPTION":"옵션",
"STR_MENU_OPTION":"설정",
"STR_MENU_SECURE_BOOT":"보안 부트 (Secure Boot) 지원",
"STR_MENU_PART_CFG":"파티션 구성",
"STR_BTN_OK":"확인",
@@ -1172,13 +1172,13 @@
"name":"Spanish (Latinoamérica)",
"FontFamily":"Courier New",
"FontSize":16,
"Author":"MELERIX",
"Author":"MELERIX, independent-arg",
"STR_ERROR":"Error",
"STR_WARNING":"Advertencia",
"STR_INFO":"Información",
"STR_INCORRECT_DIR":"¡Por favor, ejecuta bajo el directorio correcto!",
"STR_INCORRECT_TREE_DIR":"No me ejecutes aquí, por favor descarga el paquete de instalación lanzado, y ejecútalo allí.",
"STR_INCORRECT_DIR":"¡Por favor, ejecuta el programa bajo el directorio correcto!",
"STR_INCORRECT_TREE_DIR":"No me ejecutes aquí. Por favor descarga el paquete de instalación oficial y ejecútalo desde allí.",
"STR_DEVICE":"Dispositivo",
"STR_LOCAL_VER":"Ventoy En Paquete",
"STR_DISK_VER":"Ventoy En Dispositivo",
@@ -1189,47 +1189,47 @@
"STR_INSTALL_TIP":"El dispositivo será formateado y todos los datos se perderán.#@¿Continuar?",
"STR_INSTALL_TIP2":"El dispositivo será formateado y todos los datos se perderán.#@¿Continuar? (Doble Comprobación)",
"STR_INSTALL_SUCCESS":"¡Felicitaciones!#@Ventoy ha sido instalado exitosamente en el dispositivo.",
"STR_INSTALL_FAILED":"Ocurrió un error durante la instalación. Puedes reinsertar el dispositivo USB e intentar de nuevo. Comprueba log.txt para detalles. Si siempre falla, consulta las PF en el sitio web oficial.",
"STR_INSTALL_FAILED":"Ocurrió un error durante la instalación. Puedes reinsertar el dispositivo USB e intentar de nuevo. Comprueba log.txt para más detalles. Si siempre falla, consulta las preguntas frecuentes (FAQ) en el sitio web oficial.",
"STR_UPDATE_SUCCESS":"¡Felicitaciones!#@Ventoy ha sido actualizado exitosamente en el dispositivo.",
"STR_UPDATE_FAILED":"Ocurrió un error durante la actualización. Puedes reinsertar el dispositivo USB e intentar de nuevo. Comprueba log.txt para detalles. Si siempre falla, consulta las PF en el sitio web oficial.",
"STR_WAIT_PROCESS":"Un hilo está ejecutándose, por favor espera...",
"STR_UPDATE_FAILED":"Ocurrió un error durante la actualización. Puedes reinsertar el dispositivo USB e intentar de nuevo. Comprueba log.txt para más detalles. Si siempre falla, consulta las preguntas frecuentes (FAQ) en el sitio web oficial.",
"STR_WAIT_PROCESS":"Un hilo del sistema está ejecutándose, por favor espera...",
"STR_MENU_OPTION":"Opción",
"STR_MENU_SECURE_BOOT":"Soporte De Arranque Seguro",
"STR_MENU_PART_CFG":"Configuración De Partición",
"STR_MENU_SECURE_BOOT":"Soporte de arranque seguro",
"STR_MENU_PART_CFG":"Configuración de partición",
"STR_BTN_OK":"Aceptar",
"STR_BTN_CANCEL":"Cancelar",
"STR_PRESERVE_SPACE":"Preservar algo de espacio al final del dispositivo",
"STR_SPACE_VAL_INVALID":"Valor inválido para espacio reservado",
"STR_SPACE_VAL_INVALID":"Valor inválido para el espacio reservado",
"STR_MENU_CLEAR":"Limpiar Ventoy",
"STR_CLEAR_SUCCESS":"Ventoy ha sido removido exitosamente desde el dispositivo.",
"STR_CLEAR_FAILED":"Ocurrió un error al remover Ventoy del dispositivo. Puedes reinsertar el dispositivo USB e intentar de nuevo. Comprueba log.txt para detalles.",
"STR_MENU_PART_STYLE":"Estilo De Partición",
"STR_DISK_2TB_MBR_ERROR":"Por favor selecciona GPT para dispositivos sobre 2TB",
"STR_SHOW_ALL_DEV":"Mostrar Todos Los Dispositivos",
"STR_PART_ALIGN_4KB":"Alinear particiones con 4KB",
"STR_CLEAR_SUCCESS":"Ventoy ha sido eliminado exitosamente del dispositivo.",
"STR_CLEAR_FAILED":"Ocurrió un error al eliminar Ventoy del dispositivo. Puedes reinsertar el dispositivo USB e intentar de nuevo. Comprueba log.txt para más detalles.",
"STR_MENU_PART_STYLE":"Estilo de partición",
"STR_DISK_2TB_MBR_ERROR":"Por favor selecciona GPT para dispositivos de más de 2TB",
"STR_SHOW_ALL_DEV":"Mostrar todos los dispositivos",
"STR_PART_ALIGN_4KB":"Alinear particiones a 4KB",
"STR_WEB_COMMUNICATION_ERR":"Error de comunicación:",
"STR_WEB_REMOTE_ABNORMAL":"Error de comunicación: anormal remoto",
"STR_WEB_REQUEST_TIMEOUT":"Error de comunicación: Tiempo de espera agotado",
"STR_WEB_SERVICE_UNAVAILABLE":"Error de comunicación: Servicio No Disponible",
"STR_WEB_REMOTE_ABNORMAL":"Error de comunicación: anomalía remoto",
"STR_WEB_REQUEST_TIMEOUT":"Error de comunicación: tiempo de espera agotado",
"STR_WEB_SERVICE_UNAVAILABLE":"Error de comunicación: servicio no disponible",
"STR_WEB_TOKEN_MISMATCH":" Estado del daemon actualizado, por favor reintenta más tarde.",
"STR_WEB_SERVICE_BUSY":" El servicio está ocupado, por favor reintenta más tarde.",
"STR_MENU_VTSI_CREATE":"Generar Archivo VTSI",
"STR_VTSI_CREATE_TIP":"Esta vez no se escribirá al dispositivo, pero solo generará un archivo VTSI#@¿Continuar?",
"STR_MENU_VTSI_CREATE":"Generar archivo VTSI",
"STR_VTSI_CREATE_TIP":"Esta acción no escribirá en el dispositivo, sólo generará un archivo VTSI.#@¿Continuar?",
"STR_VTSI_CREATE_SUCCESS":"¡Archivo VTSI creado exitosamente!#@Puedes usar Rufus(3.15+) para escribirlo al dispositivo a fin de completar la instalación de Ventoy.",
"STR_VTSI_CREATE_FAILED":"Fallo en el archivo VTSI creado.",
"STR_VTSI_CREATE_FAILED":"Error al crear el archivo VTSI.",
"STR_MENU_PART_RESIZE":"Instalación no destructiva",
"STR_PART_RESIZE_TIP":"Ventoy intentará una instalación no destructiva si es posible. #@¿Continuar?",
"STR_PART_RESIZE_SUCCESS":"¡Felicitaciones!#@La instalación no destructiva de Ventoy a finalizado exitosamente.",
"STR_PART_RESIZE_FAILED":"Instalación no destructiva fallida, Comprueba log.txt para detalles.",
"STR_PART_RESIZE_UNSUPPORTED":"Instalación no destructiva de Ventoy detenida porque algunas condiciones no se pueden cumplir. Comprueba log.txt para detalles.",
"STR_PART_RESIZE_UNSUPPORTED":"Instalación no destructiva de Ventoy detenida porque algunas condiciones no se pueden cumplir. Comprueba log.txt para más detalles.",
"STR_INSTALL_YES_TIP1":"Advertencia: ¡Los datos se perderán!",
"STR_INSTALL_YES_TIP2":"Por favor ingresa YES en el cuadro de texto a continuación para confirmar que realmente quieres realizar una instalación nueva en vez de actualizar.",
"STR_PART_VENTOY_FS":"Sistema de archivos para partición de Ventoy",
"STR_PART_FS":"Sistema de archivos",
"STR_PART_CLUSTER":"Tamaño de cluster",
"STR_PART_CLUSTER":"Tamaño del clúster",
"STR_PART_CLUSTER_DEFAULT":"Valor predeterminado del sistema",
"STR_DONATE":"Donar",
"STR_4KN_UNSUPPORTED":"Actualmente Ventoy no soporta dispositivos nativos 4K.",
"STR_4KN_UNSUPPORTED":"Actualmente Ventoy no es compatible con dispositivos nativos 4K.",
"STRXXX":""
},
@@ -3043,14 +3043,14 @@
"STR_PART_RESIZE_SUCCESS":"Onnittelut!#@Ventoyn ei-tuhoisa asennus saapui päätökseen onnistuneesti.",
"STR_PART_RESIZE_FAILED":"Ei-tuhoisa asennusmuoto epäonnistui, tarkista log.txt nähdäksesi yksityiskohtaiset tiedot.",
"STR_PART_RESIZE_UNSUPPORTED":"Ventoyn ei-tuhoisa asennus pysähtyi koska jotkut ehdot eivät täyttyneet. Tarkista log.txt nähdäksesi yksityiskohdat.",
"STR_INSTALL_YES_TIP1":"Warning: Data will be lost!",
"STR_INSTALL_YES_TIP2":"Please enter YES in the text box below to confirm that you indeed want to do a fresh install instead of upgrade.",
"STR_PART_VENTOY_FS":"File System For Ventoy Partition",
"STR_PART_FS":"File System",
"STR_PART_CLUSTER":"Cluster Size",
"STR_PART_CLUSTER_DEFAULT":"System Default Value",
"STR_INSTALL_YES_TIP1":"Varoitus: Data menetetään!",
"STR_INSTALL_YES_TIP2":"Kirjoita YES alla olevaan tekstikenttään vahvistaaksesi että haluat tehdä uuden asennuksen päivityksen sijaan.",
"STR_PART_VENTOY_FS":"Ventoy -osion tiedostojärjestelmä",
"STR_PART_FS":"Tiedostojärjestelmä",
"STR_PART_CLUSTER":"Klusterin koko",
"STR_PART_CLUSTER_DEFAULT":"Järjestelmän oletusarvo",
"STR_DONATE":"Lahjoittaa",
"STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native devices.",
"STR_4KN_UNSUPPORTED":"Tällä hetkellä Ventoy ei tue 4K laitteita.",
"STRXXX":""
},
+1 -1
View File
@@ -414,7 +414,7 @@ else\
if (node->unData.pcStrVal[0] == '0') val = 0
#define CONTROL_PARSE_INT_DEF_3(node, val) \
if (node->unData.pcStrVal[0] == '3') val = 3
if (node->unData.pcStrVal[0] >= '0' && node->unData.pcStrVal[0] < '3') val = node->unData.pcStrVal[0] - '0'
#define VTOY_JSON_INT(key, val) vtoy_json_get_int(json, key, &val)
#define VTOY_JSON_STR(key, buf) vtoy_json_get_string(json, key, sizeof(buf), buf)
+1 -1
View File
@@ -1 +1 @@
20260624 16:39:09
20260625 19:36:29
+4 -4
View File
@@ -760,7 +760,7 @@
<footer class="main-footer">
<div class="pull-right hidden-xs">
<b id="plugson_build_date">20260624 16:39:09</b>
<b id="plugson_build_date">20260625 19:36:29</b>
</div>
<strong><a href="https://www.ventoy.net" target="_blank">https://www.ventoy.net</a></strong>
</footer>
@@ -780,10 +780,10 @@
<script src="/static/js/jQuery-2.1.4.min.js"></script>
<!-- jquery validate -->
<script src="/static/js/jquery.validate.min.js"></script>
<script src="/static/js/jquery.validate.vtoymethods.js?v=317"></script>
<script src="/static/js/jquery.validate.vtoymethods.js?v=331"></script>
<script src="/static/js/jquery.vtoy.alert.js?v=317"></script>
<script src="/static/js/vtoy.js?v=317"></script>
<script src="/static/js/jquery.vtoy.alert.js?v=331"></script>
<script src="/static/js/vtoy.js?v=331"></script>
<script src="/static/js/md5.min.js"></script>
<!-- Bootstrap 3.3.5 -->
+5
View File
@@ -214,6 +214,11 @@
});
$("#id_conf_replace_tbl").on('click', '.ConfReplaceAddBtn', function() {
if (m_data_conf_replace[current_tab_index].length >= 2) {
Message.error(g_vtoy_cur_language.STR_CONF_REPLACE_MAX_ENTRY);
return;
}
if (g_current_language === 'en') {
$('#ConfReplaceForm #ConfReplaceForm_lang_1').text("ISO Path");
$('#ConfReplaceForm #ConfReplaceForm_lang_2').text(" OK");
+2
View File
@@ -397,6 +397,7 @@ var g_vtoy_cur_language_en =
"STR_INVALID_NUMBER": "Please input valid non-negative integer!",
"STR_INVALID_AUTOSEL": "autosel exceeds the length of the list!",
"STR_INVALID_TIMEOUT": "Please input valid timeout integer!",
"STR_CONF_REPLACE_MAX_ENTRY": "At most 2 entries are allowed for each mode, please delete an existing entry first!",
"STR_INVALID_PERCENT": "Please input integer between 0-100 !",
"STR_INVALID_COLOR": "Please input valid color!",
"STR_SELECT": "Please Select",
@@ -539,6 +540,7 @@ var g_vtoy_cur_language_cn =
"STR_INVALID_NUMBER": "请输入合法的非负整数!",
"STR_INVALID_AUTOSEL": "autosel 的值超过了列表实际长度!",
"STR_INVALID_TIMEOUT": "请输入合法的超时秒数!",
"STR_CONF_REPLACE_MAX_ENTRY": "每种模式最多只能添加2条记录,请先删除已有的记录!",
"STR_INVALID_PERCENT": "请输入 0-100 以内的整数!",
"STR_INVALID_COLOR": "请输入合法的颜色!",
"STR_SELECT": "请选择",
@@ -228,6 +228,7 @@ DRESULT disk_write (
return RES_OK;
}
buff += 512;
sector++;
count--;
}
+69
View File
@@ -0,0 +1,69 @@
@echo off
chcp 65001
echo ==============================================
echo VS Build Script
echo ==============================================
:: ==========================================================
set "VS_DEV_CMD=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat"
set "SLN_FILE=Ventoy2Disk.sln"
:: ==========================================================
echo Initialize environment ...
call "%VS_DEV_CMD%" -no_logo
if %errorlevel% neq 0 (
echo Error: VS env error.
pause
exit /b 1
)
:: ============== Build Release Win32 (x86) ==============
echo.
echo Building: Release Win32
MSBuild "%SLN_FILE%" /t:Build /p:Configuration=Release;Platform=Win32 /m
if %errorlevel% neq 0 (
echo Build Release Win32 failed!
pause
exit /b 1
)
:: ============== Build Release x64 ==============
echo.
echo Building: Release x64
MSBuild "%SLN_FILE%" /t:Build /p:Configuration=Release;Platform=x64 /m
if %errorlevel% neq 0 (
echo Build Release x64 failed!
pause
exit /b 1
)
:: ============== Build Release ARM ==============
echo.
echo Building: Release ARM
MSBuild "%SLN_FILE%" /t:Build /p:Configuration=Release;Platform=ARM /m
if %errorlevel% neq 0 (
echo Build Release ARM failed!
pause
exit /b 1
)
:: ============== Build Release ARM64 ==============
echo.
echo Building: Release ARM64
MSBuild "%SLN_FILE%" /t:Build /p:Configuration=Release;Platform=ARM64 /m
if %errorlevel% neq 0 (
echo Build Release ARM64 failed!
pause
exit /b 1
)
echo.
echo ==============================================
echo ✅ Build Success
echo ==============================================
pause
+74 -65
View File
@@ -7,12 +7,12 @@
* 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/>.
*
@@ -29,7 +29,7 @@
/* Volume Descriptor */
#define BISO_VD_TYPE_BOOT 0
#define BISO_VD_TYPE_PVD 1
#define BISO_VD_TYPE_PVD 1
#define BISO_VD_TYPE_SVD 2
#define BISO_VD_TYPE_PART 3
#define BISO_VD_TYPE_END 255
@@ -82,6 +82,15 @@
UINT32 uiData;\
UINT32 uiData##Swap;
#define BISO_FILL_723(usData, usVal) \
usData = (UINT16)usVal; \
usData##Swap = __builtin_bswap16(usData)
#define BISO_FILL_733(uiData, uiVal) \
uiData = (UINT32)uiVal; \
uiData##Swap = __builtin_bswap32(uiData)
#define BISO_PATHTBL_LOCATION(pstPVD) (pstPVD->uiTypeLPathTblLoc)
#elif (__BYTE_ORDER == __BIG_ENDIAN)
@@ -105,12 +114,12 @@
typedef struct tagBISO_DATE_915
{
UCHAR ucYear; /* 1900+ */
UCHAR ucMonth;
UCHAR ucDay;
UCHAR ucHour;
UCHAR ucMin;
UCHAR ucSec;
CHAR cTimeZone;
UCHAR ucMonth;
UCHAR ucDay;
UCHAR ucHour;
UCHAR ucMin;
UCHAR ucSec;
CHAR cTimeZone;
}BISO_DATE_915_S;
typedef struct tagBISO_PATH_TABLE
@@ -124,7 +133,7 @@ typedef struct tagBISO_PATH_TABLE
UINT16 usParentDirNum;
CHAR szDirName[1];
/* UCHAR ucPadding; */
}BISO_PATH_TABLE_S;
@@ -140,7 +149,7 @@ typedef struct tagBISO_DIR_RECORD
BISO_DEF_733(uiSize)
BISO_DATE_915_S stDate;
BISO_DATE_915_S stDate;
UCHAR ucFlags;
@@ -160,7 +169,7 @@ typedef struct tagBISO_DIR_RECORD
#define BISO_DIR_RECORD_IS_PATH(pstDirRecord) \
((1 == ((pstDirRecord->ucFlags >> 1) & 0x01)) ? BOOL_TRUE : BOOL_FALSE)
typedef struct tagBISO_VOLUME_DESC
typedef struct tagBISO_VOLUME_DESC
{
UCHAR ucType;
@@ -183,8 +192,8 @@ typedef struct tagBISO_PRIMARY_VOLUME_DESC
/* ucResv1: unused1 [ISODCL ( 8, 8)] */
UCHAR ucResv1;
/*
* szSystemId[32]: system_id [ISODCL ( 9, 40)]
/*
* szSystemId[32]: system_id [ISODCL ( 9, 40)]
*/
CHAR szSystemId[32];
@@ -201,18 +210,18 @@ typedef struct tagBISO_PRIMARY_VOLUME_DESC
BISO_DEF_723(usVolumeSet)
/*
* usVolumeSeq: volume_sequence_number [ISODCL (125, 128)]
/*
* usVolumeSeq: volume_sequence_number [ISODCL (125, 128)]
*/
BISO_DEF_723(usVolumeSeq)
/*
/*
* usBlockSize: logical_block_size [ISODCL (129, 132)]
*/
BISO_DEF_723(usBlockSize)
/*
* uiPathTblSize: path_table_size [ISODCL (133, 140)]
* uiPathTblSize: path_table_size [ISODCL (133, 140)]
*/
BISO_DEF_733(uiPathTblSize)
@@ -221,50 +230,50 @@ typedef struct tagBISO_PRIMARY_VOLUME_DESC
UINT32 uiOptTypeLPathTblLoc;
UINT32 uiTypeMPathTblLoc;
UINT32 uiOptTypeMPathTblLoc;
BISO_DIR_RECORD_S stRootDirRecord;
/* szVolumeSetId: volume_set_id [ISODCL (191, 318)] */
CHAR szVolumeSetId[128];
/* szPublisherId: publisher_id [ISODCL (319, 446)] */
CHAR szPublisherId[128];
/* szPreparerId: preparer_id [ISODCL (447, 574)] */
CHAR szPreparerId[128];
/* szApplicationId: application_id [ISODCL (575, 702)] */
CHAR szApplicationId[128];
/* szCopyrightFileId: copyright_file_id [ISODCL (703, 739)] [1] */
CHAR szCopyrightFileId[37];
/* szAbstractFileId: abstract_file_id [ISODCL (740, 776)] */
CHAR szAbstractFileId[37];
/* szBibliographicFileId: bibliographic_file_id [ISODCL (777, 813)] */
CHAR szBibliographicFileId[37];
/* szCreationDate: creation_date [ISODCL (814, 830)] */
CHAR szCreationDate[17];
/* szModifyDate: modification_date [ISODCL (831, 847)] */
CHAR szModifyDate[17];
/* szExpirationDate: expiration_date [ISODCL (848, 864)] */
CHAR szExpirationDate[17];
/* szEffectiveDate: effective_date [ISODCL (865, 881)] */
CHAR szEffectiveDate[17];
/* ucFileStructVer: file_structure_version [ISODCL (882, 882)] */
UCHAR ucFileStructVer;
/* ucResv4: unused4 [ISODCL (883, 883)] */
UCHAR ucResv4;
/* aucApplicationData: application_data [ISODCL (884, 1395)] */
UCHAR aucApplicationData[512];
@@ -276,21 +285,21 @@ typedef struct tagBISO_SUPPLEMENTARY_VOLUME_DESC
{
UCHAR ucType;
/*
* szId[5]: id [ISODCL ( 2, 6)]
/*
* szId[5]: id [ISODCL ( 2, 6)]
*/
CHAR szId[5];
/* ucVersion: version [ISODCL ( 7, 7)] */
UCHAR ucVersion;
/*
* ucFlags: flags [ISODCL ( 8, 8)]
/*
* ucFlags: flags [ISODCL ( 8, 8)]
*/
UCHAR ucFlags;
/*
* szSystemId[32]: system_id [ISODCL ( 9, 40)]
/*
* szSystemId[32]: system_id [ISODCL ( 9, 40)]
*/
CHAR szSystemId[32];
@@ -300,8 +309,8 @@ typedef struct tagBISO_SUPPLEMENTARY_VOLUME_DESC
/* aucResv2[8]: unused2 [ISODCL ( 73, 80)] */
UCHAR aucResv2[8];
/*
* uiVolumeSpace: volume_space_size [ISODCL ( 81, 88)]
/*
* uiVolumeSpace: volume_space_size [ISODCL ( 81, 88)]
*/
BISO_DEF_733(uiVolumeSpace)
@@ -309,16 +318,16 @@ typedef struct tagBISO_SUPPLEMENTARY_VOLUME_DESC
UCHAR aucEscape[32];
/*
* usVolumeSet: volume_set_size [ISODCL (121, 124)]
* usVolumeSet: volume_set_size [ISODCL (121, 124)]
*/
BISO_DEF_723(usVolumeSet)
/*
* usVolumeSeq: volume_sequence_number [ISODCL (125, 128)]
/*
* usVolumeSeq: volume_sequence_number [ISODCL (125, 128)]
*/
BISO_DEF_723(usVolumeSeq)
/*
/*
* usBlockSize: logical_block_size [ISODCL (129, 132)]
*/
BISO_DEF_723(usBlockSize)
@@ -330,50 +339,50 @@ typedef struct tagBISO_SUPPLEMENTARY_VOLUME_DESC
UINT32 uiOptTypeLPathTblLoc;
UINT32 uiTypeMPathTblLoc;
UINT32 uiOptTypeMPathTblLoc;
BISO_DIR_RECORD_S stRootDirRecord;
/* szVolumeSetId: volume_set_id [ISODCL (191, 318)] */
CHAR szVolumeSetId[128];
/* szPublisherId: publisher_id [ISODCL (319, 446)] */
CHAR szPublisherId[128];
/* szPreparerId: preparer_id [ISODCL (447, 574)] */
CHAR szPreparerId[128];
/* szApplicationId: application_id [ISODCL (575, 702)] */
CHAR szApplicationId[128];
/* szCopyrightFileId: copyright_file_id [ISODCL (703, 739)] */
CHAR szCopyrightFileId[37];
/* szAbstractFileId: abstract_file_id [ISODCL (740, 776)]*/
CHAR szAbstractFileId[37];
/* szBibliographicFileId: bibliographic_file_id [ISODCL (777, 813)] */
CHAR szBibliographicFileId[37];
/* szCreationDate: creation_date [ISODCL (814, 830)]*/
CHAR szCreationDate[17];
/* szModifyDate: modification_date [ISODCL (831, 847)] */
CHAR szModifyDate[17];
/* szExpirationDate: expiration_date [ISODCL (848, 864)] */
CHAR szExpirationDate[17];
/* szEffectiveDate: effective_date [ISODCL (865, 881)] */
CHAR szEffectiveDate[17];
/* ucFileStructVer: file_structure_version [ISODCL (882, 882)] */
UCHAR ucFileStructVer;
/* ucResv4: unused4 [ISODCL (883, 883)] */
UCHAR ucResv4;
/* aucApplicationData: application_data [ISODCL (884, 1395)] */
UCHAR aucApplicationData[512];
@@ -384,8 +393,8 @@ typedef struct tagBISO_SUPPLEMENTARY_VOLUME_DESC
typedef struct tagBISO_BOOT_DESC
{
UCHAR ucType;
/*
* szId[5]: id [ISODCL ( 2, 6)]
/*
* szId[5]: id [ISODCL ( 2, 6)]
*/
CHAR szId[5];
@@ -430,7 +439,7 @@ typedef struct tagBISO_EXTATTR_RECORD
UCHAR aucResv[64];
BISO_DEF_723(usAppDataLen)
/* UCHAR aucAppData[xxx]; */
/* UCHAR aucEscape[xxx]; */
}BISO_EXTATTR_RECORD_S;
@@ -520,14 +529,14 @@ typedef struct tagBISO_PARSER
UCHAR ucRRIPSkipLen;
BISO_DIR_TREE_S stDirTree;
BISO_SVD_DIR_TREE_S stSVDDirTree;
}BISO_PARSER_S;
ULONG BISO_9660_OpenImage
(
IN BOOL_T bParseSVDDirTree,
IN CONST CHAR *pcFileName,
IN CONST CHAR *pcFileName,
OUT BISO_PARSER_S *pstParser
);
BISO_PARSER_S * BISO_9660_CreateParser(VOID);
@@ -540,12 +549,12 @@ ULONG BISO_9660_ParseDate84261
VOID BISO_9660_FmtDate84261(IN time_t ulTime, IN UINT uiBufSize, OUT CHAR *pcDate);
VOID BISO_9660_FillDfsStack
(
IN BISO_DIR_TREE_S *pstTop,
IN BISO_DIR_TREE_S *pstTop,
INOUT BISO_QUEUE_S *pstQueue
);
ULONG BISO_9660_ExtractFile
(
IN BISO_FILE_S *pstFile,
IN BISO_FILE_S *pstFile,
IN CONST CHAR *pcDstFullPath,
IN CONST BISO_DIR_TREE_S *pstFileNode,
IN CONST BISO_EXTRACT_CTRL_S *pstCtrl
+347 -41
View File
@@ -7,12 +7,12 @@
* 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/>.
*
@@ -69,6 +69,8 @@ static int verbose = 0;
#define CMD_EXTRACT_ISO_FILE 4
#define CMD_PRINT_EXTRACT_ISO_FILE 5
#define CMD_PRINT_RAW_TABLE 6
#define CMD_COPY_ISO 7
#define CMD_PRINT_WRAP_TABLE 8
static uint64_t g_iso_file_size;
static char g_disk_name[128];
@@ -82,7 +84,7 @@ ventoy_img_chunk * vtoydm_get_img_map_data(const char *img_map_file, int *plen)
int rc = 1;
FILE *fp = NULL;
ventoy_img_chunk *chunk = NULL;
fp = fopen(img_map_file, "rb");
if (NULL == fp)
{
@@ -111,7 +113,7 @@ ventoy_img_chunk * vtoydm_get_img_map_data(const char *img_map_file, int *plen)
if (len % sizeof(ventoy_img_chunk))
{
fprintf(stderr, "image map file size %d is not aligned with %d\n",
fprintf(stderr, "image map file size %d is not aligned with %d\n",
len, (int)sizeof(ventoy_img_chunk));
goto end;
}
@@ -139,7 +141,7 @@ UINT64 vtoydm_get_file_size(const char *pcFileName)
(void)pcFileName;
debug("vtoydm_get_file_size %s %lu\n", pcFileName, (unsigned long)g_iso_file_size);
return g_iso_file_size;
}
@@ -157,14 +159,14 @@ BISO_FILE_S * vtoydm_open_file(const char *pcFileName)
file->FileSize = g_iso_file_size;
file->CurPos = 0;
}
return file;
}
void vtoydm_close_file(BISO_FILE_S *pstFile)
{
debug("vtoydm_close_file\n");
if (pstFile)
{
free(pstFile);
@@ -187,7 +189,7 @@ UINT64 vtoydm_map_iso_sector(UINT64 sector)
{
int i;
UINT64 disk_sector = 0;
for (i = 0; i < g_img_chunk_num; i++)
{
if (sector >= g_img_chunk[i].img_start_sector && sector <= g_img_chunk[i].img_end_sector)
@@ -205,7 +207,7 @@ int vtoydm_read_iso_sector(UINT64 sector, void *buf)
int i;
int fd;
UINT64 disk_sector = 0;
for (i = 0; i < g_img_chunk_num; i++)
{
if (sector >= g_img_chunk[i].img_start_sector && sector <= g_img_chunk[i].img_end_sector)
@@ -232,9 +234,9 @@ int vtoydm_read_iso_sector(UINT64 sector, void *buf)
UINT64 vtoydm_read_file
(
BISO_FILE_S *pstFile,
UINT uiBlkSize,
UINT uiBlkNum,
BISO_FILE_S *pstFile,
UINT uiBlkSize,
UINT uiBlkNum,
VOID *pBuf
)
{
@@ -249,7 +251,7 @@ UINT64 vtoydm_read_file
if (pos > 0)
{
align = 2048 - pos;
vtoydm_read_iso_sector(pstFile->CurPos / 2048, g_iso_sector_buf);
if (readlen > align)
{
@@ -270,7 +272,7 @@ UINT64 vtoydm_read_file
{
vtoydm_read_iso_sector(pstFile->CurPos / 2048, curbuf);
pstFile->CurPos += 2048;
curbuf += 2048;
readlen -= 2048;
}
@@ -281,7 +283,7 @@ UINT64 vtoydm_read_file
memcpy(curbuf, g_iso_sector_buf, readlen);
pstFile->CurPos += readlen;
}
return uiBlkSize * uiBlkNum;
}
@@ -295,7 +297,7 @@ int vtoydm_dump_iso(const char *img_map_file, const char *diskname)
BISO_READ_S *iso;
BISO_PARSER_S *parser = NULL;
char label[64] = {0};
chunk = vtoydm_get_img_map_data(img_map_file, &len);
if (NULL == chunk)
{
@@ -324,7 +326,7 @@ int vtoydm_dump_iso(const char *img_map_file, const char *diskname)
ret = BISO_OpenImage("XXX", iso);
debug("open iso image ret=0x%lx\n", ret);
parser = (BISO_PARSER_S *)iso;
parser = (BISO_PARSER_S *)iso;
memcpy(label, parser->pstPVD->szVolumeId, 32);
for (i = 32; i >=0; i--)
{
@@ -340,11 +342,11 @@ int vtoydm_dump_iso(const char *img_map_file, const char *diskname)
if (label[0])
{
printf("VENTOY_ISO_LABEL %s\n", label);
printf("VENTOY_ISO_LABEL %s\n", label);
}
BISO_DumpFileTree(iso);
BISO_FreeReadHandle(iso);
free(chunk);
@@ -353,7 +355,7 @@ int vtoydm_dump_iso(const char *img_map_file, const char *diskname)
static int vtoydm_extract_iso
(
const char *img_map_file,
const char *img_map_file,
const char *diskname,
unsigned long first_sector,
unsigned long long file_size,
@@ -394,16 +396,119 @@ static int vtoydm_extract_iso
file_size = 0;
}
}
fclose(fp);
free(g_img_chunk);
return 0;
}
static int vtoydm_copy_iso
(
const char *img_map_file,
const char *diskname,
const char *outfile
)
{
int i;
int len;
int fd = -1;
int ret = 1;
uint32_t bufsize = 1048576;
uint64_t TotSize = 0;
uint64_t ChunkSize = 0;
uint64_t Second1 = 0;
uint64_t Second2 = 0;
FILE *fp = NULL;
char *pcBuf = NULL;
Second1 = time(NULL);
debug("Start copy iso file ...\n");
pcBuf = (char *)malloc(bufsize);
if (!pcBuf)
{
goto end;
}
g_img_chunk = vtoydm_get_img_map_data(img_map_file, &len);
if (NULL == g_img_chunk)
{
goto end;
}
g_img_chunk_num = len / sizeof(ventoy_img_chunk);
strncpy(g_disk_name, diskname, sizeof(g_disk_name) - 1);
fd = open(g_disk_name, O_RDONLY | O_BINARY);
if (fd < 0)
{
debug("Failed to open %s\n", g_disk_name);
goto end;
}
fp = fopen(outfile, "wb");
if (fp == NULL)
{
fprintf(stderr, "Failed to create file %s err:%d\n", outfile, errno);
goto end;
}
for (i = 0; i < g_img_chunk_num; i++)
{
ChunkSize = (g_img_chunk[i].img_end_sector + 1 - g_img_chunk[i].img_start_sector) * 2048;
TotSize += ChunkSize;
lseek(fd, g_img_chunk[i].disk_start_sector * 512, SEEK_SET);
while (ChunkSize > 0)
{
if (ChunkSize >= bufsize)
{
read(fd, pcBuf, bufsize);
fwrite(pcBuf, bufsize, 1, fp);
ChunkSize -= bufsize;
}
else
{
read(fd, pcBuf, ChunkSize);
fwrite(pcBuf, ChunkSize, 1, fp);
ChunkSize = 0;
}
}
}
Second2 = time(NULL);
debug("Copy finish, iso size:%llu seconds:%d\n", (_ULL)TotSize, (int)(Second2 - Second1));
ret = 0;
end:
if (fp)
{
fclose(fp);
}
if (fd >= 0)
{
close(fd);
}
if (g_img_chunk)
{
free(g_img_chunk);
}
if (pcBuf)
{
free(pcBuf);
}
return ret;
}
static int vtoydm_print_extract_iso
(
const char *img_map_file,
const char *img_map_file,
const char *diskname,
unsigned long first_sector,
unsigned long long file_size,
@@ -461,7 +566,7 @@ static int vtoydm_print_extract_iso
last = sector;
count = 4;
}
if (file_size > 2048)
{
file_size -= 2048;
@@ -478,7 +583,7 @@ static int vtoydm_print_extract_iso
buf[1] = count;
fwrite(buf, 1, sizeof(buf), fp);
}
fclose(fp);
free(g_img_chunk);
return 0;
@@ -494,7 +599,7 @@ static int vtoydm_print_linear_table(const char *img_map_file, const char *diskn
uint32_t disk_sector_num;
uint32_t sector_start;
ventoy_img_chunk *chunk = NULL;
chunk = vtoydm_get_img_map_data(img_map_file, &len);
if (NULL == chunk)
{
@@ -508,20 +613,20 @@ static int vtoydm_print_linear_table(const char *img_map_file, const char *diskn
/* TBD: to be more flexible */
#if 0
printf("%u %u linear %s %llu\n",
(sector_start << 2), disk_sector_num,
printf("%u %u linear %s %llu\n",
(sector_start << 2), disk_sector_num,
diskname, (unsigned long long)chunk[i].disk_start_sector);
#else
if (strstr(diskname, "nvme") || strstr(diskname, "mmc") || strstr(diskname, "nbd"))
{
printf("%u %u linear %sp%d %llu\n",
(sector_start << 2), disk_sector_num,
printf("%u %u linear %sp%d %llu\n",
(sector_start << 2), disk_sector_num,
diskname, part, (unsigned long long)chunk[i].disk_start_sector - offset);
}
else
{
printf("%u %u linear %s%d %llu\n",
(sector_start << 2), disk_sector_num,
printf("%u %u linear %s%d %llu\n",
(sector_start << 2), disk_sector_num,
diskname, part, (unsigned long long)chunk[i].disk_start_sector - offset);
}
#endif
@@ -539,7 +644,7 @@ static int vtoydm_print_help(FILE *fp)
" vtoydm -i -f img_map_file -d diskname [ -v ] \n"
" vtoydm -e -f img_map_file -d diskname -s sector -l len -o file [ -v ] \n"
);
return 0;
return 0;
}
static uint64_t vtoydm_get_part_start(const char *diskname, int part)
@@ -561,7 +666,7 @@ static uint64_t vtoydm_get_part_start(const char *diskname, int part)
if (access(diskpath, F_OK) >= 0)
{
debug("get part start from sysfs for %s %d\n", diskname, part);
fd = open(diskpath, O_RDONLY | O_BINARY);
if (fd >= 0)
{
@@ -600,7 +705,7 @@ static uint64_t vtoydm_get_part_secnum(const char *diskname, int 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)
{
@@ -647,12 +752,12 @@ static int vtoydm_vlnk_convert(char *disk, int len, int *part, uint64_t *offset)
if (param.vtoy_reserved[6])
{
cnt = vtoy_find_disk_by_guid(&param, diskname);
debug("vtoy_find_disk_by_guid cnt=%d\n", cnt);
debug("vtoy_find_disk_by_guid cnt=%d\n", cnt);
if (cnt == 1)
{
*part = param.vtoy_disk_part_id;
*offset = vtoydm_get_part_start(diskname, *part);
debug("VLNK <%s> <%s> <P%d> <%llu>\n", disk, diskname, *part, (unsigned long long)(*offset));
snprintf(disk, len, "/dev/%s", diskname);
@@ -681,10 +786,195 @@ static int vtoydm_print_raw_linear_table(const char *img_map_file, const char *d
{
printf("0 %lu linear %s%d 0\n", (unsigned long)disk_sector_num, diskname, part);
}
return 0;
}
static int vtoydm_print_wrap_linear_table(const char *img_map_file, const char *diskname, int part, uint64_t offset)
{
int i;
int len;
int cnt;
uint64_t sector_num = 0;
uint64_t iso_file_size = 0;
uint32_t dir_rec_secs = 0;
uint32_t curr_offset = 0;
uint32_t dir_entry_cnt = 0;
uint32_t head_sector_num = 0;
uint32_t uiCurrExtent = 0;
uint32_t iso_sector_num = 0;
uint32_t disk_sector_num;
uint32_t sector_start;
ventoy_img_chunk *chunk = NULL;
uint8_t *pucBuf = NULL;
FILE *pstFile = NULL;
BISO_PVD_S *pstPVD = NULL;
BISO_VD_S *pstEVD = NULL;
BISO_DIR_RECORD_S *pstRecord = NULL;
chunk = vtoydm_get_img_map_data(img_map_file, &len);
if (NULL == chunk)
{
return 1;
}
cnt = len / sizeof(ventoy_img_chunk);
for (i = 0; i < cnt; i++)
{
sector_num = chunk[i].img_end_sector - chunk[i].img_start_sector + 1;
iso_file_size += sector_num * 2048;
}
iso_sector_num = (uint32_t)(iso_file_size / 2048);
dir_entry_cnt = (uint32_t)((iso_file_size + (0xFFFFF800 - 1)) / 0xFFFFF800);
head_sector_num = 16 + 2 + dir_entry_cnt / (2048 / 46) + 2;
debug("Total iso file size: %llu iso sectors:%u dir record cnt:%u, header sectors:%u\n",
(_ULL)iso_file_size, iso_sector_num, dir_entry_cnt, head_sector_num);
pucBuf = (uint8_t *)malloc(head_sector_num * 2048);
if (!pucBuf)
{
free(chunk);
return 1;
}
memset(pucBuf, 0, head_sector_num * 2048);
/* Fill PVD */
pstPVD = (BISO_PVD_S *)(pucBuf + 0x8000);
pstPVD->ucType = BISO_VD_TYPE_PVD;
memcpy(pstPVD->szId, BISO_VD_ID, 5);
pstPVD->ucVersion = 1;
memset(pstPVD->szSystemId, ' ', sizeof(pstPVD->szSystemId));
memset(pstPVD->szVolumeSetId, ' ', sizeof(pstPVD->szVolumeSetId));
memset(pstPVD->szPublisherId, ' ', sizeof(pstPVD->szPublisherId));
memset(pstPVD->szPreparerId, ' ', sizeof(pstPVD->szPreparerId));
memset(pstPVD->szApplicationId, ' ', sizeof(pstPVD->szApplicationId));
memset(pstPVD->szCopyrightFileId, ' ', sizeof(pstPVD->szCopyrightFileId));
memset(pstPVD->szAbstractFileId, ' ', sizeof(pstPVD->szAbstractFileId));
memset(pstPVD->szBibliographicFileId, ' ', sizeof(pstPVD->szBibliographicFileId));
memset(pstPVD->szCreationDate, '0', sizeof(pstPVD->szCreationDate));
memset(pstPVD->szModifyDate, '0', sizeof(pstPVD->szModifyDate));
memset(pstPVD->szExpirationDate, '0', sizeof(pstPVD->szExpirationDate));
memset(pstPVD->szEffectiveDate, '0', sizeof(pstPVD->szEffectiveDate));
memset(pstPVD->szVolumeId, ' ', sizeof(pstPVD->szVolumeId));
memcpy(pstPVD->szVolumeId, "Ventoy", 6);
memcpy(pstPVD->szPublisherId, "VENTOY", 6);
memcpy(pstPVD->szPreparerId, "https://www.ventoy.net", 22);
BISO_FILL_733(pstPVD->uiVolumeSpace, head_sector_num + iso_sector_num);
BISO_FILL_723(pstPVD->usVolumeSet, 1);
BISO_FILL_723(pstPVD->usVolumeSeq, 1);
BISO_FILL_723(pstPVD->usBlockSize, 2048);
pstPVD->stRootDirRecord.ucLength = 34;
pstPVD->stRootDirRecord.ucExtAttrLen = 0;
BISO_FILL_733(pstPVD->stRootDirRecord.uiExtent, 0x12);
pstPVD->stRootDirRecord.ucFlags = 2;
BISO_FILL_723(pstPVD->stRootDirRecord.uiVolumeSeqNum, 1);
pstPVD->stRootDirRecord.ucNameLen = 1;
/* End VD */
pstEVD = (BISO_VD_S *)(pucBuf + 0x8800);
pstEVD->ucType = BISO_VD_TYPE_END;
memcpy(pstEVD->szId, BISO_VD_ID, 5);
pstEVD->ucVersion = 1;
/* Fill Dir Record */
pstRecord = (BISO_DIR_RECORD_S *)(pucBuf + 0x9000 + 2 * sizeof(BISO_DIR_RECORD_S));
uiCurrExtent = head_sector_num;
curr_offset = sizeof(BISO_DIR_RECORD_S) * 2;
dir_rec_secs = 1;
while (iso_file_size > 0)
{
pstRecord->ucLength = 46;
BISO_FILL_733(pstRecord->uiExtent, uiCurrExtent);
BISO_FILL_723(pstRecord->uiVolumeSeqNum, 1);
pstRecord->ucNameLen = 12;
memcpy(pstRecord->szName, "ventoy.raw;1", 12);
if (iso_file_size > 0xFFFFF800)
{
pstRecord->ucFlags = 0x80;
BISO_FILL_733(pstRecord->uiSize, 0xFFFFF800);
uiCurrExtent += 0xFFFFF800 / 2048;
iso_file_size -= 0xFFFFF800;
pstRecord = (BISO_DIR_RECORD_S *)((char *)pstRecord + 46);
curr_offset += 46;
if (curr_offset > (2048 - 46))
{
pstRecord = (BISO_DIR_RECORD_S *)((char *)pstRecord + (2048 - curr_offset));
curr_offset = 0;
dir_rec_secs++;
}
}
else
{
pstRecord->ucFlags = 0x00;
BISO_FILL_733(pstRecord->uiSize, iso_file_size);
break;
}
}
BISO_FILL_733(pstPVD->stRootDirRecord.uiSize, dir_rec_secs * 2048);
pstRecord = (BISO_DIR_RECORD_S *)(pucBuf + 0x9000);
memcpy(pstRecord, &pstPVD->stRootDirRecord, sizeof(BISO_DIR_RECORD_S));
pstRecord++;
memcpy(pstRecord, &pstPVD->stRootDirRecord, sizeof(BISO_DIR_RECORD_S));
pstRecord->szName[0] = 0x01;
pstFile = fopen("/ventoy/dmwrapper.bin", "wb+");
if (pstFile)
{
fwrite(pucBuf, 2048, head_sector_num, pstFile);
fclose(pstFile);
}
printf("0 %u linear /dev/loop0 0\n", head_sector_num * 4);
for (i = 0; i < len / sizeof(ventoy_img_chunk); i++)
{
sector_start = chunk[i].img_start_sector + head_sector_num;
disk_sector_num = (uint32_t)(chunk[i].disk_end_sector + 1 - chunk[i].disk_start_sector);
/* TBD: to be more flexible */
#if 0
printf("%u %u linear %s %llu\n",
(sector_start << 2), disk_sector_num,
diskname, (unsigned long long)chunk[i].disk_start_sector);
#else
if (strstr(diskname, "nvme") || strstr(diskname, "mmc") || strstr(diskname, "nbd"))
{
printf("%u %u linear %sp%d %llu\n",
(sector_start << 2), disk_sector_num,
diskname, part, (unsigned long long)chunk[i].disk_start_sector - offset);
}
else
{
printf("%u %u linear %s%d %llu\n",
(sector_start << 2), disk_sector_num,
diskname, part, (unsigned long long)chunk[i].disk_start_sector - offset);
}
#endif
}
free(chunk);
free(pucBuf);
return 0;
}
int vtoydm_main(int argc, char **argv)
{
int ch;
@@ -697,7 +987,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::r::c::h::e::E::")) != -1)
while ((ch = getopt(argc, argv, "s:l:o:d:f:v::i::p::r::c::h::e::E::C::w::")) != -1)
{
if (ch == 'd')
{
@@ -715,10 +1005,18 @@ int vtoydm_main(int argc, char **argv)
{
cmd = CMD_PRINT_RAW_TABLE;
}
else if (ch == 'w')
{
cmd = CMD_PRINT_WRAP_TABLE;
}
else if (ch == 'c')
{
cmd = CMD_CREATE_DM;
}
else if (ch == 'C')
{
cmd = CMD_COPY_ISO;
}
else if (ch == 'i')
{
cmd = CMD_DUMP_ISO_INFO;
@@ -764,11 +1062,11 @@ int vtoydm_main(int argc, char **argv)
return 1;
}
debug("cmd=%d file=<%s> disk=<%s> first_sector=%lu file_size=%llu\n",
debug("cmd=%d file=<%s> disk=<%s> first_sector=%lu file_size=%llu\n",
cmd, filepath, diskname, first_sector, file_size);
vtoydm_vlnk_convert(diskname, sizeof(diskname), &part, &offset);
switch (cmd)
{
case CMD_PRINT_TABLE:
@@ -779,6 +1077,10 @@ int vtoydm_main(int argc, char **argv)
{
return vtoydm_print_raw_linear_table(filepath, diskname, part);
}
case CMD_PRINT_WRAP_TABLE:
{
return vtoydm_print_wrap_linear_table(filepath, diskname, part, offset);
}
case CMD_CREATE_DM:
{
break;
@@ -795,6 +1097,10 @@ int vtoydm_main(int argc, char **argv)
{
return vtoydm_print_extract_iso(filepath, diskname, first_sector, file_size, outfile);
}
case CMD_COPY_ISO:
{
return vtoydm_copy_iso(filepath, diskname, outfile);
}
default :
{
fprintf(stderr, "Invalid cmd \n");
+211
View File
@@ -0,0 +1,211 @@
/******************************************************************************
* vtoygpt.c ---- ventoy gpt
*
* Copyright (c) 2026, 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/>.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
static int verbose = 0;
#define debug(fmt, ...) if(verbose) printf(fmt, ##__VA_ARGS__)
#define VOID void
#define CHAR char
#define UINT64 unsigned long long
#define UINT32 unsigned int
#define UINT16 unsigned short
#define CHAR16 unsigned short
#define UINT8 unsigned char
UINT32 VtoyCrc32(VOID *Buffer, UINT32 Length);
#define COMPILE_ASSERT(expr) extern char __compile_assert[(expr) ? 1 : -1]
#pragma pack(1)
typedef struct PART_TABLE
{
UINT8 Active;
UINT8 StartHead;
UINT16 StartSector : 6;
UINT16 StartCylinder : 10;
UINT8 FsFlag;
UINT8 EndHead;
UINT16 EndSector : 6;
UINT16 EndCylinder : 10;
UINT32 StartSectorId;
UINT32 SectorCount;
}PART_TABLE;
typedef struct MBR_HEAD
{
UINT8 BootCode[446];
PART_TABLE PartTbl[4];
UINT8 Byte55;
UINT8 ByteAA;
}MBR_HEAD;
typedef struct GUID
{
UINT32 data1;
UINT16 data2;
UINT16 data3;
UINT8 data4[8];
}GUID;
typedef struct VTOY_GPT_HDR
{
CHAR Signature[8]; /* EFI PART */
UINT8 Version[4];
UINT32 Length;
UINT32 Crc;
UINT8 Reserved1[4];
UINT64 EfiStartLBA;
UINT64 EfiBackupLBA;
UINT64 PartAreaStartLBA;
UINT64 PartAreaEndLBA;
GUID DiskGuid;
UINT64 PartTblStartLBA;
UINT32 PartTblTotNum;
UINT32 PartTblEntryLen;
UINT32 PartTblCrc;
UINT8 Reserved2[420];
}VTOY_GPT_HDR;
COMPILE_ASSERT(sizeof(VTOY_GPT_HDR) == 512);
typedef struct VTOY_GPT_PART_TBL
{
GUID PartType;
GUID PartGuid;
UINT64 StartLBA;
UINT64 LastLBA;
UINT64 Attr;
CHAR16 Name[36];
}VTOY_GPT_PART_TBL;
COMPILE_ASSERT(sizeof(VTOY_GPT_PART_TBL) == 128);
typedef struct VTOY_GPT_INFO
{
MBR_HEAD MBR;
VTOY_GPT_HDR Head;
VTOY_GPT_PART_TBL PartTbl[128];
}VTOY_GPT_INFO;
typedef struct VTOY_BK_GPT_INFO
{
VTOY_GPT_PART_TBL PartTbl[128];
VTOY_GPT_HDR Head;
}VTOY_BK_GPT_INFO;
COMPILE_ASSERT(sizeof(VTOY_GPT_INFO) == 512 * 34);
COMPILE_ASSERT(sizeof(VTOY_BK_GPT_INFO) == 512 * 33);
#pragma pack()
static void dump_gpt_partuuid(int fd, int part)
{
int i;
int start, end;
GUID *guid = NULL;
VTOY_GPT_INFO *pInfo = NULL;
pInfo = (VTOY_GPT_INFO *)malloc(sizeof(VTOY_GPT_INFO));
lseek(fd, 0, SEEK_SET);
read(fd, pInfo, sizeof(VTOY_GPT_INFO));
if (part >= 1 && part <= 128)
{
start = end = part;
}
else
{
start = 1;
end = 128;
}
for (i = start; i <= end; i++)
{
if (pInfo->PartTbl[i - 1].StartLBA == 0)
{
break;
}
guid = &(pInfo->PartTbl[i - 1].PartGuid);
printf("%d %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n", i,
guid->data1, guid->data2, guid->data3,
guid->data4[0], guid->data4[1], guid->data4[2], guid->data4[3],
guid->data4[4], guid->data4[5], guid->data4[6], guid->data4[7]);
}
}
int vtoygpt_main(int argc, char **argv)
{
int i;
int part;
int fd;
for (i = 0; i < argc; i++)
{
if (argv[i][0] == '-' && argv[i][1] == 'v')
{
verbose = 1;
break;
}
}
part = (int)strtol(argv[2], NULL, 10);
fd = open(argv[1], O_RDONLY);
if (fd < 0)
{
debug("Failed to open %s\n", argv[1]);
return 1;
}
dump_gpt_partuuid(fd, part);
close(fd);
return 0;
}
// wrapper main
#ifndef BUILD_VTOY_TOOL
int main(int argc, char **argv)
{
return vtoygpt_main(argc, argv);
}
#endif
+8 -6
View File
@@ -7,12 +7,12 @@
* 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/>.
*
@@ -38,10 +38,11 @@ int vtoyloader_main(int argc, char **argv);
int vtoyvine_main(int argc, char **argv);
int vtoyksym_main(int argc, char **argv);
int vtoykmod_main(int argc, char **argv);
int vtoygpt_main(int argc, char **argv);
int vtoyexpand_main(int argc, char **argv);
static char *g_vtoytool_name = NULL;
static cmd_def g_cmd_list[] =
static cmd_def g_cmd_list[] =
{
{ "vine_patch_loader", vtoyvine_main },
{ "vtoydump", vtoydump_main },
@@ -51,6 +52,7 @@ static cmd_def g_cmd_list[] =
{ "vtoyksym", vtoyksym_main },
{ "vtoykmod", vtoykmod_main },
{ "vtoyexpand", vtoyexpand_main },
{ "vtoygpt", vtoygpt_main },
{ "--install", vtoytool_install },
};
@@ -60,7 +62,7 @@ int vtoytool_install(int argc, char **argv)
int i;
char toolpath[128];
char filepath[128];
for (i = 0; i < sizeof(g_cmd_list) / sizeof(g_cmd_list[0]); i++)
{
if (g_cmd_list[i].cmd[0] != '-')
@@ -70,14 +72,14 @@ int vtoytool_install(int argc, char **argv)
link(toolpath, filepath);
}
}
return 0;
}
int main(int argc, char **argv)
{
int i;
if ((g_vtoytool_name = strstr(argv[0], "vtoytool")) != NULL)
{
argc--;
+10 -8
View File
@@ -7,12 +7,12 @@
* 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/>.
*
@@ -67,7 +67,7 @@ typedef struct ventoy_image_disk_region
typedef struct ventoy_image_location
{
ventoy_guid guid;
/* image sector size, currently this value is always 2048 */
uint32_t image_sector_size;
@@ -75,12 +75,12 @@ typedef struct ventoy_image_location
uint32_t disk_sector_size;
uint32_t region_count;
/*
* disk region data
* If the image file has more than one fragments in disk,
* If the image file has more than one fragments in disk,
* there will be more than one region data here.
* You can calculate the region count by
* You can calculate the region count by
*/
ventoy_image_disk_region regions[1];
@@ -99,7 +99,7 @@ typedef struct ventoy_os_param
char vtoy_img_path[384]; // It seems to be enough, utf-8 format
uint64_t vtoy_img_size; // image file size in bytes
/*
/*
* Ventoy will write a copy of ventoy_image_location data into runtime memory
* this is the physically address and length of that memory.
* Address 0 means no such data exist.
@@ -112,7 +112,7 @@ typedef struct ventoy_os_param
uint8_t vtoy_reserved[32]; // Internal use by ventoy
uint8_t vtoy_disk_signature[4];
uint8_t reserved[27];
}ventoy_os_param;
@@ -121,3 +121,5 @@ typedef struct ventoy_os_param
int vtoy_find_disk_by_guid(ventoy_os_param *param, char *diskname);
#endif
#define _ULL unsigned long long