Compare commits

...
417 Commits
Author SHA1 Message Date
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
longpanda d51e76daa9 1.1.15 release
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-06-25 08:56:32 +08:00
longpanda f677d72e8d Fix the boot issue when Secure Boot is disabled in the UEFI firmware. (#3650) 2026-06-25 08:52:07 +08:00
longpanda 6418c2a09f 1.1.14
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-06-24 20:55:20 +08:00
longpanda c2a3f181c0 Fix the secure boot issue. 2026-06-24 20:52:56 +08:00
longpanda 90e4f9db63 1.1.13 release
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-06-24 18:41:35 +08:00
longpanda 255e84dbab Update BLOB_List.md 2026-06-24 18:41:24 +08:00
longpanda 213ce02985 add build.bat for VentoyPlugson 2026-06-24 18:41:03 +08:00
longpanda 8c2a3b44da Update BLOB_List.md 2026-06-24 17:39:31 +08:00
longpanda 536545cd39 VentoyPlugson Update
- Add missing option (VTOY_WIN_UEFI_RES_LOCK)
 - Add new option (VTOY_SECURE_BOOT_POLICY)
 - Remove deprecated option (VTOY_LINUX_REMOUNT)
2026-06-24 16:43:10 +08:00
longpanda 0f59e92a01 Fix grub i386 build issue.
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-06-23 22:34:10 +08:00
longpanda 4b1e5ce89c Update SecureBoot.md 2026-06-23 22:11:24 +08:00
longpanda 1ed7bc9596 Ventoy Secure Boot Policy Update
- Update Ventoy grub code to match the new policy.
2026-06-23 21:19:46 +08:00
longpanda 71ac855b36 Ventoy Secure Boot Policy Update
- Update pack script (add efi file signature process)
2026-06-23 21:10:17 +08:00
longpanda 4302854b8d Ventoy Secure Boot Policy Update
- Update shim and MokManager for x86_64. I choose the shim file from Rocky Linux 9.2 because it was signed with both UEFI CA 2011 and UEFI CA 2023.
 - Update Ventoy Secure Boot CA.
2026-06-23 21:08:48 +08:00
longpanda 036f7234ad Ventoy Secure Boot Policy Update
- Add SecureBoot.md
2026-06-23 21:04:09 +08:00
longpanda 26a394ce84 Ventoy Secure Boot Policy Update
- Add Ventoy Preload module.
2026-06-23 21:02:56 +08:00
longpanda 25369d5884 Merge branch 'master' of https://github.com/Ventoy/Ventoy
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-05-07 11:18:23 +08:00
longpanda 12387fff81 Fix the boot issue for some WinPE iso. 2026-05-07 11:17:57 +08:00
andrewczmandGitHub b54a7fe93b Polish translation - update (#3576)
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
* Update pl_PL.json

* Update pl_PL.json

* Update languages.json
2026-04-24 15:40:01 +08:00
longpanda dba7530b21 1.1.12
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-04-23 18:04:05 +08:00
longpanda e9b4c86082 Fix Oracle Linux 6.9 install issue
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-04-23 00:23:21 +08:00
longpanda dbcdf51950 Improve for UEFI boot Windows/WinPE resolution issue fix. 2026-04-23 00:00:05 +08:00
longpanda de3e6c6d1d rollback dmsetup operation.
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-04-14 19:42:19 +08:00
longpanda 3c0df07b92 Improve for UEFI boot Windows/WinPE resolution issue fix.
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-04-14 15:38:06 +08:00
longpanda c1c27cd30c Bugfix for ubuntu24.04.4 install failure. (#3567) 2026-04-14 11:03:02 +08:00
longpanda 167c87402c 1.1.11
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
. Fix the display issue when UEFI boot Windows/WinPE
. #3537
. #3532
. Add VT_WINDOWS_DISK_NONVTOY_CLOSEST_XXX  VT_LINUX_DISK_NONVTOY_CLOSEST_XXX
2026-04-05 23:11:45 +08:00
longpanda d35b8431fe Update distro check
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-04-05 17:30:17 +08:00
Florian FuchsandGitHub a1771bd9b8 Improve booting of T2SDE live ISOs (#3526)
T2SDE changed the boot process vastly with 26.3 as it ships as a live
image now. So the injection hooks need to be customized.
2026-04-05 16:49:01 +08:00
panchenboandGitHub ed61a955bf add kylinsecos support (#3552)
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-04-02 18:09:08 +08:00
longpanda e7cf29fd9d Add create_ventoy_iso_part_dm.sh (#3497)
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-02-01 13:54:16 +08:00
longpandaandGitHub b5d87d394a Update imdisk download link in BuildVentoyFromSource.txt
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-01-31 23:14:18 +08:00
longpanda 36da0e0f3d Add VT_WINDOWS_DISK_NONVTOY_CLOSEST_XXX
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2026-01-23 10:47:49 +08:00
Florian FuchsandGitHub 903fd7aa01 Support booting T2SDE ISOs better (#3468)
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
T2 uses zstd compressed kernel modules, where dm-mod also depends on
dax module. So the default fallback to only decompress dm-mod isn't
sufficient. So we manually uncompress dax.ko and dm-mod.ko and insmod
this, as default busybox modprobe/insmod doesn't support zstd modules.
2026-01-08 16:26:35 +08:00
longpanda 81728a817c 1.1.10 release
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-12-21 20:56:53 +08:00
longpanda f68d4a8076 Revert "added the Uzbek language я исправил потвердите (#3306)"
This reverts commit d3b911d249.
2025-12-21 20:33:25 +08:00
Ida BagusandGitHub f6c248e983 Update languages.json (#3198) 2025-12-21 20:26:14 +08:00
Ida BagusandGitHub 0906cd34fe Update id_ID.json (#3199) 2025-12-21 20:26:00 +08:00
+9
tojik_proof_93GitHubCopilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
d3b911d249 added the Uzbek language я исправил потвердите (#3306)
* added the Uzbek language

* Potential fix for code scanning alert no. 1: DOM text reinterpreted as HTML

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Potential fix for code scanning alert no. 2: DOM text reinterpreted as HTML

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Potential fix for code scanning alert no. 3: DOM text reinterpreted as HTML

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Potential fix for code scanning alert no. 13: Time-of-check time-of-use filesystem race condition

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Potential fix for code scanning alert no. 12: Time-of-check time-of-use filesystem race condition

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Potential fix for code scanning alert no. 4: DOM text reinterpreted as HTML

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Potential fix for code scanning alert no. 11: Time-of-check time-of-use filesystem race condition

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Potential fix for code scanning alert no. 5: DOM text reinterpreted as HTML

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Potential fix for code scanning alert no. 7: Unsafe jQuery plugin

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Potential fix for code scanning alert no. 8: Unsafe jQuery plugin

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Potential fix for code scanning alert no. 14: DOM text reinterpreted as HTML

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Potential fix for code scanning alert no. 10: Time-of-check time-of-use filesystem race condition

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Potential fix for code scanning alert no. 15: Time-of-check time-of-use filesystem race condition

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Potential fix for code scanning alert no. 9: Call to `memset` may be deleted

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Update bootstrap.js

* Update ci.yml

* Potential fix for code scanning alert no. 17: Workflow does not contain permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Potential fix for code scanning alert no. 16: Workflow does not contain permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Update ci.yml

* Update ci.yml

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-12-21 20:23:34 +08:00
VenusGirl❤andGitHub 5c6e1c2446 Update ko_KR.txt (#3307) 2025-12-21 20:22:38 +08:00
SIDDHARTHandGitHub 3a97ab9165 Added Malayalam language support to languages.json (#3351) 2025-12-21 20:20:11 +08:00
Muhammad RamzanandGitHub 6fe6231790 Add Urdu language support for Ventoy UI (#3356)
* Add Urdu language support for Ventoy UI

* Add Urdu language support for Ventoy UI

* Add Urdu language support for Ventoy UI

* Update languages.json
2025-12-21 20:19:56 +08:00
9564f125a7 Added Persian Language (#3376)
Co-authored-by: Mojtaba Asgari <Mojtaba.asgari512@gmail.com>
2025-12-21 20:15:00 +08:00
David RefouaandGitHub e380575b91 fix grammar (#3413) 2025-12-21 20:13:04 +08:00
Moses CursorandGitHub 0fd49126bd Add Luganda help text (#3417)
Add Luganda Menu translation
2025-12-21 20:11:31 +08:00
Maison da SilvaandGitHub a466d787b8 Update ANSI for UTF-8 Lang pt-BR (#3432)
Update ANSI for UTF-8 Lang pt-BR
2025-12-21 20:11:02 +08:00
Andrew Poženel - SloDevTeamandGitHub ab5d00bafb Add and update Slovenian translations (#3445)
Added a new Slovenian help file for GRUB and replaced the existing Slovenian translation in languages.json with an updated and expanded version. The new translation provides improved accuracy and consistency for Slovenian users. I've included both authors, the previous one and myself.
2025-12-21 20:10:31 +08:00
longpanda 450caa6654 update README.md
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-12-20 11:26:26 +08:00
longpanda ef93b55c91 Fix the LinuxGUI program crash issue in wayland environment. (#3406)
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-12-20 09:07:08 +08:00
longpanda 4d7fcc26d4 Add support for AerynOS. (#3433)
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-12-19 23:19:58 +08:00
longpanda 3597f15814 Fix the LinuxGUI program crash issue in wayland environment. (#3406)
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-12-19 14:48:53 +08:00
longpanda f7e4a7a6ec Ventoy2Disk.sh supports musl libc envrionment. (#3332)
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
Only Ventoy2Disk.sh support, WebUI/LinuxGUI does not support.
2025-12-18 23:32:34 +08:00
longpanda 65b88aabc5 Fix the vhd.vtoy file boot issue in ext4 file system. (#3444)
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-12-18 08:55:37 +08:00
longpanda c42abd33c2 Fix a Windows boot issue in F2 mode.
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-12-17 22:51:58 +08:00
longpanda af34df278f Fix the boot issue with Kylin Server V11. (#3369)
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-12-12 23:19:34 +08:00
longpanda 68fd17df5b 1.1.09 release
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-12-12 19:53:55 +08:00
longpanda 628a72db2f Fix some VentoyPlugson bug. (#3252) 2025-12-12 14:59:58 +08:00
longpanda a20ee878df Fix the issue that persistence plugin does not work for Arch Linux (#3407)
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-12-12 11:49:57 +08:00
longpanda 3de3a36e9f experimental support for btrfs file system.
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
Requirements:
1. Only support NO RAID mode (single mode).
2. ISO file can NOT be compressed.
2025-12-11 17:11:15 +08:00
longpanda 06f164ef70 experimental support for btrfs file system. (#3438 #3431 #3077 #2093) 2025-12-11 16:29:59 +08:00
longpanda 40fbc041ea Fix vt_strstr
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-12-10 23:51:47 +08:00
longpanda 935516ed49 Fix the boot issue for openSUSE 16.0 (#3379)
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-12-09 09:37:32 +08:00
longpanda a71d4513e4 update README.md
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-12-08 20:16:18 +08:00
longpanda 82fef5314b In latest Ventoy release, we use kernel native method to mount the ISO partition, so the dmpatch is not needed, delete it.
For details, please refer: https://www.ventoy.net/en/doc_linux_remount.html
2025-12-08 19:50:36 +08:00
longpanda 052a0152e4 1.1.08 release 2025-12-08 18:06:42 +08:00
longpanda 5fae0ca35f Add support for FreeBSD 15.0
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-12-07 20:41:03 +08:00
longpanda 6482f2e7b3 1.1.07 release
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-08-18 23:20:15 +08:00
longpanda bd8aebf166 Merge branch 'master' of https://github.com/Ventoy/Ventoy 2025-08-18 23:19:14 +08:00
longpanda 3c05d55b8a Fix the issue (introduced in 1.1.06) that the Ventoy ISO partition cannot be mounted after boot linux distro. 2025-08-18 23:19:00 +08:00
longpanda 92ed0c995e Update README.md
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-08-18 11:59:04 +08:00
longpanda dc7e310828 Update README.md 2025-08-18 11:56:48 +08:00
longpanda 67d7091255 1.1.06 release
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-08-18 11:16:07 +08:00
longpanda 2ab1474694 Fix the issue that cannot boot Tails 6.13+ (#3171)
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-08-17 23:56:35 +08:00
longpanda aa7a77df5a Fix the order issue in TreeView mode. (#3218) 2025-08-17 23:08:09 +08:00
longpanda 4790dedbb1 Fix the order issue in TreeView mode. (#3218) 2025-08-17 22:41:16 +08:00
longpanda de085ba086 Fix the order issue in TreeView mode. (#3218)
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-08-17 17:50:17 +08:00
longpanda bb94ec6d6f Fix Libreelec 12.2.0 fails to boot #3323
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-08-17 00:05:44 +08:00
fsLegandGitHub b9892660b5 Fix the boot issue for Parted Magic (#3304)
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-08-05 09:10:33 +08:00
A1iveandGitHub 0e9d34422a Update xfs to latest (#3284)
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
Thanks!
2025-07-07 09:21:53 +08:00
longpandaandGitHub c7c9c62ec7 Update BLOB_List.md
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-05-22 12:55:41 +08:00
longpanda 9e13955af1 Add BLOB list file and some missing build desc. 2025-05-14 14:35:44 +08:00
longpanda 2dafe75509 Fix the boot issue for TrueNAS Scale. (#3069)
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-03-03 14:42:44 +08:00
longpanda 6fbc08cfcb Only for VirtualBox.
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-02-28 14:58:36 +08:00
longpanda 6034b25cba Don't force to use max resolution for VMware/VirtualBox. (#3140) 2025-02-28 14:49:40 +08:00
longpanda c5fd64d21c Support TrueNAS Scale (Linux) distro. (#3069 #3137)
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-02-26 23:25:27 +08:00
longpanda 32fac72b5b 1.1.05
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-02-24 19:29:46 +08:00
longpanda 022322c8fa Fix the resolution issue when boot Windows/WinPE in UEFI mode. 2025-02-24 19:17:19 +08:00
longpanda 96f11252d9 support devuan in Legacy BIOS mode. 2025-02-24 19:16:31 +08:00
longpanda 004ad27e0d 1.1.04 release
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-02-22 11:27:31 +08:00
longpanda 9a8dc42d93 Fix the issue introduced in LinuxGUI version. (#3128) 2025-02-22 11:27:18 +08:00
longpanda 6166a813ea 1.1.03
Ventoy CI / build (push) Waiting to run
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Waiting to run
2025-02-21 18:14:18 +08:00
longpanda 786a9ec678 Update Ventoy2Disk.exe
Ventoy CI / build (push) Waiting to run
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Waiting to run
2025-02-21 13:00:15 +08:00
longpanda 0600576c78 Update Linux GUI type condition 2025-02-21 13:00:01 +08:00
longpanda 72b722c86c Fix the boot issue for latest TinyCore Linux. 2025-02-21 12:59:33 +08:00
longpanda bea5607ea5 Fix the boot issue for pfSense 2.7.x (#2775)
Ventoy CI / build (push) Waiting to run
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Waiting to run
2025-02-21 00:29:38 +08:00
longpanda b3c2bcf58f Fix the issue that SLES/OpenSUSE can not boot after install. (#3125) 2025-02-20 22:07:28 +08:00
longpanda 4e8d8b2e19 Fix Windows 11 error 0x80070001. (#3010 #3029 #3105)
Ventoy CI / build (push) Waiting to run
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Waiting to run
2025-02-19 23:49:03 +08:00
longpanda 60d88cb7b1 1.1.02 release
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-02-12 23:01:35 +08:00
longpanda f7e6bbc70c Fix the "Unsupported vtoy type unknown" error when boot a VDI file created by VirtualBox 7.x 2025-02-12 23:00:27 +08:00
longpanda ee994a0569 github ai version update
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-02-10 21:46:39 +08:00
longpanda 966ed21de7 1.1.01
Ventoy CI / build (push) Waiting to run
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Waiting to run
2025-02-10 20:14:46 +08:00
longpanda ff7ee9c10e 1.1.00 release 2025-01-22 19:32:29 +08:00
f43461a16c loader/linux: Ensure the newc pathname is NULL-terminated (#3082)
Per "man 5 cpio", the namesize in the cpio header includes the trailing
NUL byte of the pathname and the pathname is followed by NUL bytes, but
the current implementation ignores the trailing NUL byte when making
the newc header. Although make_header() tries to pad the pathname string,
the padding won't happen when strlen(name) + sizeof(struct newc_head)
is a multiple of 4, and the non-NULL-terminated pathname may lead to
unexpected results.

Assume that a file is created with 'echo -n aaaa > /boot/test12' and
loaded by grub2:

    linux /boot/vmlinuz
    initrd newc:test12:/boot/test12 /boot/initrd

The initrd command eventually invoked grub_initrd_load() and sent
't''e''s''t''1''2' to make_header() to generate the header:

00000070  30 37 30 37 30 31 33 30  31 43 41 30 44 45 30 30  |070701301CA0DE00|
00000080  30 30 38 31 41 34 30 30  30 30 30 33 45 38 30 30  |0081A4000003E800|
00000090  30 30 30 30 36 34 30 30  30 30 30 30 30 31 36 33  |0000640000000163|
000000a0  37 36 45 34 35 32 30 30  30 30 30 30 30 34 30 30  |76E4520000000400|
000000b0  30 30 30 30 30 38 30 30  30 30 30 30 31 33 30 30  |0000080000001300|
000000c0  30 30 30 30 30 30 30 30  30 30 30 30 30 30 30 30  |0000000000000000|
000000d0  30 30 30 30 30 36 30 30  30 30 30 30 30 30 74 65  |00000600000000te|
                                                                  ^namesize
000000e0  73 74 31 32 61 61 61 61  30 37 30 37 30 31 30 30  |st12aaaa07070100|
                   ^^ end of the pathname

Since strlen("test12") + sizeof(struct newc_head) is 116 = 29 * 4,
make_header() didn't pad the pathname, and the file content followed
"test12" immediately. This violates the cpio format and may trigger such
error during linux boot:

    Initramfs unpacking failed: ZSTD-compressed data is trunc

To avoid the potential problems, this commit counts the trailing NUL byte
in when calling make_header() and adjusts the initrd size accordingly.

Now the header becomes

00000070  30 37 30 37 30 31 33 30  31 43 41 30 44 45 30 30  |070701301CA0DE00|
00000080  30 30 38 31 41 34 30 30  30 30 30 33 45 38 30 30  |0081A4000003E800|
00000090  30 30 30 30 36 34 30 30  30 30 30 30 30 31 36 33  |0000640000000163|
000000a0  37 36 45 34 35 32 30 30  30 30 30 30 30 34 30 30  |76E4520000000400|
000000b0  30 30 30 30 30 38 30 30  30 30 30 30 31 33 30 30  |0000080000001300|
000000c0  30 30 30 30 30 30 30 30  30 30 30 30 30 30 30 30  |0000000000000000|
000000d0  30 30 30 30 30 37 30 30  30 30 30 30 30 30 74 65  |00000700000000te|
                                                                  ^namesize
000000e0  73 74 31 32 00 00 00 00  61 61 61 61 30 37 30 37  |st12....aaaa0707|
                      ^^ end of the pathname

Besides the trailing NUL byte, make_header() pads 3 more NUL bytes, and
the user can safely read the pathname without a further check.

To conform to the cpio format, the headers for "TRAILER!!!" are also
adjusted to include the trailing NUL byte, not ignore it.


Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Signed-off-by: Gary Lin <glin@suse.com>
Co-authored-by: Gary Lin <glin@suse.com>
2025-01-22 19:19:29 +08:00
longpanda 377e3fb7bc Fix the boot issue of SystemRescue 11.02+ (#2958) (#3058) 2025-01-22 19:07:08 +08:00
longpanda f62bd1be14 support eweOS ISO (#3068) 2025-01-22 18:24:09 +08:00
longpanda b11c38779d docker file 2024-11-16 17:00:25 +08:00
longpanda f202542c62 docker compose up 2024-11-16 12:38:43 +08:00
longpanda 279491a36a Update to latest Shim (Fix verifying shim SBAT data failed) #2947 2024-11-16 12:34:39 +08:00
longpanda cb209f9b9e 1.0.99 2024-06-08 17:26:33 +08:00
Andrei StepanovandGitHub b7b2f6a5c1 Update Russian translation (#2857) 2024-06-08 17:10:31 +08:00
3967fb5fb5 Fix French language (#2850)
Co-authored-by: tamdaz <tamda.zohir.pro@gmail.com>
2024-06-08 17:10:07 +08:00
bovirusandGitHub a2ad95792d Fixed Italian language (#2840) 2024-06-08 17:09:53 +08:00
Re*Index. (ot_inc)andGitHub 791308d2ce Japanese Fix typo. (#2839)
* Japanese translation Fixed.

* Fix typo

Fix Typo.
2024-06-08 17:09:26 +08:00
longpanda 0ffb1b15ef Fix the issue that VTOY_LINUX_REMOUNT option does not take effect in latest openSUSE. (#2551) 2024-05-25 18:13:52 +08:00
longpanda d6e1730ca0 Fix the install issue for /dev/mdX device. (#2846) 2024-05-23 19:30:11 +08:00
longpanda 4d55f505f9 Fix the UEFI boot issue for some computer. 2024-05-22 22:53:55 +08:00
longpanda 30a61ac5c4 1.0.98 release 2024-05-19 23:14:49 +08:00
Re*Index. (ot_inc)andGitHub 9b79831516 Japanese translation Fixed. (#2808) 2024-05-19 16:43:20 +08:00
jermanutsandGitHub af2d6bc247 Update ar_AR.json (#2755)
* Update ar_AR.json

* Update ar_AR.json
2024-05-19 16:41:51 +08:00
bovirusandGitHub d8ae740427 Update Italian help/menu (#2752) 2024-05-19 16:41:37 +08:00
Samuel JohnsonandGitHub b685157ae3 Minor Update on README.md for Consistency (#2687) 2024-05-19 16:41:12 +08:00
Fabian-GruenbichlerandGitHub 3f6ddb6fb6 support zvol devices (#2678)
their partitions are exposed as "/dev/zdXXpY", handle accordingly.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-05-19 16:39:34 +08:00
Zhymabek RomanandGitHub b8838b305d Adding root user check to ExtendPersistentImg (as in CreatePersistentImg) (#2633)
* Adding root user check & Enhance help info

* Update root user check
2024-05-19 16:35:22 +08:00
BatuhanandGitHub 00de8b932d Update tr_TR.txt (#2618)
corrected grammar mistakes, fixed typos
2024-05-19 16:29:13 +08:00
WebSnkeandGitHub 1e49dbe957 Update German translation (#2612) 2024-05-19 16:28:35 +08:00
Ida BagusandGitHub 580416facc Update languages.json (#2600)
minor update for indonesian language
2024-05-19 16:28:25 +08:00
75cf728fa9 The gpt pointer is not initialized, and when offset < 0, it may result in freeing unallocated memory. (#2499)
Signed-off-by: yuxiaojun <yuxiaojun1011@outlook.com>
Co-authored-by: yuxiaojun <yuxiaojun1011@outlook.com>
2024-05-19 16:27:19 +08:00
Ikko Eltociear AshimineandGitHub 8723aeb4cc fix typo in diskio.h (#2497)
fucntion -> function
2024-05-19 16:25:42 +08:00
SunderBandGitHub dc9a99bb20 Correct some spelling and grammar in BuildVentoyFromSource.txt (#2491) 2024-05-19 16:24:41 +08:00
Hoang NguyenandGitHub a40456d9d2 Added Vietnamese language support for GRUB and updated Vietnamese translation of the installer (#2362)
* Updated Vietnamese language

Added new translation for `STR_4KN_UNSUPPORTED` and retouched in some places

* Added Vietnamese language support for GRUB menu

* Removed vi_VN from helplist and menulist
2024-05-19 16:17:54 +08:00
Balázs ÚrandGitHub bdab55e8aa Updated Hungarian translation (#2836) 2024-05-19 16:11:30 +08:00
longpanda 1b2483ec14 Skip trash directory by default. (#2831) 2024-05-19 16:00:46 +08:00
longpanda c16e76130b Fix VTOY_LINUX_REMOUNT option for latest CentOS 9 Stream. (#2827) 2024-05-19 15:35:05 +08:00
longpanda d672af4819 Support ext4 fs with checksum seed feature. 2024-05-19 12:14:02 +08:00
longpanda 712f10e86a Fix VTOY_LINUX_REMOUNT feature in RHEL 9.4+ (#2827) 2024-05-14 14:59:12 +08:00
longpanda 2be340d2e8 update 2024-05-12 14:57:19 +08:00
longpanda b77ef718b4 bugfix 2024-05-12 12:37:12 +08:00
longpanda 72f5710b88 Fix arch iso boot issue (#2825 #2824) 2024-05-12 12:36:58 +08:00
longpanda ee7da60d88 Fix the boot issue for latest KAOS. 2024-04-06 23:53:07 +08:00
longpanda 44fb9f4564 Fix the VTOY_LINUX_REMOUNT option on latest linux kernel 2024-04-06 21:22:17 +08:00
longpanda 3f65f0ef03 1.0.97 release 2024-01-24 15:02:32 +08:00
longpanda 4faa5e4344 update tool 2024-01-24 13:35:27 +08:00
longpanda c7693d4ecd Fix VTOY_LINUX_REMOUNT option does not work with latest linux kernel version. (#2661 #2674) 2024-01-24 12:09:29 +08:00
longpanda 4527e1db79 Add support for FreeBSD 14.0 2024-01-23 09:08:23 +08:00
longpanda 757cacf274 Fix Proxmox 8.1 boot issue. (#2657) 2023-12-04 23:00:31 +08:00
longpanda 39703cabb7 Fix the VentoyPlugson issue that default_file value is wrong for more than 10 theme files. (#2608) 2023-10-14 22:15:24 +08:00
longpanda 854d17a4e9 1.0.96 release 2023-10-06 22:39:39 +08:00
Maicol BattistiniandGitHub a326b13fc3 Added italian translation (#2580) 2023-10-06 22:33:17 +08:00
longpanda 3ff1867a2a Fix the warning prompt for Ventoy2Disk.sh (#2593) 2023-10-06 22:05:39 +08:00
longpanda 7f63a1c327 Fix the issue that VTOY_LINUX_REMOUNT=1 does not work on some distros (e.g. Pop OS/openSUSE/Ubuntu 23.04) (#2475 #2551) 2023-10-06 21:12:34 +08:00
longpanda d617985093 Add escaping for path in VentoyPlugson.sh (#2585) 2023-10-06 16:43:26 +08:00
longpanda 605da1ba94 Fix that bootpwd not working for VentoyPlugson. (#2584) 2023-10-03 23:49:22 +08:00
longpanda c8dc36a5c3 1.0.95 release 2023-08-23 09:26:53 +08:00
I'm an OSK user, are you?andGitHub 689f7df902 Update Swedish language (#2443) 2023-08-22 11:34:38 +08:00
Sönke JoppienandGitHub a9d53e7448 Update German translation (#2500) 2023-08-22 11:33:48 +08:00
Hugo CarvalhoandGitHub 46061bcd41 Update languages.json (#2504)
Update Portuguese (Portugal) translation
2023-08-22 11:33:34 +08:00
FelipeandGitHub 01b0de7811 Updated brazilian portuguese translation - aside that included 2 missing translations. (#2533)
* Updated brazilian portuguese translation

Translated one string that wasnt translated and fixed the other ones.

* Added a brazilian portuguese file

It was missing one, suggested by https://www.ventoy.net/en/doc_menu_language.html

* Added a brazilian portuguese file

One was missing, again this is also a suggestion of https://www.ventoy.net/en/doc_menu_language.html
2023-08-22 11:23:15 +08:00
longpanda 2fee243a56 Support drag resize dialog window width. 2023-08-22 11:21:17 +08:00
longpanda d0e10f8e48 Support veket_24 2023-07-31 23:33:25 +08:00
longpanda 7ff243f9bb Fix the media missing issue when boot UOS server ISO file. 2023-07-30 12:58:29 +08:00
longpanda f8811a4656 1.0.94 release 2023-07-20 11:54:46 +08:00
VenusGirl❤andGitHub 0ce90ad9b9 Update ko_KR.json (#2483) 2023-07-20 11:00:38 +08:00
VasilisandGitHub 5bfddae81d Update languages.json (#2482)
Greek language update
2023-07-20 11:00:21 +08:00
YALdysseandGitHub 2991f097fb fixed ukrainian translation (#2469)
* Update uk_UA.txt

* fix ukrainian translation
2023-07-20 10:59:48 +08:00
StanislavandGitHub 986835338d i18n: Small fix Russian language (#2473)
* i18n: Small fix Russian language

* Update languages.json
2023-07-20 10:59:34 +08:00
bovirusandGitHub f2562fecb9 Update italian strings (#2465) 2023-07-20 10:58:08 +08:00
Jianfeng LiuandGitHub 529541f218 fix Synchronous Exception on some arm cpus (#2488) 2023-07-20 10:56:55 +08:00
longpanda 430f81ac49 cc 2023-06-23 23:07:21 +08:00
longpanda 038c0533d9 1.0.92 release 2023-06-23 21:29:51 +08:00
lollilolandGitHub 102b179cd9 change password input field to type=password (#2427) 2023-06-23 16:28:38 +08:00
Kosta StojiljkovicandGitHub 6785f5d049 Added Serbian translation for STR_4KN_UNSUPPORTED strings for cyrilic and latin scripts. (#2406) 2023-06-23 16:27:11 +08:00
William Poetra YogaandGitHub 0c812ed5e9 fix: grep warning (#2398) 2023-06-23 16:26:55 +08:00
Blaž OsredkarandGitHub 9f2b9b0867 Added Slovenian language (#2378) 2023-06-23 16:26:19 +08:00
wiz64andGitHub c79b072680 Update languages.json (viva l' ventoy) (#2372) 2023-06-23 16:25:39 +08:00
Nikolas GarofilandGitHub 6b4509a550 Environment typos (#2368) 2023-06-23 16:24:36 +08:00
longpanda feea11e2bb Support unattended auto install for Deepin/UOS 2023-05-29 00:11:21 +08:00
A1iveandGitHub 35c952d891 Correct EFI chainloader image device path (#2397) 2023-05-19 23:23:14 +08:00
Dolphin OracleandGitHub 82053680bf Update ventoy-hook.sh for MX Linux (#2390)
due to a systemd issue, we had to rename initrd-release to initrd_release.
2023-05-15 12:30:03 +08:00
longpanda 6d5de12f52 Merge branch 'master' of https://github.com/ventoy/Ventoy 2023-04-21 20:05:40 +08:00
longpanda 84b2ee7ee3 Fix the boot issue for Fedora/CentOS when file name contains special character (e.g. '(' ) #2360 2023-04-21 20:05:30 +08:00
K.B.Dharun KrishnaandGitHub da1b306e81 ci.yml: bump actions to v3 to fix node warning (#2341) 2023-04-13 19:25:31 +08:00
longpanda 0961ce5624 1.0.91 release 2023-04-05 20:41:34 +08:00
longpanda 07574f0379 Improve grub2 mode process for legacy BIOS mode. 2023-04-05 20:16:36 +08:00
SteveandGitHub 142aa47944 fixed german translation (#2318)
* Updated german translation

#2277 has an small issue (misstyping; "nocht" should read "noch")
Changed the translation. It is minimally shorter.

* fixed german translation
2023-04-04 13:54:49 +08:00
longpanda 11739fa9d0 Fix a bug that Fedora boot error if Ventoy partition is NTFS. (#2333) 2023-04-03 21:49:21 +08:00
longpanda 9fc85051a7 Fix the issue for booting Bliss OS 15.x 2023-04-03 09:18:13 +08:00
longpanda b9e82bcf16 Support FreeBSD 14-CURRENT 2023-04-02 13:17:20 +08:00
longpanda cff3a01289 Support NTFS with large cluster size (greater than 64KB). 2023-03-28 11:38:46 +08:00
longpanda 0f90149c4e 1.0.90 release 2023-03-26 19:01:13 +08:00
longpanda 8ef9732931 Update vtoytool 2023-03-26 16:03:32 +08:00
longpanda b32eda4262 Fix the VTOY_LINUX_REMOUNT option for new linux kernel in intel 11th(and later) gen CPU. 2023-03-26 10:45:19 +08:00
longpanda e743f7c15f Add support for chimera linux. (#2309) 2023-03-24 20:43:47 +08:00
longpanda 652475f1ef Optimization for Fedora boot process 2023-03-24 10:37:24 +08:00
longpanda abfc2a6343 Add checksum jif 2023-03-21 15:44:54 +08:00
longpanda e73ac04cb6 update README.md 2023-03-20 17:15:36 +08:00
StoyanDimitrovandGitHub 8727e63880 Update languages.json (#2299) 2023-03-17 17:39:57 +08:00
VenusGirl❤andGitHub 2d281d7dee Update ko_KR.json (#2286)
Korean Update
2023-03-17 17:39:21 +08:00
SteveandGitHub 385c806adf Updated german translation (#2279)
#2277 has an small issue (misstyping; "nocht" should read "noch")
Changed the translation. It is minimally shorter.
2023-03-17 17:39:02 +08:00
longpanda e869bc2386 Fix the issue that Fedora Rawhide install media not detected. (#2283) 2023-03-10 22:33:53 +08:00
longpanda b47aa1abc7 Support LibreELEC 11.0+ (#2281) 2023-03-09 23:59:12 +08:00
longpanda d8698b2194 1.0.89 release 2023-03-07 19:21:15 +08:00
longpanda 7fa4724743 Fix the menu missing issue when there exist an invalid vlnk file. (#2228) 2023-03-07 18:05:33 +08:00
WebSnkeandGitHub 2717405a7a Add German translation for STR_4KN_UNSUPPORTED (#2277) 2023-03-05 20:59:09 +08:00
wiz64andGitHub d494007df9 update japanese (#2264) 2023-03-05 20:58:55 +08:00
Tayfun AkkoyunandGitHub bc9e3f641b Update tr_TR.txt (#2262)
Long translations edited to be shorter
2023-03-05 20:58:32 +08:00
dmitrygribenchukandGitHub 9f02d37001 Update translation (#2261)
* update translation

* update translation
2023-03-05 20:58:16 +08:00
Thunderstrike116andGitHub fa1461bac7 Add Greek Language (#2258)
* Added Greek Translation

* Added Greek Translation
2023-03-05 20:57:55 +08:00
marcellogianolaandGitHub 3d56c3fa17 Update languages.json (#2257) 2023-03-05 20:57:29 +08:00
ИEØ_ΙΙØZandGitHub a7e3d78d14 Update zh_TW.json (#2256) 2023-03-05 20:57:05 +08:00
longpanda 879a7592bd Fix dm_patch for new linux kernel. 2023-02-20 11:59:03 +08:00
longpanda 5a433f49f7 Optimization for booting Fedora series. 2023-02-18 21:33:05 +08:00
Ikko Eltociear AshimineandGitHub 0cce956c54 Fix typo in EXT/README.txt (#2247)
bellow -> below
2023-02-18 21:31:37 +08:00
Ing. Jan KalábandGitHub 0b6372857c Fix typo in Czech translation (#2252)
Thanks to Jiří Červinka
2023-02-18 21:31:19 +08:00
MandGitHub 028663de9a Update Polish translation (#2232) 2023-02-18 21:31:09 +08:00
TyemakandGitHub 5feb3f7b4b Update languages.json (#2230) 2023-02-18 21:30:48 +08:00
longpanda 7035787f38 update languages.json 2023-02-08 10:42:35 +08:00
ИEØ_ΙΙØZandGitHub 7dd0f509f5 Update languages.json (#2207)
Fixed one string for Traditional Chinese,
Sorry, I missed it in my last submission.
2023-02-08 10:37:35 +08:00
andrewczmandGitHub 15947caea2 Updated Polish translation (#2212)
* Update pl_PL.json

A few corrections to the Polish translation

* Update pl_PL.json

small correction

* Update pl_PL.json

the latest update

* Updated Polish translation

Some cosmetic corrections in the Polish translation
2023-02-08 10:36:39 +08:00
YALdysseandGitHub 6aeba8f8b4 fix ukrainian language (#2222) 2023-02-08 10:36:16 +08:00
ИEØ_ΙΙØZandGitHub fd46b2c3c3 Update languages.json (#2204)
add & correct some strings
2023-02-02 15:51:28 +08:00
YALdysseandGitHub e502f4291e Ukrainian language (#2199) 2023-02-02 15:50:22 +08:00
andrewczmandGitHub 9c59c27eff Update pl_PL.json (#2191)
* Update pl_PL.json

A few corrections to the Polish translation

* Update pl_PL.json

small correction

* Update pl_PL.json

the latest update
2023-02-02 15:50:02 +08:00
YALdysseandGitHub daeb96ce80 fixed russian translation (#2190) 2023-02-02 15:49:42 +08:00
YALdysseandGitHub b7e878c466 fixed russian translation (#2189) 2023-02-02 15:49:28 +08:00
VenusGirl❤andGitHub b76ebf5b07 Update languages.json (#2186) 2023-02-02 15:49:10 +08:00
VenusGirl❤andGitHub 9532776f39 Update ko_KR.txt (#2188)
* Update ko_KR.txt

* Update ko_KR.txt
2023-02-02 15:48:43 +08:00
d8e81d41e4 Czech translation (#2185)
* Czech translation

* Fix missing translations

---------

Co-authored-by: Ing. Jan Kaláb <jan@kalabovi.org>
2023-02-02 15:48:16 +08:00
VenusGirl❤andGitHub fa3aa3b36f Update ko_KR.json (#2177)
* Update ko_KR.json

* Update ko_KR.json

* Update ko_KR.json
2023-02-02 15:47:48 +08:00
MELERIXandGitHub e717d00d53 Update Spanish Latinoamérica translation (#2179) 2023-02-02 15:47:30 +08:00
wiz64andGitHub 6bcaf19a1a Update languages.json (#2172) 2023-01-16 15:35:25 +08:00
wiz64andGitHub bcbe8835d4 update Russian and Bengali languages.json (#2167) 2023-01-15 21:10:25 +08:00
gidanoandGitHub ed746ce13e Fixed hungarian text (#2163) 2023-01-15 21:10:11 +08:00
VenusGirl❤andGitHub 07a790fc6a Update languages.json (#2160)
Korean Update
2023-01-15 21:09:54 +08:00
Tayfun AkkoyunandGitHub fd393a02fd Update languages.json (#2159)
"STR_4KN_UNSUPPORTED" line is translated to turkish language
2023-01-15 21:09:37 +08:00
longpanda 0501d03dbb Fix the syntax error in hu_HU.json 2023-01-15 13:15:51 +08:00
longpanda c9939a8cfc Ignore reserved space when do non-destructive installation via GUI. (#2168) 2023-01-15 09:41:46 +08:00
longpanda 5067020a61 Add tip message when theme file contains non-enclosed literal values. (#2166) 2023-01-14 23:07:08 +08:00
longpanda 4f5334026e 1. Fix the issue that Ventoy2Disk_X64.exe can not run under altexe directory.
2. Fix the issue that VentoyPlugson_X64.exe exit silently.
3. Add missing /FS option for Ventoy2Disk.exe in Windows command line mode.
4. Ventoy2Disk.exe automatically change current directory when started from other directory.
2023-01-14 21:56:19 +08:00
longpanda 3e34dd8514 1.0.88 release 2023-01-13 21:57:44 +08:00
longpanda 4df793e021 1. Add new options for Windows CLI mode.
2. Add tip message for 4k native disk.
2023-01-13 20:55:40 +08:00
longpanda e0132ac4b5 switch to en_US when use text mode. 2023-01-10 16:17:08 +08:00
VenusGirl❤andGitHub 2b3192b098 Update ko_KR.json (#2152) 2023-01-10 15:48:22 +08:00
민웅기andGitHub 7ee3a6d9f8 Update ko_KR (부트 -> 부팅) (#2147)
Changed the word "boot" to be spelled "부팅" rather than "부트" in the general context.

일반적인 맥락에서 단어 "boot"는 부트보다 부팅로 표기되므로 변경하였습니다.
2023-01-10 15:09:29 +08:00
Pierfrancesco PasseriniandGitHub e1d3ca9fc4 Update italian language (#2141)
Small fix to Italian
2023-01-10 15:09:17 +08:00
Stefan ŠućurandGitHub 8653832551 Fixed and updated Serbian translations (both writing systems) (#2144)
* Update Serbian (both writing systems)

Fixed a stray Cyrillic word in the Latin text.
Translated the untranslated strings in both texts.
Changed a word in both texts.
Added part of a string that was missing in the Cyrillic version.
Fixed spelling mistakes in the Cyrillic text.

* Update languages.json

Added myself to the credits of the Cyrillic text too, as I forgot to do so earlier.
2023-01-10 15:08:54 +08:00
longpanda c308892db0 Show file checksum menu title according to the existence of checksum value. 2023-01-10 12:23:35 +08:00
longpanda 1300f7f4f1 Fix the VHD(x) boot issue introduced in 1.0.87. 2023-01-10 09:37:05 +08:00
longpanda d9182dbfa4 Fix the syntax error in F4 localboot 2023-01-10 09:17:18 +08:00
longpanda e988c0dfe2 Fix that workaround #2 not working for Legacy BIOS access limit. 2023-01-08 21:35:50 +08:00
longpanda 0714971f8c Fix VTOY_WIN11_BYPASS_CHECK/VTOY_WIN11_BYPASS_NRO option web page display issue. 2023-01-07 20:14:38 +08:00
longpanda 3c03df31ce 1.0.87 release 2023-01-07 15:57:53 +08:00
longpanda e24dacadcd Add /F option for VentoyPlugson.exe to use the system default browser.
By default it will firstly try to use Google Chrome if possible.
2023-01-07 15:35:47 +08:00
longpanda 315cabb945 Fix the file path when file checksum in F2 browse mode. 2023-01-07 11:33:04 +08:00
longpanda 72f25f14fc Merge branch 'master' of https://github.com/ventoy/Ventoy 2023-01-06 21:26:39 +08:00
longpanda 47e1553d23 Optimization for VTOY_WIN11_BYPASS_NRO option process. 2023-01-06 21:26:31 +08:00
MELERIXandGitHub 9a2a7e83eb Add Spanish Translation (json/txt) grub menu (#2135)
* Add Spanish Tranlsation (json/txt) grub menu

* renamed
2023-01-06 12:23:05 +08:00
K.B.Dharun KrishnaandGitHub 5f747148c6 grub/menu: Update Tamil translation (#2133) 2023-01-06 11:55:40 +08:00
longpanda 686ed11037 Optimization for Lenovo Recovery Image (USB unplug process) 2023-01-05 22:18:39 +08:00
longpanda 7fe4762faa 1. grub2 mode supports Porteus ISO file.
2. Optimization for Lenovo Recovery Image.
2023-01-04 21:46:40 +08:00
longpanda eac1c35f76 Fix the bug when F2 browse and boot VHD/VHDX files in an extend logic partition. 2023-01-04 19:22:02 +08:00
longpanda c7dcaa5734 1. Fix the blank item in the last of Language select menu
2. Fix the menu display VTLANG_NO_PERSISTENCE issue when use persistence
2023-01-04 19:19:32 +08:00
longpanda 4b17ee30c4 Add "return to previous menu" in secondary boot menu for convenience. 2023-01-04 15:55:32 +08:00
longpanda a18aa36c01 Code optimization 2023-01-04 15:39:03 +08:00
TyemakandGitHub 1de7489c6d Update ru_RU.txt (#2130) 2023-01-03 20:58:13 +08:00
longpanda afb3340ce7 Disable Fn/L/Ctrl hotkeys when selecting auto install script or perssitence file. 2023-01-03 19:11:36 +08:00
longpanda fdce4a756a Add support for Dell PER ISO. (#2113) 2023-01-03 16:43:17 +08:00
longpanda 5a7fa0c565 Support lenovo product recovery iso file. 2023-01-03 11:35:27 +08:00
longpanda 287d77224c Disable Fn/L/Ctrl hotkeys on select WIM menu. 2023-01-03 11:29:50 +08:00
longpanda c6bd857cbe Support BSD style for .md5/.sha1/.sh256/.sha512 checksum file.
Support VENTOY_CHECKSUM file for checksum file.
(#2112)
2023-01-01 00:31:08 +08:00
wiz64andGitHub b4bb6efd3c Update ru_RU.txt (#2120) 2022-12-31 20:59:08 +08:00
Hildo Guillardi JúniorandGitHub 7386f64ed8 Update pt_PT.json (#2118) 2022-12-31 20:58:50 +08:00
Hildo Guillardi JúniorandGitHub 044ca8811d PT translate and SI grammar (#2117) 2022-12-31 20:58:38 +08:00
TyemakandGitHub 8c6fd872af Update ru_RU.json (#2114) 2022-12-31 20:58:06 +08:00
longpanda 683101ae1a vtoyjump optimization.
Signed-off-by: longpanda <admin@ventoy.net>
2022-12-31 19:41:15 +08:00
longpanda 0e968e266e Update the F1 help text. WIMBOOT mode supports both Windows and WinPE ISO files. 2022-12-29 18:48:06 +08:00
longpanda d94d59583a Search VTEFI directory for UEFI boot files.
When user install for example Windows in the reserved space of Ventoy USB stick in UEFI mode.
Windows will create part 3 as the EFI partition and when you boot the USB stick, the BIOS may skip Ventoy and directly boot the Windows.
To avoid this, we suggest to rename the directory name from EFI to VTEFI.
2022-12-26 22:08:23 +08:00
gidanoandGitHub 05bbef63c1 Edited! (#2105)
* Hungarian translation

* Hungarian translation

* HU update languages.json

Jól értettem, hogy a *#-t módosítani kell \r\n-re?!

* Edited!
2022-12-26 17:01:43 +08:00
longpanda 8923d4b8f1 Fix the menu title of F5 Tools ---> Power ---> $VTLANG_POWER_REBOOT_EFIFW 2022-12-26 16:56:53 +08:00
longpanda 377cd9e468 Update readme 2022-12-25 17:23:50 +08:00
longpanda be78728342 1.0.86 release 2022-12-24 21:19:31 +08:00
Tayfun AkkoyunandGitHub 3938fbb351 Update tr_TR.json (#2101) 2022-12-24 15:59:32 +08:00
longpanda a2e7afd893 Update menu language translation 2022-12-24 10:16:13 +08:00
wiz64andGitHub 27bb4a1168 Update bn_BN.json (#2100) 2022-12-24 10:06:41 +08:00
wiz64andGitHub b8b8c7bd66 Update hi_HI.json (#2099) 2022-12-24 10:06:29 +08:00
longpanda 12b51bcf09 Change the prompt format when check device failed. (#2094) 2022-12-24 09:39:27 +08:00
longpanda 911d5dcab9 Remove useless BypassStorageCheck registry when VTOY_WIN11_BYPASS_CHECK is set to 1. (#1873) 2022-12-23 23:41:57 +08:00
longpanda f597497da6 1. Add VTOY_WIN11_BYPASS_NRO option in Global Control Plugin.
2. Change the default value of VTOY_WIN11_BYPASS_CHECK and VTOY_WIN11_BYPASS_NRO options to 1.
2022-12-23 23:17:39 +08:00
Frede HandGitHub 54bca8c942 Added Danish (Dansk) to languages.json (#2096) 2022-12-23 16:01:45 +08:00
VenusGirl❤andGitHub 6b422ad9c1 Update ko_KR.json (#2092) 2022-12-23 15:54:27 +08:00
wiz64andGitHub 925d057883 Update ru_RU.json (#2091) 2022-12-23 15:54:08 +08:00
longpanda a377dd6172 Support config ventoy_left/ventoy_top/ventoy_color in theme.txt.
The configuration must be the first line in theme.txt and must be in the following format.
ventoy_left_top_color: "@5%@95%@#0000ff@"

The format is very strict:
1. ventoy_left_top_color must start with no space in front of.
2. left/top/color options must be around with 4 @
2022-12-23 15:52:43 +08:00
longpanda 4707022ef9 Add prompt and wait for key when Ventoy check device failed. (#2094) 2022-12-23 11:42:22 +08:00
Tayfun AkkoyunandGitHub e03c73978a Update tr_TR.json (#2090)
New Turkish menu interface lines is translated (VTLANG_CTRL_TEMP_SET,VTLANG_WIN11_BYPASS_CHECK,VTLANG_LINUX_REMOUNT,VTLANG_SECONDARY_BOOT_MENU)
2022-12-22 23:13:49 +08:00
longpanda f434d1f5d0 Add Temporary Control Settings menu.
Refer https://www.ventoy.net/en/doc_ctrl_settings.html for details.
2022-12-22 22:14:51 +08:00
longpanda 23f8bc8aeb Add resolution_fit option in theme plugin. 2022-12-22 18:26:01 +08:00
wiz64andGitHub f2016ab899 Update Actions Image route (#2088) 2022-12-22 14:28:52 +08:00
wiz64andGitHub 7acbf7e819 Update bn_BN.json (#2085) 2022-12-22 14:28:38 +08:00
Ida BagusandGitHub 0135bf1934 Update languages.json (#2087) 2022-12-22 10:04:22 +08:00
wiz64andGitHub f2c94bd963 Improve grammar (Readme.md) (#2086) 2022-12-22 10:04:01 +08:00
longpanda 676ae725ae Fix the egrep warning. (#2083) 2022-12-21 19:59:16 +08:00
longpanda 54dd35d277 Merge branch 'master' of https://github.com/ventoy/Ventoy 2022-12-21 13:22:11 +08:00
longpanda 3e75b2df3b VentoyPlugson: Add Windows duplicate file path check for different upper/lower case. 2022-12-21 13:21:54 +08:00
wiz64andGitHub 2d1230cba4 Update hi_HI.json (#2081) 2022-12-20 21:17:49 +08:00
wiz64andGitHub 309f85fd35 update ru_RU.json (#2080)
* Update ru_RU.json

* Update ru_RU.json
2022-12-20 21:17:41 +08:00
VenusGirl❤andGitHub a13d6d9c0e Update ko_KR.json (#2079) 2022-12-20 21:17:24 +08:00
longpanda 9b7d6cbc3d Add theme plugin duplicate file check. (#2078) 2022-12-20 20:02:06 +08:00
longpanda bf797ceadb Fix the drive letter case check issue for VentoyPlugson in Windows. (#2078) 2022-12-20 18:46:04 +08:00
longpanda cd0c7ca884 Extend the donate link width. 2022-12-20 14:05:01 +08:00
longpanda 201f7cc13c Change the MBR partition type to 0x0C when select FAT32 for installation. 2022-12-20 00:16:01 +08:00
longpanda 44a3e23740 Optimization for the implement of menu languages. 2022-12-19 23:49:25 +08:00
andGitHub 9c3e1a6880 update Japanese translation (#2077)
* Remove unnecessary space.

* Unify the translation terms into which used in other files
  (language.json, help/ja_JP.txt...)
2022-12-19 22:21:27 +08:00
wiz64andGitHub 8a664faa04 Update languages.json (#2076) 2022-12-19 22:20:51 +08:00
Hoàng Điềm TĩnhandGitHub 398ba9fb56 Update languages.json (#2075)
I update for Vietnamese lang. Please add to your the next release.
2022-12-19 22:20:34 +08:00
Tayfun AkkoyunandGitHub e7a0c2d359 Update languages.json (#2074)
hi master
STR_DONATE parameter is translated for turkish users again
2022-12-19 22:20:07 +08:00
longpanda 22ad828df2 1.0.85 release 2022-12-18 22:11:28 +08:00
longpanda 83f22173a5 menu language update 2022-12-18 17:30:29 +08:00
longpanda 2de7d9ffe0 Suppress some prompt window when install Ventoy. 2022-12-17 23:36:59 +08:00
TyemakandGitHub 5c174c4521 Update languages.json (russian translation) (#2070)
* Update languages.json

* Update languages.json
2022-12-17 23:34:03 +08:00
longpanda c76ece4b74 Fix the format failure when install Ventoy. 2022-12-16 17:03:05 +08:00
longpanda 27eda4d1e7 Fix the issue when booting Peux distro iso file. 2022-12-13 12:17:46 +08:00
longpanda acf5a84467 Add Arabic menu language. 2022-12-12 11:00:57 +08:00
longpanda c93e406aa5 Add missing file. 2022-12-11 21:59:09 +08:00
longpanda 1b164e74e4 update pl_PL.json 2022-12-11 10:49:02 +08:00
longpanda 308cb86f83 Fix json syntax error. 2022-12-11 10:30:31 +08:00
longpanda 2ec593d355 Add pl_PL language for menu. 2022-12-11 10:22:39 +08:00
longpanda 594e735b91 Merge branch 'master' of https://github.com/ventoy/Ventoy 2022-12-10 19:27:49 +08:00
longpanda 6203366040 grub2 mode support KNOPPIX 2022-12-10 19:27:38 +08:00
Thomas De RockerandGitHub 64f4400305 Update languages.json (#2046) 2022-12-10 17:32:03 +08:00
d00e08e2e1 added Georgian (ka_GE) translation (json/txt) for grub menu (#2044)
Co-authored-by: Alexander Dolidze <alexander.dolidze@azry.com>
2022-12-10 17:31:48 +08:00
Hugo CarvalhoandGitHub c6008be394 Update Portuguese(Portugal) Translation (#2039)
* Update languages.json

Update Portuguese (Portugal) language

* Update Portuguese(Portugal) Translation

* Update Portuguese(Portugal) Translation
2022-12-10 17:31:31 +08:00
longpanda a5c6859f5f Add zh_TW menu language. 2022-12-09 21:36:32 +08:00
longpanda 497d4cc991 update grub2 mod file 2022-12-09 21:33:59 +08:00
VenusGirl❤andGitHub 7e7687afe3 Update ko_KR.txt (#2038) 2022-12-08 21:11:04 +08:00
Ida BagusandGitHub dd3276badf Update id_ID.json (#2034)
first translation, if they find unrelevant translation, i will update it later
2022-12-08 21:10:49 +08:00
Ida BagusandGitHub 4a06f4a694 Update id_ID.txt (#2033)
fix little translation
2022-12-08 21:10:34 +08:00
SilejonuandGitHub c73bf256be French translation additions & corrections (#2032)
* Update fr_FR.txt

* Update fr_FR.json
2022-12-08 21:10:17 +08:00
longpanda 21851f7e96 Optimization for booting memtest86-usb.img. 2022-12-05 11:19:46 +08:00
longpanda f222f8cac9 Auto memdisk plugin support some IMA/IMG files. 2022-12-05 10:51:15 +08:00
gidanoandGitHub 40c4825aac Hungarian translation (#2028)
* Hungarian translation

* Hungarian translation
2022-12-04 18:42:53 +08:00
VenusGirl❤andGitHub dd906e0b16 Update ko_KR.txt (#2025) 2022-12-04 17:38:48 +08:00
K.B.Dharun KrishnaandGitHub 324f2b927c grub/*: add Tamil translation (#2023)
* grub/menu: Add Tamil translation

Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>

* grub/help: Add Tamil translation

Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>

Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>
2022-12-04 17:38:32 +08:00
K.B.Dharun KrishnaandGitHub 5797ca3396 grub/help/en_US: Fix typos (#2024)
* grub/help/en_US: Fix typos

* Apply suggestions from code review

* Fix typo in line 15
2022-12-04 17:37:25 +08:00
longpanda b36b322c03 Update languages.json 2022-12-04 17:33:46 +08:00
longpanda fd7e34b632 1.0.84 release 2022-12-04 15:33:16 +08:00
longpanda e85c02756b 1.0.83 release 2022-12-04 13:15:18 +08:00
wiz64andGitHub c1d68bd787 Add Russian Tranlsation (json/txt) grub menu (#2022) 2022-12-04 11:18:33 +08:00
wiz64andGitHub a35a822723 add Bengali (bn_BN.json/txt) (#2019) 2022-12-04 09:22:26 +08:00
Tayfun AkkoyunandGitHub 05137c83e2 Update tr_TR.txt (#2020)
tr_TR.txt Help file is updated.
2022-12-04 09:21:58 +08:00
VenusGirl❤andGitHub 8058856182 Update ko_KR.json (#2021) 2022-12-04 09:21:36 +08:00
longpanda 33b958e112 Update language json files 2022-12-03 21:37:09 +08:00
Tayfun AkkoyunandGitHub 9eb50a85e4 Update tr_TR.json (#2018)
Master hi!
I translated lines again. Can you UPDATE this file again?
2022-12-03 20:17:13 +08:00
SteveandGitHub 3cc7e3772e german translation (grub and related help) (#2016)
* updated german translation

translated the new strings

* german translation updated

* fixed STR_INSTALL_YES_TIP2

* german translation

* fix for F6

* german translation
2022-12-03 20:16:31 +08:00
longpanda 9c8292867f Update menu langauge json file 2022-12-03 17:53:42 +08:00
wiz64andGitHub a4053d2d05 add grub/menu hi.json (hindi) (#2014)
* add grub/menu hi.json (hindi)

* Update hi.json

* Update hotkey and rename

* Update and rename hi_HI.json to hi.json

* Rename hi.json to hi_HI.json

* Update hi_HI.json

* add grub/help/hi_HI.txt (hindi)
2022-12-03 17:45:47 +08:00
longpanda 5c14ea0a4a Add some menu language xx.json template. (copy from English) 2022-12-03 16:51:03 +08:00
longpanda 194e948cb6 Remove VTOY_HELP_TXT_LANGUAGE option from Global Control Plugin. 2022-12-03 14:33:52 +08:00
K.B.Dharun KrishnaandGitHub c896c03efe language.json: Update Tamil translation (#2009) 2022-12-03 13:52:47 +08:00
wiz64andGitHub 574b4d850c Update French [languages.json] (#2015) 2022-12-03 13:52:23 +08:00
wiz64andGitHub 68a98325e6 Update German [languages.json] (#2006) 2022-12-03 13:52:08 +08:00
longpanda 25b055bb0f Hotkey change:
1. Change F1 from Memdisk to help
2. Add d/Ctrl+d for Memdisk
3. Add L for Language selection

So update the help txt files and menu json files at the same time.
2022-12-03 13:44:46 +08:00
longpanda bda74cd89b VentoyPlugson supports multi-language menu option. 2022-12-02 20:46:57 +08:00
longpanda 511b8091eb Add muli-languages support for Ventoy menu.
F5 ---> Menu Language Select
Language files are in INSTALL/grub/menu/ directory.
2022-12-02 20:35:59 +08:00
VenusGirl❤andGitHub 3be4aacd78 Update languages.json (#2003) 2022-12-02 20:26:34 +08:00
wiz64andGitHub 2d8b27b172 Update Hindi & Bengali languages (#2002) 2022-12-02 20:26:21 +08:00
wiz64GitHubcezarlacatus 42448787+cezarlacatus@users.noreply.github.com
c174410d35 Update Romanian Translation (#2001)
Co-authored-by: cezarlacatus 42448787+cezarlacatus@users.noreply.github.com
2022-12-02 20:26:06 +08:00
wiz64andGitHub f83e84f868 Fixed syntax errors for recent PRs (#1999) 2022-12-02 20:25:50 +08:00
dmitrygribenchukandGitHub a39078b87a add belarussian and update ukranian and russian (#1998) 2022-12-02 11:42:59 +08:00
Tayfun AkkoyunandGitHub 2576235f97 Turkish update_language.json (#1996)
New Turkish translate rows are completed
2022-12-02 11:42:31 +08:00
longpanda ee04af5243 Ventoy2Disk update:
1. Add UDF filesytem option.
2. Add Cluster Size option.
3. Support FAT32 for disk bigger than 32GB.
4. Fix the format fail issue.
5. Add a tip bubble with cluster size when mouse hover on the file system type string.
6. The secure boot lock character can not show in early Windows, change it to a yellow icon.
2022-11-30 21:12:43 +08:00
Ida BagusandGitHub 118bedd546 Indonesian translation update (#1978)
translating STR_PART_VENTOY_FS row & little change
2022-11-30 20:54:37 +08:00
longpanda 44ff3dd8d4 VentoyPlugson: Fix the garbled preview json for unicode characters. 2022-11-23 14:27:58 +08:00
9da5a6ce65 Update Romanian Translation (languages.json) (#1968)
* Updated Romanian (languages.json)

Co-authored-by: cezarlacatus <42448787+cezarlacatus@users.noreply.github.com>

* Updated Romanian (languages.json)

Co-authored-by: cezarlacatus <42448787+cezarlacatus@users.noreply.github.com>

Co-authored-by: cezarlacatus <42448787+cezarlacatus@users.noreply.github.com>
2022-11-19 19:17:38 +08:00
marcellogianolaandGitHub 604b25ec82 Update languages.json (#1965) 2022-11-19 19:17:14 +08:00
VasilisandGitHub 0918355035 Update languages.json (#1963)
Updated Greek translation
2022-11-18 15:28:32 +08:00
ce76fd5649 Update German, French (#1962)
Co-authored-by: galaxy2211 <56916688+galaxy2211@users.noreply.github.com>

Co-authored-by: galaxy2211 <56916688+galaxy2211@users.noreply.github.com>
2022-11-18 15:28:17 +08:00
MELERIXandGitHub 42535f35bc Update Spanish (Latinoamérica) translation (#1961)
* Update Spanish (Latinoamérica) translation

* Delete languages.json.bak
2022-11-18 15:25:38 +08:00
longpanda 68a9cebe19 1.0.82 release 2022-11-17 17:56:11 +08:00
wiz64andGitHub cc77c74bf4 Update Russian, Hindi, Bengali (languages.json) (#1959) 2022-11-17 17:15:29 +08:00
Tayfun AkkoyunandGitHub ee952e3f69 Turkish update.json (#1960) 2022-11-17 17:15:01 +08:00
longpanda b11a499939 Update BOOT/BOOTX64.EFI and mm efi files from Fedora 37. 2022-11-16 22:34:37 +08:00
longpanda fdf4693433 Ventoy2Disk.exe update.
1. Add exFAT/NTFS/FAT32 option when install Ventoy
2. Display Ventoy partition file system in physical disk
3. String "Status x%" is missing for translations (#1667)
2022-11-16 20:33:14 +08:00
VenusGirl❤andGitHub ac65c0fb24 Update languages.json (#1957) 2022-11-16 19:45:15 +08:00
wiz64andGitHub ea0afe7c8b Update Bengali Translation (#1956) 2022-11-16 19:44:58 +08:00
wiz64andGitHub f8ca8b13d3 Update Hindi Translation (#1941) 2022-11-16 17:56:04 +08:00
longpanda 678a2abdf1 Fix the disk display error when pCloud virtual disk is installed in Windows OS. 2022-11-13 19:29:49 +08:00
longpanda e645301713 Optimization for Windows unattended install process. 2022-11-10 10:10:10 +08:00
longpanda 43b415c032 Fix an issue that CGI backup tool can not open in WePE. 2022-11-08 15:27:08 +08:00
longpanda 311d2961ca Fix the issue that help line disappears when auto-going to a submenu. (#1939) 2022-11-02 20:13:12 +08:00
longpanda 1d66584190 Change Ventoy LiveCD GUI default language to English (#1938) 2022-10-31 09:40:10 +08:00
longpanda 553c853865 Fix the issue that Linux WEB/GUI does not restore MBR when updating. (#1935) 2022-10-30 13:39:19 +08:00
longpanda 7d90912a09 Add VTOY_SHOW_PASSWORD_ASTERISK option in global control plugon. (#1931) 2022-10-26 15:27:51 +08:00
383 changed files with 23383 additions and 4116 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ body:
attributes: attributes:
label: Ventoy Version label: Ventoy Version
description: What version of ventoy are you running? description: What version of ventoy are you running?
placeholder: 1.0.80 placeholder: 1.0.96
validations: validations:
required: true required: true
- type: dropdown - type: dropdown
+8 -8
View File
@@ -12,26 +12,26 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Run docker-compose up - name: Run docker compose up
run: docker-compose up run: docker compose up
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v4
with: with:
name: ventoy-windows name: ventoy-windows
path: INSTALL/ventoy-*windows* path: INSTALL/ventoy-*windows*
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v4
with: with:
name: ventoy-linux name: ventoy-linux
path: INSTALL/ventoy-*linux* path: INSTALL/ventoy-*linux*
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v4
with: with:
name: ventoy-livecd name: ventoy-livecd
path: INSTALL/ventoy-*livecd* path: INSTALL/ventoy-*livecd*
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v4
with: with:
name: SHA256SUM name: SHA256SUM
path: INSTALL/sha256.txt path: INSTALL/sha256.txt
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v4
with: with:
name: xxx-build-log name: xxx-build-log
path: DOC/build.log path: DOC/build.log
+194
View File
@@ -0,0 +1,194 @@
<table>
<thead>
<tr>
<th>BLOB</th>
<th>File Source</th>
<th>Desc</th>
</tr>
</thead>
<tbody>
<tr> <td>./BUSYBOX/chmod/vtchmod32</td> <td rowspan=5>build</td> <td rowspan=5>Build Instructions:<br/> ./BUSYBOX/chmod/build.sh</td> </tr>
<tr> <td>./BUSYBOX/chmod/vtchmod64</td> </tr>
<tr> <td>./BUSYBOX/chmod/vtchmod64_musl</td> </tr>
<tr> <td>./BUSYBOX/chmod/vtchmodaa64</td> </tr>
<tr> <td>./BUSYBOX/chmod/vtchmodm64e</td> </tr>
<tr> <td>./cryptsetup/veritysetup32</td> <td rowspan=2>build</td> <td rowspan=2>Build Instructions:<br/> ./cryptsetup/cryptsetup-build.txt</td> </tr>
<tr> <td>./cryptsetup/veritysetup64</td> </tr>
<tr> <td>./DMSETUP/dmsetup32</td> <td rowspan=4>build</td> <td rowspan=4>Build Instructions:<br/> ./DMSETUP/build.txt</td> </tr>
<tr> <td>./DMSETUP/dmsetup64</td> </tr>
<tr> <td>./DMSETUP/dmsetupaa64</td> </tr>
<tr> <td>./DMSETUP/dmsetupm64e</td> </tr>
<tr> <td>./FUSEISO/vtoy_fuse_iso_32</td> <td rowspan=3>build</td> <td rowspan=3>Build Instructions:<br/> ./FUSEISO/build.sh<br/>./FUSEISO/build_aarch64.sh<br/>./FUSEISO/build_libfuse.sh<br/>./FUSEISO/build_libfuse_aarch64.sh </td> </tr>
<tr> <td>./FUSEISO/vtoy_fuse_iso_64</td> </tr>
<tr> <td>./FUSEISO/vtoy_fuse_iso_aa64</td> </tr>
<tr> <td>./IMG/cpio_arm64/ventoy/busybox/a64</td> <td>build</td> <td>Build Instructions:<br/>./BUSYBOX/build.txt ash</td> </tr>
<tr> <td>./IMG/cpio_arm64/ventoy/busybox/vtchmodaa64</td> <td>build</td> <td>Same with ./BUSYBOX/chmod/vtchmodaa64<br/>Check the file hash to confirm</td> </tr>
<tr> <td>./IMG/cpio_arm64/ventoy/busybox/xzminidecaa64</td> <td>build</td> <td>Build Instructions:<br/>./DOC/BuildVentoyFromSource.txt 4.17</td> </tr>
<tr> <td>./IMG/cpio_arm64/ventoy/tool/lz4cataa64</td> <td>build</td> <td>Same with ./LZIP/lz4cataa64<br/>Check the file hash to confirm</td> </tr>
<tr> <td>./IMG/cpio_arm64/ventoy/tool/zstdcataa64</td> <td>build</td> <td>Same with ./ZSTD/zstdcataa64<br/>Check the file hash to confirm</td> </tr>
<tr> <td>./IMG/cpio_mips64/ventoy/busybox/m64</td> <td>build</td> <td>Build Instructions:<br/>./BUSYBOX/build.txt ash</td> </tr>
<tr> <td>./IMG/cpio_mips64/ventoy/busybox/vtchmodm64e</td> <td>build</td> <td>Same with ./BUSYBOX/chmod/vtchmodm64e<br/>Check the file hash to confirm</td> </tr>
<tr> <td>./IMG/cpio_mips64/ventoy/busybox/xzminidecm64e</td> <td>build</td> <td>Build Instructions:<br/>./DOC/BuildVentoyFromSource.txt 4.18</td> </tr>
<tr> <td>./IMG/cpio_mips64/ventoy/tool/lz4catm64e</td> <td>build</td> <td>Same with ./LZIP/lz4catm64e<br/>Check the file hash to confirm</td> </tr>
<tr> <td>./IMG/cpio_x86/ventoy/busybox/64h</td> <td>build</td> <td>Build Instructions:<br/>./BUSYBOX/build.txt ash</td> </tr>
<tr> <td>./IMG/cpio_x86/ventoy/busybox/ash</td> <td>upstream</td> <td>Download from BusyBox website.<br/>URL & File Hash documented in<br/> ./DOC/BuildVentoyFromSource.txt 5.4</td> </tr>
<tr> <td>./IMG/cpio_x86/ventoy/busybox/vtchmod32</td> <td>build</td> <td>Same with ./BUSYBOX/chmod/vtchmod32<br/>Check the file hash to confirm</td> </tr>
<tr> <td>./IMG/cpio_x86/ventoy/busybox/vtchmod64</td> <td>build</td> <td>Same with ./BUSYBOX/chmod/vtchmod64<br/>Check the file hash to confirm</td> </tr>
<tr> <td>./IMG/cpio_x86/ventoy/busybox/vtchmod64_musl</td> <td>build</td> <td>Same with ./BUSYBOX/chmod/vtchmod64_musl<br/>Check the file hash to confirm</td> </tr>
<tr> <td>./IMG/cpio_x86/ventoy/busybox/xzminidec32</td> <td>build</td> <td>Build Instructions:<br/>./DOC/BuildVentoyFromSource.txt 4.15</td> </tr>
<tr> <td>./IMG/cpio_x86/ventoy/busybox/xzminidec64</td> <td>build</td> <td>Build Instructions:<br/>./DOC/BuildVentoyFromSource.txt 4.16</td> </tr>
<tr> <td>./IMG/cpio_x86/ventoy/busybox/xzminidec64_musl</td> <td>build</td> <td>Build Instructions:<br/>./DOC/BuildVentoyFromSource.txt 4.16</td> </tr>
<tr> <td>./IMG/cpio_x86/ventoy/tool/ar</td> <td>upstream</td> <td>Download from BusyBox website.<br/>URL & File Hash documented in<br/> ./DOC/BuildVentoyFromSource.txt 5.2</td> </tr>
<tr> <td>./IMG/cpio_x86/ventoy/tool/inotifyd</td> <td>upstream</td> <td>Download from BusyBox website.<br/>URL & File Hash documented in<br/> ./DOC/BuildVentoyFromSource.txt 5.3</td> </tr>
<tr> <td>./IMG/cpio_x86/ventoy/tool/lz4cat</td> <td>upstream</td> <td>URL & File Hash documented in<br/> ./DOC/BuildVentoyFromSource.txt 5.1</td> </tr>
<tr> <td>./IMG/cpio_x86/ventoy/tool/lz4cat64</td> <td>build</td> <td>Build Instructions:<br/>./LZIP/buildlz4.txt</td> </tr>
<tr> <td>./IMG/cpio_x86/ventoy/tool/zstdcat</td> <td>build</td> <td>Same with ./ZSTD/zstdcat<br/>Check the file hash to confirm</td> </tr>
<tr> <td>./IMG/cpio_x86/ventoy/tool/zstdcat64</td> <td>build</td> <td>Same with ./ZSTD/zstdcat64<br/>Check the file hash to confirm</td> </tr>
<tr> <td>./INSTALL/EFI/BOOT/BOOTAA64.EFI</td> <td rowspan=4>build</td> <td rowspan=4>Build Instructions:<br/> ./DOC/BuildVentoyFromSource.txt 4.1-Build grub2</td> </tr>
<tr> <td>./INSTALL/EFI/BOOT/BOOTMIPS.EFI</td> </tr>
<tr> <td>./INSTALL/EFI/BOOT/grubia32_real.efi</td></tr>
<tr> <td>./INSTALL/EFI/BOOT/grubx64_real.efi</td></tr>
<tr> <td>./INSTALL/EFI/BOOT/BOOTIA32.EFI</td> <td rowspan=3>upstream</td> <td rowspan=3>https://github.com/ValdikSS/Super-UEFIinSecureBoot-Disk </td> </tr>
<tr> <td>./INSTALL/EFI/BOOT/grubia32.efi</td></tr>
<tr> <td>./INSTALL/EFI/BOOT/mmia32.efi</td></tr>
<tr> <td>./INSTALL/EFI/BOOT/BOOTX64.EFI</td> <td rowspan=2>upstream</td> <td rowspan=2>From Rocky Linux 9.8 x86_64 ISO file<br/>Check the file hash to confirm </td> </tr>
<tr> <td>./INSTALL/EFI/BOOT/mmx64.efi</td></tr>
<tr> <td>./INSTALL/tool/aarch64/ash</td> <td rowspan=12>build</td> <td rowspan=12>Build Instructions:<br/>./DOC/BUSYBOX/build.txt</td> </tr>
<tr> <td>./INSTALL/tool/aarch64/hexdump</td></tr>
<tr> <td>./INSTALL/tool/aarch64/xzcat</td></tr>
<tr> <td>./INSTALL/tool/i386/ash</td></tr>
<tr> <td>./INSTALL/tool/i386/hexdump</td></tr>
<tr> <td>./INSTALL/tool/i386/xzcat</td></tr>
<tr> <td>./INSTALL/tool/mips64el/ash</td></tr>
<tr> <td>./INSTALL/tool/mips64el/hexdump</td></tr>
<tr> <td>./INSTALL/tool/mips64el/xzcat</td></tr>
<tr> <td>./INSTALL/tool/x86_64/ash</td></tr>
<tr> <td>./INSTALL/tool/x86_64/hexdump</td></tr>
<tr> <td>./INSTALL/tool/x86_64/xzcat</td></tr>
<tr> <td>./INSTALL/tool/aarch64/Ventoy2Disk.gtk3</td> <td rowspan=6>build</td> <td rowspan=6>Build Instructions:<br/>./LinuxGUI/build_gtk.sh</td> </tr>
<tr> <td>./INSTALL/tool/i386/Ventoy2Disk.gtk3</td></tr>
<tr> <td>./INSTALL/tool/i386/Ventoy2Disk.gtk2</td></tr>
<tr> <td>./INSTALL/tool/mips64el/Ventoy2Disk.gtk3</td></tr>
<tr> <td>./INSTALL/tool/x86_64/Ventoy2Disk.gtk3</td></tr>
<tr> <td>./INSTALL/tool/x86_64/Ventoy2Disk.gtk2</td></tr>
<tr> <td>./INSTALL/tool/aarch64/Ventoy2Disk.qt5</td> <td rowspan=4>build</td> <td rowspan=4>Build Instructions:<br/>./LinuxGUI/build_qt.sh</td> </tr>
<tr> <td>./INSTALL/tool/i386/Ventoy2Disk.qt5</td></tr>
<tr> <td>./INSTALL/tool/mips64el/Ventoy2Disk.qt5</td></tr>
<tr> <td>./INSTALL/tool/x86_64/Ventoy2Disk.qt5</td></tr>
<tr> <td>./INSTALL/tool/aarch64/Plugson</td> <td rowspan=4>build</td> <td rowspan=4>Build Instructions:<br/>./Plugson/build.sh</td> </tr>
<tr> <td>./INSTALL/tool/i386/Plugson</td></tr>
<tr> <td>./INSTALL/tool/mips64el/Plugson</td></tr>
<tr> <td>./INSTALL/tool/x86_64/Plugson</td></tr>
<tr> <td>./INSTALL/tool/aarch64/V2DServer</td> <td rowspan=4>build</td> <td rowspan=4>Build Instructions:<br/>./LinuxGUI/build.sh</td> </tr>
<tr> <td>./INSTALL/tool/i386/V2DServer</td></tr>
<tr> <td>./INSTALL/tool/mips64el/V2DServer</td></tr>
<tr> <td>./INSTALL/tool/x86_64/V2DServer</td></tr>
<tr> <td>./INSTALL/tool/aarch64/mkexfatfs</td> <td rowspan=9>build</td> <td rowspan=8>Build Instructions:<br/>./DOC/BuildVentoyFromSource.txt 4.9<br/>./ExFAT/buidexfat.sh<br/>./ExFAT/buidexfat_aarch64.sh<br/>./ExFAT/buidlibfuse.sh<br/>./ExFAT/buidlibfuse_aarch64.sh<br/></td> </tr>
<tr> <td>./INSTALL/tool/aarch64/mount.exfat-fuse</td></tr>
<tr> <td>./INSTALL/tool/i386/mkexfatfs</td></tr>
<tr> <td>./INSTALL/tool/i386/mount.exfat-fuse</td></tr>
<tr> <td>./INSTALL/tool/mips64el/mkexfatfs</td></tr>
<tr> <td>./INSTALL/tool/mips64el/mount.exfat-fuse</td></tr>
<tr> <td>./INSTALL/tool/x86_64/mkexfatfs</td></tr>
<tr> <td>./INSTALL/tool/x86_64/mkexfatfs_static</td></tr>
<tr> <td>./INSTALL/tool/x86_64/mount.exfat-fuse</td> </tr>
<tr> <td>./INSTALL/tool/aarch64/vlnk</td> <td rowspan=4>build</td> <td rowspan=4>Build Instructions:<br/>./Vlnk/build.sh</td> </tr>
<tr> <td>./INSTALL/tool/i386/vlnk</td></tr>
<tr> <td>./INSTALL/tool/mips64el/vlnk</td></tr>
<tr> <td>./INSTALL/tool/x86_64/vlnk</td></tr>
<tr> <td>./INSTALL/tool/aarch64/vtoycli</td> <td rowspan=4>build</td> <td rowspan=4>Build Instructions:<br/>./vtoycli/build.sh</td> </tr>
<tr> <td>./INSTALL/tool/i386/vtoycli</td></tr>
<tr> <td>./INSTALL/tool/mips64el/vtoycli</td></tr>
<tr> <td>./INSTALL/tool/x86_64/vtoycli</td></tr>
<tr> <td>./INSTALL/ventoy/imdisk/32/imdisk.cpl</td> <td rowspan=6>upstream</td> <td rowspan=6>Download from imdisk project.<br/>URL & File Hash documented in<br/> ./DOC/BuildVentoyFromSource.txt 5.8</td> </tr>
<tr> <td>./INSTALL/ventoy/imdisk/32/imdisk.exe</td></tr>
<tr> <td>./INSTALL/ventoy/imdisk/32/imdisk.sys</td></tr>
<tr> <td>./INSTALL/ventoy/imdisk/64/imdisk.cpl</td></tr>
<tr> <td>./INSTALL/ventoy/imdisk/64/imdisk.exe</td></tr>
<tr> <td>./INSTALL/ventoy/imdisk/64/imdisk.sys</td></tr>
<tr> <td>./INSTALL/ventoy/iso9660_aa64.efi</td> <td rowspan=6>build</td> <td rowspan=6>Build Instructions:<br/>./DOC/BuildVentoyFromSource.txt 4.17</td> </tr>
<tr> <td>./INSTALL/ventoy/udf_aa64.efi</td></tr>
<tr> <td>./INSTALL/ventoy/iso9660_ia32.efi</td></tr>
<tr> <td>./INSTALL/ventoy/udf_ia32.efi</td></tr>
<tr> <td>./INSTALL/ventoy/iso9660_x64.efi</td></tr>
<tr> <td>./INSTALL/ventoy/udf_x64.efi</td></tr>
<tr> <td>./INSTALL/VentoyGUI.aarch64</td> <td rowspan=4>build</td> <td rowspan=4>Build Instructions:<br/>./LinuxGUI/build_gtk.sh</td> </tr>
<tr> <td>./INSTALL/VentoyGUI.i386</td></tr>
<tr> <td>./INSTALL/VentoyGUI.mips64el</td></tr>
<tr> <td>./INSTALL/VentoyGUI.x86_64</td></tr>
<tr> <td>./INSTALL/Ventoy2Disk.exe</td> <td rowspan=4>build</td> <td rowspan=4>Build Instructions:<br/>./Ventoy2Disk/Ventoy2Disk.sln</td> </tr>
<tr> <td>./INSTALL/Ventoy2Disk_ARM.exe</td></tr>
<tr> <td>./INSTALL/Ventoy2Disk_ARM64.exe</td></tr>
<tr> <td>./INSTALL/Ventoy2Disk_X64.exe</td></tr>
<tr> <td>./INSTALL/ventoy/vtoyjump32.exe</td> <td rowspan=2>build</td> <td rowspan=2>Build Instructions:<br/>./vtoyjump/vtoyjump.sln</td> </tr>
<tr> <td>./INSTALL/ventoy/vtoyjump64.exe</td></tr>
<tr> <td>./INSTALL/ventoy/ventoy_aa64.efi</td> <td rowspan=7>build</td> <td rowspan=7>Build Instructions:<br/>./EDK2/buildedk.sh</td> </tr>
<tr> <td>./INSTALL/ventoy/ventoy_ia32.efi</td></tr>
<tr> <td>./INSTALL/ventoy/ventoy_x64.efi</td></tr>
<tr> <td>./INSTALL/ventoy/vtoyutil_aa64.efi</td></tr>
<tr> <td>./INSTALL/ventoy/vtoyutil_ia32.efi</td></tr>
<tr> <td>./INSTALL/ventoy/vtoyutil_x64.efi</td></tr>
<tr> <td>./INSTALL/EFI/BOOT/fbx64.efi</td></tr>
<tr> <td>./INSTALL/ventoy/ipxe.krn</td> <td>build</td> <td>Build Instructions:<br/>./IPXE/buildipxe.sh</td> </tr>
<tr> <td>./INSTALL/ventoy/memdisk</td> <td>upstream</td> <td>Download from syslinux project.<br/>URL & File Hash documented in<br/> ./DOC/BuildVentoyFromSource.txt 5.9</td> </tr>
<tr> <td>./LiveCD/ISO/EFI/boot/vmlinuz64</td> <td>upstream</td> <td>Download from TinyLinux website.<br/>URL & File Hash documented in<br/> ./DOC/BuildVentoyFromSource.txt 5.14</td> </tr>
<tr> <td>./LiveCDGUI/EXT/busybox-x86_64</td> <td>build</td> <td>Same with ./IMG/cpio_x86/ventoy/busybox/busybox64<br/>Check the file hash to confirm</td> </tr>
<tr> <td>./LiveCDGUI/GRUB/bootx64.efi</td> <td rowspan=2>build</td> <td rowspan=2>./DOC/BuildVentoyFromSource.txt 4.1-Build grub2</td> </tr>
<tr> <td>./LiveCD/GRUB/bootx64.efi</td></tr>
<tr> <td>./LZIP/lunzip32</td> <td rowspan=3>build</td> <td rowspan=3>Build Instructions:<br/>./DOC/BuildVentoyFromSource.txt 4.19</td> </tr>
<tr> <td>./LZIP/lunzip64</td></tr>
<tr> <td>./LZIP/lunzipaa64</td></tr>
<tr> <td>./LZIP/lz4cat64</td> <td rowspan=3>build</td> <td rowspan=3>Build Instructions:<br/>./LZIP/buildlz4.txt</td> </tr>
<tr> <td>./LZIP/lz4cataa64</td></tr>
<tr> <td>./LZIP/lz4catm64e</td></tr>
<tr> <td>./Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe</td> <td rowspan=2>build</td> <td rowspan=2>Build Instructions:<br/>./Plugson/vs/VentoyPlugson/VentoyPlugson.sln</td> </tr>
<tr> <td>./Plugson/vs/VentoyPlugson/x64/Release/VentoyPlugson_X64.exe</td></tr>
<tr> <td>./SQUASHFS/unsquashfs_32</td> <td rowspan=3>build</td> <td rowspan=3>Build Instructions:<br/>./SQUASHFS/build.sh</td> </tr>
<tr> <td>./SQUASHFS/unsquashfs_64</td></tr>
<tr> <td>./SQUASHFS/unsquashfs_aa64</td></tr>
<tr> <td>./Unix/ventoy_unix/DragonFly/sbin/dmsetup</td> <td>upstream</td> <td>Get from DragonFly ISO.<br/>URL & File Hash documented in<br/> ./DOC/BuildVentoyFromSource.txt 5.13</td> </tr>
<tr> <td>./Unix/ventoy_unix/DragonFly/sbin/init</td> <td>build</td> <td>Build Instructions:<br/>./Unix/ventoy_unix_src/DragonFly/build.sh</td> </tr>
<tr> <td>./VBLADE/vblade-master/vblade_32</td> <td rowspan=3>build</td> <td rowspan=3>Build Instructions:<br/>./VBLADE/vblade-master/build.sh</td> </tr>
<tr> <td>./VBLADE/vblade-master/vblade_64</td></tr>
<tr> <td>./VBLADE/vblade-master/vblade_aa64</td></tr>
<tr> <td>./Vlnk/vs/VentoyVlnk/Release/VentoyVlnk.exe</td> <td>build</td> <td>Build Instructions:<br/>./Vlnk/vs/VentoyVlnk/VentoyVlnk.sln</td> </tr>
<tr> <td>./VtoyTool/vtoytool/00/vtoytool_32</td> <td rowspan=6>build</td> <td rowspan=6>Build Instructions:<br/>./VtoyTool/build.sh</td> </tr>
<tr> <td>./VtoyTool/vtoytool/00/vtoytool_64</td></tr>
<tr> <td>./VtoyTool/vtoytool/00/vtoytool_aa64</td></tr>
<tr> <td>./VtoyTool/vtoytool/00/vtoytool_m64e</td></tr>
<tr> <td>./VtoyTool/vtoytool/01/vtoytool_64</td></tr>
<tr> <td>./VtoyTool/vtoytool/02/vtoytool_64</td></tr>
<tr> <td>./ZSTD/zstdcat</td> <td rowspan=3>build</td> <td rowspan=3>Build Instructions:<br/>./ZSTD/build.txt</td> </tr>
<tr> <td>./ZSTD/zstdcat64</td></tr>
<tr> <td>./ZSTD/zstdcataa64</td></tr>
<tr> <td>./IMG/cpio_x86/ventoy/busybox/busybox32</td> <td rowspan=6>build</td> <td rowspan=6>Build Instructions:<br/>./BUSYBOX/build.txt full busybox</td> </tr>
<tr> <td>./IMG/cpio_x86/ventoy/busybox/busybox64</td></tr>
<tr> <td>./IMG/cpio_x86/ventoy/busybox/xzcat32_musl</td></tr>
<tr> <td>./IMG/cpio_x86/ventoy/busybox/xzcat64_musl</td></tr>
<tr> <td>./IMG/cpio_arm64/ventoy/busybox/busyboxaa64</td></tr>
<tr> <td>./IMG/cpio_mips64/ventoy/busybox/busyboxm64e</td> </tr>
<tr> <td>ISNTALL/ventoy/7z/64/7za.exe</td> <td rowspan=2>upstream</td> <td>Download from 7z project.<br/>URL & File Hash documented in<br/> ./DOC/BuildVentoyFromSource.txt 5.12</td> </tr>
<tr> <td>ISNTALL/ventoy/7z/32/7za.exe</td></tr>
<tr> <td>./INSTALL/ventoy/wimboot.i386.efi</td> <td rowspan=2>build</td> <td rowspan=2>Build Instructions:<br/>./wimboot/build.sh</td> </tr>
<tr> <td>./INSTALL/ventoy/wimboot.x86_64</td></tr>
<tr> <td> ./Unix/ventoy_unix/ClonOS/geom_ventoy_ko/13.x/64/geom_ventoy.ko</td> <td rowspan=18>build</td> <td rowspan=18>Build Instructions:<br/>./Unix/BuildUnixKmod.txt</td> </tr>
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/10.x/32/geom_ventoy.ko</td></tr>
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/10.x/64/geom_ventoy.ko</td></tr>
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/11.x/32/geom_ventoy.ko</td></tr>
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/11.x/64/geom_ventoy.ko</td></tr>
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/12.x/32/geom_ventoy.ko</td></tr>
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/12.x/64/geom_ventoy.ko</td></tr>
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/13.x/32/geom_ventoy.ko</td></tr>
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/13.x/64/geom_ventoy.ko</td></tr>
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/14.x/32/geom_ventoy.ko</td></tr>
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/14.x/64/geom_ventoy.ko</td></tr>
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/9.x/32/geom_ventoy.ko</td></tr>
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/9.x/64/geom_ventoy.ko</td></tr>
<tr> <td> ./Unix/ventoy_unix/MidnightBSD/geom_ventoy_ko/11.x/32/geom_ventoy.ko</td></tr>
<tr> <td> ./Unix/ventoy_unix/MidnightBSD/geom_ventoy_ko/11.x/64/geom_ventoy.ko</td></tr>
<tr> <td> ./Unix/ventoy_unix/MidnightBSD/geom_ventoy_ko/2.x/32/geom_ventoy.ko</td></tr>
<tr> <td> ./Unix/ventoy_unix/MidnightBSD/geom_ventoy_ko/2.x/64/geom_ventoy.ko</td></tr>
<tr> <td> ./Unix/ventoy_unix/pfSense/geom_ventoy_ko/14.x/64/geom_ventoy.ko</td></tr>
</tbody>
</table>
-7
View File
@@ -1,7 +0,0 @@
obj-m += dm_patch.o
EXTRA_CFLAGS := -Wall
dm_patch-objs := dmpatch.o
-217
View File
@@ -1,217 +0,0 @@
/******************************************************************************
* dmpatch.c ---- patch for device-mapper
*
* Copyright (c) 2021, 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 <linux/init.h>
#include <linux/module.h>
#include <linux/kallsyms.h>
#include <linux/mutex.h>
#include <linux/mempool.h>
#include <linux/delay.h>
#include <linux/wait.h>
#include <linux/slab.h>
#define MAX_PATCH 4
#define magic_sig 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF
typedef int (*kprobe_reg_pf)(void *);
typedef void (*kprobe_unreg_pf)(void *);
typedef int (*printk_pf)(const char *fmt, ...);
typedef int (*set_memory_attr_pf)(unsigned long addr, int numpages);
#pragma pack(1)
typedef struct ko_param
{
unsigned char magic[16];
unsigned long struct_size;
unsigned long pgsize;
unsigned long printk_addr;
unsigned long ro_addr;
unsigned long rw_addr;
unsigned long reg_kprobe_addr;
unsigned long unreg_kprobe_addr;
unsigned long sym_get_addr;
unsigned long sym_get_size;
unsigned long sym_put_addr;
unsigned long sym_put_size;
unsigned long padding[3];
}ko_param;
#pragma pack()
static printk_pf kprintf = NULL;
static set_memory_attr_pf set_mem_ro = NULL;
static set_memory_attr_pf set_mem_rw = NULL;
static kprobe_reg_pf reg_kprobe = NULL;
static kprobe_unreg_pf unreg_kprobe = NULL;
static volatile ko_param g_ko_param =
{
{ magic_sig },
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
#if defined(CONFIG_X86_64)
#define PATCH_OP_POS 3
#define CODE_MATCH(code, i) \
(code[i] == 0x40 && code[i + 1] == 0x80 && code[i + 2] == 0xce && code[i + 3] == 0x80)
#elif defined(CONFIG_X86_32)
#define PATCH_OP_POS 2
#define CODE_MATCH(code, i) \
(code[i] == 0x80 && code[i + 1] == 0xca && code[i + 2] == 0x80 && code[i + 3] == 0xe8)
#else
#error "unsupported arch"
#endif
#define vdebug(fmt, args...) if(kprintf) kprintf(KERN_ERR fmt, ##args)
static unsigned char *g_get_patch[MAX_PATCH] = { NULL };
static unsigned char *g_put_patch[MAX_PATCH] = { NULL };
static void notrace dmpatch_restore_code(unsigned char *opCode)
{
unsigned long align;
if (opCode)
{
align = (unsigned long)opCode / g_ko_param.pgsize * g_ko_param.pgsize;
set_mem_rw(align, 1);
*opCode = 0x80;
set_mem_ro(align, 1);
}
}
static int notrace dmpatch_replace_code
(
unsigned long addr,
unsigned long size,
int expect,
const char *desc,
unsigned char **patch
)
{
int i = 0;
int cnt = 0;
unsigned long align;
unsigned char *opCode = (unsigned char *)addr;
vdebug("patch for %s 0x%lx %d\n", desc, addr, (int)size);
for (i = 0; i < (int)size - 4; i++)
{
if (CODE_MATCH(opCode, i) && cnt < MAX_PATCH)
{
patch[cnt] = opCode + i + PATCH_OP_POS;
cnt++;
}
}
if (cnt != expect || cnt >= MAX_PATCH)
{
vdebug("patch error: cnt=%d expect=%d\n", cnt, expect);
return 1;
}
for (i = 0; i < cnt; i++)
{
opCode = patch[i];
align = (unsigned long)opCode / g_ko_param.pgsize * g_ko_param.pgsize;
set_mem_rw(align, 1);
*opCode = 0;
set_mem_ro(align, 1);
}
return 0;
}
static int notrace dmpatch_init(void)
{
int r = 0;
int rc = 0;
kprintf = (printk_pf)(g_ko_param.printk_addr);
vdebug("dmpatch_init start pagesize=%lu ...\n", g_ko_param.pgsize);
if (g_ko_param.struct_size != sizeof(ko_param))
{
vdebug("Invalid struct size %d %d\n", (int)g_ko_param.struct_size, (int)sizeof(ko_param));
return -EINVAL;
}
if (g_ko_param.sym_get_addr == 0 || g_ko_param.sym_put_addr == 0 ||
g_ko_param.ro_addr == 0 || g_ko_param.rw_addr == 0)
{
return -EINVAL;
}
set_mem_ro = (set_memory_attr_pf)(g_ko_param.ro_addr);
set_mem_rw = (set_memory_attr_pf)(g_ko_param.rw_addr);
reg_kprobe = (kprobe_reg_pf)g_ko_param.reg_kprobe_addr;
unreg_kprobe = (kprobe_unreg_pf)g_ko_param.unreg_kprobe_addr;
r = dmpatch_replace_code(g_ko_param.sym_get_addr, g_ko_param.sym_get_size, 2, "dm_get_table_device", g_get_patch);
if (r)
{
rc = -EINVAL;
goto out;
}
vdebug("patch dm_get_table_device success\n");
r = dmpatch_replace_code(g_ko_param.sym_put_addr, g_ko_param.sym_put_size, 1, "dm_put_table_device", g_put_patch);
if (r)
{
rc = -EINVAL;
goto out;
}
vdebug("patch dm_put_table_device success\n");
vdebug("#####################################\n");
vdebug("######## dm patch success ###########\n");
vdebug("#####################################\n");
out:
return rc;
}
static void notrace dmpatch_exit(void)
{
int i = 0;
for (i = 0; i < MAX_PATCH; i++)
{
dmpatch_restore_code(g_get_patch[i]);
dmpatch_restore_code(g_put_patch[i]);
}
vdebug("dmpatch_exit success\n");
}
module_init(dmpatch_init);
module_exit(dmpatch_exit);
MODULE_DESCRIPTION("dmpatch driver");
MODULE_AUTHOR("longpanda <admin@ventoy.net>");
MODULE_LICENSE("GPL");
-36
View File
@@ -1,36 +0,0 @@
1. install ubuntu 21.10
2. apt-get install build-essential flex libncurses-dev linux-headers-generic linux-source libssl-dev ...... and so on
3. cp /lib/modules/5.13.0-23-generic/build/Module.symvers ./
4. /boot/config-5.13.0-23-generic as .config make oldconfig
5. make menuconfig
1. close CONFIG_STACKPROTECTOR
2. close CONFIG_RETPOLINE
6. modify ./scripts/mod/modpost.c
1. skip add_srcversion (just return)
2. force add_retpoline (#ifdef --> #ifndef)
3. force add_intree_flag
7. make modules_prepare LOCALVERSION=-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
8. Append padding at the end of struct module <include/linux/module.h>
struct module {
enum module_state state;
/* Member of list of modules */
struct list_head list;
/* Unique handle for this module */
char name[MODULE_NAME_LEN];
....
char padding[1024];
};
This is because struct module size is different in different kernel versions or with different CONFIG item.
9. make modules M=/home/dmpatch
10. strip --strip-debug /home/dmpatch/dm_patch.ko
+1 -1
View File
@@ -5,7 +5,7 @@ use an old version of dmsetup
http://vault.centos.org/5.3/os/SRPMS/device-mapper-1.02.28-2.el5.src.rpm http://vault.centos.org/5.3/os/SRPMS/device-mapper-1.02.28-2.el5.src.rpm
https://www.fefe.de/dietlibc/dietlibc-0.34.tar.xz https://www.fefe.de/dietlibc/dietlibc-0.34.tar.xz
======== Build Envrioment ======== ======== Build Environment ========
build for 32bit, static linked with dietlibc build for 32bit, static linked with dietlibc
1. install centos 6.10 i386 with CentOS-6.10-i386-bin-DVD1.iso 1. install centos 6.10 i386 with CentOS-6.10-i386-bin-DVD1.iso
2. yum install gcc kernel-devel package 2. yum install gcc kernel-devel package
+38 -21
View File
@@ -1,9 +1,9 @@
========================================== ==========================================
1. Compile Enviroment 1. Compile Environment
========================================== ==========================================
My build envrioment is CentOS 7.8 x86_64. So here I first explain how to create the build environment from scratch. My build environment is CentOS 7.8 x86_64. So here I first explain how to create the build environment from scratch.
Because Ventoy is based on many open source projects, so the environment is important. I suggest you test it on a virtual machine firstly. Ventoy is based on many open source projects, so the build environment is important. I suggest you first test it on a virtual machine.
1.1 Install CentOS 7.8 1.1 Install CentOS 7.8
I use CentOS-7-x86_64-Everything-2003.iso and select Minimal install I use CentOS-7-x86_64-Everything-2003.iso and select Minimal install
@@ -21,10 +21,10 @@
========================================== ==========================================
2. Download Source Code 2. Download Source Code
========================================== ==========================================
2.1 Download Ventoy source code from github and decompress it. 2.1 Download Ventoy source code from GitHub and decompress it.
Next I assume that you have unzipped the code into the /home directory (check /home/Ventoy-master/README.md file for the directory layout). 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-part source code and tool 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://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://musl.libc.org/releases/musl-1.2.1.tar.gz ===> /home/Ventoy-master/DOC/musl-1.2.1.tar.gz
@@ -34,7 +34,7 @@
https://codeload.github.com/libfuse/libfuse/zip/fuse-2.9.9 ===> /home/Ventoy-master/ExFAT/libfuse-fuse-2.9.9.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://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://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
http://ftp.loongnix.cn/toolchain/gcc/release/mips/gcc7/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/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 https://github.com/ventoy/musl-cross-make/releases/download/latest/output.tar.bz2 ===> /opt/output.tar.bz2
@@ -42,7 +42,7 @@
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/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 http://www.tinycorelinux.net/11.x/x86_64/release/distribution_files/modules64.gz ===> /home/Ventoy-master/LiveCD/ISO/EFI/boot/modules64.gz
2.3 Prepare third-part tools 2.3 Prepare third-party tools
cd /home/Ventoy-master/DOC/ cd /home/Ventoy-master/DOC/
tar xf musl-1.2.1.tar.gz tar xf musl-1.2.1.tar.gz
cd musl-1.2.1 cd musl-1.2.1
@@ -54,7 +54,7 @@
mv /opt/output /opt/mips64el-linux-musl-gcc730 mv /opt/output /opt/mips64el-linux-musl-gcc730
2.4 Set PATH envrioment 2.4 Set PATH environment
export PATH=$PATH:/opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/bin:/opt/aarch64--uclibc--stable-2020.08-1/bin:/opt/mips64el-linux-musl-gcc730/bin export PATH=$PATH:/opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/bin:/opt/aarch64--uclibc--stable-2020.08-1/bin:/opt/mips64el-linux-musl-gcc730/bin
better to add this line to /root/.bashrc and relogin as root better to add this line to /root/.bashrc and relogin as root
@@ -62,21 +62,21 @@
========================================== ==========================================
3. All in one script 3. All in one script
========================================== ==========================================
I have made a all_in_one.sh, you can run this script to build and pack ventoy. I have made an all-in-one script `all_in_one.sh`. You can run this script to build and pack ventoy.
If you want to compile a certain part separately, you can continue to refer to the later chapters of this text. If you want to compile a certain part separately, you can continue to refer to the later chapters of this text.
cd /home/Ventoy-master/INSTALL cd /home/Ventoy-master/INSTALL
sh all_in_one.sh sh all_in_one.sh
It should be noted that: It should be noted that:
1. Only grub2/EDK2/IPXE will be recompiled in all_in_one.sh. Other part contains the binaries and are few modified, so will no be recompiled everytime. 1. Only grub2/EDK2/IPXE will be recompiled in all_in_one.sh. Other parts contain binaries and are rarely modified, so will not be recompiled everytime.
You can rebuild these parts separately if you want. You can rebuild these parts separately if you want.
2. some part of Ventoy has 32bit&64bit version (like 4.9 4.10 4.11 follows) 2. Some parts of Ventoy have a 32-bit and 64-bit version (like 4.9, 4.10, 4.11 follows)
all_in_one.sh only build 64bit version of them, if you want to rebuild the 32bit verison. You should create a 32bit CentOS environment and build them. all_in_one.sh only builds the 64bit version of them. If you want to rebuild the 32bit verison, you should create a 32-bit CentOS environment and build them.
Fortunately these parts are few modified, you only need to build once or you can directly use the binary I have built. Fortunately these parts are rarely modified, so you only need to build once or you can directly use the binaries I have built.
Besides, after a fully compile and pack, you can only build the part you modified (for example grub2) and run ventoy_pack.sh to generate the package. Besides, after a full compile and packaging, you can only build the part you modified (for example grub2) and run ventoy_pack.sh to generate the package.
========================================== ==========================================
4. Build every part of Ventoy 4. Build every part of Ventoy
@@ -122,14 +122,14 @@
After that, copy EXFAT/shared/mkexfatfs ===> /home/Ventoy-master/INSTALL/tool/mkexfatfs_64 After that, copy EXFAT/shared/mkexfatfs ===> /home/Ventoy-master/INSTALL/tool/mkexfatfs_64
After that, copy EXFAT/shared/mount.exfat-fuse ===> /home/Ventoy-master/INSTALL/tool/mount.exfat-fuse_64 After that, copy EXFAT/shared/mount.exfat-fuse ===> /home/Ventoy-master/INSTALL/tool/mount.exfat-fuse_64
Use the same build step to build exfat-util 32bit in a 32bit CentOS system and get mkexfatfs_32 and mount.exfat-fuse_32 Use the same build step to build exfat-util 32-bit in a 32-bit CentOS system and get mkexfatfs_32 and mount.exfat-fuse_32
4.10 == Build vtoy_fuse_iso_64/vtoy_fuse_iso_32 == 4.10 == Build vtoy_fuse_iso_64/vtoy_fuse_iso_32 ==
cd /home/Ventoy-master/FUSEISO cd /home/Ventoy-master/FUSEISO
sh build_libfuse.sh sh build_libfuse.sh
sh build.sh sh build.sh
Use the same build step to build in a 32bit CentOS system and get vtoy_fuse_iso_32 Use the same build step to build in a 32-bit CentOS system and get vtoy_fuse_iso_32
4.11 == Build unsquashfs_64/unsquashfs_32 == 4.11 == Build unsquashfs_64/unsquashfs_32 ==
cd /home/Ventoy-master/SQUASHFS/SRC cd /home/Ventoy-master/SQUASHFS/SRC
@@ -141,7 +141,7 @@
cd /home/Ventoy-master/SQUASHFS/squashfs-tools-4.4/squashfs-tools cd /home/Ventoy-master/SQUASHFS/squashfs-tools-4.4/squashfs-tools
sh build.sh sh build.sh
Use the same build step to build in a 32bit CentOS system and get unsquashfs_32 Use the same build step to build in a 32-bit CentOS system and get unsquashfs_32
4.12 == Build vblade_64/vblade_32 == 4.12 == Build vblade_64/vblade_32 ==
cd /home/Ventoy-master/VBLADE/vblade-master cd /home/Ventoy-master/VBLADE/vblade-master
@@ -159,12 +159,12 @@
make -f ventoy_makefile make -f ventoy_makefile
strip --strip-all xzminidec strip --strip-all xzminidec
4.16 == Build xzminidec64 == 4.16 == Build xzminidec64/xzminidec64_musl ==
cd /home/Ventoy-master/Ventoy2Disk/Ventoy2Disk/xz-embedded-20130513/userspace cd /home/Ventoy-master/Ventoy2Disk/Ventoy2Disk/xz-embedded-20130513/userspace
make -f ventoy_makefile64 make -f ventoy_makefile64 or make -f ventoy_makefile64_musl
strip --strip-all xzminidec strip --strip-all xzminidec
4.17 == Build iso9660_x64.efi == 4.17 == Build iso9660_x64.efi/udf_x64.efi/iso9660_ia32.efi/udf_ia32.efi/iso9660_aa64.efi/udf_aa64.efi/ ==
This efi driver is from https://github.com/pbatard/efifs This efi driver is from https://github.com/pbatard/efifs
Follow all the build instructions in this project. I modified 3 files (the original and modified source are at /home/Ventoy-master/EDK2/efiffs) Follow all the build instructions in this project. I modified 3 files (the original and modified source are at /home/Ventoy-master/EDK2/efiffs)
@@ -185,6 +185,16 @@
make make
aarch64-buildroot-linux-uclibc-strip --strip-all lunzip aarch64-buildroot-linux-uclibc-strip --strip-all lunzip
4.17 == Build xzminidecaa64 ==
cd /home/Ventoy-master/Ventoy2Disk/Ventoy2Disk/xz-embedded-20130513/userspace
make -f ventoy_makefileaa64
strip --strip-all xzminidec
4.18 == Build xzminidecm64e ==
cd /home/Ventoy-master/Ventoy2Disk/Ventoy2Disk/xz-embedded-20130513/userspace
make -f ventoy_makefilem64e
strip --strip-all xzminidec
========================================== ==========================================
@@ -222,7 +232,7 @@
SHA-256: cde08b6a2cf5ad914f05203e18e3f7c2ed6060a63604e3d75536f19b55e8e0af SHA-256: cde08b6a2cf5ad914f05203e18e3f7c2ed6060a63604e3d75536f19b55e8e0af
5.8 imdisk 5.8 imdisk
download http://www.ltr-data.se/files/imdiskinst.exe and extract it by 7zip. download http://static.ltr-data.se/files/imdiskinst_2.0.10.exe and extract it by 7zip.
INSTALL/ventoy/imdisk/64/imdisk.sys --> sys/amd64/imdisk.sys SHA-256: 6702202220268787e361f5a82dae53362c8e6c6dcd240bb01b44dd77ae0788da INSTALL/ventoy/imdisk/64/imdisk.sys --> sys/amd64/imdisk.sys SHA-256: 6702202220268787e361f5a82dae53362c8e6c6dcd240bb01b44dd77ae0788da
INSTALL/ventoy/imdisk/64/imdisk.exe --> cli/amd64/imdisk.exe SHA-256: 9759175380af836869443e5f21ce2e33022125d154bc6b3d1c04dc36b190de04 INSTALL/ventoy/imdisk/64/imdisk.exe --> cli/amd64/imdisk.exe SHA-256: 9759175380af836869443e5f21ce2e33022125d154bc6b3d1c04dc36b190de04
@@ -256,5 +266,12 @@
ISNTALL/ventoy/7z/64/7za.exe SHA-256: 8117e40ee7f824f63373a4f5625bb62749f69159d0c449b3ce2f35aad3b83549 ISNTALL/ventoy/7z/64/7za.exe SHA-256: 8117e40ee7f824f63373a4f5625bb62749f69159d0c449b3ce2f35aad3b83549
ISNTALL/ventoy/7z/32/7za.exe SHA-256: ea308c76a2f927b160a143d94072b0dce232e04b751f0c6432a94e05164e716d ISNTALL/ventoy/7z/32/7za.exe SHA-256: ea308c76a2f927b160a143d94072b0dce232e04b751f0c6432a94e05164e716d
5.13 ./Ventoy/Unix/ventoy_unix/DragonFly/sbin/dmsetup
download from https://cdimage.debian.org/mirror/dragonflybsd.org/iso-images/dfly-x86_64-5.8.3_REL.iso.bz2
extract from the ISO file sbin/dmsetup
dmsetup SHA-256: bedcf26650e87edfe961e33bae20d832bce73efd4b6239f9a6a5785661e4e698
5.14 ./LiveCD/ISO/EFI/boot/vmlinuz64
download from http://www.tinycorelinux.net/11.x/x86_64/archive/11.0/distribution_files/vmlinuz64
vmlinuz64 SHA-256: 641077fc1f9914af244c248453005f56536ba9e7f54ba3e52402f26709ddb8a5
+6 -1
View File
@@ -1,6 +1,11 @@
FROM centos:7 FROM centos:7
RUN yum -y -q install \ RUN sed -i \
-e 's/^mirrorlist/#mirrorlist/' \
-e 's/^#baseurl/baseurl/' \
-e 's/mirror\.centos\.org/vault.centos.org/' \
/etc/yum.repos.d/*.repo && \
yum -y -q install \
libXpm net-tools bzip2 wget vim gcc gcc-c++ samba dos2unix glibc-devel glibc.i686 glibc-devel.i686 \ libXpm net-tools bzip2 wget vim gcc gcc-c++ samba dos2unix glibc-devel glibc.i686 glibc-devel.i686 \
mpfr.i686 mpfr-devel.i686 rsync autogen autoconf automake libtool gettext* bison binutils \ mpfr.i686 mpfr-devel.i686 rsync autogen autoconf automake libtool gettext* bison binutils \
flex device-mapper-devel SDL libpciaccess libusb freetype freetype-devel gnu-free-* qemu-* virt-* \ flex device-mapper-devel SDL libpciaccess libusb freetype freetype-devel gnu-free-* qemu-* virt-* \
+113
View File
@@ -0,0 +1,113 @@
#!/bin/sh
if [ -z "$1" ]; then
EDKARCH=X64
postfix=x64
elif [ "$1" = "ia32" ]; then
EDKARCH=IA32
postfix=ia32
shift
elif [ "$1" = "aa64" ]; then
EDKARCH=AARCH64
postfix=aa64
shift
fi
cd edk2-edk2-stable201911
rm -rf ./Conf/.cache
rm -f ./Conf/.AutoGenIdFile.txt
VTEFI_PATH=Build/MdeModule/RELEASE_GCC48/$EDKARCH/MdeModulePkg/Application/VtoyShim/VtoyShim/OUTPUT/VtoyShim.efi
DST_PATH=../../INSTALL/EFI/BOOT/fb${postfix}.efi
rm -f $VTEFI_PATH
rm -f $DST_PATH
unset WORKSPACE
source ./edksetup.sh
if [ "$EDKARCH" = "AARCH64" ]; then
PATH=$PATH:/opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/bin \
GCC48_AARCH64_PREFIX=aarch64-linux-gnu- \
build -p MdeModulePkg/MdeModulePkg.dsc -a $EDKARCH -b RELEASE -t GCC48 -m MdeModulePkg/Application/VtoyShim/VtoyShim.inf
else
build -p MdeModulePkg/MdeModulePkg.dsc -a $EDKARCH -b RELEASE -t GCC48 -m MdeModulePkg/Application/VtoyShim/VtoyShim.inf
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"
#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'
cd ..
else
echo -e '\n\n====================== FAILED ========================\n\n'
cd ..
exit 1
fi
+4
View File
@@ -19,3 +19,7 @@ sh ./build.sh aa64 || exit 1
echo '======== build EDK2 for x86_64-efi ===============' echo '======== build EDK2 for x86_64-efi ==============='
sh ./build.sh || exit 1 sh ./build.sh || exit 1
echo '======== build EDK2 for x86_64-efi ==============='
sh ./build_shim.sh || exit 1
@@ -7,12 +7,12 @@
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of the * published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>. * along with this program; if not, see <http://www.gnu.org/licenses/>.
* *
@@ -76,7 +76,7 @@ STATIC EFI_EXIT_BOOT_SERVICES g_org_exit_boot_service = NULL;
/* Boot filename */ /* Boot filename */
UINTN gBootFileStartIndex = 1; UINTN gBootFileStartIndex = 1;
CONST CHAR16 *gEfiBootFileName[] = CONST CHAR16 *gEfiBootFileName[] =
{ {
L"@", L"@",
EFI_REMOVABLE_MEDIA_FILE_NAME, EFI_REMOVABLE_MEDIA_FILE_NAME,
@@ -101,7 +101,7 @@ CONST CHAR16 *gEfiBootFileName[] =
L"\\EFI\\BOOT\\bootaa64.efi", L"\\EFI\\BOOT\\bootaa64.efi",
L"\\efi\\boot\\bootaa64.efi", L"\\efi\\boot\\bootaa64.efi",
#endif #endif
}; };
VOID EFIAPI VtoyDebug(IN CONST CHAR8 *Format, ...) VOID EFIAPI VtoyDebug(IN CONST CHAR8 *Format, ...)
@@ -112,14 +112,14 @@ VOID EFIAPI VtoyDebug(IN CONST CHAR8 *Format, ...)
VA_START (Marker, Format); VA_START (Marker, Format);
UnicodeVSPrintAsciiFormat(Buffer, sizeof(Buffer), Format, Marker); UnicodeVSPrintAsciiFormat(Buffer, sizeof(Buffer), Format, Marker);
VA_END (Marker); VA_END (Marker);
gST->ConOut->OutputString(gST->ConOut, Buffer); gST->ConOut->OutputString(gST->ConOut, Buffer);
} }
VOID EFIAPI ventoy_clear_input(VOID) VOID EFIAPI ventoy_clear_input(VOID)
{ {
EFI_INPUT_KEY Key; EFI_INPUT_KEY Key;
gST->ConIn->Reset(gST->ConIn, FALSE); gST->ConIn->Reset(gST->ConIn, FALSE);
while (EFI_SUCCESS == gST->ConIn->ReadKeyStroke(gST->ConIn, &Key)) while (EFI_SUCCESS == gST->ConIn->ReadKeyStroke(gST->ConIn, &Key))
{ {
@@ -142,7 +142,7 @@ static void EFIAPI ventoy_dump_img_chunk(ventoy_chain_head *chain)
for (i = 0; i < chain->img_chunk_num; i++) for (i = 0; i < chain->img_chunk_num; i++)
{ {
debug("%2u: [ %u - %u ] <==> [ %llu - %llu ]", debug("%2u: [ %u - %u ] <==> [ %llu - %llu ]",
i, chunk[i].img_start_sector, chunk[i].img_end_sector, i, chunk[i].img_start_sector, chunk[i].img_end_sector,
chunk[i].disk_start_sector, chunk[i].disk_end_sector); chunk[i].disk_start_sector, chunk[i].disk_end_sector);
if (i > 0 && (chunk[i].img_start_sector != chunk[i - 1].img_end_sector + 1)) if (i > 0 && (chunk[i].img_start_sector != chunk[i - 1].img_end_sector + 1))
@@ -161,7 +161,7 @@ static void EFIAPI ventoy_dump_img_chunk(ventoy_chain_head *chain)
{ {
debug("image chunk size check failed %d", errcnt); debug("image chunk size check failed %d", errcnt);
} }
ventoy_debug_pause(); ventoy_debug_pause();
} }
@@ -169,7 +169,7 @@ static void EFIAPI ventoy_dump_override_chunk(ventoy_chain_head *chain)
{ {
UINT32 i; UINT32 i;
ventoy_override_chunk *chunk; ventoy_override_chunk *chunk;
chunk = (ventoy_override_chunk *)((char *)chain + chain->override_chunk_offset); chunk = (ventoy_override_chunk *)((char *)chain + chain->override_chunk_offset);
debug("##################### ventoy_dump_override_chunk #######################"); debug("##################### ventoy_dump_override_chunk #######################");
@@ -186,7 +186,7 @@ static void EFIAPI ventoy_dump_virt_chunk(ventoy_chain_head *chain)
{ {
UINT32 i; UINT32 i;
ventoy_virt_chunk *node; ventoy_virt_chunk *node;
debug("##################### ventoy_dump_virt_chunk #######################"); debug("##################### ventoy_dump_virt_chunk #######################");
debug("virt_chunk_offset=%u", chain->virt_chunk_offset); debug("virt_chunk_offset=%u", chain->virt_chunk_offset);
debug("virt_chunk_num=%u", chain->virt_chunk_num); debug("virt_chunk_num=%u", chain->virt_chunk_num);
@@ -194,7 +194,7 @@ static void EFIAPI ventoy_dump_virt_chunk(ventoy_chain_head *chain)
node = (ventoy_virt_chunk *)((char *)chain + chain->virt_chunk_offset); node = (ventoy_virt_chunk *)((char *)chain + chain->virt_chunk_offset);
for (i = 0; i < chain->virt_chunk_num; i++, node++) for (i = 0; i < chain->virt_chunk_num; i++, node++)
{ {
debug("%2u: mem:[ %u, %u, %u ] remap:[ %u, %u, %u ]", i, debug("%2u: mem:[ %u, %u, %u ] remap:[ %u, %u, %u ]", i,
node->mem_sector_start, node->mem_sector_start,
node->mem_sector_end, node->mem_sector_end,
node->mem_sector_offset, node->mem_sector_offset,
@@ -202,7 +202,7 @@ static void EFIAPI ventoy_dump_virt_chunk(ventoy_chain_head *chain)
node->remap_sector_end, node->remap_sector_end,
node->org_sector_start); node->org_sector_start);
} }
ventoy_debug_pause(); ventoy_debug_pause();
} }
@@ -211,7 +211,7 @@ static void EFIAPI ventoy_dump_chain(ventoy_chain_head *chain)
UINT32 i = 0; UINT32 i = 0;
UINT8 chksum = 0; UINT8 chksum = 0;
UINT8 *guid; UINT8 *guid;
guid = chain->os_param.vtoy_disk_guid; guid = chain->os_param.vtoy_disk_guid;
for (i = 0; i < sizeof(ventoy_os_param); i++) for (i = 0; i < sizeof(ventoy_os_param); i++)
{ {
@@ -229,10 +229,10 @@ static void EFIAPI ventoy_dump_chain(ventoy_chain_head *chain)
debug("os_param->vtoy_img_size=<%llu>", chain->os_param.vtoy_img_size); debug("os_param->vtoy_img_size=<%llu>", chain->os_param.vtoy_img_size);
debug("os_param->vtoy_img_location_addr=<0x%llx>", chain->os_param.vtoy_img_location_addr); debug("os_param->vtoy_img_location_addr=<0x%llx>", chain->os_param.vtoy_img_location_addr);
debug("os_param->vtoy_img_location_len=<%u>", chain->os_param.vtoy_img_location_len); debug("os_param->vtoy_img_location_len=<%u>", chain->os_param.vtoy_img_location_len);
debug("os_param->vtoy_reserved=<%u %u %u %u %u %u %u>", debug("os_param->vtoy_reserved=<%u %u %u %u %u %u %u>",
g_os_param_reserved[0], g_os_param_reserved[0],
g_os_param_reserved[1], g_os_param_reserved[1],
g_os_param_reserved[2], g_os_param_reserved[2],
g_os_param_reserved[3], g_os_param_reserved[3],
g_os_param_reserved[4], g_os_param_reserved[4],
g_os_param_reserved[5], g_os_param_reserved[5],
@@ -240,7 +240,7 @@ static void EFIAPI ventoy_dump_chain(ventoy_chain_head *chain)
); );
ventoy_debug_pause(); ventoy_debug_pause();
debug("chain->disk_drive=0x%x", chain->disk_drive); debug("chain->disk_drive=0x%x", chain->disk_drive);
debug("chain->disk_sector_size=%u", chain->disk_sector_size); debug("chain->disk_sector_size=%u", chain->disk_sector_size);
debug("chain->real_img_size_in_bytes=%llu", chain->real_img_size_in_bytes); debug("chain->real_img_size_in_bytes=%llu", chain->real_img_size_in_bytes);
@@ -252,7 +252,7 @@ static void EFIAPI ventoy_dump_chain(ventoy_chain_head *chain)
debug("chain->override_chunk_num=%u", chain->override_chunk_num); debug("chain->override_chunk_num=%u", chain->override_chunk_num);
ventoy_debug_pause(); ventoy_debug_pause();
ventoy_dump_img_chunk(chain); ventoy_dump_img_chunk(chain);
ventoy_dump_override_chunk(chain); ventoy_dump_override_chunk(chain);
ventoy_dump_virt_chunk(chain); ventoy_dump_virt_chunk(chain);
@@ -344,7 +344,7 @@ EFI_HANDLE EFIAPI ventoy_get_parent_handle(IN EFI_DEVICE_PATH_PROTOCOL *pDevPath
EFI_DEVICE_PATH_PROTOCOL *pLastNode = NULL; EFI_DEVICE_PATH_PROTOCOL *pLastNode = NULL;
EFI_DEVICE_PATH_PROTOCOL *pCurNode = NULL; EFI_DEVICE_PATH_PROTOCOL *pCurNode = NULL;
EFI_DEVICE_PATH_PROTOCOL *pTmpDevPath = NULL; EFI_DEVICE_PATH_PROTOCOL *pTmpDevPath = NULL;
pTmpDevPath = DuplicateDevicePath(pDevPath); pTmpDevPath = DuplicateDevicePath(pDevPath);
if (!pTmpDevPath) if (!pTmpDevPath)
{ {
@@ -387,8 +387,8 @@ EFI_STATUS EFIAPI ventoy_save_ramdisk_param(VOID)
{ {
debug("find previous ramdisk variable <%llu>", g_backup_ramdisk_param.DiskSize); debug("find previous ramdisk variable <%llu>", g_backup_ramdisk_param.DiskSize);
} }
Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid, Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(g_ramdisk_param), &(g_ramdisk_param)); sizeof(g_ramdisk_param), &(g_ramdisk_param));
debug("set ramdisk variable %r", Status); debug("set ramdisk variable %r", Status);
@@ -403,14 +403,14 @@ EFI_STATUS EFIAPI ventoy_delete_ramdisk_param(VOID)
if (g_backup_ramdisk_param.DiskSize > 0 && g_backup_ramdisk_param.PhyAddr > 0) if (g_backup_ramdisk_param.DiskSize > 0 && g_backup_ramdisk_param.PhyAddr > 0)
{ {
Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid, Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(g_backup_ramdisk_param), &g_backup_ramdisk_param); sizeof(g_backup_ramdisk_param), &g_backup_ramdisk_param);
debug("resotre ramdisk variable %r", Status); debug("resotre ramdisk variable %r", Status);
} }
else else
{ {
Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid, Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
0, NULL); 0, NULL);
debug("delete ramdisk variable %r", Status); debug("delete ramdisk variable %r", Status);
@@ -432,7 +432,7 @@ EFI_STATUS EFIAPI ventoy_save_variable(VOID)
debug("find previous efi variable <%a>", g_backup_os_param_var.vtoy_img_path); debug("find previous efi variable <%a>", g_backup_os_param_var.vtoy_img_path);
} }
Status = gRT->SetVariable(L"VentoyOsParam", &VarGuid, Status = gRT->SetVariable(L"VentoyOsParam", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(g_chain->os_param), &(g_chain->os_param)); sizeof(g_chain->os_param), &(g_chain->os_param));
debug("set efi variable %r", Status); debug("set efi variable %r", Status);
@@ -447,14 +447,14 @@ EFI_STATUS EFIAPI ventoy_delete_variable(VOID)
if (0 == CompareMem(&(g_backup_os_param_var.guid), &VarGuid, sizeof(EFI_GUID))) if (0 == CompareMem(&(g_backup_os_param_var.guid), &VarGuid, sizeof(EFI_GUID)))
{ {
Status = gRT->SetVariable(L"VentoyOsParam", &VarGuid, Status = gRT->SetVariable(L"VentoyOsParam", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(g_backup_os_param_var), &(g_backup_os_param_var)); sizeof(g_backup_os_param_var), &(g_backup_os_param_var));
debug("restore efi variable %r", Status); debug("restore efi variable %r", Status);
} }
else else
{ {
Status = gRT->SetVariable(L"VentoyOsParam", &VarGuid, Status = gRT->SetVariable(L"VentoyOsParam", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
0, NULL); 0, NULL);
debug("delete efi variable %r", Status); debug("delete efi variable %r", Status);
@@ -481,7 +481,7 @@ STATIC VOID ventoy_warn_invalid_device(VOID)
gST->ConOut->OutputString(gST->ConOut, L"This is NOT a standard Ventoy device and is NOT supported.\r\n\r\n"); gST->ConOut->OutputString(gST->ConOut, L"This is NOT a standard Ventoy device and is NOT supported.\r\n\r\n");
gST->ConOut->OutputString(gST->ConOut, L"You should follow the official instructions in https://www.ventoy.net\r\n"); gST->ConOut->OutputString(gST->ConOut, L"You should follow the official instructions in https://www.ventoy.net\r\n");
gST->ConOut->OutputString(gST->ConOut, L"\r\n\r\nWill exit after 10 seconds ...... "); gST->ConOut->OutputString(gST->ConOut, L"\r\n\r\nWill exit after 10 seconds ...... ");
sleep(10); sleep(10);
@@ -489,7 +489,7 @@ STATIC VOID ventoy_warn_invalid_device(VOID)
#else #else
STATIC VOID ventoy_warn_invalid_device(VOID) STATIC VOID ventoy_warn_invalid_device(VOID)
{ {
} }
#endif #endif
@@ -513,19 +513,19 @@ STATIC EFI_STATUS EFIAPI ventoy_load_image
pFilePath->Header.Length[0] = FileNameLen + sizeof(EFI_DEVICE_PATH_PROTOCOL); pFilePath->Header.Length[0] = FileNameLen + sizeof(EFI_DEVICE_PATH_PROTOCOL);
pFilePath->Header.Length[1] = 0; pFilePath->Header.Length[1] = 0;
CopyMem(pFilePath->PathName, FileName, FileNameLen); CopyMem(pFilePath->PathName, FileName, FileNameLen);
pImgPath = AppendDevicePathNode(pDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)pFilePath); pImgPath = AppendDevicePathNode(pDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)pFilePath);
if (!pImgPath) if (!pImgPath)
{ {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
Status = gBS->LoadImage(FALSE, ImageHandle, pImgPath, NULL, 0, Image); Status = gBS->LoadImage(FALSE, ImageHandle, pImgPath, NULL, 0, Image);
debug("Load Image File %r DP: <%s>", Status, ConvertDevicePathToText(pImgPath, FALSE, FALSE)); debug("Load Image File %r DP: <%s>", Status, ConvertDevicePathToText(pImgPath, FALSE, FALSE));
FreePool(pImgPath); FreePool(pImgPath);
return Status; return Status;
} }
@@ -547,7 +547,7 @@ STATIC EFI_STATUS EFIAPI ventoy_find_iso_disk(IN EFI_HANDLE ImageHandle)
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiBlockIoProtocolGuid, Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiBlockIoProtocolGuid,
NULL, &Count, &Handles); NULL, &Count, &Handles);
if (EFI_ERROR(Status)) if (EFI_ERROR(Status))
{ {
@@ -591,16 +591,16 @@ STATIC EFI_STATUS EFIAPI ventoy_find_iso_disk(IN EFI_HANDLE ImageHandle)
ventoy_warn_invalid_device(); ventoy_warn_invalid_device();
} }
} }
gBlockData.RawBlockIoHandle = Handles[i]; gBlockData.RawBlockIoHandle = Handles[i];
gBlockData.pRawBlockIo = pBlockIo; gBlockData.pRawBlockIo = pBlockIo;
gBS->OpenProtocol(Handles[i], &gEfiDevicePathProtocolGuid, gBS->OpenProtocol(Handles[i], &gEfiDevicePathProtocolGuid,
(VOID **)&(gBlockData.pDiskDevPath), (VOID **)&(gBlockData.pDiskDevPath),
ImageHandle, ImageHandle,
Handles[i], Handles[i],
EFI_OPEN_PROTOCOL_GET_PROTOCOL); EFI_OPEN_PROTOCOL_GET_PROTOCOL);
debug("Find Ventoy Disk Sig Handle:%p DP:%s", Handles[i], debug("Find Ventoy Disk Sig Handle:%p DP:%s", Handles[i],
ConvertDevicePathToText(gBlockData.pDiskDevPath, FALSE, FALSE)); ConvertDevicePathToText(gBlockData.pDiskDevPath, FALSE, FALSE));
break; break;
} }
@@ -629,7 +629,7 @@ STATIC EFI_STATUS EFIAPI ventoy_find_iso_disk_fs(IN EFI_HANDLE ImageHandle)
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *pFile = NULL; EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *pFile = NULL;
EFI_DEVICE_PATH_PROTOCOL *pDevPath = NULL; EFI_DEVICE_PATH_PROTOCOL *pDevPath = NULL;
Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiSimpleFileSystemProtocolGuid, Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiSimpleFileSystemProtocolGuid,
NULL, &Count, &Handles); NULL, &Count, &Handles);
if (EFI_ERROR(Status)) if (EFI_ERROR(Status))
{ {
@@ -646,7 +646,7 @@ STATIC EFI_STATUS EFIAPI ventoy_find_iso_disk_fs(IN EFI_HANDLE ImageHandle)
continue; continue;
} }
Status = gBS->OpenProtocol(Handles[i], &gEfiDevicePathProtocolGuid, Status = gBS->OpenProtocol(Handles[i], &gEfiDevicePathProtocolGuid,
(VOID **)&pDevPath, (VOID **)&pDevPath,
ImageHandle, ImageHandle,
Handles[i], Handles[i],
@@ -683,29 +683,29 @@ STATIC EFI_STATUS EFIAPI ventoy_load_isoefi_driver(IN EFI_HANDLE ImageHandle)
if (gIsoUdf) if (gIsoUdf)
{ {
Status = ventoy_load_image(ImageHandle, gBlockData.pDiskFsDevPath, Status = ventoy_load_image(ImageHandle, gBlockData.pDiskFsDevPath,
gUdfEfiDriverPath, gUdfEfiDriverPath,
sizeof(gUdfEfiDriverPath), sizeof(gUdfEfiDriverPath),
&Image); &Image);
debug("load iso UDF efi driver status:%r", Status); debug("load iso UDF efi driver status:%r", Status);
} }
else else
{ {
Status = ventoy_load_image(ImageHandle, gBlockData.pDiskFsDevPath, Status = ventoy_load_image(ImageHandle, gBlockData.pDiskFsDevPath,
gIso9660EfiDriverPath, gIso9660EfiDriverPath,
sizeof(gIso9660EfiDriverPath), sizeof(gIso9660EfiDriverPath),
&Image); &Image);
debug("load iso 9660 efi driver status:%r", Status); debug("load iso 9660 efi driver status:%r", Status);
} }
if (gDebugPrint) if (gDebugPrint)
{ {
gRT->SetVariable(L"FS_LOGGING", &gShellVariableGuid, gRT->SetVariable(L"FS_LOGGING", &gShellVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(LogVar), LogVar); sizeof(LogVar), LogVar);
} }
gRT->SetVariable(L"FS_NAME_NOCASE", &gShellVariableGuid, gRT->SetVariable(L"FS_NAME_NOCASE", &gShellVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(LogVar), LogVar); sizeof(LogVar), LogVar);
@@ -732,7 +732,7 @@ STATIC EFI_STATUS ventoy_proc_img_replace_name(ventoy_grub_param_file_replace *r
} }
AsciiStrCpyS(tmp, sizeof(tmp), replace->old_file_name[0]); AsciiStrCpyS(tmp, sizeof(tmp), replace->old_file_name[0]);
for (i = 0; i < 256 && tmp[i]; i++) for (i = 0; i < 256 && tmp[i]; i++)
{ {
if (tmp[i] == '/') if (tmp[i] == '/')
@@ -755,7 +755,7 @@ EFI_STATUS EFIAPI ventoy_get_variable_wrapper
) )
{ {
EFI_STATUS Status = EFI_SUCCESS; EFI_STATUS Status = EFI_SUCCESS;
Status = g_org_get_variable(VariableName, VendorGuid, Attributes, DataSize, Data); Status = g_org_get_variable(VariableName, VendorGuid, Attributes, DataSize, Data);
if (StrCmp(VariableName, L"SecureBoot") == 0) if (StrCmp(VariableName, L"SecureBoot") == 0)
{ {
@@ -779,7 +779,7 @@ EFI_STATUS EFIAPI ventoy_exit_boot_service_wrapper
gRT->GetVariable = g_org_get_variable; gRT->GetVariable = g_org_get_variable;
g_org_get_variable = NULL; g_org_get_variable = NULL;
} }
return g_org_exit_boot_service(ImageHandle, MapKey); return g_org_exit_boot_service(ImageHandle, MapKey);
} }
@@ -803,12 +803,12 @@ STATIC EFI_STATUS EFIAPI ventoy_disable_secure_boot(IN EFI_HANDLE ImageHandle)
/* step1: wrapper security protocol. */ /* step1: wrapper security protocol. */
/* Do we still need it since we have been loaded ? */ /* Do we still need it since we have been loaded ? */
/* step2: fake SecureBoot variable */ /* step2: fake SecureBoot variable */
g_org_exit_boot_service = gBS->ExitBootServices; g_org_exit_boot_service = gBS->ExitBootServices;
gBS->ExitBootServices = ventoy_exit_boot_service_wrapper; gBS->ExitBootServices = ventoy_exit_boot_service_wrapper;
g_org_get_variable = gRT->GetVariable; g_org_get_variable = gRT->GetVariable;
gRT->GetVariable = ventoy_get_variable_wrapper; gRT->GetVariable = ventoy_get_variable_wrapper;
@@ -817,7 +817,7 @@ STATIC EFI_STATUS EFIAPI ventoy_disable_secure_boot(IN EFI_HANDLE ImageHandle)
STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle) STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
{ {
UINT32 i = 0; UINT32 i = 0;
UINT32 old_cnt = 0; UINT32 old_cnt = 0;
UINTN size = 0; UINTN size = 0;
@@ -846,12 +846,12 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
{ {
gDebugPrint = TRUE; gDebugPrint = TRUE;
} }
if (StrStr(pCmdLine, L"fallback")) if (StrStr(pCmdLine, L"fallback"))
{ {
gBootFallBack = TRUE; gBootFallBack = TRUE;
} }
if (StrStr(pCmdLine, L"dotefi")) if (StrStr(pCmdLine, L"dotefi"))
{ {
gDotEfiBoot = TRUE; gDotEfiBoot = TRUE;
@@ -861,7 +861,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
{ {
gLoadIsoEfi = TRUE; gLoadIsoEfi = TRUE;
} }
if (StrStr(pCmdLine, L"iso_udf")) if (StrStr(pCmdLine, L"iso_udf"))
{ {
gIsoUdf = TRUE; gIsoUdf = TRUE;
@@ -899,7 +899,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
{ {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
pGrubParam = (ventoy_grub_param *)StrHexToUintn(pPos + StrLen(L"env_param=")); pGrubParam = (ventoy_grub_param *)StrHexToUintn(pPos + StrLen(L"env_param="));
grub_env_set = pGrubParam->grub_env_set; grub_env_set = pGrubParam->grub_env_set;
grub_env_get = pGrubParam->grub_env_get; grub_env_get = pGrubParam->grub_env_get;
@@ -914,7 +914,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
ventoy_warn_invalid_device(); ventoy_warn_invalid_device();
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
g_file_replace_list = &pGrubParam->file_replace; g_file_replace_list = &pGrubParam->file_replace;
old_cnt = g_file_replace_list->old_file_cnt; old_cnt = g_file_replace_list->old_file_cnt;
debug("file replace: magic:0x%x virtid:%u name count:%u <%a> <%a> <%a> <%a>", debug("file replace: magic:0x%x virtid:%u name count:%u <%a> <%a> <%a> <%a>",
@@ -927,7 +927,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
old_cnt > 3 ? g_file_replace_list->old_file_name[3] : "" old_cnt > 3 ? g_file_replace_list->old_file_name[3] : ""
); );
for (i = 0; i < VTOY_MAX_CONF_REPLACE; i++) for (i = 0; i < VTOY_MAX_CONF_REPLACE; i++)
{ {
replace = pGrubParam->img_replace + i; replace = pGrubParam->img_replace + i;
@@ -948,7 +948,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
} }
} }
pPos = StrStr(pCmdLine, L"mem:"); pPos = StrStr(pCmdLine, L"mem:");
chain = (ventoy_chain_head *)StrHexToUintn(pPos + 4); chain = (ventoy_chain_head *)StrHexToUintn(pPos + 4);
@@ -977,7 +977,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
debug("This is normal mode"); debug("This is normal mode");
g_chain = AllocatePool(size); g_chain = AllocatePool(size);
CopyMem(g_chain, chain, size); CopyMem(g_chain, chain, size);
g_chunk = (ventoy_img_chunk *)((char *)g_chain + g_chain->img_chunk_offset); g_chunk = (ventoy_img_chunk *)((char *)g_chain + g_chain->img_chunk_offset);
g_img_chunk_num = g_chain->img_chunk_num; g_img_chunk_num = g_chain->img_chunk_num;
g_override_chunk = (ventoy_override_chunk *)((char *)g_chain + g_chain->override_chunk_offset); g_override_chunk = (ventoy_override_chunk *)((char *)g_chain + g_chain->override_chunk_offset);
@@ -997,7 +997,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
{ {
g_hook_keyboard = TRUE; g_hook_keyboard = TRUE;
} }
if (g_os_param_reserved[5] == 1 && g_os_param_reserved[2] == ventoy_chain_linux) if (g_os_param_reserved[5] == 1 && g_os_param_reserved[2] == ventoy_chain_linux)
{ {
ventoy_disable_secure_boot(ImageHandle); ventoy_disable_secure_boot(ImageHandle);
@@ -1024,7 +1024,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
} }
g_fix_windows_1st_cdrom_issue = FALSE; g_fix_windows_1st_cdrom_issue = FALSE;
if (ventoy_chain_windows == g_os_param_reserved[2] || if (ventoy_chain_windows == g_os_param_reserved[2] ||
ventoy_chain_wim == g_os_param_reserved[2]) ventoy_chain_wim == g_os_param_reserved[2])
{ {
if (ventoy_is_cdrom_dp_exist()) if (ventoy_is_cdrom_dp_exist())
@@ -1066,7 +1066,7 @@ EFI_STATUS EFIAPI ventoy_clean_env(VOID)
if (!gMemdiskMode) if (!gMemdiskMode)
{ {
FreePool(g_chain); FreePool(g_chain);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
@@ -1126,7 +1126,7 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
Count = 0; Count = 0;
Handles = NULL; Handles = NULL;
Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiSimpleFileSystemProtocolGuid, Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiSimpleFileSystemProtocolGuid,
NULL, &Count, &Handles); NULL, &Count, &Handles);
if (EFI_ERROR(Status)) if (EFI_ERROR(Status))
{ {
@@ -1145,7 +1145,7 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
debug("FS:%u Protocol:%p OpenVolume:%p", i, pFile, pFile->OpenVolume); debug("FS:%u Protocol:%p OpenVolume:%p", i, pFile, pFile->OpenVolume);
Status = gBS->OpenProtocol(Handles[i], &gEfiDevicePathProtocolGuid, Status = gBS->OpenProtocol(Handles[i], &gEfiDevicePathProtocolGuid,
(VOID **)&pDevPath, (VOID **)&pDevPath,
ImageHandle, ImageHandle,
Handles[i], Handles[i],
@@ -1165,7 +1165,7 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
for (j = gBootFileStartIndex; j < ARRAY_SIZE(gEfiBootFileName); j++) for (j = gBootFileStartIndex; j < ARRAY_SIZE(gEfiBootFileName); j++)
{ {
Status = ventoy_load_image(ImageHandle, pDevPath, gEfiBootFileName[j], Status = ventoy_load_image(ImageHandle, pDevPath, gEfiBootFileName[j],
StrSize(gEfiBootFileName[j]), &Image); StrSize(gEfiBootFileName[j]), &Image);
if (EFI_SUCCESS == Status) if (EFI_SUCCESS == Status)
{ {
@@ -1187,7 +1187,7 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
{ {
gST->ConIn->Reset(gST->ConIn, FALSE); gST->ConIn->Reset(gST->ConIn, FALSE);
} }
if ((g_file_replace_list && g_file_replace_list->magic == GRUB_FILE_REPLACE_MAGIC) || g_img_replace_list) if ((g_file_replace_list && g_file_replace_list->magic == GRUB_FILE_REPLACE_MAGIC) || g_img_replace_list)
{ {
ventoy_wrapper_push_openvolume(pFile->OpenVolume); ventoy_wrapper_push_openvolume(pFile->OpenVolume);
@@ -1199,7 +1199,7 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
//ventoy_wrapper_system(); //ventoy_wrapper_system();
Status = gBS->StartImage(Image, NULL, NULL); Status = gBS->StartImage(Image, NULL, NULL);
ventoy_hook_stop(); ventoy_hook_stop();
if (EFI_ERROR(Status)) if (EFI_ERROR(Status))
{ {
debug("Failed to start image %r", Status); debug("Failed to start image %r", Status);
@@ -1217,7 +1217,7 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
{ {
break; break;
} }
debug("Fs not found, now wait and retry..."); debug("Fs not found, now wait and retry...");
sleep(1); sleep(1);
} }
@@ -1239,7 +1239,7 @@ EFI_STATUS EFIAPI VentoyEfiMain
{ {
EFI_STATUS Status = EFI_SUCCESS; EFI_STATUS Status = EFI_SUCCESS;
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *Protocol; EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *Protocol;
g_sector_flag_num = 512; /* initial value */ g_sector_flag_num = 512; /* initial value */
g_sector_flag = AllocatePool(g_sector_flag_num * sizeof(ventoy_sector_flag)); g_sector_flag = AllocatePool(g_sector_flag_num * sizeof(ventoy_sector_flag));
@@ -1263,6 +1263,11 @@ EFI_STATUS EFIAPI VentoyEfiMain
return Status; return Status;
} }
if (g_os_param_reserved[11])
{
ventoy_lock_res(g_os_param_reserved[11]);
}
ventoy_disable_ex_filesystem(); ventoy_disable_ex_filesystem();
if (gMemdiskMode) if (gMemdiskMode)
@@ -1278,12 +1283,12 @@ EFI_STATUS EFIAPI VentoyEfiMain
ventoy_find_iso_disk_fs(ImageHandle); ventoy_find_iso_disk_fs(ImageHandle);
ventoy_load_isoefi_driver(ImageHandle); ventoy_load_isoefi_driver(ImageHandle);
} }
ventoy_install_blockio(ImageHandle, g_iso_buf_size); ventoy_install_blockio(ImageHandle, g_iso_buf_size);
ventoy_debug_pause(); ventoy_debug_pause();
Status = ventoy_boot(ImageHandle); Status = ventoy_boot(ImageHandle);
ventoy_delete_ramdisk_param(); ventoy_delete_ramdisk_param();
if (gLoadIsoEfi && gBlockData.IsoDriverImage) if (gLoadIsoEfi && gBlockData.IsoDriverImage)
@@ -1310,14 +1315,14 @@ EFI_STATUS EFIAPI VentoyEfiMain
} }
ventoy_debug_pause(); ventoy_debug_pause();
ventoy_install_blockio(ImageHandle, g_chain->virt_img_size_in_bytes); ventoy_install_blockio(ImageHandle, g_chain->virt_img_size_in_bytes);
ventoy_debug_pause(); ventoy_debug_pause();
Status = ventoy_boot(ImageHandle); Status = ventoy_boot(ImageHandle);
} }
ventoy_clean_env(); ventoy_clean_env();
} }
@@ -1330,17 +1335,22 @@ EFI_STATUS EFIAPI VentoyEfiMain
sleep(30); sleep(30);
} }
} }
ventoy_clear_input(); ventoy_clear_input();
gST->ConOut->ClearScreen(gST->ConOut); gST->ConOut->ClearScreen(gST->ConOut);
if (gDotEfiBoot && (EFI_NOT_FOUND == Status)) if (gDotEfiBoot && (EFI_NOT_FOUND == Status))
{ {
grub_env_set("vtoy_dotefi_retry", "YES"); grub_env_set("vtoy_dotefi_retry", "YES");
} }
ventoy_enable_ex_filesystem(); ventoy_enable_ex_filesystem();
if (g_os_param_reserved[11])
{
ventoy_unlock_res();
}
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@@ -7,22 +7,24 @@
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of the * published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>. * along with this program; if not, see <http://www.gnu.org/licenses/>.
* *
*/ */
#ifndef __VENTOY_H__ #ifndef __VENTOY_H__
#define __VENTOY_H__ #define __VENTOY_H__
#define COMPILE_ASSERT(expr) extern char __compile_assert[(expr) ? 1 : -1] #define COMPILE_ASSERT(expr) extern char __compile_assert[(expr) ? 1 : -1]
#define VTOY_SHIM_POLICY_GUID {0x90a29d14, 0x3968, 0x48fe, { 0x85, 0x81, 0x6b, 0x7f, 0x7d, 0xc4, 0x70, 0x55 }};
#define VENTOY_GUID { 0x77772020, 0x2e77, 0x6576, { 0x6e, 0x74, 0x6f, 0x79, 0x2e, 0x6e, 0x65, 0x74 }} #define VENTOY_GUID { 0x77772020, 0x2e77, 0x6576, { 0x6e, 0x74, 0x6f, 0x79, 0x2e, 0x6e, 0x65, 0x74 }}
typedef enum ventoy_chain_type typedef enum ventoy_chain_type
@@ -54,7 +56,7 @@ typedef struct ventoy_image_disk_region
typedef struct ventoy_image_location typedef struct ventoy_image_location
{ {
ventoy_guid guid; ventoy_guid guid;
/* image sector size, currently this value is always 2048 */ /* image sector size, currently this value is always 2048 */
UINT32 image_sector_size; UINT32 image_sector_size;
@@ -62,10 +64,10 @@ typedef struct ventoy_image_location
UINT32 disk_sector_size; UINT32 disk_sector_size;
UINT32 region_count; UINT32 region_count;
/* /*
* disk region data * 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. * there will be more than one region data here.
* *
*/ */
@@ -86,7 +88,7 @@ typedef struct ventoy_os_param
char vtoy_img_path[384]; // It seems to be enough, utf-8 format char vtoy_img_path[384]; // It seems to be enough, utf-8 format
UINT64 vtoy_img_size; // image file size in bytes UINT64 vtoy_img_size; // image file size in bytes
/* /*
* Ventoy will write a copy of ventoy_image_location data into runtime memory * Ventoy will write a copy of ventoy_image_location data into runtime memory
* this is the physically address and length of that memory. * this is the physically address and length of that memory.
* Address 0 means no such data exist. * Address 0 means no such data exist.
@@ -95,7 +97,7 @@ typedef struct ventoy_os_param
*/ */
UINT64 vtoy_img_location_addr; UINT64 vtoy_img_location_addr;
UINT32 vtoy_img_location_len; UINT32 vtoy_img_location_len;
UINT64 vtoy_reserved[4]; // Internal use by ventoy UINT64 vtoy_reserved[4]; // Internal use by ventoy
UINT8 vtoy_disk_signature[4]; UINT8 vtoy_disk_signature[4];
@@ -124,7 +126,7 @@ typedef struct ventoy_chain_head
UINT64 virt_img_size_in_bytes; UINT64 virt_img_size_in_bytes;
UINT32 boot_catalog; UINT32 boot_catalog;
UINT8 boot_catalog_sector[2048]; UINT8 boot_catalog_sector[2048];
UINT32 img_chunk_offset; UINT32 img_chunk_offset;
UINT32 img_chunk_num; UINT32 img_chunk_num;
@@ -199,11 +201,11 @@ typedef struct ventoy_virt_chunk
typedef struct ventoy_sector_flag typedef struct ventoy_sector_flag
{ {
UINT8 flag; // 0:init 1:mem 2:remap UINT8 flag; // 0:init 1:mem 2:remap
UINT64 remap_lba; UINT64 remap_lba;
}ventoy_sector_flag; }ventoy_sector_flag;
typedef struct vtoy_block_data typedef struct vtoy_block_data
{ {
EFI_HANDLE Handle; EFI_HANDLE Handle;
EFI_BLOCK_IO_MEDIA Media; /* Media descriptor */ EFI_BLOCK_IO_MEDIA Media; /* Media descriptor */
@@ -272,7 +274,7 @@ typedef struct ventoy_grub_param
grub_env_set_pf grub_env_set; grub_env_set_pf grub_env_set;
ventoy_grub_param_file_replace file_replace; ventoy_grub_param_file_replace file_replace;
ventoy_grub_param_file_replace img_replace[VTOY_MAX_CONF_REPLACE]; ventoy_grub_param_file_replace img_replace[VTOY_MAX_CONF_REPLACE];
grub_env_printf_pf grub_env_printf; grub_env_printf_pf grub_env_printf;
}ventoy_grub_param; }ventoy_grub_param;
typedef struct ventoy_ram_disk typedef struct ventoy_ram_disk
@@ -318,7 +320,7 @@ typedef struct MBR_HEAD
#pragma pack() #pragma pack()
typedef struct well_known_guid typedef struct well_known_guid
{ {
EFI_GUID *guid; EFI_GUID *guid;
const char *name; const char *name;
@@ -331,7 +333,7 @@ typedef struct ventoy_system_wrapper
EFI_HANDLE_PROTOCOL NewHandleProtocol; EFI_HANDLE_PROTOCOL NewHandleProtocol;
EFI_HANDLE_PROTOCOL OriHandleProtocol; EFI_HANDLE_PROTOCOL OriHandleProtocol;
EFI_OPEN_PROTOCOL NewOpenProtocol; EFI_OPEN_PROTOCOL NewOpenProtocol;
EFI_OPEN_PROTOCOL OriOpenProtocol; EFI_OPEN_PROTOCOL OriOpenProtocol;
@@ -382,7 +384,7 @@ typedef struct DriverBindWrapper
extern BOOLEAN gDebugPrint; extern BOOLEAN gDebugPrint;
VOID EFIAPI VtoyDebug(IN CONST CHAR8 *Format, ...); VOID EFIAPI VtoyDebug(IN CONST CHAR8 *Format, ...);
EFI_STATUS EFIAPI ventoy_wrapper_system(VOID); EFI_STATUS EFIAPI ventoy_wrapper_system(VOID);
EFI_STATUS EFIAPI ventoy_block_io_read EFI_STATUS EFIAPI ventoy_block_io_read
( (
IN EFI_BLOCK_IO_PROTOCOL *This, IN EFI_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId, IN UINT32 MediaId,
@@ -428,6 +430,8 @@ EFI_STATUS ventoy_hook_1st_cdrom_start(VOID);
EFI_STATUS ventoy_hook_1st_cdrom_stop(VOID); EFI_STATUS ventoy_hook_1st_cdrom_stop(VOID);
EFI_STATUS ventoy_disable_ex_filesystem(VOID); EFI_STATUS ventoy_disable_ex_filesystem(VOID);
EFI_STATUS ventoy_enable_ex_filesystem(VOID); EFI_STATUS ventoy_enable_ex_filesystem(VOID);
EFI_STATUS ventoy_lock_res(UINT8 LockType);
EFI_STATUS ventoy_unlock_res(VOID);
#endif #endif
@@ -24,6 +24,10 @@
VERSION_STRING = 1.0 VERSION_STRING = 1.0
ENTRY_POINT = VentoyEfiMain ENTRY_POINT = VentoyEfiMain
[BuildOptions]
# Force standard GNU ld to pack and align ELF segments to 4KB page boundaries
GCC:*_*_*_DLINK_FLAGS = -Wl,-z,common-page-size=0x1000 -Wl,-z,max-page-size=0x1000
[Sources] [Sources]
Ventoy.h Ventoy.h
@@ -7,12 +7,12 @@
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of the * published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>. * along with this program; if not, see <http://www.gnu.org/licenses/>.
* *
@@ -85,7 +85,7 @@ BOOLEAN ventoy_is_cdrom_dp_exist(VOID)
EFI_STATUS Status = EFI_SUCCESS; EFI_STATUS Status = EFI_SUCCESS;
EFI_DEVICE_PATH_PROTOCOL *DevicePath = NULL; EFI_DEVICE_PATH_PROTOCOL *DevicePath = NULL;
Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiDevicePathProtocolGuid, Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiDevicePathProtocolGuid,
NULL, &Count, &Handles); NULL, &Count, &Handles);
if (EFI_ERROR(Status)) if (EFI_ERROR(Status))
{ {
@@ -107,24 +107,24 @@ BOOLEAN ventoy_is_cdrom_dp_exist(VOID)
FreePool(Handles); FreePool(Handles);
return TRUE; return TRUE;
} }
DevicePath = NextDevicePathNode(DevicePath); DevicePath = NextDevicePathNode(DevicePath);
} }
} }
FreePool(Handles); FreePool(Handles);
return FALSE; return FALSE;
} }
#if 0 #if 0
/* Block IO procotol */ /* Block IO procotol */
#endif #endif
EFI_STATUS EFIAPI ventoy_block_io_reset EFI_STATUS EFIAPI ventoy_block_io_reset
( (
IN EFI_BLOCK_IO_PROTOCOL *This, IN EFI_BLOCK_IO_PROTOCOL *This,
IN BOOLEAN ExtendedVerification IN BOOLEAN ExtendedVerification
) )
{ {
(VOID)This; (VOID)This;
(VOID)ExtendedVerification; (VOID)ExtendedVerification;
@@ -151,8 +151,8 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
ventoy_img_chunk *pchunk = g_chunk; ventoy_img_chunk *pchunk = g_chunk;
ventoy_override_chunk *pOverride = g_override_chunk; ventoy_override_chunk *pOverride = g_override_chunk;
EFI_BLOCK_IO_PROTOCOL *pRawBlockIo = gBlockData.pRawBlockIo; EFI_BLOCK_IO_PROTOCOL *pRawBlockIo = gBlockData.pRawBlockIo;
debug("read iso sector %lu count %u Buffer:%p Align:%u blk:%u", debug("read iso sector %lu count %u Buffer:%p Align:%u blk:%u",
Sector, Count, Buffer, pRawBlockIo->Media->IoAlign, pRawBlockIo->Media->BlockSize); Sector, Count, Buffer, pRawBlockIo->Media->IoAlign, pRawBlockIo->Media->BlockSize);
ReadStart = Sector * 2048; ReadStart = Sector * 2048;
@@ -207,7 +207,7 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
{ {
OverrideStart = pOverride->img_offset; OverrideStart = pOverride->img_offset;
OverrideEnd = pOverride->img_offset + pOverride->override_size; OverrideEnd = pOverride->img_offset + pOverride->override_size;
if (OverrideStart >= ReadEnd || ReadStart >= OverrideEnd) if (OverrideStart >= ReadEnd || ReadStart >= OverrideEnd)
{ {
continue; continue;
@@ -217,7 +217,7 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
{ {
if (ReadEnd <= OverrideEnd) if (ReadEnd <= OverrideEnd)
{ {
CopyMem(pCurBuf + OverrideStart - ReadStart, pOverride->override_data, ReadEnd - OverrideStart); CopyMem(pCurBuf + OverrideStart - ReadStart, pOverride->override_data, ReadEnd - OverrideStart);
} }
else else
{ {
@@ -228,7 +228,7 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
{ {
if (ReadEnd <= OverrideEnd) if (ReadEnd <= OverrideEnd)
{ {
CopyMem(pCurBuf, pOverride->override_data + ReadStart - OverrideStart, ReadEnd - ReadStart); CopyMem(pCurBuf, pOverride->override_data + ReadStart - OverrideStart, ReadEnd - ReadStart);
} }
else else
{ {
@@ -236,7 +236,7 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
} }
} }
if (g_fixup_iso9660_secover_enable && (!g_fixup_iso9660_secover_start) && if (g_fixup_iso9660_secover_enable && (!g_fixup_iso9660_secover_start) &&
pOverride->override_size == sizeof(ventoy_iso9660_override)) pOverride->override_size == sizeof(ventoy_iso9660_override))
{ {
ventoy_iso9660_override *dirent = (ventoy_iso9660_override *)pOverride->override_data; ventoy_iso9660_override *dirent = (ventoy_iso9660_override *)pOverride->override_data;
@@ -256,7 +256,7 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
} }
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
STATIC EFI_STATUS EFIAPI ventoy_write_iso_sector STATIC EFI_STATUS EFIAPI ventoy_write_iso_sector
@@ -276,7 +276,7 @@ STATIC EFI_STATUS EFIAPI ventoy_write_iso_sector
UINT8 *pCurBuf = (UINT8 *)Buffer; UINT8 *pCurBuf = (UINT8 *)Buffer;
ventoy_img_chunk *pchunk = g_chunk; ventoy_img_chunk *pchunk = g_chunk;
EFI_BLOCK_IO_PROTOCOL *pRawBlockIo = gBlockData.pRawBlockIo; EFI_BLOCK_IO_PROTOCOL *pRawBlockIo = gBlockData.pRawBlockIo;
debug("write iso sector %lu count %u", Sector, Count); debug("write iso sector %lu count %u", Sector, Count);
ReadStart = Sector * 2048; ReadStart = Sector * 2048;
@@ -321,17 +321,17 @@ STATIC EFI_STATUS EFIAPI ventoy_write_iso_sector
} }
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFIAPI ventoy_block_io_ramdisk_write EFI_STATUS EFIAPI ventoy_block_io_ramdisk_write
( (
IN EFI_BLOCK_IO_PROTOCOL *This, IN EFI_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId, IN UINT32 MediaId,
IN EFI_LBA Lba, IN EFI_LBA Lba,
IN UINTN BufferSize, IN UINTN BufferSize,
IN VOID *Buffer IN VOID *Buffer
) )
{ {
(VOID)This; (VOID)This;
(VOID)MediaId; (VOID)MediaId;
@@ -349,14 +349,14 @@ EFI_STATUS EFIAPI ventoy_block_io_ramdisk_write
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFIAPI ventoy_block_io_ramdisk_read EFI_STATUS EFIAPI ventoy_block_io_ramdisk_read
( (
IN EFI_BLOCK_IO_PROTOCOL *This, IN EFI_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId, IN UINT32 MediaId,
IN EFI_LBA Lba, IN EFI_LBA Lba,
IN UINTN BufferSize, IN UINTN BufferSize,
OUT VOID *Buffer OUT VOID *Buffer
) )
{ {
//debug("### ventoy_block_io_ramdisk_read sector:%u count:%u", (UINT32)Lba, (UINT32)BufferSize / 2048); //debug("### ventoy_block_io_ramdisk_read sector:%u count:%u", (UINT32)Lba, (UINT32)BufferSize / 2048);
@@ -364,12 +364,12 @@ EFI_STATUS EFIAPI ventoy_block_io_ramdisk_read
(VOID)MediaId; (VOID)MediaId;
CopyMem(Buffer, g_iso_data_buf + (Lba * 2048), BufferSize); CopyMem(Buffer, g_iso_data_buf + (Lba * 2048), BufferSize);
if (g_blockio_start_record_bcd && FALSE == g_blockio_bcd_read_done) if (g_blockio_start_record_bcd && FALSE == g_blockio_bcd_read_done)
{ {
if (*(UINT32 *)Buffer == 0x66676572) if (*(UINT32 *)Buffer == 0x66676572)
{ {
g_blockio_bcd_read_done = TRUE; g_blockio_bcd_read_done = TRUE;
} }
} }
@@ -429,14 +429,14 @@ end:
return Lba; return Lba;
} }
EFI_STATUS EFIAPI ventoy_block_io_read_real EFI_STATUS EFIAPI ventoy_block_io_read_real
( (
IN EFI_BLOCK_IO_PROTOCOL *This, IN EFI_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId, IN UINT32 MediaId,
IN EFI_LBA Lba, IN EFI_LBA Lba,
IN UINTN BufferSize, IN UINTN BufferSize,
OUT VOID *Buffer OUT VOID *Buffer
) )
{ {
UINT32 i = 0; UINT32 i = 0;
UINT32 j = 0; UINT32 j = 0;
@@ -450,7 +450,7 @@ EFI_STATUS EFIAPI ventoy_block_io_read_real
UINT8 *lastbuffer; UINT8 *lastbuffer;
ventoy_sector_flag *cur_flag; ventoy_sector_flag *cur_flag;
ventoy_virt_chunk *node; ventoy_virt_chunk *node;
debug("### block_io_read_real sector:%u count:%u Buffer:%p", (UINT32)Lba, (UINT32)BufferSize / 2048, Buffer); debug("### block_io_read_real sector:%u count:%u Buffer:%p", (UINT32)Lba, (UINT32)BufferSize / 2048, Buffer);
secNum = BufferSize / 2048; secNum = BufferSize / 2048;
@@ -510,7 +510,7 @@ EFI_STATUS EFIAPI ventoy_block_io_read_real
{ {
if (curlba >= node->mem_sector_start && curlba < node->mem_sector_end) if (curlba >= node->mem_sector_start && curlba < node->mem_sector_end)
{ {
CopyMem((UINT8 *)Buffer + j * 2048, CopyMem((UINT8 *)Buffer + j * 2048,
(char *)g_virt_chunk + node->mem_sector_offset + (curlba - node->mem_sector_start) * 2048, (char *)g_virt_chunk + node->mem_sector_offset + (curlba - node->mem_sector_start) * 2048,
2048); 2048);
cur_flag->flag = 1; cur_flag->flag = 1;
@@ -564,7 +564,7 @@ EFI_STATUS EFIAPI ventoy_block_io_read
IN EFI_LBA Lba, IN EFI_LBA Lba,
IN UINTN BufferSize, IN UINTN BufferSize,
OUT VOID *Buffer OUT VOID *Buffer
) )
{ {
UINT32 IoAlign = 0; UINT32 IoAlign = 0;
VOID *NewBuf = NULL; VOID *NewBuf = NULL;
@@ -593,18 +593,18 @@ EFI_STATUS EFIAPI ventoy_block_io_read
return Status; return Status;
} }
EFI_STATUS EFIAPI ventoy_block_io_write EFI_STATUS EFIAPI ventoy_block_io_write
( (
IN EFI_BLOCK_IO_PROTOCOL *This, IN EFI_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId, IN UINT32 MediaId,
IN EFI_LBA Lba, IN EFI_LBA Lba,
IN UINTN BufferSize, IN UINTN BufferSize,
IN VOID *Buffer IN VOID *Buffer
) )
{ {
UINT32 secNum = 0; UINT32 secNum = 0;
UINT64 offset = 0; UINT64 offset = 0;
(VOID)This; (VOID)This;
(VOID)MediaId; (VOID)MediaId;
@@ -636,8 +636,8 @@ STATIC UINTN ventoy_get_current_device_path_id(VOID)
EFI_STATUS Status = EFI_SUCCESS; EFI_STATUS Status = EFI_SUCCESS;
EFI_DEVICE_PATH_PROTOCOL *DevicePath = NULL; EFI_DEVICE_PATH_PROTOCOL *DevicePath = NULL;
VENDOR_DEVICE_PATH *venPath = NULL; VENDOR_DEVICE_PATH *venPath = NULL;
Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiDevicePathProtocolGuid, Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiDevicePathProtocolGuid,
NULL, &Count, &Handles); NULL, &Count, &Handles);
if (EFI_ERROR(Status)) if (EFI_ERROR(Status))
{ {
@@ -688,7 +688,7 @@ EFI_STATUS EFIAPI ventoy_fill_device_path(VOID)
venPath->Header.Length[1] = 0; venPath->Header.Length[1] = 0;
CopyMem(&venPath->Guid, &gVtoyBlockDevicePathGuid, sizeof(EFI_GUID)); CopyMem(&venPath->Guid, &gVtoyBlockDevicePathGuid, sizeof(EFI_GUID));
CopyMem(venPath + 1, VtoyDpName, NameLen); CopyMem(venPath + 1, VtoyDpName, NameLen);
gBlockData.Path = AppendDevicePathNode(NULL, (EFI_DEVICE_PATH_PROTOCOL *)TmpBuf); gBlockData.Path = AppendDevicePathNode(NULL, (EFI_DEVICE_PATH_PROTOCOL *)TmpBuf);
gBlockData.DevicePathCompareLen = sizeof(VENDOR_DEVICE_PATH) + NameLen; gBlockData.DevicePathCompareLen = sizeof(VENDOR_DEVICE_PATH) + NameLen;
@@ -710,7 +710,7 @@ EFI_STATUS EFIAPI ventoy_connect_driver(IN EFI_HANDLE ControllerHandle, IN CONST
debug("ventoy_connect_driver <%s>...", DrvName); debug("ventoy_connect_driver <%s>...", DrvName);
Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentName2ProtocolGuid, Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentName2ProtocolGuid,
NULL, &Count, &Handles); NULL, &Count, &Handles);
if (EFI_ERROR(Status)) if (EFI_ERROR(Status))
{ {
@@ -748,7 +748,7 @@ EFI_STATUS EFIAPI ventoy_connect_driver(IN EFI_HANDLE ControllerHandle, IN CONST
FreePool(Handles); FreePool(Handles);
Handles = NULL; Handles = NULL;
Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentNameProtocolGuid, Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentNameProtocolGuid,
NULL, &Count, &Handles); NULL, &Count, &Handles);
if (EFI_ERROR(Status)) if (EFI_ERROR(Status))
{ {
@@ -781,10 +781,10 @@ EFI_STATUS EFIAPI ventoy_connect_driver(IN EFI_HANDLE ControllerHandle, IN CONST
} }
Status = EFI_NOT_FOUND; Status = EFI_NOT_FOUND;
end: end:
FreePool(Handles); FreePool(Handles);
return Status; return Status;
} }
@@ -805,11 +805,11 @@ STATIC BOOLEAN ventoy_filesystem_need_wrapper(IN CONST CHAR16 *DrvName)
} }
/* /*
* suppress some file system drivers * suppress some file system drivers
* 1. rEFInd File System Driver * 1. rEFInd File System Driver
* *
*/ */
if (StrStr(UpperDrvName, L"REFIND") && StrStr(UpperDrvName, L"FILE SYSTEM")) if (StrStr(UpperDrvName, L"REFIND") && StrStr(UpperDrvName, L"FILE SYSTEM"))
{ {
return TRUE; return TRUE;
@@ -820,7 +820,7 @@ STATIC BOOLEAN ventoy_filesystem_need_wrapper(IN CONST CHAR16 *DrvName)
STATIC VOID ventoy_add_filesystem_wrapper STATIC VOID ventoy_add_filesystem_wrapper
( (
IN EFI_DRIVER_BINDING_PROTOCOL *DriverBindProtocol, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBindProtocol,
IN CONST CHAR16 *DriverName IN CONST CHAR16 *DriverName
) )
{ {
@@ -865,10 +865,10 @@ STATIC EFI_STATUS ventoy_find_filesystem_driverbind(VOID)
EFI_COMPONENT_NAME_PROTOCOL *NameProtocol = NULL; EFI_COMPONENT_NAME_PROTOCOL *NameProtocol = NULL;
EFI_COMPONENT_NAME2_PROTOCOL *Name2Protocol = NULL; EFI_COMPONENT_NAME2_PROTOCOL *Name2Protocol = NULL;
EFI_DRIVER_BINDING_PROTOCOL *DriverBindProtocol = NULL; EFI_DRIVER_BINDING_PROTOCOL *DriverBindProtocol = NULL;
debug("ventoy_find_filesystem_driverbind..."); debug("ventoy_find_filesystem_driverbind...");
Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentName2ProtocolGuid, Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentName2ProtocolGuid,
NULL, &Count, &Handles); NULL, &Count, &Handles);
if (EFI_ERROR(Status)) if (EFI_ERROR(Status))
{ {
@@ -899,7 +899,7 @@ STATIC EFI_STATUS ventoy_find_filesystem_driverbind(VOID)
FreePool(Handles); FreePool(Handles);
Handles = NULL; Handles = NULL;
Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentNameProtocolGuid, Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentNameProtocolGuid,
NULL, &Count, &Handles); NULL, &Count, &Handles);
if (EFI_ERROR(Status)) if (EFI_ERROR(Status))
{ {
@@ -927,7 +927,7 @@ STATIC EFI_STATUS ventoy_find_filesystem_driverbind(VOID)
} }
FreePool(Handles); FreePool(Handles);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@@ -988,7 +988,7 @@ EFI_STATUS ventoy_disable_ex_filesystem(VOID)
debug("Wrapper Ex Driver Binding %lu", g_DriverBindWrapperCnt); debug("Wrapper Ex Driver Binding %lu", g_DriverBindWrapperCnt);
ventoy_debug_pause(); ventoy_debug_pause();
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@@ -1046,10 +1046,10 @@ EFI_STATUS EFIAPI ventoy_block_io_read_512
if (BufferSize >= 2048) if (BufferSize >= 2048)
{ {
ReadSize = BufferSize / 2048 * 2048; ReadSize = BufferSize / 2048 * 2048;
Status |= g_sector_2048_read(This, MediaId, Lba / 4, ReadSize, CurBuf); Status |= g_sector_2048_read(This, MediaId, Lba / 4, ReadSize, CurBuf);
CurBuf += ReadSize; CurBuf += ReadSize;
Lba += ReadSize / 512; Lba += ReadSize / 512;
BufferSize -= ReadSize; BufferSize -= ReadSize;
} }
@@ -1096,7 +1096,7 @@ EFI_STATUS EFIAPI ventoy_block_io_write_512
ReadSize = (4 - Mod) * 512; ReadSize = (4 - Mod) * 512;
CopyMem(g_sector_buf + Mod * 512, CurBuf, ReadSize); CopyMem(g_sector_buf + Mod * 512, CurBuf, ReadSize);
g_sector_2048_write(This, MediaId, Lba / 4, 2048, g_sector_buf); g_sector_2048_write(This, MediaId, Lba / 4, 2048, g_sector_buf);
CurBuf += ReadSize; CurBuf += ReadSize;
Lba += (4 - Mod); Lba += (4 - Mod);
BufferSize -= ReadSize; BufferSize -= ReadSize;
@@ -1106,10 +1106,10 @@ EFI_STATUS EFIAPI ventoy_block_io_write_512
if (BufferSize >= 2048) if (BufferSize >= 2048)
{ {
ReadSize = BufferSize / 2048 * 2048; ReadSize = BufferSize / 2048 * 2048;
Status |= g_sector_2048_write(This, MediaId, Lba / 4, ReadSize, CurBuf); Status |= g_sector_2048_write(This, MediaId, Lba / 4, ReadSize, CurBuf);
CurBuf += ReadSize; CurBuf += ReadSize;
Lba += ReadSize / 512; Lba += ReadSize / 512;
BufferSize -= ReadSize; BufferSize -= ReadSize;
} }
@@ -1117,7 +1117,7 @@ EFI_STATUS EFIAPI ventoy_block_io_write_512
if (BufferSize > 0) if (BufferSize > 0)
{ {
Status |= g_sector_2048_read(This, MediaId, Lba / 4, 2048, g_sector_buf); Status |= g_sector_2048_read(This, MediaId, Lba / 4, 2048, g_sector_buf);
CopyMem(g_sector_buf, CurBuf, BufferSize); CopyMem(g_sector_buf, CurBuf, BufferSize);
g_sector_2048_write(This, MediaId, Lba / 4, 2048, g_sector_buf); g_sector_2048_write(This, MediaId, Lba / 4, 2048, g_sector_buf);
} }
@@ -1126,10 +1126,10 @@ EFI_STATUS EFIAPI ventoy_block_io_write_512
} }
EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 ImgSize) EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 ImgSize)
{ {
EFI_STATUS Status = EFI_SUCCESS; EFI_STATUS Status = EFI_SUCCESS;
EFI_BLOCK_IO_PROTOCOL *pBlockIo = &(gBlockData.BlockIo); EFI_BLOCK_IO_PROTOCOL *pBlockIo = &(gBlockData.BlockIo);
ventoy_fill_device_path(); ventoy_fill_device_path();
debug("install block io protocol %p", ImageHandle); debug("install block io protocol %p", ImageHandle);
@@ -1144,10 +1144,10 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im
else else
{ {
gBlockData.Media.BlockSize = 2048; gBlockData.Media.BlockSize = 2048;
gBlockData.Media.LastBlock = ImgSize / 2048 - 1; gBlockData.Media.LastBlock = ImgSize / 2048 - 1;
gBlockData.Media.ReadOnly = TRUE; gBlockData.Media.ReadOnly = TRUE;
} }
gBlockData.Media.MediaPresent = 1; gBlockData.Media.MediaPresent = 1;
gBlockData.Media.LogicalBlocksPerPhysicalBlock = 1; gBlockData.Media.LogicalBlocksPerPhysicalBlock = 1;
@@ -1164,10 +1164,10 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im
} }
else else
{ {
pBlockIo->ReadBlocks = gMemdiskMode ? ventoy_block_io_ramdisk_read : ventoy_block_io_read; pBlockIo->ReadBlocks = gMemdiskMode ? ventoy_block_io_ramdisk_read : ventoy_block_io_read;
pBlockIo->WriteBlocks = ventoy_block_io_write; pBlockIo->WriteBlocks = ventoy_block_io_write;
} }
pBlockIo->FlushBlocks = ventoy_block_io_flush; pBlockIo->FlushBlocks = ventoy_block_io_flush;
Status = gBS->InstallMultipleProtocolInterfaces(&gBlockData.Handle, Status = gBS->InstallMultipleProtocolInterfaces(&gBlockData.Handle,
@@ -1295,7 +1295,7 @@ DEF_WRAP_FUNC(7);
#error "VTOY_MAX_CONF_REPLACE overflow" #error "VTOY_MAX_CONF_REPLACE overflow"
#endif #endif
static EFI_FILE_FLUSH_EX g_img_flush_func[VTOY_MAX_CONF_REPLACE] = static EFI_FILE_FLUSH_EX g_img_flush_func[VTOY_MAX_CONF_REPLACE] =
{ {
ventoy_wrapper_file_flush_ex_img0, ventoy_wrapper_file_flush_ex_img0,
ventoy_wrapper_file_flush_ex_img1, ventoy_wrapper_file_flush_ex_img1,
@@ -1335,7 +1335,7 @@ STATIC ventoy_efi_file_replace *ventoy_wrapper_get_replace(EFI_FILE_HANDLE This)
return g_img_file_replace + i; return g_img_file_replace + i;
} }
} }
return NULL; return NULL;
} }
@@ -1369,7 +1369,7 @@ ventoy_wrapper_file_set_pos(EFI_FILE_HANDLE This, UINT64 Position)
ventoy_efi_file_replace *replace = NULL; ventoy_efi_file_replace *replace = NULL;
replace = ventoy_wrapper_get_replace(This); replace = ventoy_wrapper_get_replace(This);
if (Position <= replace->FileSizeBytes) if (Position <= replace->FileSizeBytes)
{ {
replace->CurPos = Position; replace->CurPos = Position;
@@ -1378,7 +1378,7 @@ ventoy_wrapper_file_set_pos(EFI_FILE_HANDLE This, UINT64 Position)
{ {
replace->CurPos = replace->FileSizeBytes; replace->CurPos = replace->FileSizeBytes;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@@ -1425,7 +1425,7 @@ ventoy_wrapper_file_get_info(EFI_FILE_HANDLE This, EFI_GUID *Type, UINTN *Len, V
//Info->FileName = EFI_FILE_READ_ONLY; //Info->FileName = EFI_FILE_READ_ONLY;
*Len = Info->Size; *Len = Info->Size;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@@ -1437,7 +1437,7 @@ ventoy_wrapper_file_read(EFI_FILE_HANDLE This, UINTN *Len, VOID *Data)
ventoy_efi_file_replace *replace = NULL; ventoy_efi_file_replace *replace = NULL;
replace = ventoy_wrapper_get_replace(This); replace = ventoy_wrapper_get_replace(This);
debug("ventoy_wrapper_file_read ... %u", *Len); debug("ventoy_wrapper_file_read ... %u", *Len);
if (replace->CurPos + ReadLen > replace->FileSizeBytes) if (replace->CurPos + ReadLen > replace->FileSizeBytes)
@@ -1491,12 +1491,40 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_procotol(EFI_FILE_PROTOCOL *File, B
return EFI_SUCCESS; return EFI_SUCCESS;
} }
STATIC BOOLEAN EFIAPI ventoy_replace_name_match(CHAR8 *pReplace, CHAR8 *pName)
{
UINTN Len1, Len2;
Len1 = AsciiStrLen(pReplace);
Len2 = AsciiStrLen(pName);
if (Len1 == 0 || Len2 == 0)
{
return FALSE;
}
if (0 == AsciiStriCmp(pReplace, pName))
{
return TRUE;
}
if (Len1 > 2 && Len2 > 2)
{
if ((pReplace[0] != '\\') && (pName[0] == '\\') && (0 == AsciiStriCmp(pReplace, pName + 1)))
{
return TRUE;
}
}
return FALSE;
}
STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
( (
EFI_FILE_HANDLE This, EFI_FILE_HANDLE This,
EFI_FILE_HANDLE *New, EFI_FILE_HANDLE *New,
CHAR16 *Name, CHAR16 *Name,
UINT64 Mode, UINT64 Mode,
UINT64 Attributes UINT64 Attributes
) )
{ {
@@ -1534,7 +1562,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
AsciiSPrint(TmpName, sizeof(TmpName), "%s", Name); AsciiSPrint(TmpName, sizeof(TmpName), "%s", Name);
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
{ {
if (0 == AsciiStriCmp(g_file_replace_list[i].old_file_name[j], TmpName)) if (ventoy_replace_name_match(g_file_replace_list[i].old_file_name[j], TmpName))
{ {
g_original_fclose(*New); g_original_fclose(*New);
*New = &g_efi_file_replace.WrapperHandle; *New = &g_efi_file_replace.WrapperHandle;
@@ -1543,7 +1571,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
virt = g_virt_chunk + g_file_replace_list->new_file_virtual_id; virt = g_virt_chunk + g_file_replace_list->new_file_virtual_id;
Sectors = (virt->mem_sector_end - virt->mem_sector_start) + (virt->remap_sector_end - virt->remap_sector_start); Sectors = (virt->mem_sector_end - virt->mem_sector_start) + (virt->remap_sector_end - virt->remap_sector_start);
g_efi_file_replace.BlockIoSectorStart = virt->mem_sector_start; g_efi_file_replace.BlockIoSectorStart = virt->mem_sector_start;
g_efi_file_replace.FileSizeBytes = Sectors * 2048; g_efi_file_replace.FileSizeBytes = Sectors * 2048;
@@ -1553,7 +1581,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
g_efi_file_replace.BlockIoSectorStart, Sectors, Sectors * 2048); g_efi_file_replace.BlockIoSectorStart, Sectors, Sectors * 2048);
sleep(3); sleep(3);
} }
return Status; return Status;
} }
} }
@@ -1577,9 +1605,9 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
{ {
AsciiStrCpyS(OldName, sizeof(OldName), replace->old_file_name[j]); AsciiStrCpyS(OldName, sizeof(OldName), replace->old_file_name[j]);
if ((0 == AsciiStrCmp(OldName, TmpName)) || if ((0 == AsciiStrCmp(OldName, TmpName)) ||
(AsciiStrnCmp(OldName, "\\loader\\entries\\", 16) == 0 && (AsciiStrnCmp(OldName, "\\loader\\entries\\", 16) == 0 &&
AsciiStrCmp(OldName + 16, TmpName) == 0 AsciiStrCmp(OldName + 16, TmpName) == 0
) )
) )
{ {
g_original_fclose(*New); g_original_fclose(*New);
@@ -1589,7 +1617,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
virt = g_virt_chunk + replace->new_file_virtual_id; virt = g_virt_chunk + replace->new_file_virtual_id;
Sectors = (virt->mem_sector_end - virt->mem_sector_start) + (virt->remap_sector_end - virt->remap_sector_start); Sectors = (virt->mem_sector_end - virt->mem_sector_start) + (virt->remap_sector_end - virt->remap_sector_start);
g_img_file_replace[i].BlockIoSectorStart = virt->mem_sector_start; g_img_file_replace[i].BlockIoSectorStart = virt->mem_sector_start;
g_img_file_replace[i].FileSizeBytes = Sectors * 2048; g_img_file_replace[i].FileSizeBytes = Sectors * 2048;
@@ -1599,7 +1627,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
g_img_file_replace[i].BlockIoSectorStart, Sectors, Sectors * 2048); g_img_file_replace[i].BlockIoSectorStart, Sectors, Sectors * 2048);
sleep(3); sleep(3);
} }
return Status; return Status;
} }
} }
@@ -1620,7 +1648,7 @@ EFI_STATUS EFIAPI ventoy_wrapper_open_volume
) )
{ {
EFI_STATUS Status = EFI_SUCCESS; EFI_STATUS Status = EFI_SUCCESS;
Status = g_original_open_volume(This, Root); Status = g_original_open_volume(This, Root);
if (!EFI_ERROR(Status)) if (!EFI_ERROR(Status))
{ {
@@ -1657,10 +1685,10 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_read_key_ex
KeyData->Key.UnicodeChar = 0; KeyData->Key.UnicodeChar = 0;
KeyData->KeyState.KeyShiftState = 0; KeyData->KeyState.KeyShiftState = 0;
KeyData->KeyState.KeyToggleState = 0; KeyData->KeyState.KeyToggleState = 0;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
return g_org_read_key_ex(This, KeyData); return g_org_read_key_ex(This, KeyData);
} }
@@ -1697,7 +1725,7 @@ EFI_STATUS ventoy_hook_keyboard_start(VOID)
g_org_read_key = gST->ConIn->ReadKeyStroke; g_org_read_key = gST->ConIn->ReadKeyStroke;
gST->ConIn->ReadKeyStroke = ventoy_wrapper_read_key; gST->ConIn->ReadKeyStroke = ventoy_wrapper_read_key;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@@ -1735,7 +1763,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_locate_handle
EFI_STATUS Status = EFI_SUCCESS; EFI_STATUS Status = EFI_SUCCESS;
Status = g_org_locate_handle(SearchType, Protocol, SearchKey, BufferSize, Buffer); Status = g_org_locate_handle(SearchType, Protocol, SearchKey, BufferSize, Buffer);
if (EFI_SUCCESS == Status && Protocol && CompareGuid(&gEfiBlockIoProtocolGuid, Protocol)) if (EFI_SUCCESS == Status && Protocol && CompareGuid(&gEfiBlockIoProtocolGuid, Protocol))
{ {
for (i = 0; i < (*BufferSize) / sizeof(EFI_HANDLE); i++) for (i = 0; i < (*BufferSize) / sizeof(EFI_HANDLE); i++)
@@ -1757,7 +1785,7 @@ EFI_STATUS ventoy_hook_1st_cdrom_start(VOID)
{ {
g_org_locate_handle = gBS->LocateHandle; g_org_locate_handle = gBS->LocateHandle;
gBS->LocateHandle = ventoy_wrapper_locate_handle; gBS->LocateHandle = ventoy_wrapper_locate_handle;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@@ -1765,7 +1793,180 @@ EFI_STATUS ventoy_hook_1st_cdrom_stop(VOID)
{ {
gBS->LocateHandle = g_org_locate_handle; gBS->LocateHandle = g_org_locate_handle;
g_org_locate_handle = NULL; g_org_locate_handle = NULL;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
#if 0
/* For force highest resolution for Windows/WinPE */
#endif
STATIC UINT32 g_org_mode_num = 0;
STATIC EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE g_org_set_mode = NULL;
STATIC EFI_STATUS EFIAPI ventoy_set_mode
(
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
IN UINT32 ModeNumber
)
{
(void)This;
(void)ModeNumber;
/* Force highest resolution */
return EFI_SUCCESS;
}
STATIC EFI_STATUS EFIAPI ventoy_set_mode2
(
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
IN UINT32 ModeNumber
)
{
UINTN Size;
EFI_STATUS rc;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info = NULL;
/* Force >= 1024x768 */
rc = This->QueryMode(This, ModeNumber, &Size, &info);
if (rc == EFI_SUCCESS)
{
if (info->HorizontalResolution < 1024 || info->VerticalResolution < 768)
{
return EFI_SUCCESS;
}
}
return g_org_set_mode(This, ModeNumber);
}
EFI_STATUS ventoy_lock_res(UINT8 LockType)
{
UINT32 i = 0;
UINT32 x = 0;
UINT32 y = 0;
UINT32 SelMode = 0;
UINT32 CurMode = 0;
UINT32 Highest = 0;
UINT32 M1024_768 = MAX_UINT32;
UINTN Size;
EFI_STATUS rc;
EFI_GRAPHICS_OUTPUT_PROTOCOL *gop = NULL;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info = NULL;
/* already hook */
if (g_org_set_mode)
{
return EFI_SUCCESS;
}
/* 1: Highest 2: 1024x768 3: >= 1024x768 */
if (LockType == 0 || LockType > 3)
{
return EFI_SUCCESS;
}
rc = gBS->LocateProtocol(&gEfiGraphicsOutputProtocolGuid, NULL, (void **)&gop);
if (rc != EFI_SUCCESS)
{
debug("Failed to locate GOP protocol");
return EFI_SUCCESS;
}
if (LockType == 3)
{
g_org_mode_num = MAX_UINT32;
g_org_set_mode = gop->SetMode;
gop->SetMode = ventoy_set_mode2;
return EFI_SUCCESS;
}
CurMode = gop->Mode->Mode;
for (i = 0 ; i < gop->Mode->MaxMode ; i++)
{
/* Get mode information */
if (gop->QueryMode(gop, i, &Size, &info) == EFI_SUCCESS)
{
if (info->HorizontalResolution == 1024 && info->VerticalResolution == 768)
{
M1024_768 = i;
}
if (x < info->HorizontalResolution ||
(x == info->HorizontalResolution && y < info->VerticalResolution))
{
Highest = i;
x = info->HorizontalResolution;
y = info->VerticalResolution;
}
}
}
if (LockType == 1)
{
SelMode = Highest;
}
else
{
if (M1024_768 == MAX_UINT32)
{
SelMode = Highest;
}
else
{
SelMode = M1024_768;
x = 1024;
y = 768;
}
}
if (SelMode != CurMode)
{
gop->SetMode(gop, SelMode);
}
debug("Lock resolution to Mode:%d %d x %d", SelMode, x, y);
g_org_mode_num = CurMode;
g_org_set_mode = gop->SetMode;
gop->SetMode = ventoy_set_mode;
return EFI_SUCCESS;
}
EFI_STATUS ventoy_unlock_res(VOID)
{
EFI_STATUS rc;
EFI_GRAPHICS_OUTPUT_PROTOCOL *gop = NULL;
/* not hooked yet */
if (!g_org_set_mode)
{
return EFI_SUCCESS;
}
rc = gBS->LocateProtocol(&gEfiGraphicsOutputProtocolGuid, NULL, (void **)&gop);
if (rc != EFI_SUCCESS)
{
debug("Failed to locate GOP protocol");
return EFI_SUCCESS;
}
if (g_org_mode_num != MAX_UINT32)
{
g_org_set_mode(gop, g_org_mode_num);
}
gop->SetMode = g_org_set_mode;
g_org_set_mode = NULL;
return EFI_SUCCESS;
}
@@ -0,0 +1,665 @@
/******************************************************************************
* 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>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <Library/PeCoffLib.h>
#include <Protocol/LoadedImage.h>
#include <Guid/FileInfo.h>
#include <Guid/FileSystemInfo.h>
#include <Protocol/BlockIo.h>
#include <Protocol/RamDisk.h>
#include <Protocol/SimpleFileSystem.h>
#include <Protocol/DevicePathToText.h>
#include <Protocol/DevicePathFromText.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/Security.h>
#include <Protocol/Security2.h>
#include <IndustryStandard/PeImage.h>
#include <VtoyShim.h>
#define CUR_SBAT_VER 1
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_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;
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, ...)
{
VA_LIST Marker;
CHAR16 Buffer[512];
UINTN BufLen = 0;
Buffer[0] = 0;
VA_START(Marker, Format);
BufLen = UnicodeVSPrint(Buffer, sizeof(Buffer), Format, Marker);
VA_END(Marker);
if (gST->ConOut && gST->ConOut->OutputString)
{
gST->ConOut->OutputString(gST->ConOut, Buffer);
}
}
STATIC VOID EFIAPI DumpDevicePath(const EFI_DEVICE_PATH_PROTOCOL *DevicePath)
{
CHAR16 *DPStr = NULL;
if (DevicePath)
{
DPStr = ConvertDevicePathToText(DevicePath, TRUE, TRUE);
}
if (DPStr)
{
vLog(L"%s", DPStr);
FreePool(DPStr);
}
else
{
vLog(L"NULL");
}
}
STATIC VOID EFIAPI ShowSBWarning(const EFI_DEVICE_PATH_PROTOCOL *DevicePath)
{
vLog(L"\r\n=======================================================");
vLog(L"=======================================================\r\n");
DumpDevicePath(DevicePath);
vLog(L"\r\n####### Ventoy Security Boot Violation ##########\r\n");
vLog(L"=======================================================");
vLog(L"=======================================================");
VtoySleep(5);
}
STATIC VOID * EFIAPI FindShimFuncAddr(UINT64 FuncOffset)
{
EFI_STATUS Status;
SHIM_IMAGE_LOADER *ImgLoader = NULL;
EFI_GUID ShimImgLoaderGuid = SHIM_IMAGE_LOADER_GUID;
Status = gBS->LocateProtocol(&ShimImgLoaderGuid, NULL, (VOID **)&ImgLoader);
if (EFI_ERROR(Status) || !ImgLoader || !ImgLoader->LoadImage)
{
vLog(L"Failed to locate shim image loader protocol %lx %p", Status, ImgLoader);
return NULL;
}
if (NM_SHIM_LOAD_IMAGE_OFFSET > FuncOffset)
{
return (UINT8 *)ImgLoader->LoadImage - (NM_SHIM_LOAD_IMAGE_OFFSET - FuncOffset);
}
else
{
return (UINT8 *)ImgLoader->LoadImage + (FuncOffset - NM_SHIM_LOAD_IMAGE_OFFSET);
}
}
EFI_STATUS EFIAPI LaunchRealGrub(EFI_HANDLE ImageHandle, CONST CHAR16 *FileName)
{
EFI_STATUS Status;
UINTN BufferSize = 0;
CHAR16 *DevDpStr = NULL;
CHAR16 *NewDpStr = NULL;
EFI_HANDLE ChildHandle = NULL;
EFI_LOADED_IMAGE_PROTOCOL *Li = NULL;
EFI_DEVICE_PATH_PROTOCOL *DeviceDP = NULL;
EFI_DEVICE_PATH_PROTOCOL *TargetDp = NULL;
Status = gBS->HandleProtocol(ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID**)&Li);
if (EFI_ERROR(Status))
{
vLog(L"Failed to locate loaded image protocol %lx", Status);
return Status;
}
DeviceDP = DevicePathFromHandle(Li->DeviceHandle);
if (!DeviceDP || !IsDevicePathValid(DeviceDP, 0))
{
vLog(L"Failed to get device path of device handle %p", Li->DeviceHandle);
Status = EFI_NOT_FOUND;
goto END;
}
DevDpStr = ConvertDevicePathToText(DeviceDP, FALSE, TRUE);
if (!DevDpStr)
{
vLog(L"Failed to convert device path to text");
Status = EFI_OUT_OF_RESOURCES;
goto END;
}
BufferSize = (StrLen(DevDpStr) + 64) * sizeof(CHAR16);
NewDpStr = (CHAR16 *)AllocatePool(BufferSize);
if (!NewDpStr)
{
vLog(L"Failed to alloc new device path string buffer size:%lu", BufferSize);
Status = EFI_OUT_OF_RESOURCES;
goto END;
}
UnicodeSPrint(NewDpStr, BufferSize, L"%s/EFI/BOOT/%s", DevDpStr, FileName);
TargetDp = ConvertTextToDevicePath(NewDpStr);
if (!TargetDp)
{
vLog(L"Failed to convert new text <%s> to device path", NewDpStr);
Status = EFI_NOT_FOUND;
goto END;
}
Status = gBS->LoadImage(FALSE, ImageHandle, TargetDp, NULL, 0, &ChildHandle);
if (EFI_ERROR(Status))
{
vLog(L"Failed to LoadImage %lx", Status);
goto END;
}
Status = gBS->StartImage(ChildHandle, NULL, NULL);
if (EFI_ERROR(Status))
{
vLog(L"Failed to StartImage %lx", Status);
gBS->UnloadImage(ChildHandle);
goto END;
}
END:
CheckFreePool(DevDpStr);
CheckFreePool(NewDpStr);
CheckFreePool(TargetDp);
return Status;
}
STATIC EFI_STATUS EFIAPI CheckVtoyGrub
(
VOID *FileBuffer,
UINTN FileSize
)
{
UINT8 Sha256Hash[64];
if (!FileBuffer || FileSize < sizeof(EFI_IMAGE_DOS_HEADER))
{
vErr(L"Invalid FileBuffer:%p or size:%ld", FileBuffer, FileSize);
return EFI_SECURITY_VIOLATION;
}
ZeroMem(Sha256Hash, sizeof(Sha256Hash));
calc_sha256(FileBuffer, (UINT64)FileSize, Sha256Hash);
if (CompareMem(Sha256Hash, gVtoyGrubSha256Hash, 32) != 0)
{
vErr(L"Ventoy hash check failed.");
gRT->ResetSystem(EfiResetWarm, EFI_SECURITY_VIOLATION, 0, NULL);
return EFI_SECURITY_VIOLATION;
}
return EFI_SUCCESS;
}
STATIC EFI_STATUS EFIAPI SecurityPolicyAuth
(
const EFI_SECURITY_ARCH_PROTOCOL *This,
UINT32 AuthenticationStatus,
const EFI_DEVICE_PATH_PROTOCOL *DevicePathConst
)
{
/*
* 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.
*
*/
(VOID)This;
(VOID)AuthenticationStatus;
(VOID)DevicePathConst;
return EFI_SUCCESS;
}
STATIC EFI_STATUS EFIAPI Security2PolicyAuth
(
const EFI_SECURITY2_ARCH_PROTOCOL *This,
const EFI_DEVICE_PATH_PROTOCOL *DevicePath,
VOID *FileBuffer,
UINTN FileSize,
BOOLEAN BootPolicy
)
{
EFI_STATUS Status;
/* Just return OK if the user choose to bypass SB */
if (gVtoyByPassSB)
{
return EFI_SUCCESS;
}
if (!gGrubLaunched)
{
return CheckVtoyGrub(FileBuffer, FileSize);
}
/*
* Step 1:
* Use original UEFI firmware auth API.
* If it's OK, it may be signed with Microsoft UEFI CA. (e.g. bootmgr/shim/...)
*/
if (gSysSec2FileAuth)
{
Status = gSysSec2FileAuth(This, DevicePath, FileBuffer, FileSize, BootPolicy);
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.Verify)
{
if (FileBuffer && FileSize > 0 && FileSize < 0xFFFFFFFFUL)
{
Status = gShimLock.Verify(FileBuffer, (UINT32)FileSize);
if (!EFI_ERROR(Status))
{
return EFI_SUCCESS;
}
}
}
ShowSBWarning(DevicePath);
return EFI_SECURITY_VIOLATION;
}
STATIC EFI_STATUS EFIAPI HookSecurityPolicy(VOID)
{
EFI_STATUS Status;
EFI_STATUS Status2;
EFI_SECURITY_ARCH_PROTOCOL *Security = NULL;
EFI_SECURITY2_ARCH_PROTOCOL *Security2 = NULL;
Status = gBS->LocateProtocol(&gEfiSecurityArchProtocolGuid, NULL, (VOID **)&Security);
Status2 = gBS->LocateProtocol(&gEfiSecurity2ArchProtocolGuid, NULL, (VOID **)&Security2);
if (EFI_ERROR(Status) && EFI_ERROR(Status2))
{
vLog(L"Failed to locate security or security2 protocol. %lx %lx %p %p",
Status, Status2, Security, Security2);
return EFI_NOT_FOUND;
}
if (Security2)
{
gSysSec2FileAuth = Security2->FileAuthentication;
Security2->FileAuthentication = Security2PolicyAuth;
}
if (Security)
{
gSysSecFileAuth = Security->FileAuthenticationState;
Security->FileAuthenticationState = SecurityPolicyAuth;
}
return EFI_SUCCESS;
}
STATIC VOID EFIAPI UnHookSecurityPolicy(VOID)
{
EFI_STATUS Status;
EFI_STATUS Status2;
EFI_SECURITY_ARCH_PROTOCOL *Security = NULL;
EFI_SECURITY2_ARCH_PROTOCOL *Security2 = NULL;
if (!gSysSec2FileAuth && !gSysSecFileAuth)
{
return;
}
Status = gBS->LocateProtocol(&gEfiSecurityArchProtocolGuid, NULL, (VOID **)&Security);
Status2 = gBS->LocateProtocol(&gEfiSecurity2ArchProtocolGuid, NULL, (VOID **)&Security2);
if (EFI_ERROR(Status) && EFI_ERROR(Status2))
{
vLog(L"Failed to locate security or security2 protocol. %lx %lx %p %p",
Status, Status2, Security, Security2);
return;
}
if (Security2 && gSysSec2FileAuth && Security2->FileAuthentication == Security2PolicyAuth)
{
Security2->FileAuthentication = gSysSec2FileAuth;
gSysSec2FileAuth = NULL;
}
if (Security && gSysSecFileAuth && Security->FileAuthenticationState == SecurityPolicyAuth)
{
Security->FileAuthenticationState = gSysSecFileAuth;
gSysSecFileAuth = NULL;
}
}
STATIC VOID EFIAPI VtoyByPassSB(VOID)
{
gVtoyByPassSB = TRUE;
}
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;
if (gVtoyShimProtHandle)
{
gBS->UninstallProtocolInterface(gVtoyShimProtHandle, &Guid, &gVtoyShimProtocol);
gVtoyShimProtHandle = NULL;
}
}
STATIC EFI_STATUS EFIAPI InstallVtoyShimProtocol(VOID)
{
EFI_STATUS Status;
EFI_GUID Guid = VTOY_SHIM_POLICY_GUID;
VTOY_SHIM *Prot = NULL;
gVtoyShimProtocol.ByPassSB = VtoyByPassSB;
gVtoyShimProtocol.CheckSB = VtoyCheckSB;
gVtoyShimProtocol.Launched = VtoyLaunched;
Status = gBS->LocateProtocol(&Guid, NULL, (VOID**)&Prot);
if (!EFI_ERROR(Status))
{
vLog(L"Ventoy shim already loaded, cannot be nested.");
return EFI_ALREADY_STARTED;
}
Status = gBS->InstallProtocolInterface(&gVtoyShimProtHandle, &Guid,
EFI_NATIVE_INTERFACE, &gVtoyShimProtocol);
if (EFI_ERROR(Status))
{
vLog(L"Failed to install protocol %lx", Status);
}
return Status;
}
STATIC BOOLEAN EFIAPI IsSecureBootEnabled(VOID)
{
UINT8 SecureBoot = 0;
UINTN DataSize;
EFI_STATUS Status;
DataSize = sizeof(SecureBoot);
Status = gST->RuntimeServices->GetVariable(L"SecureBoot", &gEfiGlobalVariableGuid, NULL,
&DataSize, &SecureBoot);
if (EFI_ERROR(Status))
{
return FALSE;
}
return SecureBoot ? TRUE : FALSE;
}
STATIC BOOLEAN EFIAPI IsSetupMode(VOID)
{
UINT8 SetupMode = 0;
UINTN DataSize;
EFI_STATUS Status;
DataSize = sizeof(SetupMode);
Status = gST->RuntimeServices->GetVariable(L"SetupMode", &gEfiGlobalVariableGuid, NULL,
&DataSize, &SetupMode);
if (EFI_ERROR(Status))
{
return FALSE;
}
return SetupMode ? TRUE : FALSE;
}
STATIC EFI_STATUS EFIAPI ShimEfiMain
(
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
SHIM_LOCK *ShimLock = NULL;
shim_void_func_pf Func1 = NULL;
shim_void_func_pf Func2 = NULL;
/* 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))
{
vErr(L"Failed to install ventoy shim protocol");
return Status;
}
/*
* IMPORTANT: All recent shim implementations hook the UEFI Boot Services
* (e.g. LoadImage, StartImage) to enforce signature verification.
*
* We must restore the original system service pointers here. If we fail to do this,
* we will be unable to launch Ventoy-signed EFI binaries or any other unsigned
* EFI applications later, even when the user has explicitly opted to disable
* all Secure Boot validation checks.
*
* To the best of my knowledge, there is no official way to remove these hooks.
* This is a tricky hack that relies on shim's internal implementation details.
* It may break in future versions of shim, and a better approach may exist.
*
*/
Func1 = FindShimFuncAddr(NM_UNHOOK_SYSTEM_SERVICES_OFFSET);
Func2 = FindShimFuncAddr(NM_UNINSTALL_SHIM_PROTOCOLS_OFFSET);
if (!Func1 || !Func2)
{
vErr(L"Can not find shim func %p %p", Func1, Func2);
Status = EFI_NOT_FOUND;
goto END;
}
Func1(); /* call shim unhook_system_services() */
Func2(); /* call shim uninstall_shim_protocols() */
HookSystemService();
/* Hook the system security policy */
Status = HookSecurityPolicy();
if (EFI_ERROR(Status))
{
vErr(L"Failed to hook system security policy");
goto END;
}
/* Finally launch Ventoy grub */
Status = LaunchRealGrub(ImageHandle, REAL_GRUB_FILE);
if (EFI_ERROR(Status))
{
vErr(L"Failed to finally launch real grub %s", REAL_GRUB_FILE);
goto END;
}
END:
/* UnHook system security policy */
UnHookSecurityPolicy();
UnInstallVtoyShimProtocol();
UnHookSystemService();
return Status;
}
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 && (*DataSize) > 0)
{
bChk = TRUE;
}
Status = gSysGetVariable(VariableName, VendorGuid, Attributes, DataSize, Data);
if (bChk && (!EFI_ERROR(Status)))
{
if (CompareMem(&gShimLockGUID, VendorGuid, 16) == 0 &&
StrCmp(VariableName, L"MokSBState") == 0)
{
*(UINT8 *)Data = 1;
}
}
return Status;
}
STATIC VOID EFIAPI UnHookSystemService(VOID)
{
if (gSysExitBootServices)
{
gBS->ExitBootServices = gSysExitBootServices;
gSysExitBootServices = NULL;
}
if (gSysGetVariable)
{
gST->RuntimeServices->GetVariable = gSysGetVariable;
gSysGetVariable = NULL;
}
}
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)
{
gSysExitBootServices = gBS->ExitBootServices;
gBS->ExitBootServices = VtoyExitBootServices;
gSysGetVariable = gST->RuntimeServices->GetVariable;
gST->RuntimeServices->GetVariable = VtoyGetVariable;
}
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;
}
@@ -0,0 +1,116 @@
/******************************************************************************
* VtoyShim.h
*
* Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
* SPDX-License-Identifier: BSD-2-Clause-Patent
*
*/
#ifndef __VTOYSHIM_H__
#define __VTOYSHIM_H__
#if defined (MDE_CPU_IA32)
#define REAL_GRUB_FILE L"grubia32_real.efi"
#elif defined (MDE_CPU_X64)
#define REAL_GRUB_FILE L"grubx64_real.efi"
#elif defined (MDE_CPU_AARCH64)
#define REAL_GRUB_FILE L"grubaa64_real.efi"
#else
#error "Not supported now"
#endif
/* The following definations are copied from shim source code */
#define SHIM_LOCK_GUID {0x605dab50, 0xe046, 0x4300, {0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23 } };
typedef
EFI_STATUS
(*EFI_SHIM_LOCK_VERIFY) (
IN VOID *buffer,
IN UINT32 size
);
typedef
EFI_STATUS
(*EFI_SHIM_LOCK_HASH) (
IN char *data,
IN int datasize,
PE_COFF_LOADER_IMAGE_CONTEXT *context,
UINT8 *sha256hash,
UINT8 *sha1hash
);
typedef
EFI_STATUS
(*EFI_SHIM_LOCK_CONTEXT) (
IN VOID *data,
IN unsigned int datasize,
PE_COFF_LOADER_IMAGE_CONTEXT *context
);
typedef struct _SHIM_LOCK {
EFI_SHIM_LOCK_VERIFY Verify;
EFI_SHIM_LOCK_HASH Hash;
EFI_SHIM_LOCK_CONTEXT Context;
} SHIM_LOCK;
#define SHIM_IMAGE_LOADER_GUID {0x1f492041, 0xfadb, 0x4e59, {0x9e, 0x57, 0x7c, 0xaf, 0xe7, 0x3a, 0x55, 0xab } }
typedef struct _SHIM_IMAGE_LOADER {
EFI_IMAGE_LOAD LoadImage;
EFI_IMAGE_START StartImage;
EFI_EXIT Exit;
EFI_IMAGE_UNLOAD UnloadImage;
} SHIM_IMAGE_LOADER;
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
#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(2)
#define CheckFreePool(p) \
do { \
if (p) { \
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;
void calc_sha256(const void *data, UINT64 len, void *output);
#endif
@@ -0,0 +1,84 @@
#************************************************************************************
# 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/>.
#
#************************************************************************************
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = VtoyShim
FILE_GUID = 6d7c7406-b32c-461f-8454-ddaa5243d93d
MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0
ENTRY_POINT = VtoyShimEfiMain
[BuildOptions]
# Force standard GNU ld to pack and align ELF segments to 4KB page boundaries
GCC:*_*_*_DLINK_FLAGS = -Wl,-z,common-page-size=0x1000 -Wl,-z,max-page-size=0x1000
[Sources]
VtoyShim.h
VtoyShim.c
sha256.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
ShellPkg/ShellPkg.dec
[LibraryClasses]
UefiApplicationEntryPoint
UefiLib
DevicePathLib
DebugLib
[Guids]
gEfiGlobalVariableGuid
gShellVariableGuid
gEfiVirtualCdGuid
gEfiFileInfoGuid
[Protocols]
gEfiSecurityArchProtocolGuid
gEfiSecurity2ArchProtocolGuid
gEfiLoadedImageProtocolGuid
gEfiBlockIoProtocolGuid
gEfiDevicePathProtocolGuid
gEfiDevicePathToTextProtocolGuid
gEfiDevicePathFromTextProtocolGuid
gEfiSimpleFileSystemProtocolGuid
gEfiRamDiskProtocolGuid
gEfiAbsolutePointerProtocolGuid
gEfiAcpiTableProtocolGuid
gEfiBlockIo2ProtocolGuid
gEfiBusSpecificDriverOverrideProtocolGuid
gEfiComponentNameProtocolGuid
gEfiComponentName2ProtocolGuid
gEfiDriverBindingProtocolGuid
gEfiDiskIoProtocolGuid
gEfiDiskIo2ProtocolGuid
gEfiGraphicsOutputProtocolGuid
gEfiHiiConfigAccessProtocolGuid
gEfiHiiFontProtocolGuid
gEfiLoadFileProtocolGuid
gEfiLoadFile2ProtocolGuid
gEfiLoadedImageProtocolGuid
gEfiLoadedImageDevicePathProtocolGuid
gEfiPciIoProtocolGuid
gEfiSerialIoProtocolGuid
gEfiSimpleTextInProtocolGuid
gEfiSimpleTextInputExProtocolGuid
gEfiSimpleTextOutProtocolGuid
@@ -0,0 +1,2 @@
sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
ventoy-shim,1,Ventoy,ventoy-shim,1.0,https://www.ventoy.net/
1 sbat 1 SBAT Version sbat 1 https://github.com/rhboot/shim/blob/main/SBAT.md
2 ventoy-shim 1 Ventoy ventoy-shim 1.0 https://www.ventoy.net/
@@ -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);
}
}
@@ -7,12 +7,12 @@
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of the * published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>. * along with this program; if not, see <http://www.gnu.org/licenses/>.
* *
@@ -41,7 +41,7 @@ STATIC CONST CHAR16 *gCurFeature= NULL;
STATIC CHAR16 *gCmdLine = NULL; STATIC CHAR16 *gCmdLine = NULL;
STATIC grub_env_printf_pf g_env_printf = NULL; STATIC grub_env_printf_pf g_env_printf = NULL;
STATIC VtoyUtilFeature gFeatureList[] = STATIC VtoyUtilFeature gFeatureList[] =
{ {
{ L"fix_windows_mmap", FixWindowsMemhole }, { L"fix_windows_mmap", FixWindowsMemhole },
{ L"show_efi_drivers", ShowEfiDrivers }, { L"show_efi_drivers", ShowEfiDrivers },
@@ -93,7 +93,7 @@ VOID EFIAPI VtoyUtilDebug(IN CONST CHAR8 *Format, ...)
} }
STATIC EFI_STATUS ParseCmdline(IN EFI_HANDLE ImageHandle) STATIC EFI_STATUS ParseCmdline(IN EFI_HANDLE ImageHandle)
{ {
CHAR16 *pPos = NULL; CHAR16 *pPos = NULL;
CHAR16 *pCmdLine = NULL; CHAR16 *pCmdLine = NULL;
EFI_STATUS Status = EFI_SUCCESS; EFI_STATUS Status = EFI_SUCCESS;
@@ -117,7 +117,7 @@ STATIC EFI_STATUS ParseCmdline(IN EFI_HANDLE ImageHandle)
gST->ConOut->OutputString(gST->ConOut, L"\r\n##########################"); gST->ConOut->OutputString(gST->ConOut, L"\r\n##########################");
return EFI_SUCCESS; return EFI_SUCCESS;
} }
if (StrStr(pCmdLine, L"debug")) if (StrStr(pCmdLine, L"debug"))
{ {
gVtoyDebugPrint = TRUE; gVtoyDebugPrint = TRUE;
@@ -139,9 +139,9 @@ STATIC EFI_STATUS ParseCmdline(IN EFI_HANDLE ImageHandle)
} }
gCurFeature = pPos + StrLen(L"feature="); gCurFeature = pPos + StrLen(L"feature=");
gCmdLine = pCmdLine; gCmdLine = pCmdLine;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@@ -153,7 +153,7 @@ EFI_STATUS EFIAPI VtoyUtilEfiMain
{ {
UINTN i; UINTN i;
UINTN Len; UINTN Len;
ParseCmdline(ImageHandle); ParseCmdline(ImageHandle);
for (i = 0; gCurFeature && i < ARRAY_SIZE(gFeatureList); i++) for (i = 0; gCurFeature && i < ARRAY_SIZE(gFeatureList); i++)
@@ -170,7 +170,7 @@ EFI_STATUS EFIAPI VtoyUtilEfiMain
if (gCmdLine) if (gCmdLine)
{ {
FreePool(gCmdLine); FreePool(gCmdLine);
gCmdLine = NULL; gCmdLine = NULL;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
@@ -7,20 +7,22 @@
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of the * published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>. * along with this program; if not, see <http://www.gnu.org/licenses/>.
* *
*/ */
#ifndef __VTOYUTIL_H__ #ifndef __VTOYUTIL_H__
#define __VTOYUTIL_H__ #define __VTOYUTIL_H__
#define VTOY_SHIM_POLICY_GUID {0x90a29d14, 0x3968, 0x48fe, { 0x85, 0x81, 0x6b, 0x7f, 0x7d, 0xc4, 0x70, 0x55 }};
#pragma pack(1) #pragma pack(1)
typedef EFI_STATUS (*VTOY_UTIL_PROC_PF)(IN EFI_HANDLE ImageHandle, IN CONST CHAR16 *CmdLine); typedef EFI_STATUS (*VTOY_UTIL_PROC_PF)(IN EFI_HANDLE ImageHandle, IN CONST CHAR16 *CmdLine);
@@ -44,14 +46,14 @@ typedef struct ventoy_grub_param
grub_env_set_pf grub_env_set; grub_env_set_pf grub_env_set;
ventoy_grub_param_file_replace file_replace; ventoy_grub_param_file_replace file_replace;
ventoy_grub_param_file_replace img_replace[VTOY_MAX_CONF_REPLACE]; ventoy_grub_param_file_replace img_replace[VTOY_MAX_CONF_REPLACE];
grub_env_printf_pf grub_env_printf; grub_env_printf_pf grub_env_printf;
}ventoy_grub_param; }ventoy_grub_param;
#pragma pack() #pragma pack()
typedef struct VtoyUtilFeature typedef struct VtoyUtilFeature
{ {
CONST CHAR16 *Cmd; CONST CHAR16 *Cmd;
VTOY_UTIL_PROC_PF MainProc; VTOY_UTIL_PROC_PF MainProc;
}VtoyUtilFeature; }VtoyUtilFeature;
@@ -23,7 +23,10 @@
MODULE_TYPE = UEFI_APPLICATION MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0 VERSION_STRING = 1.0
ENTRY_POINT = VtoyUtilEfiMain ENTRY_POINT = VtoyUtilEfiMain
[BuildOptions]
# Force standard GNU ld to pack and align ELF segments to 4KB page boundaries
GCC:*_*_*_DLINK_FLAGS = -Wl,-z,common-page-size=0x1000 -Wl,-z,max-page-size=0x1000
[Sources] [Sources]
VtoyUtil.h VtoyUtil.h
@@ -205,6 +205,7 @@
[Components] [Components]
MdeModulePkg/Application/Ventoy/Ventoy.inf MdeModulePkg/Application/Ventoy/Ventoy.inf
MdeModulePkg/Application/VtoyUtil/VtoyUtil.inf MdeModulePkg/Application/VtoyUtil/VtoyUtil.inf
MdeModulePkg/Application/VtoyShim/VtoyShim.inf
MdeModulePkg/Application/VDiskChain/VDiskChain.inf MdeModulePkg/Application/VDiskChain/VDiskChain.inf
MdeModulePkg/Application/HelloWorld/HelloWorld.inf MdeModulePkg/Application/HelloWorld/HelloWorld.inf
MdeModulePkg/Application/DumpDynPcd/DumpDynPcd.inf MdeModulePkg/Application/DumpDynPcd/DumpDynPcd.inf
@@ -1533,7 +1533,7 @@ module = {
name = squash4; name = squash4;
common = fs/squash4.c; common = fs/squash4.c;
cflags = '$(CFLAGS_POSIX) -Wno-undef'; cflags = '$(CFLAGS_POSIX) -Wno-undef';
cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -I$(srcdir)/lib/minilzo -DMINILZO_HAVE_CONFIG_H'; cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -I$(srcdir)/lib/minilzo -I$(srcdir)/lib/zstd -DMINILZO_HAVE_CONFIG_H';
}; };
module = { module = {
@@ -260,6 +260,7 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
grub_file_t file; grub_file_t file;
grub_err_t err; grub_err_t err;
unsigned j; unsigned j;
int vlnk = 0;
file = grub_file_open (args[i], GRUB_FILE_TYPE_TO_HASH file = grub_file_open (args[i], GRUB_FILE_TYPE_TO_HASH
| (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS | (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
: GRUB_FILE_TYPE_NONE)); : GRUB_FILE_TYPE_NONE));
@@ -272,6 +273,7 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
unread++; unread++;
continue; continue;
} }
vlnk = file->vlnk;
err = hash_file (file, hash, result); err = hash_file (file, hash, result);
grub_file_close (file); grub_file_close (file);
if (err) if (err)
@@ -288,7 +290,7 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
grub_printf ("%02x", ((grub_uint8_t *) result)[j]); grub_printf ("%02x", ((grub_uint8_t *) result)[j]);
len += grub_snprintf(hashsum + len, sizeof(hashsum) - len, "%02x", ((grub_uint8_t *) result)[j]); len += grub_snprintf(hashsum + len, sizeof(hashsum) - len, "%02x", ((grub_uint8_t *) result)[j]);
} }
grub_printf (" %s\n", args[i]); grub_printf (" %s\n", vlnk ? grub_file_get_vlnk(args[i], NULL) : args[i]);
grub_env_set("VT_LAST_CHECK_SUM", hashsum); grub_env_set("VT_LAST_CHECK_SUM", hashsum);
} }
File diff suppressed because it is too large Load Diff
+14 -5
View File
@@ -103,6 +103,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080 #define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
#define EXT4_FEATURE_INCOMPAT_MMP 0x0100 #define EXT4_FEATURE_INCOMPAT_MMP 0x0100
#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200 #define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
#define EXT4_FEATURE_INCOMPAT_CSUM_SEED 0x2000
#define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000 #define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000
/* The set of back-incompatible features this driver DOES support. Add (OR) /* The set of back-incompatible features this driver DOES support. Add (OR)
@@ -123,9 +124,16 @@ GRUB_MOD_LICENSE ("GPLv3+");
* mmp: Not really back-incompatible - was added as such to * mmp: Not really back-incompatible - was added as such to
* avoid multiple read-write mounts. Safe to ignore for this * avoid multiple read-write mounts. Safe to ignore for this
* RO driver. * RO driver.
* checksum seed: Not really back-incompatible - was added to allow tools
* such as tune2fs to change the UUID on a mounted metadata
* checksummed filesystem. Safe to ignore for now since the
* driver doesn't support checksum verification. But it must
* be removed from this list if that support is added later.
*
*/ */
#define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER \ #define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER \
| EXT4_FEATURE_INCOMPAT_MMP) | EXT4_FEATURE_INCOMPAT_MMP \
| EXT4_FEATURE_INCOMPAT_CSUM_SEED)
#define EXT3_JOURNAL_MAGIC_NUMBER 0xc03b3998U #define EXT3_JOURNAL_MAGIC_NUMBER 0xc03b3998U
@@ -723,10 +731,11 @@ grub_ext2_read_symlink (grub_fshelp_node_t node)
if (! symlink) if (! symlink)
return 0; return 0;
/* If the filesize of the symlink is bigger than /*
60 the symlink is stored in a separate block, * If the filesize of the symlink is equal to or bigger than 60 the symlink
otherwise it is stored in the inode. */ * is stored in a separate block, otherwise it is stored in the inode.
if (grub_le_to_cpu32 (diro->inode.size) <= sizeof (diro->inode.symlink)) */
if (grub_le_to_cpu32 (diro->inode.size) < sizeof (diro->inode.symlink))
grub_memcpy (symlink, grub_memcpy (symlink,
diro->inode.symlink, diro->inode.symlink,
grub_le_to_cpu32 (diro->inode.size)); grub_le_to_cpu32 (diro->inode.size));
+8 -3
View File
@@ -889,6 +889,7 @@ grub_ntfs_mount (grub_disk_t disk)
struct grub_ntfs_bpb bpb; struct grub_ntfs_bpb bpb;
struct grub_ntfs_data *data = 0; struct grub_ntfs_data *data = 0;
grub_uint32_t spc; grub_uint32_t spc;
grub_uint32_t sectors_per_cluster;
if (!disk) if (!disk)
goto fail; goto fail;
@@ -903,14 +904,18 @@ grub_ntfs_mount (grub_disk_t disk)
if (grub_disk_read (disk, 0, 0, sizeof (bpb), &bpb)) if (grub_disk_read (disk, 0, 0, sizeof (bpb), &bpb))
goto fail; goto fail;
sectors_per_cluster = bpb.sectors_per_cluster;
if (sectors_per_cluster > 0x80)
sectors_per_cluster = 1U << (256U - bpb.sectors_per_cluster);
if (grub_memcmp ((char *) &bpb.oem_name, "NTFS", 4) != 0 if (grub_memcmp ((char *) &bpb.oem_name, "NTFS", 4) != 0
|| bpb.sectors_per_cluster == 0 || sectors_per_cluster == 0
|| (bpb.sectors_per_cluster & (bpb.sectors_per_cluster - 1)) != 0 || (sectors_per_cluster & (sectors_per_cluster - 1)) != 0
|| bpb.bytes_per_sector == 0 || bpb.bytes_per_sector == 0
|| (bpb.bytes_per_sector & (bpb.bytes_per_sector - 1)) != 0) || (bpb.bytes_per_sector & (bpb.bytes_per_sector - 1)) != 0)
goto fail; goto fail;
spc = (((grub_uint32_t) bpb.sectors_per_cluster spc = (((grub_uint32_t) sectors_per_cluster
* (grub_uint32_t) grub_le_to_cpu16 (bpb.bytes_per_sector)) * (grub_uint32_t) grub_le_to_cpu16 (bpb.bytes_per_sector))
>> GRUB_NTFS_BLK_SHR); >> GRUB_NTFS_BLK_SHR);
if (spc == 0) if (spc == 0)
+25 -1
View File
@@ -27,6 +27,7 @@
#include <grub/fshelp.h> #include <grub/fshelp.h>
#include <grub/deflate.h> #include <grub/deflate.h>
#include <minilzo.h> #include <minilzo.h>
#include <zstd.h>
#include "xz.h" #include "xz.h"
#include "xz_stream.h" #include "xz_stream.h"
@@ -184,6 +185,7 @@ enum
COMPRESSION_LZO = 3, COMPRESSION_LZO = 3,
COMPRESSION_XZ = 4, COMPRESSION_XZ = 4,
COMPRESSION_LZ4 = 5, COMPRESSION_LZ4 = 5,
COMPRESSION_ZSTD = 6,
}; };
@@ -398,6 +400,25 @@ static grub_ssize_t lz4_decompress_wrap(char *inbuf, grub_size_t insize, grub_of
return len; return len;
} }
static grub_ssize_t zstd_decompress_wrap(char *inbuf, grub_size_t insize, grub_off_t off,
char *outbuf, grub_size_t len, struct grub_squash_data *data)
{
char *udata = NULL;
int usize = data->blksz;
if (usize < 8192)
usize = 8192;
udata = grub_malloc (usize);
if (!udata)
return -1;
ZSTD_decompress(udata, usize, inbuf, insize);
grub_memcpy(outbuf, udata + off, len);
grub_free(udata);
return len;
}
static struct grub_squash_data * static struct grub_squash_data *
squash_mount (grub_disk_t disk) squash_mount (grub_disk_t disk)
{ {
@@ -447,6 +468,9 @@ squash_mount (grub_disk_t disk)
case grub_cpu_to_le16_compile_time (COMPRESSION_LZ4): case grub_cpu_to_le16_compile_time (COMPRESSION_LZ4):
data->decompress = lz4_decompress_wrap; data->decompress = lz4_decompress_wrap;
break; break;
case grub_cpu_to_le16_compile_time (COMPRESSION_ZSTD):
data->decompress = zstd_decompress_wrap;
break;
case grub_cpu_to_le16_compile_time (COMPRESSION_XZ): case grub_cpu_to_le16_compile_time (COMPRESSION_XZ):
data->decompress = xz_decompress; data->decompress = xz_decompress;
data->xzbuf = grub_malloc (XZBUFSIZ); data->xzbuf = grub_malloc (XZBUFSIZ);
@@ -519,7 +543,7 @@ grub_squash_iterate_dir (grub_fshelp_node_t dir,
break; break;
case grub_cpu_to_le16_compile_time (SQUASH_TYPE_LONG_DIR): case grub_cpu_to_le16_compile_time (SQUASH_TYPE_LONG_DIR):
off = grub_le_to_cpu16 (dir->ino.long_dir.offset); off = grub_le_to_cpu16 (dir->ino.long_dir.offset);
endoff = grub_le_to_cpu16 (dir->ino.long_dir.size) + off - 3; endoff = grub_le_to_cpu32 (dir->ino.long_dir.size) + off - 3;
chunk = grub_le_to_cpu32 (dir->ino.long_dir.chunk); chunk = grub_le_to_cpu32 (dir->ino.long_dir.chunk);
break; break;
default: default:
+239 -45
View File
@@ -23,11 +23,25 @@
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/disk.h> #include <grub/disk.h>
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/time.h>
#include <grub/types.h> #include <grub/types.h>
#include <grub/fshelp.h> #include <grub/fshelp.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
#define NSEC_PER_SEC ((grub_int64_t) 1000000000)
// GRUB 2.04 doesn't have safemath.h
// #include <grub/safemath.h>
// gcc < 5.1 doesn't support __builtin_add_overflow and __builtin_mul_overflow
// #define grub_add(a, b, res) __builtin_add_overflow(a, b, res)
// #define grub_mul(a, b, res) __builtin_mul_overflow(a, b, res)
// Warning: This is unsafe!
#define grub_add(a, b, res) ({ *(res) = (a) + (b); 0; })
#define grub_mul(a, b, res) ({ *(res) = (a) * (b); 0; })
#define XFS_INODE_EXTENTS 9 #define XFS_INODE_EXTENTS 9
#define XFS_INODE_FORMAT_INO 1 #define XFS_INODE_FORMAT_INO 1
@@ -74,10 +88,22 @@ GRUB_MOD_LICENSE ("GPLv3+");
XFS_SB_VERSION2_PROJID32BIT | \ XFS_SB_VERSION2_PROJID32BIT | \
XFS_SB_VERSION2_FTYPE) XFS_SB_VERSION2_FTYPE)
/* Inode flags2 flags */
#define XFS_DIFLAG2_BIGTIME_BIT 3
#define XFS_DIFLAG2_BIGTIME (1 << XFS_DIFLAG2_BIGTIME_BIT)
#define XFS_DIFLAG2_NREXT64_BIT 4
#define XFS_DIFLAG2_NREXT64 (1 << XFS_DIFLAG2_NREXT64_BIT)
/* incompat feature flags */ /* incompat feature flags */
#define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */ #define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */
#define XFS_SB_FEAT_INCOMPAT_SPINODES (1 << 1) /* sparse inode chunks */ #define XFS_SB_FEAT_INCOMPAT_SPINODES (1 << 1) /* sparse inode chunks */
#define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2) /* metadata UUID */ #define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2) /* metadata UUID */
#define XFS_SB_FEAT_INCOMPAT_BIGTIME (1 << 3) /* large timestamps */
#define XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR (1 << 4) /* needs xfs_repair */
#define XFS_SB_FEAT_INCOMPAT_NREXT64 (1 << 5) /* large extent counters */
#define XFS_SB_FEAT_INCOMPAT_EXCHRANGE (1 << 6) /* exchangerange supported */
#define XFS_SB_FEAT_INCOMPAT_PARENT (1 << 7) /* parent pointers */
#define XFS_SB_FEAT_INCOMPAT_METADIR (1 << 8) /* metadata dir tree */
/* /*
* Directory entries with ftype are explicitly handled by GRUB code. * Directory entries with ftype are explicitly handled by GRUB code.
@@ -87,11 +113,26 @@ GRUB_MOD_LICENSE ("GPLv3+");
* *
* We do not currently verify metadata UUID, so it is safe to read filesystems * We do not currently verify metadata UUID, so it is safe to read filesystems
* with the XFS_SB_FEAT_INCOMPAT_META_UUID feature. * with the XFS_SB_FEAT_INCOMPAT_META_UUID feature.
*
* We do not currently replay the log, so it is safe to read filesystems
* with the XFS_SB_FEAT_INCOMPAT_EXCHRANGE feature.
*
* We do not currently read directory parent pointers, so it is safe to read
* filesystems with the XFS_SB_FEAT_INCOMPAT_PARENT feature.
*
* We do not currently look at realtime or quota metadata, so it is safe to
* read filesystems with the XFS_SB_FEAT_INCOMPAT_METADIR feature.
*/ */
#define XFS_SB_FEAT_INCOMPAT_SUPPORTED \ #define XFS_SB_FEAT_INCOMPAT_SUPPORTED \
(XFS_SB_FEAT_INCOMPAT_FTYPE | \ (XFS_SB_FEAT_INCOMPAT_FTYPE | \
XFS_SB_FEAT_INCOMPAT_SPINODES | \ XFS_SB_FEAT_INCOMPAT_SPINODES | \
XFS_SB_FEAT_INCOMPAT_META_UUID) XFS_SB_FEAT_INCOMPAT_META_UUID | \
XFS_SB_FEAT_INCOMPAT_BIGTIME | \
XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR | \
XFS_SB_FEAT_INCOMPAT_NREXT64 | \
XFS_SB_FEAT_INCOMPAT_EXCHRANGE | \
XFS_SB_FEAT_INCOMPAT_PARENT | \
XFS_SB_FEAT_INCOMPAT_METADIR)
struct grub_xfs_sblock struct grub_xfs_sblock
{ {
@@ -176,33 +217,49 @@ struct grub_xfs_btree_root
grub_uint64_t keys[1]; grub_uint64_t keys[1];
} GRUB_PACKED; } GRUB_PACKED;
struct grub_xfs_time struct grub_xfs_time_legacy
{ {
grub_uint32_t sec; grub_uint32_t sec;
grub_uint32_t nanosec; grub_uint32_t nanosec;
} GRUB_PACKED; } GRUB_PACKED;
/*
* The struct grub_xfs_inode layout was taken from the
* struct xfs_dinode_core which is described here:
* https://mirrors.edge.kernel.org/pub/linux/utils/fs/xfs/docs/xfs_filesystem_structure.pdf
*/
struct grub_xfs_inode struct grub_xfs_inode
{ {
grub_uint8_t magic[2]; grub_uint8_t magic[2];
grub_uint16_t mode; grub_uint16_t mode;
grub_uint8_t version; grub_uint8_t version;
grub_uint8_t format; grub_uint8_t format;
grub_uint8_t unused2[26]; grub_uint8_t unused2[18];
struct grub_xfs_time atime; grub_uint64_t nextents_big;
struct grub_xfs_time mtime; grub_uint64_t atime;
struct grub_xfs_time ctime; grub_uint64_t mtime;
grub_uint64_t ctime;
grub_uint64_t size; grub_uint64_t size;
grub_uint64_t nblocks; grub_uint64_t nblocks;
grub_uint32_t extsize; grub_uint32_t extsize;
grub_uint32_t nextents; grub_uint32_t nextents;
grub_uint16_t unused3; grub_uint16_t unused3;
grub_uint8_t fork_offset; grub_uint8_t fork_offset;
grub_uint8_t unused4[17]; grub_uint8_t unused4[17]; /* Last member of inode v2. */
grub_uint8_t unused5[20]; /* First member of inode v3. */
grub_uint64_t flags2;
grub_uint8_t unused6[48]; /* Last member of inode v3. */
} GRUB_PACKED; } GRUB_PACKED;
#define XFS_V2_INODE_SIZE sizeof(struct grub_xfs_inode) #define XFS_V3_INODE_SIZE sizeof(struct grub_xfs_inode)
#define XFS_V3_INODE_SIZE (XFS_V2_INODE_SIZE + 76) /* Size of struct grub_xfs_inode v2, up to unused4 member included. */
#define XFS_V2_INODE_SIZE (XFS_V3_INODE_SIZE - 76)
struct grub_xfs_dir_leaf_entry
{
grub_uint32_t hashval;
grub_uint32_t address;
} GRUB_PACKED;
struct grub_xfs_dirblock_tail struct grub_xfs_dirblock_tail
{ {
@@ -220,6 +277,7 @@ struct grub_fshelp_node
struct grub_xfs_data struct grub_xfs_data
{ {
grub_size_t data_size;
struct grub_xfs_sblock sblock; struct grub_xfs_sblock sblock;
grub_disk_t disk; grub_disk_t disk;
int pos; int pos;
@@ -232,8 +290,6 @@ struct grub_xfs_data
static grub_dl_t my_mod; static grub_dl_t my_mod;
static int grub_xfs_sb_hascrc(struct grub_xfs_data *data) static int grub_xfs_sb_hascrc(struct grub_xfs_data *data)
{ {
return (data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) == return (data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) ==
@@ -296,9 +352,21 @@ static int grub_xfs_sb_valid(struct grub_xfs_data *data)
} }
return 1; return 1;
} }
grub_error (GRUB_ERR_BAD_FS, "unsupported XFS filesystem version");
return 0; return 0;
} }
static int
grub_xfs_sb_needs_repair (struct grub_xfs_data *data)
{
return ((data->sblock.version &
grub_cpu_to_be16_compile_time (XFS_SB_VERSION_NUMBITS)) ==
grub_cpu_to_be16_compile_time (XFS_SB_VERSION_5) &&
(data->sblock.sb_features_incompat &
grub_cpu_to_be32_compile_time (XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR)));
}
/* Filetype information as used in inodes. */ /* Filetype information as used in inodes. */
#define FILETYPE_INO_MASK 0170000 #define FILETYPE_INO_MASK 0170000
#define FILETYPE_INO_REG 0100000 #define FILETYPE_INO_REG 0100000
@@ -354,7 +422,6 @@ GRUB_XFS_EXTENT_SIZE (struct grub_xfs_extent *exts, int ex)
return (grub_be_to_cpu32 (exts[ex].raw[3]) & ((1 << 21) - 1)); return (grub_be_to_cpu32 (exts[ex].raw[3]) & ((1 << 21) - 1));
} }
static inline grub_uint64_t static inline grub_uint64_t
grub_xfs_inode_block (struct grub_xfs_data *data, grub_xfs_inode_block (struct grub_xfs_data *data,
grub_uint64_t ino) grub_uint64_t ino)
@@ -489,7 +556,7 @@ grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino,
grub_uint64_t block = grub_xfs_inode_block (data, ino); grub_uint64_t block = grub_xfs_inode_block (data, ino);
int offset = grub_xfs_inode_offset (data, ino); int offset = grub_xfs_inode_offset (data, ino);
grub_dprintf("xfs", "Reading inode (%"PRIuGRUB_UINT64_T") - %"PRIuGRUB_UINT64_T", %d\n", grub_dprintf("xfs", "Reading inode (%" PRIuGRUB_UINT64_T ") - %" PRIuGRUB_UINT64_T ", %d\n",
ino, block, offset); ino, block, offset);
/* Read the inode. */ /* Read the inode. */
if (grub_disk_read (data->disk, block, offset, grub_xfs_inode_size(data), if (grub_disk_read (data->disk, block, offset, grub_xfs_inode_size(data),
@@ -509,11 +576,26 @@ get_fsb (const void *keys, int idx)
return grub_be_to_cpu64 (grub_get_unaligned64 (p)); return grub_be_to_cpu64 (grub_get_unaligned64 (p));
} }
static int
grub_xfs_inode_has_large_extent_counts (const struct grub_xfs_inode *inode)
{
return inode->version >= 3 &&
(inode->flags2 & grub_cpu_to_be64_compile_time (XFS_DIFLAG2_NREXT64));
}
static grub_uint64_t
grub_xfs_get_inode_nextents (struct grub_xfs_inode *inode)
{
return (grub_xfs_inode_has_large_extent_counts (inode)) ?
grub_be_to_cpu64 (inode->nextents_big) :
grub_be_to_cpu32 (inode->nextents);
}
static grub_disk_addr_t static grub_disk_addr_t
grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
{ {
struct grub_xfs_btree_node *leaf = 0; struct grub_xfs_btree_node *leaf = 0;
int ex, nrec; grub_uint64_t ex, nrec;
struct grub_xfs_extent *exts; struct grub_xfs_extent *exts;
grub_uint64_t ret = 0; grub_uint64_t ret = 0;
@@ -538,7 +620,18 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
/ (2 * sizeof (grub_uint64_t)); / (2 * sizeof (grub_uint64_t));
do do
{ {
int i; grub_uint64_t i;
grub_addr_t keys_end, data_end;
if (grub_mul (sizeof (grub_uint64_t), nrec, &keys_end) ||
grub_add ((grub_addr_t) keys, keys_end, &keys_end) ||
grub_add ((grub_addr_t) node->data, node->data->data_size, &data_end) ||
keys_end > data_end)
{
grub_error (GRUB_ERR_BAD_FS, "invalid number of XFS root keys");
grub_free (leaf);
return 0;
}
for (i = 0; i < nrec; i++) for (i = 0; i < nrec; i++)
{ {
@@ -556,7 +649,10 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
if (grub_disk_read (node->data->disk, if (grub_disk_read (node->data->disk,
GRUB_XFS_FSB_TO_BLOCK (node->data, get_fsb (keys, i - 1 + recoffset)) << (node->data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS), GRUB_XFS_FSB_TO_BLOCK (node->data, get_fsb (keys, i - 1 + recoffset)) << (node->data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS),
0, node->data->bsize, leaf)) 0, node->data->bsize, leaf))
return 0; {
grub_free (leaf);
return 0;
}
if ((!node->data->hascrc && if ((!node->data->hascrc &&
grub_strncmp ((char *) leaf->magic, "BMAP", 4)) || grub_strncmp ((char *) leaf->magic, "BMAP", 4)) ||
@@ -579,8 +675,20 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
} }
else if (node->inode.format == XFS_INODE_FORMAT_EXT) else if (node->inode.format == XFS_INODE_FORMAT_EXT)
{ {
nrec = grub_be_to_cpu32 (node->inode.nextents); grub_addr_t exts_end = 0;
grub_addr_t data_end = 0;
nrec = grub_xfs_get_inode_nextents (&node->inode);
exts = (struct grub_xfs_extent *) grub_xfs_inode_data(&node->inode); exts = (struct grub_xfs_extent *) grub_xfs_inode_data(&node->inode);
if (grub_mul (sizeof (struct grub_xfs_extent), nrec, &exts_end) ||
grub_add ((grub_addr_t) node->data, exts_end, &exts_end) ||
grub_add ((grub_addr_t) node->data, node->data->data_size, &data_end) ||
exts_end > data_end)
{
grub_error (GRUB_ERR_BAD_FS, "invalid number of XFS extents");
return 0;
}
} }
else else
{ {
@@ -634,6 +742,7 @@ static char *
grub_xfs_read_symlink (grub_fshelp_node_t node) grub_xfs_read_symlink (grub_fshelp_node_t node)
{ {
grub_ssize_t size = grub_be_to_cpu64 (node->inode.size); grub_ssize_t size = grub_be_to_cpu64 (node->inode.size);
grub_size_t sz;
if (size < 0) if (size < 0)
{ {
@@ -655,7 +764,12 @@ grub_xfs_read_symlink (grub_fshelp_node_t node)
if (node->data->hascrc) if (node->data->hascrc)
off = 56; off = 56;
symlink = grub_malloc (size + 1); if (grub_add (size, 1, &sz))
{
grub_error (GRUB_ERR_OUT_OF_RANGE, N_("symlink size overflow"));
return 0;
}
symlink = grub_malloc (sz);
if (!symlink) if (!symlink)
return 0; return 0;
@@ -705,8 +819,15 @@ static int iterate_dir_call_hook (grub_uint64_t ino, const char *filename,
{ {
struct grub_fshelp_node *fdiro; struct grub_fshelp_node *fdiro;
grub_err_t err; grub_err_t err;
grub_size_t sz;
fdiro = grub_malloc (grub_xfs_fshelp_size(ctx->diro->data) + 1); if (grub_add (grub_xfs_fshelp_size(ctx->diro->data), 1, &sz))
{
grub_error (GRUB_ERR_OUT_OF_RANGE, N_("directory data size overflow"));
grub_print_error ();
return 0;
}
fdiro = grub_malloc (sz);
if (!fdiro) if (!fdiro)
{ {
grub_print_error (); grub_print_error ();
@@ -722,6 +843,7 @@ static int iterate_dir_call_hook (grub_uint64_t ino, const char *filename,
if (err) if (err)
{ {
grub_print_error (); grub_print_error ();
grub_free (fdiro);
return 0; return 0;
} }
@@ -764,12 +886,20 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
if (iterate_dir_call_hook (parent, "..", &ctx)) if (iterate_dir_call_hook (parent, "..", &ctx))
return 1; return 1;
for (i = 0; i < head->count; i++) for (i = 0; i < head->count &&
(grub_uint8_t *) de < ((grub_uint8_t *) dir + grub_xfs_fshelp_size (dir->data)); i++)
{ {
grub_uint64_t ino; grub_uint64_t ino;
grub_uint8_t *inopos = grub_xfs_inline_de_inopos(dir->data, de); grub_uint8_t *inopos = grub_xfs_inline_de_inopos(dir->data, de);
grub_uint8_t c; grub_uint8_t c;
if ((inopos + (smallino ? 4 : 8)) > (grub_uint8_t *) dir + grub_xfs_fshelp_size (dir->data))
{
grub_error (GRUB_ERR_BAD_FS, "invalid XFS inode");
return 0;
}
/* inopos might be unaligned. */ /* inopos might be unaligned. */
if (smallino) if (smallino)
ino = (((grub_uint32_t) inopos[0]) << 24) ino = (((grub_uint32_t) inopos[0]) << 24)
@@ -824,24 +954,49 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
{ {
struct grub_xfs_dir2_entry *direntry = struct grub_xfs_dir2_entry *direntry =
grub_xfs_first_de(dir->data, dirblock); grub_xfs_first_de(dir->data, dirblock);
int entries; int entries = -1;
struct grub_xfs_dirblock_tail *tail = char *end = dirblock + dirblk_size;
grub_xfs_dir_tail(dir->data, dirblock); grub_uint32_t magic;
numread = grub_xfs_read_file (dir, 0, 0, numread = grub_xfs_read_file (dir, 0, 0,
blk << dirblk_log2, blk << dirblk_log2,
dirblk_size, dirblock, 0); dirblk_size, dirblock, 0);
if (numread != dirblk_size) if (numread != dirblk_size)
return 0; {
grub_free (dirblock);
return 0;
}
entries = (grub_be_to_cpu32 (tail->leaf_count) /*
- grub_be_to_cpu32 (tail->leaf_stale)); * If this data block isn't actually part of the extent list then
* grub_xfs_read_file() returns a block of zeros. So, if the magic
if (!entries) * number field is all zeros then this block should be skipped.
*/
magic = *(grub_uint32_t *)(void *) dirblock;
if (!magic)
continue; continue;
/*
* Leaf and tail information are only in the data block if the number
* of extents is 1.
*/
if (grub_xfs_get_inode_nextents (&dir->inode) == 1)
{
struct grub_xfs_dirblock_tail *tail = grub_xfs_dir_tail (dir->data, dirblock);
end = (char *) tail;
/* Subtract the space used by leaf nodes. */
end -= grub_be_to_cpu32 (tail->leaf_count) * sizeof (struct grub_xfs_dir_leaf_entry);
entries = grub_be_to_cpu32 (tail->leaf_count) - grub_be_to_cpu32 (tail->leaf_stale);
if (!entries)
continue;
}
/* Iterate over all entries within this block. */ /* Iterate over all entries within this block. */
while ((char *)direntry < (char *)tail) while ((char *) direntry < (char *) end)
{ {
grub_uint8_t *freetag; grub_uint8_t *freetag;
char *filename; char *filename;
@@ -861,22 +1016,34 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
} }
filename = (char *)(direntry + 1); filename = (char *)(direntry + 1);
if (filename + direntry->len + 1 > (char *) end)
{
grub_error (GRUB_ERR_BAD_FS, "invalid XFS directory entry");
return 0;
}
/* The byte after the filename is for the filetype, padding, or /* The byte after the filename is for the filetype, padding, or
tag, which is not used by GRUB. So it can be overwritten. */ tag, which is not used by GRUB. So it can be overwritten. */
filename[direntry->len] = '\0'; filename[direntry->len] = '\0';
if (iterate_dir_call_hook (grub_be_to_cpu64(direntry->inode), if (iterate_dir_call_hook (grub_be_to_cpu64(direntry->inode),
filename, &ctx)) filename, &ctx))
{ {
grub_free (dirblock); grub_free (dirblock);
return 1; return 1;
} }
/* Check if last direntry in this block is /*
reached. */ * The expected number of directory entries is only tracked for the
entries--; * single extent case.
if (!entries) */
break; if (grub_xfs_get_inode_nextents (&dir->inode) == 1)
{
/* Check if last direntry in this block is reached. */
entries--;
if (!entries)
break;
}
/* Select the next directory entry. */ /* Select the next directory entry. */
direntry = grub_xfs_next_de(dir->data, direntry); direntry = grub_xfs_next_de(dir->data, direntry);
@@ -899,11 +1066,14 @@ static struct grub_xfs_data *
grub_xfs_mount (grub_disk_t disk) grub_xfs_mount (grub_disk_t disk)
{ {
struct grub_xfs_data *data = 0; struct grub_xfs_data *data = 0;
grub_size_t sz;
data = grub_zalloc (sizeof (struct grub_xfs_data)); data = grub_zalloc (sizeof (struct grub_xfs_data));
if (!data) if (!data)
return 0; return 0;
data->data_size = sizeof (struct grub_xfs_data);
grub_dprintf("xfs", "Reading sb\n"); grub_dprintf("xfs", "Reading sb\n");
/* Read the superblock. */ /* Read the superblock. */
if (grub_disk_read (disk, 0, 0, if (grub_disk_read (disk, 0, 0,
@@ -913,14 +1083,19 @@ grub_xfs_mount (grub_disk_t disk)
if (!grub_xfs_sb_valid(data)) if (!grub_xfs_sb_valid(data))
goto fail; goto fail;
data = grub_realloc (data, if (grub_xfs_sb_needs_repair (data))
sizeof (struct grub_xfs_data) grub_dprintf ("xfs", "XFS filesystem needs repair, boot may fail\n");
- sizeof (struct grub_xfs_inode)
+ grub_xfs_inode_size(data) + 1); if (grub_add (grub_xfs_inode_size (data),
sizeof (struct grub_xfs_data) - sizeof (struct grub_xfs_inode) + 1, &sz))
goto fail;
data = grub_realloc (data, sz);
if (! data) if (! data)
goto fail; goto fail;
data->data_size = sz;
data->diropen.data = data; data->diropen.data = data;
data->diropen.ino = grub_be_to_cpu64(data->sblock.rootino); data->diropen.ino = grub_be_to_cpu64(data->sblock.rootino);
data->diropen.inode_read = 1; data->diropen.inode_read = 1;
@@ -931,7 +1106,7 @@ grub_xfs_mount (grub_disk_t disk)
data->disk = disk; data->disk = disk;
data->pos = 0; data->pos = 0;
grub_dprintf("xfs", "Reading root ino %"PRIuGRUB_UINT64_T"\n", grub_dprintf("xfs", "Reading root ino %" PRIuGRUB_UINT64_T "\n",
grub_cpu_to_be64(data->sblock.rootino)); grub_cpu_to_be64(data->sblock.rootino));
grub_xfs_read_inode (data, data->diropen.ino, &data->diropen.inode); grub_xfs_read_inode (data, data->diropen.ino, &data->diropen.inode);
@@ -939,7 +1114,7 @@ grub_xfs_mount (grub_disk_t disk)
return data; return data;
fail: fail:
if (grub_errno == GRUB_ERR_OUT_OF_RANGE) if (grub_errno == GRUB_ERR_OUT_OF_RANGE || grub_errno == GRUB_ERR_NONE)
grub_error (GRUB_ERR_BAD_FS, "not an XFS filesystem"); grub_error (GRUB_ERR_BAD_FS, "not an XFS filesystem");
grub_free (data); grub_free (data);
@@ -947,7 +1122,6 @@ grub_xfs_mount (grub_disk_t disk)
return 0; return 0;
} }
/* Context for grub_xfs_dir. */ /* Context for grub_xfs_dir. */
struct grub_xfs_dir_ctx struct grub_xfs_dir_ctx
{ {
@@ -955,6 +1129,27 @@ struct grub_xfs_dir_ctx
void *hook_data; void *hook_data;
}; };
/* Bigtime inodes helpers. */
#define XFS_BIGTIME_EPOCH_OFFSET (-(grub_int64_t) GRUB_INT32_MIN)
static int grub_xfs_inode_has_bigtime (const struct grub_xfs_inode *inode)
{
return inode->version >= 3 &&
(inode->flags2 & grub_cpu_to_be64_compile_time (XFS_DIFLAG2_BIGTIME));
}
static grub_int64_t
grub_xfs_get_inode_time (struct grub_xfs_inode *inode)
{
struct grub_xfs_time_legacy *lts;
if (grub_xfs_inode_has_bigtime (inode))
return grub_divmod64 (grub_be_to_cpu64 (inode->mtime), NSEC_PER_SEC, NULL) - XFS_BIGTIME_EPOCH_OFFSET;
lts = (struct grub_xfs_time_legacy *) &inode->mtime;
return grub_be_to_cpu32 (lts->sec);
}
/* Helper for grub_xfs_dir. */ /* Helper for grub_xfs_dir. */
static int static int
grub_xfs_dir_iter (const char *filename, enum grub_fshelp_filetype filetype, grub_xfs_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
@@ -967,7 +1162,7 @@ grub_xfs_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
if (node->inode_read) if (node->inode_read)
{ {
info.mtimeset = 1; info.mtimeset = 1;
info.mtime = grub_be_to_cpu32 (node->inode.mtime.sec); info.mtime = grub_xfs_get_inode_time (&node->inode);
} }
info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR); info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
grub_free (node); grub_free (node);
@@ -1132,8 +1327,6 @@ grub_xfs_uuid (grub_device_t device, char **uuid)
return grub_errno; return grub_errno;
} }
static struct grub_fs grub_xfs_fs = static struct grub_fs grub_xfs_fs =
{ {
.name = "xfs", .name = "xfs",
@@ -1152,6 +1345,7 @@ static struct grub_fs grub_xfs_fs =
GRUB_MOD_INIT(xfs) GRUB_MOD_INIT(xfs)
{ {
//grub_xfs_fs.mod = mod;
grub_fs_register (&grub_xfs_fs); grub_fs_register (&grub_xfs_fs);
my_mod = mod; my_mod = mod;
} }
@@ -31,6 +31,7 @@ extern int g_ventoy_iso_raw;
extern int g_ventoy_grub2_mode; extern int g_ventoy_grub2_mode;
extern int g_ventoy_wimboot_mode; extern int g_ventoy_wimboot_mode;
extern int g_ventoy_iso_uefi_drv; extern int g_ventoy_iso_uefi_drv;
extern char g_ventoy_hotkey_tip[256];
static const char *align_options[] = static const char *align_options[] =
{ {
@@ -230,10 +231,11 @@ label_set_property (void *vself, const char *name, const char *value)
value = g_ventoy_iso_uefi_drv ? grub_env_get("VTOY_ISO_UEFI_DRV_STR") : " "; value = g_ventoy_iso_uefi_drv ? grub_env_get("VTOY_ISO_UEFI_DRV_STR") : " ";
} }
else if (grub_strcmp (value, "@VTOY_HOTKEY_TIP@") == 0) { else if (grub_strcmp (value, "@VTOY_HOTKEY_TIP@") == 0) {
value = grub_env_get("VTOY_HOTKEY_TIP"); value = g_ventoy_hotkey_tip;
if (value == NULL) { } else if (value[0] == '@' && value[1] == '@' && value[2]) {
value = _(" "); value = grub_env_get(value + 2);
} if (!value)
value = " ";
} }
self->template = grub_strdup (value); self->template = grub_strdup (value);
@@ -295,6 +295,8 @@ theme_set_string (grub_gfxmenu_view_t view,
if (! view->title_text) if (! view->title_text)
return grub_errno; return grub_errno;
} }
else if (! grub_strcmp ("ventoy_left_top_color", name))
return grub_errno;
else else
{ {
return grub_error (GRUB_ERR_BAD_ARGUMENT, return grub_error (GRUB_ERR_BAD_ARGUMENT,
@@ -732,6 +734,11 @@ read_property (struct parsebuf *p)
"%s:%d:%d property value invalid; " "%s:%d:%d property value invalid; "
"enclose literal values in quotes (\")", "enclose literal values in quotes (\")",
p->filename, p->line_num, p->col_num); p->filename, p->line_num, p->col_num);
grub_printf("File: %s\nLine:%d Column:%d\n"
"property value invalid; enclose literal values in quotes (\")\n\n",
p->filename, p->line_num, p->col_num);
goto done; goto done;
} }
@@ -0,0 +1,195 @@
/* corecmd.c - critical commands which are registered in kernel */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 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/mm.h>
#include <grub/dl.h>
#include <grub/err.h>
#include <grub/env.h>
#include <grub/misc.h>
#include <grub/term.h>
#include <grub/file.h>
#include <grub/device.h>
#include <grub/command.h>
#include <grub/i18n.h>
/* set ENVVAR=VALUE */
static grub_err_t
grub_core_cmd_set (struct grub_command *cmd __attribute__ ((unused)),
int argc, char *argv[])
{
char *var;
char *val;
if (argc < 1)
{
struct grub_env_var *env;
FOR_SORTED_ENV (env)
grub_printf ("%s=%s\n", env->name, grub_env_get (env->name));
return 0;
}
var = argv[0];
val = grub_strchr (var, '=');
if (! val)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "not an assignment");
val[0] = 0;
grub_env_set (var, val + 1);
val[0] = '=';
return 0;
}
static grub_err_t
grub_core_cmd_unset (struct grub_command *cmd __attribute__ ((unused)),
int argc, char *argv[])
{
if (argc < 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
N_("one argument expected"));
grub_env_unset (argv[0]);
return 0;
}
/* insmod MODULE */
static grub_err_t
grub_core_cmd_insmod (struct grub_command *cmd __attribute__ ((unused)),
int argc, char *argv[])
{
grub_dl_t mod;
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
/* For simple, just disable insmod when SecureBoot is enabled. */
if (g_sys_sb && g_sb_policy == VTOY_SB_POLICY_CHECK)
{
return grub_error (GRUB_ERR_BAD_SIGNATURE, "Cannot insmod when SecureBoot is enabled and Policy is check.");
}
if (argv[0][0] == '/' || argv[0][0] == '(' || argv[0][0] == '+')
mod = grub_dl_load_file (argv[0]);
else
mod = grub_dl_load (argv[0]);
if (mod)
grub_dl_ref (mod);
return 0;
}
static int
grub_mini_print_devices (const char *name, void *data __attribute__ ((unused)))
{
grub_printf ("(%s) ", name);
return 0;
}
static int
grub_mini_print_files (const char *filename,
const struct grub_dirhook_info *info,
void *data __attribute__ ((unused)))
{
grub_printf ("%s%s ", filename, info->dir ? "/" : "");
return 0;
}
/* ls [ARG] */
static grub_err_t
grub_core_cmd_ls (struct grub_command *cmd __attribute__ ((unused)),
int argc, char *argv[])
{
if (argc < 1)
{
grub_device_iterate (grub_mini_print_devices, NULL);
grub_xputs ("\n");
grub_refresh ();
}
else
{
char *device_name;
grub_device_t dev = 0;
grub_fs_t fs;
char *path;
device_name = grub_file_get_device_name (argv[0]);
if (grub_errno)
goto fail;
dev = grub_device_open (device_name);
if (! dev)
goto fail;
fs = grub_fs_probe (dev);
path = grub_strchr (argv[0], ')');
if (! path)
path = argv[0];
else
path++;
if (! *path && ! device_name)
{
grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument");
goto fail;
}
if (! *path)
{
if (grub_errno == GRUB_ERR_UNKNOWN_FS)
grub_errno = GRUB_ERR_NONE;
grub_printf ("(%s): Filesystem is %s.\n",
device_name, fs ? fs->name : "unknown");
}
else if (fs)
{
(fs->fs_dir) (dev, path, grub_mini_print_files, NULL);
grub_xputs ("\n");
grub_refresh ();
}
fail:
if (dev)
grub_device_close (dev);
grub_free (device_name);
}
return grub_errno;
}
void
grub_register_core_commands (void)
{
grub_command_t cmd;
cmd = grub_register_command ("set", grub_core_cmd_set,
N_("[ENVVAR=VALUE]"),
N_("Set an environment variable."));
if (cmd)
cmd->flags |= GRUB_COMMAND_FLAG_EXTRACTOR;
grub_register_command ("unset", grub_core_cmd_unset,
N_("ENVVAR"),
N_("Remove an environment variable."));
grub_register_command ("ls", grub_core_cmd_ls,
N_("[ARG]"), N_("List devices or files."));
grub_register_command ("insmod", grub_core_cmd_insmod,
N_("MODULE"), N_("Insert a module."));
}
@@ -466,6 +466,37 @@ grub_err_t grub_disk_blocklist_read(void *chunklist, grub_uint64_t sector,
return 0; return 0;
} }
grub_err_t grub_disk_blocklist_read2(grub_disk_t disk, grub_uint64_t sector,
grub_uint64_t size, char *buf)
{
ventoy_img_chunk_list *chunk_list = (ventoy_img_chunk_list *)(disk->read_hook_data);
if (buf < chunk_list->buf || buf >= chunk_list->buf + VTOY_CHUNK_BUF_SIZE)
{
return 2;
}
if ((chunk_list->buf + chunk_list->last_off) != buf)
{
chunk_list->err_code = VTOY_CHUNK_ERR_NOT_FLAT;
return 0;
}
if (chunk_list->last_off + size > VTOY_CHUNK_BUF_SIZE)
{
chunk_list->err_code = VTOY_CHUNK_ERR_OVER_FLOW;
return 0;
}
chunk_list->last_off += (grub_uint32_t)size;
if (chunk_list->last_off == VTOY_CHUNK_BUF_SIZE)
{
chunk_list->last_off = 0;
}
return grub_disk_blocklist_read(chunk_list, sector, size, disk->log_sector_size);
}
/* Read data from the disk. */ /* Read data from the disk. */
grub_err_t grub_err_t
grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector, grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
@@ -475,6 +506,14 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
{ {
return grub_disk_blocklist_read((ventoy_img_chunk_list *)disk->read_hook_data, sector, size, disk->log_sector_size); return grub_disk_blocklist_read((ventoy_img_chunk_list *)disk->read_hook_data, sector, size, disk->log_sector_size);
} }
else if (disk->read_hook == (grub_disk_read_hook_t)(void *)grub_disk_blocklist_read2)
{
grub_err_t rv = grub_disk_blocklist_read2(disk, sector, size, (char *)buf);
if (rv != 2)
{
return rv;
}
}
/* First of all, check if the region is within the disk. */ /* First of all, check if the region is within the disk. */
if (grub_disk_adjust_range (disk, &sector, &offset, size) != GRUB_ERR_NONE) if (grub_disk_adjust_range (disk, &sector, &offset, size) != GRUB_ERR_NONE)
@@ -0,0 +1,253 @@
/* env.c - Environment variables */
/*
* 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/env.h>
#include <grub/env_private.h>
#include <grub/misc.h>
#include <grub/mm.h>
grub_uint8_t g_sys_sb = 0;
grub_uint8_t g_sb_policy = VTOY_SB_POLICY_BYPASS;
/* The initial context. */
static struct grub_env_context initial_context;
/* The current context. */
struct grub_env_context *grub_current_context = &initial_context;
static grub_env_read_hook_t vtoy_menu_lang_read_hook;
/* Return the hash representation of the string S. */
static unsigned int
grub_env_hashval (const char *s)
{
unsigned int i = 0;
/* XXX: This can be done much more efficiently. */
while (*s)
i += 5 * *(s++);
return i % HASHSZ;
}
static struct grub_env_var *
grub_env_find (const char *name)
{
struct grub_env_var *var;
int idx = grub_env_hashval (name);
/* Look for the variable in the current context. */
for (var = grub_current_context->vars[idx]; var; var = var->next)
if (grub_strcmp (var->name, name) == 0)
return var;
return 0;
}
static void
grub_env_insert (struct grub_env_context *context,
struct grub_env_var *var)
{
int idx = grub_env_hashval (var->name);
/* Insert the variable into the hashtable. */
var->prevp = &context->vars[idx];
var->next = context->vars[idx];
if (var->next)
var->next->prevp = &(var->next);
context->vars[idx] = var;
}
static void
grub_env_remove (struct grub_env_var *var)
{
/* Remove the entry from the variable table. */
*var->prevp = var->next;
if (var->next)
var->next->prevp = var->prevp;
}
grub_err_t
grub_env_set (const char *name, const char *val)
{
struct grub_env_var *var;
/* If the variable does already exist, just update the variable. */
var = grub_env_find (name);
if (var)
{
char *old = var->value;
if (var->write_hook)
var->value = var->write_hook (var, val);
else
var->value = grub_strdup (val);
if (! var->value)
{
var->value = old;
return grub_errno;
}
grub_free (old);
return GRUB_ERR_NONE;
}
/* The variable does not exist, so create a new one. */
var = grub_zalloc (sizeof (*var));
if (! var)
return grub_errno;
var->name = grub_strdup (name);
if (! var->name)
goto fail;
var->value = grub_strdup (val);
if (! var->value)
goto fail;
grub_env_insert (grub_current_context, var);
return GRUB_ERR_NONE;
fail:
grub_free (var->name);
grub_free (var->value);
grub_free (var);
return grub_errno;
}
const char *
grub_env_get (const char *name)
{
struct grub_env_var *var;
if (name && vtoy_menu_lang_read_hook && grub_strncmp(name, "VTLANG_", 7) == 0)
return vtoy_menu_lang_read_hook(NULL, name);
var = grub_env_find (name);
if (! var)
return 0;
if (var->read_hook)
return var->read_hook (var, var->value);
return var->value;
}
void
grub_env_unset (const char *name)
{
struct grub_env_var *var;
var = grub_env_find (name);
if (! var)
return;
if (var->read_hook || var->write_hook)
{
grub_env_set (name, "");
return;
}
grub_env_remove (var);
grub_free (var->name);
grub_free (var->value);
grub_free (var);
}
struct grub_env_var *
grub_env_update_get_sorted (void)
{
struct grub_env_var *sorted_list = 0;
int i;
/* Add variables associated with this context into a sorted list. */
for (i = 0; i < HASHSZ; i++)
{
struct grub_env_var *var;
for (var = grub_current_context->vars[i]; var; var = var->next)
{
struct grub_env_var *p, **q;
for (q = &sorted_list, p = *q; p; q = &((*q)->sorted_next), p = *q)
{
if (grub_strcmp (p->name, var->name) > 0)
break;
}
var->sorted_next = *q;
*q = var;
}
}
return sorted_list;
}
grub_err_t
grub_register_variable_hook (const char *name,
grub_env_read_hook_t read_hook,
grub_env_write_hook_t write_hook)
{
struct grub_env_var *var = grub_env_find (name);
if (! var)
{
if (grub_env_set (name, "") != GRUB_ERR_NONE)
return grub_errno;
var = grub_env_find (name);
/* XXX Insert an assertion? */
}
var->read_hook = read_hook;
var->write_hook = write_hook;
return GRUB_ERR_NONE;
}
grub_err_t
grub_register_vtoy_menu_lang_hook(grub_env_read_hook_t read_hook)
{
vtoy_menu_lang_read_hook = read_hook;
return GRUB_ERR_NONE;
}
grub_err_t
grub_env_export (const char *name)
{
struct grub_env_var *var;
var = grub_env_find (name);
if (! var)
{
grub_err_t err;
err = grub_env_set (name, "");
if (err)
return err;
var = grub_env_find (name);
}
var->global = 1;
return GRUB_ERR_NONE;
}
@@ -200,7 +200,8 @@ const char *grub_file_get_vlnk(const char *name, int *vlnk)
if (len == g_vtoy_vlnk.srclen && grub_strcmp(name, g_vtoy_vlnk.src) == 0) if (len == g_vtoy_vlnk.srclen && grub_strcmp(name, g_vtoy_vlnk.src) == 0)
{ {
*vlnk = 1; if (vlnk)
*vlnk = 1;
return g_vtoy_vlnk.dst; return g_vtoy_vlnk.dst;
} }
@@ -208,7 +209,8 @@ const char *grub_file_get_vlnk(const char *name, int *vlnk)
{ {
if (node->srclen == len && grub_strcmp(name, node->src) == 0) if (node->srclen == len && grub_strcmp(name, node->src) == 0)
{ {
*vlnk = 1; if (vlnk)
*vlnk = 1;
return node->dst; return node->dst;
} }
node = node->next; node = node->next;
@@ -340,10 +342,12 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len)
if (len == 0) if (len == 0)
return 0; return 0;
if (grub_strncmp(file->name, GRUB_MEMFILE_MEM, grub_strlen(GRUB_MEMFILE_MEM)) == 0) { if (file->name) {
if (grub_strncmp(file->name, GRUB_MEMFILE_MEM, grub_strlen(GRUB_MEMFILE_MEM)) == 0) {
grub_memcpy(buf, (grub_uint8_t *)(file->data) + file->offset, len); grub_memcpy(buf, (grub_uint8_t *)(file->data) + file->offset, len);
file->offset += len; file->offset += len;
return len; return len;
}
} }
read_hook = file->read_hook; read_hook = file->read_hook;
@@ -362,7 +362,8 @@ static grub_err_t
cmd_append (const char *line, struct syslinux_menu *menu) cmd_append (const char *line, struct syslinux_menu *menu)
{ {
if (!menu->entries) if (!menu->entries)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "kernel without label"); return GRUB_ERR_NONE;
//return grub_error (GRUB_ERR_BAD_ARGUMENT, "kernel without label");
menu->entries->append = grub_strdup (line); menu->entries->append = grub_strdup (line);
if (!menu->entries->append) if (!menu->entries->append)
@@ -229,10 +229,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
if (! file) if (! file)
goto fail; goto fail;
/* Get the root device's device path. */ dev = file->device;
dev = grub_device_open (0);
if (! dev)
goto fail;
if (dev->disk) if (dev->disk)
dev_handle = grub_efidisk_get_device_handle (dev->disk); dev_handle = grub_efidisk_get_device_handle (dev->disk);
@@ -257,16 +254,13 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
if (dev_handle) if (dev_handle)
dp = grub_efi_get_device_path (dev_handle); dp = grub_efi_get_device_path (dev_handle);
if (! dp) if (dp != NULL)
{ {
grub_error (GRUB_ERR_BAD_DEVICE, "not a valid root device"); file_path = make_file_path (dp, filename);
goto fail; if (! file_path)
goto fail;
} }
file_path = make_file_path (dp, filename);
if (! file_path)
goto fail;
//grub_printf ("file path: "); //grub_printf ("file path: ");
//grub_efi_print_device_path (file_path); //grub_efi_print_device_path (file_path);
@@ -390,16 +384,12 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
} }
grub_file_close (file); grub_file_close (file);
grub_device_close (dev);
grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0); grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0);
return 0; return 0;
fail: fail:
if (dev)
grub_device_close (dev);
if (file) if (file)
grub_file_close (file); grub_file_close (file);
@@ -35,6 +35,8 @@
#include <grub/i18n.h> #include <grub/i18n.h>
#include <grub/lib/cmdline.h> #include <grub/lib/cmdline.h>
#include <grub/linux.h> #include <grub/linux.h>
#include <grub/time.h>
#include <grub/env.h>
#include <grub/machine/kernel.h> #include <grub/machine/kernel.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@@ -88,6 +90,8 @@ static int ventoy_linux_argc = 0;
static char **ventoy_linux_args = NULL; static char **ventoy_linux_args = NULL;
static int ventoy_extra_initrd_num = 0; static int ventoy_extra_initrd_num = 0;
static char *ventoy_extra_initrd_list[256]; static char *ventoy_extra_initrd_list[256];
static grub_command_func_t ventoy_linux16_func = NULL;
static grub_command_func_t ventoy_initrd16_func = NULL;
static grub_err_t static grub_err_t
grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]); grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]);
@@ -295,7 +299,7 @@ grub_linux_setup_video (struct linux_kernel_params *params)
params->lfb_size >>= 16; params->lfb_size >>= 16;
params->have_vga = GRUB_VIDEO_LINUX_TYPE_VESA; params->have_vga = GRUB_VIDEO_LINUX_TYPE_VESA;
break; break;
case GRUB_VIDEO_DRIVER_EFI_UGA: case GRUB_VIDEO_DRIVER_EFI_UGA:
case GRUB_VIDEO_DRIVER_EFI_GOP: case GRUB_VIDEO_DRIVER_EFI_GOP:
params->have_vga = GRUB_VIDEO_LINUX_TYPE_EFIFB; params->have_vga = GRUB_VIDEO_LINUX_TYPE_EFIFB;
@@ -411,11 +415,11 @@ static void ventoy_debug_pause(void)
{ {
char key; char key;
if (0 == ventoy_debug) if (0 == ventoy_debug)
{ {
return; return;
} }
grub_printf("press Enter to continue ......\n"); grub_printf("press Enter to continue ......\n");
while (1) while (1)
{ {
@@ -424,7 +428,7 @@ static void ventoy_debug_pause(void)
{ {
break; break;
} }
} }
} }
static int ventoy_preboot(void) static int ventoy_preboot(void)
@@ -433,7 +437,7 @@ static int ventoy_preboot(void)
const char *file; const char *file;
char buf[128]; char buf[128];
if (ventoy_debug) if (ventoy_debug)
{ {
grub_printf("ventoy_preboot %d %d\n", ventoy_linux_argc, ventoy_initrd_called); grub_printf("ventoy_preboot %d %d\n", ventoy_linux_argc, ventoy_initrd_called);
ventoy_debug_pause(); ventoy_debug_pause();
@@ -460,7 +464,7 @@ static int ventoy_preboot(void)
ventoy_extra_initrd_list[ventoy_extra_initrd_num++] = grub_strdup(file); ventoy_extra_initrd_list[ventoy_extra_initrd_num++] = grub_strdup(file);
} }
if (ventoy_debug) if (ventoy_debug)
{ {
grub_printf("========== initrd list ==========\n"); grub_printf("========== initrd list ==========\n");
for (i = 0; i < ventoy_extra_initrd_num; i++) for (i = 0; i < ventoy_extra_initrd_num; i++)
@@ -468,7 +472,7 @@ static int ventoy_preboot(void)
grub_printf("%s\n", ventoy_extra_initrd_list[i]); grub_printf("%s\n", ventoy_extra_initrd_list[i]);
} }
grub_printf("=================================\n"); grub_printf("=================================\n");
ventoy_debug_pause(); ventoy_debug_pause();
} }
@@ -498,7 +502,7 @@ static int ventoy_boot_opt_filter(char *opt)
} }
return 0; return 0;
} }
if (grub_strncmp(opt, "init=", 5) == 0) if (grub_strncmp(opt, "init=", 5) == 0)
{ {
opt[0] = 'v'; opt[0] = 'v';
@@ -519,12 +523,12 @@ static int ventoy_boot_opt_filter(char *opt)
{ {
return 1; return 1;
} }
if (grub_strncmp(opt, "loglevel=", 9) == 0) if (grub_strncmp(opt, "loglevel=", 9) == 0)
{ {
return 1; return 1;
} }
if (grub_strcmp(opt, "splash") == 0) if (grub_strcmp(opt, "splash") == 0)
{ {
return 1; return 1;
@@ -571,7 +575,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[count] = ventoy_linux_args[i + (LINUX_MAX_ARGC / 2)];
ventoy_linux_args[i + (LINUX_MAX_ARGC / 2)] = NULL; ventoy_linux_args[i + (LINUX_MAX_ARGC / 2)] = NULL;
if (ventoy_linux_args[count][0] == '@') if (ventoy_linux_args[count][0] == '@')
{ {
env = grub_env_get(ventoy_linux_args[count] + 1); env = grub_env_get(ventoy_linux_args[count] + 1);
@@ -617,7 +621,7 @@ static int ventoy_bootopt_hook(int argc, char *argv[])
{ {
if (0 == ventoy_boot_opt_filter(last)) if (0 == ventoy_boot_opt_filter(last))
{ {
ventoy_linux_args[count++] = grub_strdup(last); ventoy_linux_args[count++] = grub_strdup(last);
} }
break; break;
} }
@@ -632,7 +636,7 @@ static int ventoy_bootopt_hook(int argc, char *argv[])
} }
else else
{ {
count++; count++;
} }
} }
@@ -660,58 +664,10 @@ static int ventoy_bootopt_hook(int argc, char *argv[])
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
grub_printf("%s ", ventoy_linux_args[i]); grub_printf("%s ", ventoy_linux_args[i]);
} }
grub_printf("\n================================\n"); grub_printf("\n================================\n");
} }
return 0;
}
static grub_err_t
grub_cmd_set_boot_opt (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
int i;
const char *vtdebug;
for (i = 0; i < argc; i++)
{
ventoy_linux_args[ventoy_linux_argc + (LINUX_MAX_ARGC / 2) ] = grub_strdup(argv[i]);
ventoy_linux_argc++;
}
vtdebug = grub_env_get("vtdebug_flag");
if (vtdebug && vtdebug[0])
{
ventoy_debug = 1;
}
if (ventoy_debug) grub_printf("ventoy set boot opt %d\n", ventoy_linux_argc);
return 0;
}
static grub_err_t
grub_cmd_unset_boot_opt (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
int i;
(void)argc;
(void)argv;
for (i = 0; i < LINUX_MAX_ARGC; i++)
{
if (ventoy_linux_args[i])
{
grub_free(ventoy_linux_args[i]);
}
}
ventoy_debug = 0;
ventoy_linux_argc = 0;
ventoy_initrd_called = 0;
grub_memset(ventoy_linux_args, 0, sizeof(char *) * LINUX_MAX_ARGC);
return 0; return 0;
} }
@@ -723,7 +679,7 @@ grub_cmd_extra_initrd_append (grub_command_t cmd __attribute__ ((unused)),
char *pos = NULL; char *pos = NULL;
char *end = NULL; char *end = NULL;
char buf[256] = {0}; char buf[256] = {0};
if (argc != 1) if (argc != 1)
{ {
return 1; return 1;
@@ -749,10 +705,10 @@ grub_cmd_extra_initrd_append (grub_command_t cmd __attribute__ ((unused)),
{ {
grub_snprintf(buf, sizeof(buf), "newc:%s:%s", end + 1, argv[0]); grub_snprintf(buf, sizeof(buf), "newc:%s:%s", end + 1, argv[0]);
} }
if (ventoy_extra_initrd_num < 256) 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);
} }
} }
@@ -764,7 +720,7 @@ grub_cmd_extra_initrd_reset (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[]) int argc, char *argv[])
{ {
int i; int i;
(void)argc; (void)argc;
(void)argv; (void)argv;
@@ -796,6 +752,16 @@ grub_linux_boot (void)
grub_size_t mmap_size; grub_size_t mmap_size;
grub_size_t cl_offset; grub_size_t cl_offset;
/* To be simple, just deny to boot linux kernel when SecureBoot is enabled and Policy is check */
if (g_sys_sb && g_sb_policy == VTOY_SB_POLICY_CHECK)
{
grub_printf("\n\n ######### Can not do linux boot in SecureBoot Policy Check #######\n\n");
grub_refresh();
grub_sleep(5);
grub_errno = GRUB_ERR_BAD_SIGNATURE;
return 0;
}
ventoy_preboot(); ventoy_preboot();
#ifdef GRUB_MACHINE_IEEE1275 #ifdef GRUB_MACHINE_IEEE1275
@@ -970,9 +936,9 @@ grub_linux_boot (void)
&efi_desc_size, &efi_desc_version); &efi_desc_size, &efi_desc_version);
if (err) if (err)
return err; return err;
/* Note that no boot services are available from here. */ /* Note that no boot services are available from here. */
efi_mmap_target = ctx.real_mode_target efi_mmap_target = ctx.real_mode_target
+ ((grub_uint8_t *) efi_mmap_buf - (grub_uint8_t *) real_mode_mem); + ((grub_uint8_t *) efi_mmap_buf - (grub_uint8_t *) real_mode_mem);
/* Pass EFI parameters. */ /* Pass EFI parameters. */
if (grub_le_to_cpu16 (ctx.params->version) >= 0x0208) if (grub_le_to_cpu16 (ctx.params->version) >= 0x0208)
@@ -1054,7 +1020,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
if (tip) if (tip)
{ {
grub_printf("%s\n", tip); grub_printf("%s\n", tip);
grub_refresh(); grub_refresh();
} }
} }
@@ -1132,7 +1098,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
align = 0; align = 0;
relocatable = 0; relocatable = 0;
} }
if (grub_le_to_cpu16 (lh.version) >= 0x020a) if (grub_le_to_cpu16 (lh.version) >= 0x020a)
{ {
min_align = lh.min_alignment; min_align = lh.min_alignment;
@@ -1407,7 +1373,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
- (sizeof (LINUX_IMAGE) - 1), - (sizeof (LINUX_IMAGE) - 1),
GRUB_VERIFY_KERNEL_CMDLINE); GRUB_VERIFY_KERNEL_CMDLINE);
} }
if (err) if (err)
goto fail; goto fail;
} }
@@ -1541,7 +1507,7 @@ ventoy_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
if (ventoy_linux_argc == 0) 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")); grub_snprintf(buf, sizeof(buf), "mem:%s:size:%s", grub_env_get("ventoy_cpio_addr"), grub_env_get("ventoy_cpio_size"));
@@ -1572,10 +1538,96 @@ ventoy_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
} }
grub_printf("=================================\n"); grub_printf("=================================\n");
} }
return grub_cmd_initrd(cmd, ventoy_extra_initrd_num, ventoy_extra_initrd_list); return grub_cmd_initrd(cmd, ventoy_extra_initrd_num, ventoy_extra_initrd_list);
} }
static grub_err_t
grub_cmd_set_boot_opt (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
int i;
const char *vtdebug;
grub_command_t regcmd;
for (i = 0; i < argc; i++)
{
ventoy_linux_args[ventoy_linux_argc + (LINUX_MAX_ARGC / 2) ] = grub_strdup(argv[i]);
ventoy_linux_argc++;
}
vtdebug = grub_env_get("vtdebug_flag");
if (vtdebug && vtdebug[0])
{
ventoy_debug = 1;
}
if (ventoy_debug) grub_printf("ventoy set boot opt %d\n", ventoy_linux_argc);
ventoy_linux16_func = ventoy_initrd16_func = NULL;
regcmd = grub_command_find("linux16");
if (regcmd)
{
ventoy_linux16_func = regcmd->func;
regcmd->func = grub_cmd_linux;
}
regcmd = grub_command_find("initrd16");
if (regcmd)
{
ventoy_initrd16_func = regcmd->func;
regcmd->func = ventoy_cmd_initrd;
}
return 0;
}
static grub_err_t
grub_cmd_unset_boot_opt (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
int i;
grub_command_t regcmd;
(void)argc;
(void)argv;
for (i = 0; i < LINUX_MAX_ARGC; i++)
{
if (ventoy_linux_args[i])
{
grub_free(ventoy_linux_args[i]);
}
}
ventoy_debug = 0;
ventoy_linux_argc = 0;
ventoy_initrd_called = 0;
grub_memset(ventoy_linux_args, 0, sizeof(char *) * LINUX_MAX_ARGC);
if (ventoy_linux16_func)
{
regcmd = grub_command_find("linux16");
if (regcmd)
{
regcmd->func = ventoy_linux16_func;
}
ventoy_linux16_func = NULL;
}
if (ventoy_initrd16_func)
{
regcmd = grub_command_find("initrd16");
if (regcmd)
{
regcmd->func = ventoy_initrd16_func;
}
ventoy_initrd16_func = NULL;
}
return 0;
}
static grub_command_t cmd_linux, cmd_initrd, cmd_linuxefi, cmd_initrdefi; static grub_command_t cmd_linux, cmd_initrd, cmd_linuxefi, cmd_initrdefi;
static grub_command_t cmd_set_bootopt, cmd_unset_bootopt, cmd_extra_initrd_append, cmd_extra_initrd_reset; static grub_command_t cmd_set_bootopt, cmd_unset_bootopt, cmd_extra_initrd_append, cmd_extra_initrd_reset;
@@ -1593,7 +1645,7 @@ GRUB_MOD_INIT(linux)
0, N_("Load initrd.")); 0, N_("Load initrd."));
cmd_set_bootopt = grub_register_command ("vt_set_boot_opt", grub_cmd_set_boot_opt, 0, N_("set ext boot opt")); cmd_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_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_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_("")); cmd_extra_initrd_reset = grub_register_command ("vt_img_extra_initrd_reset", grub_cmd_extra_initrd_reset, 0, N_(""));
@@ -128,11 +128,22 @@ insert_dir (const char *name, struct dir **root,
n->name = grub_strndup (cb, ce - cb); n->name = grub_strndup (cb, ce - cb);
if (ptr) if (ptr)
{ {
/*
* Create the substring with the trailing NUL byte
* to be included in the cpio header.
*/
char *tmp_name = grub_strndup (name, ce - name);
if (!tmp_name) {
grub_free (n->name);
grub_free (n);
return grub_errno;
}
grub_dprintf ("linux", "Creating directory %s, %s\n", name, ce); grub_dprintf ("linux", "Creating directory %s, %s\n", name, ce);
ptr = make_header (ptr, name, ce - name, ptr = make_header (ptr, tmp_name, ce - name + 1,
040777, 0); 040777, 0);
grub_free (tmp_name);
} }
size += ALIGN_UP ((ce - (char *) name) size += ALIGN_UP ((ce - (char *) name + 1)
+ sizeof (struct newc_head), 4); + sizeof (struct newc_head), 4);
*head = n; *head = n;
cur = n; cur = n;
@@ -183,7 +194,7 @@ grub_initrd_init (int argc, char *argv[],
} }
initrd_ctx->size initrd_ctx->size
+= ALIGN_UP (sizeof (struct newc_head) += ALIGN_UP (sizeof (struct newc_head)
+ grub_strlen (initrd_ctx->components[i].newc_name), + grub_strlen (initrd_ctx->components[i].newc_name) + 1,
4); 4);
initrd_ctx->size += insert_dir (initrd_ctx->components[i].newc_name, initrd_ctx->size += insert_dir (initrd_ctx->components[i].newc_name,
&root, 0); &root, 0);
@@ -194,7 +205,7 @@ grub_initrd_init (int argc, char *argv[],
else if (newc) else if (newc)
{ {
initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head) initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
+ sizeof ("TRAILER!!!") - 1, 4); + sizeof ("TRAILER!!!"), 4);
free_dir (root); free_dir (root);
root = 0; root = 0;
newc = 0; newc = 0;
@@ -217,7 +228,7 @@ grub_initrd_init (int argc, char *argv[],
{ {
initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4); initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4);
initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head) initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
+ sizeof ("TRAILER!!!") - 1, 4); + sizeof ("TRAILER!!!"), 4);
free_dir (root); free_dir (root);
root = 0; root = 0;
} }
@@ -269,14 +280,14 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
ptr += insert_dir (initrd_ctx->components[i].newc_name, ptr += insert_dir (initrd_ctx->components[i].newc_name,
&root, ptr); &root, ptr);
ptr = make_header (ptr, initrd_ctx->components[i].newc_name, ptr = make_header (ptr, initrd_ctx->components[i].newc_name,
grub_strlen (initrd_ctx->components[i].newc_name), grub_strlen (initrd_ctx->components[i].newc_name) + 1,
0100777, 0100777,
initrd_ctx->components[i].size); initrd_ctx->components[i].size);
newc = 1; newc = 1;
} }
else if (newc) else if (newc)
{ {
ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!"),
0, 0); 0, 0);
free_dir (root); free_dir (root);
root = 0; root = 0;
@@ -308,7 +319,7 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
{ {
grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4)); grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
ptr += ALIGN_UP_OVERHEAD (cursize, 4); ptr += ALIGN_UP_OVERHEAD (cursize, 4);
ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0); ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!"), 0, 0);
} }
free_dir (root); free_dir (root);
root = 0; root = 0;
+92 -31
View File
@@ -50,6 +50,30 @@ int g_ventoy_menu_esc = 0;
int g_ventoy_fn_mutex = 0; int g_ventoy_fn_mutex = 0;
int g_ventoy_secondary_menu_on = 0; int g_ventoy_secondary_menu_on = 0;
int g_ventoy_terminal_output = 0; int g_ventoy_terminal_output = 0;
char g_ventoy_hotkey_tip[256];
static int g_vt_key_num = 0;
static int g_vt_key_code[128];
static int ventoy_menu_pop_key(void)
{
if (g_vt_key_num > 0 && g_vt_key_num < (int)(sizeof(g_vt_key_code) / sizeof(g_vt_key_code[0])))
{
g_vt_key_num--;
return g_vt_key_code[g_vt_key_num];
}
return -1;
}
int ventoy_menu_push_key(int code)
{
if (g_vt_key_num >= 0 && g_vt_key_num < (int)(sizeof(g_vt_key_code) / sizeof(g_vt_key_code[0])))
{
g_vt_key_code[g_vt_key_num++] = code;
return 0;
}
return -1;
}
#define VTOY_COMM_HOTKEY(cmdkey) \ #define VTOY_COMM_HOTKEY(cmdkey) \
if (0 == g_ventoy_fn_mutex && 0 == g_ventoy_secondary_menu_on) { \ if (0 == g_ventoy_fn_mutex && 0 == g_ventoy_secondary_menu_on) { \
@@ -414,11 +438,11 @@ static void menu_set_chosen_tip(grub_menu_t menu, int entry)
if (g_ventoy_theme_path[0]) if (g_ventoy_theme_path[0])
{ {
grub_env_set("theme", g_ventoy_theme_path); grub_env_set("theme", g_ventoy_theme_path);
} }
g_ventoy_tip_msg1 = g_ventoy_tip_msg2 = NULL; g_ventoy_tip_msg1 = g_ventoy_tip_msg2 = NULL;
if (e && e->id && grub_strncmp(e->id, "VID_", 4) == 0) if (e && e->id && grub_strncmp(e->id, "VID_", 4) == 0)
{ {
g_ventoy_theme_path[0] = 0; g_ventoy_theme_path[0] = 0;
img = (img_info *)(void *)grub_strtoul(e->id + 4, NULL, 16); img = (img_info *)(void *)grub_strtoul(e->id + 4, NULL, 16);
@@ -456,7 +480,7 @@ static void
menu_set_chosen_entry (grub_menu_t menu, int entry) menu_set_chosen_entry (grub_menu_t menu, int entry)
{ {
struct grub_menu_viewer *cur; struct grub_menu_viewer *cur;
menu_set_chosen_tip(menu, entry); menu_set_chosen_tip(menu, entry);
for (cur = viewers; cur; cur = cur->next) for (cur = viewers; cur; cur = cur->next)
cur->set_chosen_entry (entry, cur->data); cur->set_chosen_entry (entry, cur->data);
@@ -796,7 +820,11 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
return default_entry; return default_entry;
} }
c = grub_getkey_noblock (); if (g_vt_key_num > 0) {
c = ventoy_menu_pop_key();
} else {
c = grub_getkey_noblock ();
}
/* Negative values are returned on error. */ /* Negative values are returned on error. */
if ((c != GRUB_TERM_NO_KEY) && (c > 0)) if ((c != GRUB_TERM_NO_KEY) && (c > 0))
@@ -923,22 +951,37 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
menu_fini (); menu_fini ();
if (g_ventoy_terminal_output == 0) if (g_ventoy_terminal_output == 0)
{ {
grub_script_execute_sourcecode("terminal_output console"); grub_script_execute_sourcecode("vt_push_menu_lang en_US\nterminal_output console");
g_ventoy_terminal_output = 1; g_ventoy_terminal_output = 1;
} }
else else
{ {
grub_script_execute_sourcecode("terminal_output gfxterm"); grub_script_execute_sourcecode("terminal_output gfxterm\nvt_pop_menu_lang");
g_ventoy_terminal_output = 0; g_ventoy_terminal_output = 0;
} }
goto refresh; goto refresh;
case GRUB_TERM_KEY_F1: case GRUB_TERM_KEY_F1:
case '1': case '1':
if (0 == g_ventoy_secondary_menu_on)
{
cmdstr = grub_env_get("VTOY_HELP_CMD");
if (cmdstr)
{
grub_script_execute_sourcecode(cmdstr);
while (grub_getkey() != GRUB_TERM_ESC)
;
menu_fini ();
goto refresh;
}
}
break;
case (GRUB_TERM_CTRL | 'd'):
case 'd':
if (0 == g_ventoy_secondary_menu_on) if (0 == g_ventoy_secondary_menu_on)
{ {
menu_fini (); menu_fini ();
g_ventoy_memdisk_mode = 1 - g_ventoy_memdisk_mode; g_ventoy_memdisk_mode = 1 - g_ventoy_memdisk_mode;
g_ventoy_menu_refresh = 1; g_ventoy_menu_refresh = 1;
goto refresh; goto refresh;
} }
break; break;
@@ -949,7 +992,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
menu_fini (); menu_fini ();
g_ventoy_iso_raw = 1 - g_ventoy_iso_raw; g_ventoy_iso_raw = 1 - g_ventoy_iso_raw;
g_ventoy_menu_refresh = 1; g_ventoy_menu_refresh = 1;
goto refresh; goto refresh;
} }
break; break;
case (GRUB_TERM_CTRL | 'r'): case (GRUB_TERM_CTRL | 'r'):
@@ -958,10 +1001,10 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
{ {
menu_fini (); menu_fini ();
g_ventoy_grub2_mode = 1 - g_ventoy_grub2_mode; g_ventoy_grub2_mode = 1 - g_ventoy_grub2_mode;
g_ventoy_menu_refresh = 1; g_ventoy_menu_refresh = 1;
goto refresh; goto refresh;
} }
break; break;
case (GRUB_TERM_CTRL | 'w'): case (GRUB_TERM_CTRL | 'w'):
case 'w': case 'w':
if (0 == g_ventoy_secondary_menu_on) if (0 == g_ventoy_secondary_menu_on)
@@ -982,28 +1025,21 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
goto refresh; goto refresh;
} }
break; break;
case (GRUB_TERM_CTRL | 'h'): case (GRUB_TERM_CTRL | 'l'):
case 'h': case (GRUB_TERM_CTRL | 'L'):
case (GRUB_TERM_SHIFT | 'l'):
case (GRUB_TERM_SHIFT | 'L'):
case 'l':
case 'L':
{ {
if (0 == g_ventoy_secondary_menu_on) VTOY_COMM_HOTKEY("VTOY_LANG_CMD");
{
cmdstr = grub_env_get("VTOY_HELP_CMD");
if (cmdstr)
{
grub_script_execute_sourcecode(cmdstr);
while (grub_getkey() != GRUB_TERM_ESC)
;
menu_fini ();
goto refresh;
}
}
break; break;
} }
case (GRUB_TERM_CTRL | 'm'): case (GRUB_TERM_CTRL | 'm'):
case 'm': case 'm':
{ {
if (0 == g_ventoy_secondary_menu_on) if (0 == g_ventoy_secondary_menu_on)
{ {
if (g_ventoy_cur_img_path) if (g_ventoy_cur_img_path)
{ {
grub_env_set("VTOY_CHKSUM_FILE_PATH", g_ventoy_cur_img_path); grub_env_set("VTOY_CHKSUM_FILE_PATH", g_ventoy_cur_img_path);
@@ -1092,15 +1128,17 @@ static struct grub_menu_execute_callback execution_callback =
static grub_err_t static grub_err_t
show_menu (grub_menu_t menu, int nested, int autobooted) show_menu (grub_menu_t menu, int nested, int autobooted)
{ {
const char *def; const char *def;
def = grub_env_get("VTOY_DEFAULT_IMAGE"); def = grub_env_get("VTOY_DEFAULT_IMAGE");
while (1) while (1)
{ {
int ndown;
char *pos = NULL;
int boot_entry; int boot_entry;
grub_menu_entry_t e; grub_menu_entry_t e;
int auto_boot; int auto_boot;
boot_entry = run_menu (menu, nested, &auto_boot); boot_entry = run_menu (menu, nested, &auto_boot);
if (boot_entry < 0) if (boot_entry < 0)
break; break;
@@ -1112,7 +1150,7 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
if (autobooted == 0 && auto_boot == 0) { if (autobooted == 0 && auto_boot == 0) {
g_ventoy_last_entry = boot_entry; g_ventoy_last_entry = boot_entry;
if (g_ventoy_menu_esc) if (g_ventoy_menu_esc)
break; break;
} }
if (autobooted == 0 && g_ventoy_menu_esc && auto_boot) { if (autobooted == 0 && g_ventoy_menu_esc && auto_boot) {
@@ -1125,7 +1163,7 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
continue; /* Menu is empty. */ continue; /* Menu is empty. */
if (2 == e->argc && e->args && e->args[1] && grub_strncmp(e->args[1], "VTOY_RET", 8) == 0) if (2 == e->argc && e->args && e->args[1] && grub_strncmp(e->args[1], "VTOY_RET", 8) == 0)
break; break;
grub_cls (); grub_cls ();
@@ -1138,7 +1176,30 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
break; break;
if (2 == e->argc && e->args && e->args[1] && grub_strncmp(e->args[1], "VTOY_RUN_RET", 12) == 0) if (2 == e->argc && e->args && e->args[1] && grub_strncmp(e->args[1], "VTOY_RUN_RET", 12) == 0)
break; break;
else if (2 == e->argc && e->args && e->args[1] && grub_strncmp(e->args[1], "VTOY_RUN_SET_", 13) == 0) {
pos = NULL;
ndown = (int)grub_strtol(e->args[1] + 13, &pos, 10);
while (ndown > 0)
{
ventoy_menu_push_key(GRUB_TERM_KEY_DOWN);
ndown--;
}
ventoy_menu_push_key('\n');
if (pos && *pos == '_')
{
ndown = (int)grub_strtol(pos + 1, NULL, 10);
while (ndown > 0)
{
ventoy_menu_push_key(GRUB_TERM_KEY_DOWN);
ndown--;
}
}
break;
}
} }
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
@@ -31,6 +31,8 @@
static grub_uint8_t grub_color_menu_normal; static grub_uint8_t grub_color_menu_normal;
static grub_uint8_t grub_color_menu_highlight; static grub_uint8_t grub_color_menu_highlight;
extern char g_ventoy_hotkey_tip[256];
struct menu_viewer_data struct menu_viewer_data
{ {
int first, offset; int first, offset;
@@ -204,7 +206,7 @@ command-line or ESC to discard edits and return to the GRUB menu."),
ret += grub_print_message_indented_real(szLine, STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run); ret += grub_print_message_indented_real(szLine, STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run);
ret += grub_print_message_indented_real("\n", STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run); ret += grub_print_message_indented_real("\n", STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run);
ret += grub_print_message_indented_real(grub_env_get("VTOY_HOTKEY_TIP"), ret += grub_print_message_indented_real(g_ventoy_hotkey_tip,
3, 6, term, dry_run); 3, 6, term, dry_run);
} }
} }
+378 -21
View File
@@ -1,5 +1,5 @@
/****************************************************************************** /******************************************************************************
* ventoy.c * ventoy.c
* *
* Copyright (c) 2020, longpanda <admin@ventoy.net> * Copyright (c) 2020, longpanda <admin@ventoy.net>
* *
@@ -7,12 +7,12 @@
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of the * published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>. * along with this program; if not, see <http://www.gnu.org/licenses/>.
* *
@@ -49,6 +49,10 @@ int g_ventoy_debug = 0;
static int g_efi_os = 0xFF; static int g_efi_os = 0xFF;
grub_uint32_t g_ventoy_plat_data; grub_uint32_t g_ventoy_plat_data;
#ifdef GRUB_MACHINE_EFI
static VTOY_SHIM *g_vtoy_shim = NULL;
#endif
void ventoy_debug(const char *fmt, ...) void ventoy_debug(const char *fmt, ...)
{ {
va_list args; va_list args;
@@ -115,6 +119,92 @@ int ventoy_str_all_digit(const char *str)
return 1; return 1;
} }
int ventoy_str_all_alnum(const char *str)
{
if (NULL == str || 0 == *str)
{
return 0;
}
while (*str)
{
if (!grub_isalnum(*str))
{
return 0;
}
}
return 1;
}
int ventoy_str_len_alnum(const char *str, int len)
{
int i;
int slen;
if (NULL == str || 0 == *str)
{
return 0;
}
slen = grub_strlen(str);
if (slen <= len)
{
return 0;
}
for (i = 0; i < len; i++)
{
if (!grub_isalnum(str[i]))
{
return 0;
}
}
if (str[len] == 0 || grub_isspace(str[len]))
{
return 1;
}
return 0;
}
char * ventoy_str_basename(char *path)
{
char *pos = NULL;
pos = grub_strrchr(path, '/');
if (pos)
{
pos++;
}
else
{
pos = path;
}
return pos;
}
int ventoy_str_chrcnt(const char *str, char c)
{
int n = 0;
if (str)
{
while (*str)
{
if (*str == c)
{
n++;
}
str++;
}
}
return n;
}
int ventoy_strcmp(const char *pattern, const char *str) int ventoy_strcmp(const char *pattern, const char *str)
{ {
while (*pattern && *str) while (*pattern && *str)
@@ -146,6 +236,14 @@ int ventoy_strncmp (const char *pattern, const char *str, grub_size_t n)
return (int)(grub_uint8_t)*pattern - (int)(grub_uint8_t)*str; return (int)(grub_uint8_t)*pattern - (int)(grub_uint8_t)*str;
} }
grub_err_t ventoy_env_int_set(const char *name, int value)
{
char buf[16];
grub_snprintf(buf, sizeof(buf), "%d", value);
return grub_env_set(name, buf);
}
void ventoy_debug_dump_guid(const char *prefix, grub_uint8_t *guid) void ventoy_debug_dump_guid(const char *prefix, grub_uint8_t *guid)
{ {
int i; int i;
@@ -154,13 +252,13 @@ void ventoy_debug_dump_guid(const char *prefix, grub_uint8_t *guid)
{ {
return; return;
} }
debug("%s", prefix); debug("%s", prefix);
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
grub_printf("%02x ", guid[i]); grub_printf("%02x ", guid[i]);
} }
grub_printf("\n"); grub_printf("\n");
} }
int ventoy_is_efi_os(void) int ventoy_is_efi_os(void)
@@ -196,7 +294,7 @@ void ventoy_memfile_env_set(const char *prefix, const void *buf, unsigned long l
grub_snprintf(name, sizeof(name), "%s_addr", prefix); grub_snprintf(name, sizeof(name), "%s_addr", prefix);
grub_snprintf(val, sizeof(val), "0x%llx", (ulonglong)(ulong)buf); grub_snprintf(val, sizeof(val), "0x%llx", (ulonglong)(ulong)buf);
grub_env_set(name, val); grub_env_set(name, val);
grub_snprintf(name, sizeof(name), "%s_size", prefix); grub_snprintf(name, sizeof(name), "%s_size", prefix);
grub_snprintf(val, sizeof(val), "%llu", len); grub_snprintf(val, sizeof(val), "%llu", len);
grub_env_set(name, val); grub_env_set(name, val);
@@ -204,9 +302,152 @@ void ventoy_memfile_env_set(const char *prefix, const void *buf, unsigned long l
return; return;
} }
#ifdef GRUB_MACHINE_EFI
static void ventoy_get_uefi_version(char *str, grub_size_t len)
{
grub_efi_uint8_t uefi_minor_1, uefi_minor_2;
uefi_minor_1 = (grub_efi_system_table->hdr.revision & 0xffff) / 10;
uefi_minor_2 = (grub_efi_system_table->hdr.revision & 0xffff) % 10;
grub_snprintf(str, len, "%d.%d", (grub_efi_system_table->hdr.revision >> 16), uefi_minor_1);
if (uefi_minor_2)
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;
static int set_once = 0;
/* no need when SecureBoot is disabled */
if (g_sys_sb == 0)
{
return 0;
}
/* can only set once */
if (set_once > 0)
{
return 0;
}
set_once = 1;
/* VTOY_SECURE_BOOT_POLICY only take affect once during init */
env = grub_env_get("VTOY_SECURE_BOOT_POLICY");
if (env)
{
g_sb_policy = (grub_uint8_t)(env[0] - '0');
}
if (g_sb_policy == VTOY_SB_POLICY_BYPASS)
{
if (g_vtoy_shim && g_vtoy_shim->ByPassSB)
{
g_vtoy_shim->ByPassSB();
}
}
else if (g_sb_policy == VTOY_SB_POLICY_CHECK)
{
if (g_vtoy_shim && g_vtoy_shim->CheckSB)
{
g_vtoy_shim->CheckSB();
}
}
return 0;
}
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;
}
grub_check_free(var);
}
static int ventoy_secure_boot_init(void)
{
grub_efi_guid_t ProtGuid = VTOY_SHIM_POLICY_GUID;
ventoy_get_uefi_sb();
if (g_sys_sb == 0)
{
return 0;
}
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 || g_vtoy_shim->Launched == NULL)
{
/*
* 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();
}
}
return 0;
}
#endif
static int ventoy_arch_mode_init(void) static int ventoy_arch_mode_init(void)
{ {
#ifdef GRUB_MACHINE_EFI #ifdef GRUB_MACHINE_EFI
if (grub_strcmp(GRUB_TARGET_CPU, "i386") == 0) if (grub_strcmp(GRUB_TARGET_CPU, "i386") == 0)
{ {
g_ventoy_plat_data = VTOY_PLAT_I386_UEFI; g_ventoy_plat_data = VTOY_PLAT_I386_UEFI;
@@ -235,19 +476,6 @@ static int ventoy_arch_mode_init(void)
return 0; return 0;
} }
#ifdef GRUB_MACHINE_EFI
static void ventoy_get_uefi_version(char *str, grub_size_t len)
{
grub_efi_uint8_t uefi_minor_1, uefi_minor_2;
uefi_minor_1 = (grub_efi_system_table->hdr.revision & 0xffff) / 10;
uefi_minor_2 = (grub_efi_system_table->hdr.revision & 0xffff) % 10;
grub_snprintf(str, len, "%d.%d", (grub_efi_system_table->hdr.revision >> 16), uefi_minor_1);
if (uefi_minor_2)
grub_snprintf(str, len, "%s.%d", str, uefi_minor_2);
}
#endif
static int ventoy_calc_totalmem(grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, void *data) static int ventoy_calc_totalmem(grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, void *data)
{ {
grub_uint64_t *total_mem = (grub_uint64_t *)data; grub_uint64_t *total_mem = (grub_uint64_t *)data;
@@ -269,12 +497,136 @@ static int ventoy_hwinfo_init(void)
grub_snprintf(str, sizeof(str), "%ld", (long)(total_mem / VTOY_SIZE_1MB)); grub_snprintf(str, sizeof(str), "%ld", (long)(total_mem / VTOY_SIZE_1MB));
ventoy_env_export("grub_total_ram", str); ventoy_env_export("grub_total_ram", str);
#ifdef GRUB_MACHINE_EFI #ifdef GRUB_MACHINE_EFI
ventoy_get_uefi_version(str, sizeof(str)); ventoy_get_uefi_version(str, sizeof(str));
ventoy_env_export("grub_uefi_version", 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 #endif
return 0;
}
static global_var_cfg g_global_vars[] =
{
{ "gfxmode", "1024x768", NULL },
{ ventoy_left_key, "5%", NULL },
{ ventoy_top_key, "95%", NULL },
{ ventoy_color_key, "#0000ff", NULL },
{ NULL, NULL, NULL }
};
static const char * ventoy_global_var_read_hook(struct grub_env_var *var, const char *val)
{
int i;
for (i = 0; g_global_vars[i].name; i++)
{
if (grub_strcmp(g_global_vars[i].name, var->name) == 0)
{
return g_global_vars[i].value;
}
}
return val;
}
static char * ventoy_global_var_write_hook(struct grub_env_var *var, const char *val)
{
int i;
for (i = 0; g_global_vars[i].name; i++)
{
if (grub_strcmp(g_global_vars[i].name, var->name) == 0)
{
grub_check_free(g_global_vars[i].value);
g_global_vars[i].value = grub_strdup(val);
break;
}
}
return grub_strdup(val);
}
int ventoy_global_var_init(void)
{
int i;
for (i = 0; g_global_vars[i].name; i++)
{
g_global_vars[i].value = grub_strdup(g_global_vars[i].defval);
ventoy_env_export(g_global_vars[i].name, g_global_vars[i].defval);
grub_register_variable_hook(g_global_vars[i].name, ventoy_global_var_read_hook, ventoy_global_var_write_hook);
}
return 0;
}
static ctrl_var_cfg g_ctrl_vars[] =
{
{ "VTOY_WIN11_BYPASS_CHECK", "1" },
{ "VTOY_WIN11_BYPASS_NRO", "1" },
{ "VTOY_LINUX_REMOUNT", "0" },
{ "VTOY_SECONDARY_BOOT_MENU", "1" },
{ "VTOY_WIN_UEFI_RES_LOCK", "3" },
{ NULL, "" }
};
static const char * ventoy_ctrl_var_read_hook(struct grub_env_var *var, const char *val)
{
int i;
for (i = 0; g_ctrl_vars[i].name; i++)
{
if (grub_strcmp(g_ctrl_vars[i].name, var->name) == 0)
{
return g_ctrl_vars[i].szval;
}
}
return val;
}
static char * ventoy_ctrl_var_write_hook(struct grub_env_var *var, const char *val)
{
int i;
for (i = 0; g_ctrl_vars[i].name; i++)
{
if (grub_strcmp(g_ctrl_vars[i].name, var->name) == 0)
{
if (val && grub_isdigit(val[0]) && val[1] == 0)
{
g_ctrl_vars[i].szval[0] = val[0];
return grub_strdup(val);
}
else
{
g_ctrl_vars[i].szval[0] = '0';
return grub_strdup("0");
}
}
}
return grub_strdup(val);
}
int ventoy_ctrl_var_init(void)
{
ctrl_var_cfg *cfg = g_ctrl_vars;
while (cfg->name)
{
ventoy_env_export(cfg->name, cfg->szval);
grub_register_variable_hook(cfg->name, ventoy_ctrl_var_read_hook, ventoy_ctrl_var_write_hook);
cfg++;
}
return 0; return 0;
} }
@@ -283,6 +635,11 @@ GRUB_MOD_INIT(ventoy)
ventoy_hwinfo_init(); ventoy_hwinfo_init();
ventoy_env_init(); ventoy_env_init();
ventoy_arch_mode_init(); ventoy_arch_mode_init();
#ifdef GRUB_MACHINE_EFI
ventoy_secure_boot_init();
#endif
ventoy_register_all_cmd(); ventoy_register_all_cmd();
} }
@@ -244,6 +244,15 @@ static int ventoy_browser_valid_dirname(const char *name, int len)
return 0; return 0;
} }
if (g_filt_trash_dir)
{
if (0 == grub_strncmp(name, ".trash-", 7) ||
0 == grub_strcmp(name, ".Trashes"))
{
return 0;
}
}
if (name[0] == '$') if (name[0] == '$')
{ {
if (0 == grub_strncmp(name, "$RECYCLE.BIN", 12) || if (0 == grub_strncmp(name, "$RECYCLE.BIN", 12) ||
@@ -392,6 +401,11 @@ static int ventoy_browser_iterate_dir(const char *filename, const struct grub_di
return 0; return 0;
} }
if (grub_file_is_vlnk_suffix(filename, len))
{
return 0;
}
node = grub_zalloc(sizeof(browser_node)); node = grub_zalloc(sizeof(browser_node));
if (!node) if (!node)
{ {
@@ -616,13 +630,15 @@ grub_err_t ventoy_cmd_browser_disk(grub_extcmd_context_t ctxt, int argc, char **
if (g_tree_view_menu_style == 0) if (g_tree_view_menu_style == 0)
{ {
browser_ssprintf(&mbuf, "menuentry \"%-10s [Return]\" --class=\"vtoyret\" VTOY_RET {\n " browser_ssprintf(&mbuf, "menuentry \"%-10s [%s]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n}\n", "<--"); " echo 'return ...' \n}\n", "<--",
ventoy_get_vmenu_title("VTLANG_BROWER_RETURN"));
} }
else else
{ {
browser_ssprintf(&mbuf, "menuentry \"[Return]\" --class=\"vtoyret\" VTOY_RET {\n " browser_ssprintf(&mbuf, "menuentry \"[%s]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n}\n"); " echo 'return ...' \n}\n",
ventoy_get_vmenu_title("VTLANG_BROWER_RETURN"));
} }
grub_disk_dev_iterate(ventoy_browser_iterate_disk, &mbuf); grub_disk_dev_iterate(ventoy_browser_iterate_disk, &mbuf);
File diff suppressed because it is too large Load Diff
@@ -7,12 +7,12 @@
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of the * published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>. * along with this program; if not, see <http://www.gnu.org/licenses/>.
* *
@@ -37,6 +37,7 @@
#define VTOY_SIZE_4MB (4 * 1024 * 1024) #define VTOY_SIZE_4MB (4 * 1024 * 1024)
#define VTOY_SIZE_512KB (512 * 1024) #define VTOY_SIZE_512KB (512 * 1024)
#define VTOY_SIZE_1KB 1024 #define VTOY_SIZE_1KB 1024
#define VTOY_SIZE_4KB 4096
#define VTOY_SIZE_32KB (32 * 1024) #define VTOY_SIZE_32KB (32 * 1024)
#define VTOY_SIZE_128KB (128 * 1024) #define VTOY_SIZE_128KB (128 * 1024)
@@ -62,6 +63,8 @@
#define VTOY_WARNING "!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!" #define VTOY_WARNING "!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!"
#define VTOY_CHKSUM_NUM 4
#define VTOY_PLAT_I386_UEFI 0x49413332 #define VTOY_PLAT_I386_UEFI 0x49413332
#define VTOY_PLAT_ARM64_UEFI 0x41413634 #define VTOY_PLAT_ARM64_UEFI 0x41413634
#define VTOY_PLAT_X86_64_UEFI 0x55454649 #define VTOY_PLAT_X86_64_UEFI 0x55454649
@@ -77,6 +80,10 @@
#define VTOY_ARCH_CPIO "ventoy_x86.cpio" #define VTOY_ARCH_CPIO "ventoy_x86.cpio"
#endif #endif
#define ventoy_left_key "VTLE_LFT"
#define ventoy_top_key "VTLE_TOP"
#define ventoy_color_key "VTLE_CLR"
#define ventoy_varg_4(arg) arg[0], arg[1], arg[2], arg[3] #define ventoy_varg_4(arg) arg[0], arg[1], arg[2], arg[3]
#define ventoy_varg_8(arg) arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6], arg[7] #define ventoy_varg_8(arg) arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6], arg[7]
@@ -89,6 +96,12 @@
return (err);\ return (err);\
} }
#define vtoy_tip(wait_seconds, fmt, ...) \
grub_printf(fmt, __VA_ARGS__); \
grub_refresh(); \
grub_sleep(wait_seconds)
#define VTOY_APPEND_NEWBUF(buf) \ #define VTOY_APPEND_NEWBUF(buf) \
{\ {\
char *__c = buf;\ char *__c = buf;\
@@ -99,6 +112,28 @@
}\ }\
} }
#define VTOY_SKIP_SPACE(s) \
while (ventoy_isspace(*s)) \
{\
s++;\
}
#define VTOY_SKIP_SPACE_NEXT(s, initial) \
s += initial;\
while (ventoy_isspace(*s)) \
{\
s++;\
}
#define VTOY_SKIP_SPACE_NEXT_EX(s, base, initial) \
s = base + initial;\
while (ventoy_isspace(*s)) \
{\
s++;\
}
#define VTOY_GOTO_END(v) ret = v; goto end
typedef enum VTOY_FILE_FLT typedef enum VTOY_FILE_FLT
{ {
VTOY_FILE_FLT_ISO = 0, /* .iso */ VTOY_FILE_FLT_ISO = 0, /* .iso */
@@ -107,7 +142,7 @@ typedef enum VTOY_FILE_FLT
VTOY_FILE_FLT_IMG, /* .img */ VTOY_FILE_FLT_IMG, /* .img */
VTOY_FILE_FLT_VHD, /* .vhd(x) */ VTOY_FILE_FLT_VHD, /* .vhd(x) */
VTOY_FILE_FLT_VTOY, /* .vtoy */ VTOY_FILE_FLT_VTOY, /* .vtoy */
VTOY_FILE_FLT_BUTT VTOY_FILE_FLT_BUTT
}VTOY_FILE_FLT; }VTOY_FILE_FLT;
@@ -125,7 +160,7 @@ typedef struct cmd_para
grub_extcmd_func_t func; grub_extcmd_func_t func;
grub_command_flags_t flags; grub_command_flags_t flags;
const struct grub_arg_option *parser; const struct grub_arg_option *parser;
const char *summary; const char *summary;
const char *description; const char *description;
@@ -136,7 +171,7 @@ typedef struct cmd_para
#define ventoy_align(value, align) (((value) + ((align) - 1)) & (~((align) - 1))) #define ventoy_align(value, align) (((value) + ((align) - 1)) & (~((align) - 1)))
#pragma pack(1) #pragma pack(1)
typedef struct cpio_newc_header typedef struct cpio_newc_header
{ {
char c_magic[6]; char c_magic[6];
char c_ino[8]; char c_ino[8];
@@ -160,6 +195,18 @@ typedef struct cpio_newc_header
#define check_free(p, func) if (p) { func(p); p = NULL; } #define check_free(p, func) if (p) { func(p); p = NULL; }
#define grub_check_free(p) if (p) { grub_free(p); p = NULL; } #define grub_check_free(p) if (p) { grub_free(p); p = NULL; }
#define VTOY_SHIM_POLICY_GUID {0x90a29d14, 0x3968, 0x48fe, { 0x85, 0x81, 0x6b, 0x7f, 0x7d, 0xc4, 0x70, 0x55 }};
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;
typedef int (*grub_char_check_func)(int c); typedef int (*grub_char_check_func)(int c);
#define ventoy_is_decimal(str) ventoy_string_check(str, grub_isdigit) #define ventoy_is_decimal(str) ventoy_string_check(str, grub_isdigit)
@@ -171,7 +218,7 @@ typedef struct ventoy_patch_vhd
grub_uint8_t part_offset_or_guid[16]; grub_uint8_t part_offset_or_guid[16];
grub_uint32_t reserved1; grub_uint32_t reserved1;
grub_uint32_t part_type; grub_uint32_t part_type;
grub_uint8_t disk_signature_or_guid[16]; grub_uint8_t disk_signature_or_guid[16];
grub_uint8_t reserved2[16]; grub_uint8_t reserved2[16];
grub_uint8_t vhd_file_path[1]; grub_uint8_t vhd_file_path[1];
}ventoy_patch_vhd; }ventoy_patch_vhd;
@@ -249,7 +296,7 @@ typedef struct img_info
const char *tip2; const char *tip2;
const char *class; const char *class;
const char *menu_prefix; const char *menu_prefix;
int id; int id;
int type; int type;
int plugin_list_index; int plugin_list_index;
@@ -278,8 +325,8 @@ typedef struct img_iterator_node
struct img_iterator_node *parent; struct img_iterator_node *parent;
struct img_iterator_node *firstchild; struct img_iterator_node *firstchild;
void *firstiso; void *firstiso;
}img_iterator_node; }img_iterator_node;
@@ -293,7 +340,7 @@ typedef struct initrd_info
grub_uint8_t iso_type; // 0: iso9660 1:udf grub_uint8_t iso_type; // 0: iso9660 1:udf
grub_uint32_t udf_start_block; grub_uint32_t udf_start_block;
grub_uint64_t override_offset; grub_uint64_t override_offset;
grub_uint32_t override_length; grub_uint32_t override_length;
char override_data[32]; char override_data[32];
@@ -362,7 +409,7 @@ void ventoy_debug(const char *fmt, ...);
#pragma pack(1) #pragma pack(1)
/* A WIM resource header */ /* A WIM resource header */
typedef struct wim_resource_header typedef struct wim_resource_header
{ {
grub_uint64_t size_in_wim:56; /* Compressed length */ grub_uint64_t size_in_wim:56; /* Compressed length */
grub_uint64_t flags:8; /* flags */ grub_uint64_t flags:8; /* flags */
@@ -374,7 +421,7 @@ typedef struct wim_resource_header
#define WIM_RESHDR_ZLEN_MASK 0x00ffffffffffffffULL #define WIM_RESHDR_ZLEN_MASK 0x00ffffffffffffffULL
/* WIM resource header flags */ /* WIM resource header flags */
typedef enum wim_resource_header_flags typedef enum wim_resource_header_flags
{ {
WIM_RESHDR_METADATA = ( 0x02ULL << 56 ), /* Resource contains metadata */ WIM_RESHDR_METADATA = ( 0x02ULL << 56 ), /* Resource contains metadata */
WIM_RESHDR_COMPRESSED = ( 0x04ULL << 56 ), /* Resource is compressed */ WIM_RESHDR_COMPRESSED = ( 0x04ULL << 56 ), /* Resource is compressed */
@@ -384,7 +431,7 @@ typedef enum wim_resource_header_flags
#define WIM_HEAD_SIGNATURE "MSWIM\0\0" #define WIM_HEAD_SIGNATURE "MSWIM\0\0"
/* WIM header */ /* WIM header */
typedef struct wim_header typedef struct wim_header
{ {
grub_uint8_t signature[8]; /* Signature */ grub_uint8_t signature[8]; /* Signature */
grub_uint32_t header_len; /* Header length */ grub_uint32_t header_len; /* Header length */
@@ -404,21 +451,21 @@ typedef struct wim_header
} wim_header; } wim_header;
/* WIM header flags */ /* WIM header flags */
typedef enum wim_header_flags typedef enum wim_header_flags
{ {
WIM_HDR_XPRESS = 0x00020000, /* WIM uses Xpress compresson */ WIM_HDR_XPRESS = 0x00020000, /* WIM uses Xpress compresson */
WIM_HDR_LZX = 0x00040000, /* WIM uses LZX compression */ WIM_HDR_LZX = 0x00040000, /* WIM uses LZX compression */
}wim_header_flags; }wim_header_flags;
/* A WIM file hash */ /* A WIM file hash */
typedef struct wim_hash typedef struct wim_hash
{ {
/* SHA-1 hash */ /* SHA-1 hash */
grub_uint8_t sha1[20]; grub_uint8_t sha1[20];
}wim_hash; }wim_hash;
/* A WIM lookup table entry */ /* A WIM lookup table entry */
typedef struct wim_lookup_entry typedef struct wim_lookup_entry
{ {
wim_resource_header resource; /* Resource header */ wim_resource_header resource; /* Resource header */
grub_uint16_t part; /* Part number */ grub_uint16_t part; /* Part number */
@@ -430,19 +477,19 @@ typedef struct wim_lookup_entry
#define WIM_CHUNK_LEN 32768 #define WIM_CHUNK_LEN 32768
/* A WIM chunk buffer */ /* A WIM chunk buffer */
typedef struct wim_chunk_buffer typedef struct wim_chunk_buffer
{ {
grub_uint8_t data[WIM_CHUNK_LEN]; /*Data */ grub_uint8_t data[WIM_CHUNK_LEN]; /*Data */
}wim_chunk_buffer; }wim_chunk_buffer;
/* Security data */ /* Security data */
typedef struct wim_security_header typedef struct wim_security_header
{ {
grub_uint32_t len; /* Length */ grub_uint32_t len; /* Length */
grub_uint32_t count; /* Number of entries */ grub_uint32_t count; /* Number of entries */
}wim_security_header; }wim_security_header;
typedef struct wim_stream_entry typedef struct wim_stream_entry
{ {
grub_uint64_t len; grub_uint64_t len;
grub_uint64_t unused1; grub_uint64_t unused1;
@@ -452,7 +499,7 @@ typedef struct wim_stream_entry
}wim_stream_entry; }wim_stream_entry;
/* Directory entry */ /* Directory entry */
typedef struct wim_directory_entry typedef struct wim_directory_entry
{ {
grub_uint64_t len; /* Length */ grub_uint64_t len; /* Length */
grub_uint32_t attributes; /* Attributes */ grub_uint32_t attributes; /* Attributes */
@@ -555,7 +602,7 @@ typedef struct _VTOY_JSON
struct _VTOY_JSON *pstChild; struct _VTOY_JSON *pstChild;
JSON_TYPE enDataType; JSON_TYPE enDataType;
union union
{ {
char *pcStrVal; char *pcStrVal;
int iNumVal; int iNumVal;
@@ -611,6 +658,11 @@ typedef struct chk_case_fs_dir
}chk_case_fs_dir; }chk_case_fs_dir;
int ventoy_str_all_digit(const char *str); 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);
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); int ventoy_strcmp(const char *pattern, const char *str);
int ventoy_strncmp (const char *pattern, const char *str, grub_size_t n); int ventoy_strncmp (const char *pattern, const char *str, grub_size_t n);
void ventoy_fill_os_param(grub_file_t file, ventoy_os_param *param); void ventoy_fill_os_param(grub_file_t file, ventoy_os_param *param);
@@ -623,6 +675,7 @@ grub_uint32_t ventoy_get_iso_boot_catlog(grub_file_t file);
int ventoy_has_efi_eltorito(grub_file_t file, grub_uint32_t sector); int ventoy_has_efi_eltorito(grub_file_t file, grub_uint32_t sector);
grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_linux_initrd(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_linux_limine_menu(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_linux_limine_menu(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
@@ -661,7 +714,7 @@ int vtoy_json_parse_value
( (
char *pcNewStart, char *pcNewStart,
char *pcRawStart, char *pcRawStart,
VTOY_JSON *pstJson, VTOY_JSON *pstJson,
const char *pcData, const char *pcData,
const char **ppcEnd const char **ppcEnd
); );
@@ -677,51 +730,51 @@ int vtoy_json_scan_parse
int vtoy_json_scan_array int vtoy_json_scan_array
( (
VTOY_JSON *pstJson, VTOY_JSON *pstJson,
const char *szKey, const char *szKey,
VTOY_JSON **ppstArrayItem VTOY_JSON **ppstArrayItem
); );
int vtoy_json_scan_array_ex int vtoy_json_scan_array_ex
( (
VTOY_JSON *pstJson, VTOY_JSON *pstJson,
const char *szKey, const char *szKey,
VTOY_JSON **ppstArrayItem VTOY_JSON **ppstArrayItem
); );
int vtoy_json_scan_object int vtoy_json_scan_object
( (
VTOY_JSON *pstJson, VTOY_JSON *pstJson,
const char *szKey, const char *szKey,
VTOY_JSON **ppstObjectItem VTOY_JSON **ppstObjectItem
); );
int vtoy_json_get_int int vtoy_json_get_int
( (
VTOY_JSON *pstJson, VTOY_JSON *pstJson,
const char *szKey, const char *szKey,
int *piValue int *piValue
); );
int vtoy_json_get_uint int vtoy_json_get_uint
( (
VTOY_JSON *pstJson, VTOY_JSON *pstJson,
const char *szKey, const char *szKey,
grub_uint32_t *puiValue grub_uint32_t *puiValue
); );
int vtoy_json_get_uint64 int vtoy_json_get_uint64
( (
VTOY_JSON *pstJson, VTOY_JSON *pstJson,
const char *szKey, const char *szKey,
grub_uint64_t *pui64Value grub_uint64_t *pui64Value
); );
int vtoy_json_get_bool int vtoy_json_get_bool
( (
VTOY_JSON *pstJson, VTOY_JSON *pstJson,
const char *szKey, const char *szKey,
grub_uint8_t *pbValue grub_uint8_t *pbValue
); );
int vtoy_json_get_string int vtoy_json_get_string
( (
VTOY_JSON *pstJson, VTOY_JSON *pstJson,
const char *szKey, const char *szKey,
grub_uint32_t uiBufLen, grub_uint32_t uiBufLen,
char *pcBuf char *pcBuf
); );
@@ -743,7 +796,7 @@ static inline int ventoy_isspace (int c)
static inline int ventoy_is_word_end(int c) static inline int ventoy_is_word_end(int c)
{ {
return (c == 0 || c == ',' || ventoy_isspace(c)); return (c == 0 || c == ',' || ventoy_isspace(c));
} }
#pragma pack(1) #pragma pack(1)
@@ -828,7 +881,8 @@ typedef struct vhd_footer_t
grub_uint8_t savedst; // Saved state grub_uint8_t savedst; // Saved state
}vhd_footer_t; }vhd_footer_t;
#define VDI_IMAGE_FILE_INFO "<<< Oracle VM VirtualBox Disk Image >>>\n" #define VDI_IMAGE_FILE_INFO "<<< Oracle VM VirtualBox Disk Image >>>\n"
#define VDI_IMAGE_FILE_INFO2 "<<< Oracle VirtualBox Disk Image >>>\n"
/** Image signature. */ /** Image signature. */
#define VDI_IMAGE_SIGNATURE (0xbeda107f) #define VDI_IMAGE_SIGNATURE (0xbeda107f)
@@ -914,7 +968,7 @@ typedef struct persistence_config
int cursel; int cursel;
int backendnum; int backendnum;
file_fullpath *backendpath; file_fullpath *backendpath;
struct persistence_config *next; struct persistence_config *next;
}persistence_config; }persistence_config;
@@ -1053,6 +1107,9 @@ extern int g_ventoy_case_insensitive;
extern int g_ventoy_fn_mutex; extern int g_ventoy_fn_mutex;
extern grub_uint8_t g_ventoy_chain_type; extern grub_uint8_t g_ventoy_chain_type;
extern int g_vhdboot_enable; extern int g_vhdboot_enable;
extern int g_default_menu_mode;
extern char g_ventoy_hotkey_tip[256];
extern int g_ventoy_menu_refresh;
#define VENTOY_IMG_WHITE_LIST 1 #define VENTOY_IMG_WHITE_LIST 1
#define VENTOY_IMG_BLACK_LIST 2 #define VENTOY_IMG_BLACK_LIST 2
@@ -1113,7 +1170,7 @@ int ventoy_plugin_find_conf_replace(const char *iso, conf_replace *nodes[VTOY_MA
dud * ventoy_plugin_find_dud(const char *iso); dud * ventoy_plugin_find_dud(const char *iso);
int ventoy_plugin_load_dud(dud *node, const char *isopart); int ventoy_plugin_load_dud(dud *node, const char *isopart);
int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start); int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
int ventoy_check_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start); int ventoy_check_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start, char *err, grub_uint32_t len);
void ventoy_plugin_dump_persistence(void); void ventoy_plugin_dump_persistence(void);
grub_err_t ventoy_cmd_set_theme(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_set_theme(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_set_theme_path(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_set_theme_path(grub_extcmd_context_t ctxt, int argc, char **args);
@@ -1236,10 +1293,24 @@ typedef struct systemd_menu_ctx
{ {
char *dev; char *dev;
char *buf; char *buf;
const char *initrd_cmd;
int pos; int pos;
int len; int len;
}systemd_menu_ctx; }systemd_menu_ctx;
typedef struct global_var_cfg
{
const char *name;
const char *defval;
char *value;
}global_var_cfg;
typedef struct ctrl_var_cfg
{
const char *name;
char szval[2];
}ctrl_var_cfg;
#define vtoy_check_goto_out(p) if (!p) goto out #define vtoy_check_goto_out(p) if (!p) goto out
extern char *g_tree_script_buf; extern char *g_tree_script_buf;
@@ -1249,6 +1320,7 @@ extern int g_tree_view_menu_style;
extern int g_sort_case_sensitive; extern int g_sort_case_sensitive;
extern int g_wimboot_enable; extern int g_wimboot_enable;
extern int g_filt_dot_underscore_file; extern int g_filt_dot_underscore_file;
extern int g_filt_trash_dir;
extern int g_vtoy_file_flt[VTOY_FILE_FLT_BUTT]; extern int g_vtoy_file_flt[VTOY_FILE_FLT_BUTT];
extern const char *g_menu_class[img_type_max]; extern const char *g_menu_class[img_type_max];
extern char g_iso_path[256]; extern char g_iso_path[256];
@@ -1258,6 +1330,16 @@ grub_err_t ventoy_cmd_browser_disk(grub_extcmd_context_t ctxt, int argc, char **
int ventoy_get_fs_type(const char *fs); int ventoy_get_fs_type(const char *fs);
int ventoy_img_name_valid(const char *filename, grub_size_t namelen); int ventoy_img_name_valid(const char *filename, grub_size_t namelen);
void * ventoy_alloc_chain(grub_size_t size); void * ventoy_alloc_chain(grub_size_t size);
int ventoy_plugin_load_menu_lang(int init, const char *lang);
const char *ventoy_get_vmenu_title(const char *vMenu);
grub_err_t ventoy_cmd_cur_menu_lang(grub_extcmd_context_t ctxt, int argc, char **args);
extern int ventoy_menu_push_key(int code);
int ventoy_ctrl_var_init(void);
int ventoy_global_var_init(void);
grub_err_t ventoy_cmd_push_menulang(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_pop_menulang(grub_extcmd_context_t ctxt, int argc, char **args);
void ventoy_prompt_end(void);
int ventoy_set_sb_policy(void);
#endif /* __VENTOY_DEF_H__ */ #endif /* __VENTOY_DEF_H__ */
@@ -177,10 +177,7 @@ static grub_err_t ventoy_isolinux_initrd_collect(grub_file_t file, const char *p
{ {
nextline = ventoy_get_line(start); nextline = ventoy_get_line(start);
while (ventoy_isspace(*start)) VTOY_SKIP_SPACE(start);
{
start++;
}
offset = 7; // strlen("initrd=") or "INITRD " or "initrd " offset = 7; // strlen("initrd=") or "INITRD " or "initrd "
pos = grub_strstr(start, "initrd="); pos = grub_strstr(start, "initrd=");
@@ -438,10 +435,7 @@ static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName)
{ {
nextline = ventoy_get_line(start); nextline = ventoy_get_line(start);
while (ventoy_isspace(*start)) VTOY_SKIP_SPACE(start);
{
start++;
}
if (grub_strncmp(start, "initrd", 6) != 0) if (grub_strncmp(start, "initrd", 6) != 0)
{ {
@@ -454,10 +448,7 @@ static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName)
start++; start++;
} }
while (ventoy_isspace(*start)) VTOY_SKIP_SPACE(start);
{
start++;
}
if (*start == '"') if (*start == '"')
{ {
@@ -528,10 +519,7 @@ static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName)
if (*start == ' ' || *start == '\t') if (*start == ' ' || *start == '\t')
{ {
while (ventoy_isspace(*start)) VTOY_SKIP_SPACE(start);
{
start++;
}
} }
else else
{ {
@@ -1111,6 +1099,7 @@ static grub_err_t ventoy_linux_locate_initrd(int filt, int *filtcnt)
if (filtbysize if (filtbysize
&& (NULL == grub_strstr(node->name, "minirt.gz")) && (NULL == grub_strstr(node->name, "minirt.gz"))
&& (NULL == grub_strstr(node->name, "initrd.xz")) && (NULL == grub_strstr(node->name, "initrd.xz"))
&& (NULL == grub_strstr(node->name, "initrd.gz"))
) )
{ {
if (filt > 0 && file->size <= g_ventoy_cpio_size + 2048) if (filt > 0 && file->size <= g_ventoy_cpio_size + 2048)
@@ -1813,18 +1802,12 @@ static char *ventoy_systemd_conf_tag(char *buf, const char *tag, int optional)
for (start = buf; start; start = nextline) for (start = buf; start; start = nextline)
{ {
nextline = ventoy_get_line(start); nextline = ventoy_get_line(start);
while (ventoy_isspace(*start)) VTOY_SKIP_SPACE(start);
{
start++;
}
if (grub_strncmp(start, tag, taglen) == 0 && (start[taglen] == ' ' || start[taglen] == '\t')) if (grub_strncmp(start, tag, taglen) == 0 && (start[taglen] == ' ' || start[taglen] == '\t'))
{ {
start += taglen; start += taglen;
while (ventoy_isspace(*start)) VTOY_SKIP_SPACE(start);
{
start++;
}
return start; return start;
} }
} }
@@ -1884,7 +1867,7 @@ static int ventoy_systemd_conf_hook(const char *filename, const struct grub_dirh
ctx->pos = oldpos; ctx->pos = oldpos;
goto out; goto out;
} }
vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, " echo \"Downloading kernel ...\"\n linux %s ", tag); vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, " echo \"Loading kernel ...\"\n linux %s ", tag);
/* kernel options */ /* kernel options */
grub_memcpy(filebuf, bkbuf, file->size); grub_memcpy(filebuf, bkbuf, file->size);
@@ -1893,7 +1876,7 @@ static int ventoy_systemd_conf_hook(const char *filename, const struct grub_dirh
/* initrd xxx xxx xxx */ /* initrd xxx xxx xxx */
vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, " echo \"Downloading initrd ...\"\n initrd "); vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, " echo \"Loading initrd ...\"\n %s ", ctx->initrd_cmd);
grub_memcpy(filebuf, bkbuf, file->size); grub_memcpy(filebuf, bkbuf, file->size);
tag = ventoy_systemd_conf_tag(filebuf, "initrd", 1); tag = ventoy_systemd_conf_tag(filebuf, "initrd", 1);
while (tag) while (tag)
@@ -1910,6 +1893,34 @@ out:
return 0; return 0;
} }
grub_err_t ventoy_cmd_linux_initrd(grub_extcmd_context_t ctxt, int argc, char **args)
{
int i;
int pos = 0;
char *buf = NULL;
(void)ctxt;
buf = (char *)grub_malloc(VTOY_SIZE_4KB);
if (!buf)
{
return 1;
}
pos += grub_snprintf(buf + pos, VTOY_SIZE_4KB - pos, "initrd mem:%s:size:%s",
grub_env_get("ventoy_cpio_addr"), grub_env_get("ventoy_cpio_size"));
for (i = 0; i < argc; i++)
{
pos += grub_snprintf(buf + pos, VTOY_SIZE_4KB - pos, " newc:initrd%03d:%s", i + 1, args[i]);
}
grub_script_execute_sourcecode(buf);
grub_free(buf);
return 0;
}
grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, char **args) grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, char **args)
{ {
static char *buf = NULL; static char *buf = NULL;
@@ -1953,6 +1964,7 @@ grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, c
ctx.dev = args[0]; ctx.dev = args[0];
ctx.buf = buf; ctx.buf = buf;
ctx.initrd_cmd = args[2] ? args[2] : "initrd";
ctx.pos = 0; ctx.pos = 0;
ctx.len = VTOY_LINUX_SYSTEMD_MENU_MAX_BUF; ctx.len = VTOY_LINUX_SYSTEMD_MENU_MAX_BUF;
fs->fs_dir(dev, "/loader/entries", ventoy_systemd_conf_hook, &ctx); fs->fs_dir(dev, "/loader/entries", ventoy_systemd_conf_hook, &ctx);
@@ -2038,10 +2050,7 @@ grub_err_t ventoy_cmd_linux_limine_menu(grub_extcmd_context_t ctxt, int argc, ch
for (start = filebuf; start; start = nextline) for (start = filebuf; start; start = nextline)
{ {
nextline = ventoy_get_line(start); nextline = ventoy_get_line(start);
while (ventoy_isspace(*start)) VTOY_SKIP_SPACE(start);
{
start++;
}
if (start[0] == ':') if (start[0] == ':')
{ {
File diff suppressed because it is too large Load Diff
@@ -1,5 +1,5 @@
/****************************************************************************** /******************************************************************************
* ventoy_unix.c * ventoy_unix.c
* *
* Copyright (c) 2020, longpanda <admin@ventoy.net> * Copyright (c) 2020, longpanda <admin@ventoy.net>
* *
@@ -7,12 +7,12 @@
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of the * published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>. * 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; *offset = grub_iso9660_get_last_file_dirent_pos(file) + 2;
grub_file_close(file); grub_file_close(file);
return 0; return 0;
} }
@@ -83,12 +83,12 @@ static grub_uint32_t ventoy_unix_get_override_chunk_count(void)
{ {
count++; count++;
} }
if (g_mod_new_len > 0) if (g_mod_new_len > 0)
{ {
count++; count++;
} }
if (g_ko_fillmap_len > 0) if (g_ko_fillmap_len > 0)
{ {
count += (g_ko_fillmap_len / 512); count += (g_ko_fillmap_len / 512);
@@ -109,7 +109,7 @@ static grub_uint32_t ventoy_unix_get_virt_chunk_count(void)
{ {
count++; count++;
} }
if (g_mod_new_len > 0) if (g_mod_new_len > 0)
{ {
count++; count++;
@@ -127,7 +127,7 @@ static grub_uint32_t ventoy_unix_get_virt_chunk_size(void)
{ {
size += ventoy_align_2k(g_conf_new_len); size += ventoy_align_2k(g_conf_new_len);
} }
if (g_mod_new_len > 0) if (g_mod_new_len > 0)
{ {
size += ventoy_align_2k(g_mod_new_len); 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; grub_uint32_t i;
ventoy_img_chunk *chunk = NULL; 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); (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[0] = map->magic2[0] = VENTOY_UNIX_SEG_MAGIC0;
map->magic1[1] = map->magic2[1] = VENTOY_UNIX_SEG_MAGIC1; map->magic1[1] = map->magic2[1] = VENTOY_UNIX_SEG_MAGIC1;
map->magic1[2] = map->magic2[2] = VENTOY_UNIX_SEG_MAGIC2; 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); debug("####[FAIL] Too many segments for the ISO file %u\n", g_img_chunk_list.cur_chunk);
map->segnum = VENTOY_UNIX_MAX_SEGNUM; map->segnum = VENTOY_UNIX_MAX_SEGNUM;
} }
for (i = 0; i < (grub_uint32_t)(map->segnum); i++) for (i = 0; i < (grub_uint32_t)(map->segnum); i++)
{ {
chunk = g_img_chunk_list.chunk + i; chunk = g_img_chunk_list.chunk + i;
map->seglist[i].seg_start_bytes = chunk->disk_start_sector * 512ULL; 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; grub_uint64_t sector;
ventoy_override_chunk *cur; ventoy_override_chunk *cur;
ventoy_iso9660_override *dirent; ventoy_iso9660_override *dirent;
sector = (isosize + 2047) / 2048; sector = (isosize + 2047) / 2048;
cur = (ventoy_override_chunk *)((char *)chain + chain->override_chunk_offset); 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; offset = g_mod_override_offset;
ventoy_unix_fill_map_data(chain, (struct g_ventoy_map *)data); ventoy_unix_fill_map_data(chain, (struct g_ventoy_map *)data);
for (i = 0; i < g_ko_fillmap_len / 512; i++) for (i = 0; i < g_ko_fillmap_len / 512; i++)
{ {
cur->img_offset = offset; 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; override = (char *)chain + chain->virt_chunk_offset;
cur = (ventoy_virt_chunk *)override; cur = (ventoy_virt_chunk *)override;
sector = (isosize + 2047) / 2048; sector = (isosize + 2047) / 2048;
offset = 2 * sizeof(ventoy_virt_chunk); 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_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); ventoy_unix_fill_virt(g_mod_new_data, g_mod_new_len);
} }
return; return;
} }
@@ -287,7 +287,7 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath, const char
grub_uint8_t disk_guid[16]; grub_uint8_t disk_guid[16];
debug("ventoy_freebsd_append_conf %s\n", isopath); debug("ventoy_freebsd_append_conf %s\n", isopath);
isofile = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", isopath); isofile = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", isopath);
if (!isofile) 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_load=\"%s\"\n", "YES");
vtoy_ssprintf(buf, pos, "ventoy_name=\"%s\"\n", g_ko_mod_path); vtoy_ssprintf(buf, pos, "ventoy_name=\"%s\"\n", g_ko_mod_path);
if (alias) if (alias)
{ {
vtoy_ssprintf(buf, pos, "hint.ventoy.0.alias=\"%s\"\n", 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"); debug("Fill hint.ventoy info\n");
disk = isofile->device->disk; disk = isofile->device->disk;
ventoy_get_disk_guid(isofile->name, disk_guid, disk_sig); 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++) for (i = 0; i < g_img_chunk_list.cur_chunk; i++)
{ {
chunk = g_img_chunk_list.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), i, (ulonglong)(chunk->disk_start_sector * 512),
(ulonglong)((chunk->disk_end_sector + 1) * 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)ctxt;
(void)argc; (void)argc;
(void)args; (void)args;
g_unix_vlnk_boot = 0; g_unix_vlnk_boot = 0;
g_mod_search_magic = 0; g_mod_search_magic = 0;
g_conf_new_len = 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; const char *ver = NULL;
char *buf = NULL; char *buf = NULL;
VTOY_JSON *json = NULL; VTOY_JSON *json = NULL;
(void)ctxt; (void)ctxt;
(void)argc; (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 *buf;
char *start = NULL; char *start = NULL;
char *nextline = NULL; char *nextline = NULL;
(void)ctxt; (void)ctxt;
(void)argc; (void)argc;
(void)args; (void)args;
@@ -502,7 +502,7 @@ grub_err_t ventoy_cmd_unix_freebsd_ver(grub_extcmd_context_t ctxt, int argc, cha
nextline++; nextline++;
} }
*nextline = 0; *nextline = 0;
break; break;
} }
nextline = ventoy_get_line(start); 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_free(buf);
grub_file_close(file); grub_file_close(file);
VENTOY_CMD_RETURN(GRUB_ERR_NONE); 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) grub_err_t ventoy_cmd_unix_freebsd_ver_elf(grub_extcmd_context_t ctxt, int argc, char **args)
{ {
int j; int ret = 0;
int k; int bit64 = 0;
grub_elf_t elf = NULL;
grub_off_t offset = 0;
grub_uint32_t len = 0;
char *str = NULL;
char *data = NULL; char *data = NULL;
void *hdr = NULL; grub_elf_t elf = NULL;
char ver[64] = {0};
(void)ctxt; (void)ctxt;
(void)argc;
(void)args;
if (argc != 3) 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; 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); ret = ventoy_freebsd_ver_elf(bit64, elf, ".rodata", args[2], data);
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");
} }
out: out:
grub_check_free(str);
grub_check_free(hdr);
grub_check_free(data); grub_check_free(data);
check_free(elf, grub_elf_close); check_free(elf, grub_elf_close);
VENTOY_CMD_RETURN(GRUB_ERR_NONE); 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; grub_file_t file;
char extcfg[512]; char extcfg[512];
const char *confile = NULL; const char *confile = NULL;
const char * loader_conf[] = const char * loader_conf[] =
{ {
"/boot/grub/grub.cfg", "/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); debug("Replace conf invalid argc %d\n", argc);
return 1; return 1;
} }
for (i = 0; i < sizeof(loader_conf) / sizeof(loader_conf[0]); i++) for (i = 0; i < sizeof(loader_conf) / sizeof(loader_conf[0]); i++)
{ {
if (ventoy_get_file_override(loader_conf[i], &offset) == 0) 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) if (confile == NULL)
{ {
debug("Can't find grub.cfg file from %u locations\n", i); debug("Can't find grub.cfg file from %u locations\n", i);
return 1; 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); data = grub_malloc(VTOY_MAX_SCRIPT_BUF);
if (!data) if (!data)
{ {
grub_file_close(file); grub_file_close(file);
return 1; return 1;
} }
grub_file_read(file, data, file->size); grub_file_read(file, data, file->size);
grub_file_close(file); grub_file_close(file);
g_conf_new_data = data; g_conf_new_data = data;
g_conf_new_len = (int)file->size; 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); vtoy_ssprintf(extcfg, len, ";set kFreeBSD.hint.ventoy.0.remount=%d", 1);
} }
grub_memmove(pos + len, pos, (int)(file->size - (pos - data))); grub_memmove(pos + len, pos, (int)(file->size - (pos - data)));
grub_memcpy(pos, extcfg, len); grub_memcpy(pos, extcfg, len);
g_conf_new_len += 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"); debug("no kfreebsd found\n");
} }
VENTOY_CMD_RETURN(GRUB_ERR_NONE); 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_uint64_t offset;
grub_file_t file; grub_file_t file;
const char *confile = NULL; const char *confile = NULL;
const char * loader_conf[] = const char * loader_conf[] =
{ {
"/boot/loader.conf", "/boot/loader.conf",
"/boot/defaults/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); debug("Replace conf invalid argc %d\n", argc);
return 1; return 1;
} }
for (i = 0; i < sizeof(loader_conf) / sizeof(loader_conf[0]); i++) for (i = 0; i < sizeof(loader_conf) / sizeof(loader_conf[0]); i++)
{ {
if (ventoy_get_file_override(loader_conf[i], &offset) == 0) 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) if (confile == NULL)
{ {
debug("Can't find loader.conf file from %u locations\n", i); debug("Can't find loader.conf file from %u locations\n", i);
return 1; 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); data = grub_malloc(VTOY_MAX_SCRIPT_BUF);
if (!data) if (!data)
{ {
grub_file_close(file); grub_file_close(file);
return 1; return 1;
} }
grub_file_read(file, data, file->size); grub_file_read(file, data, file->size);
grub_file_close(file); grub_file_close(file);
g_conf_new_data = data; g_conf_new_data = data;
g_conf_new_len = (int)file->size; 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]); g_conf_new_len += ventoy_dragonfly_append_conf(data + file->size, args[1]);
} }
VENTOY_CMD_RETURN(GRUB_ERR_NONE); VENTOY_CMD_RETURN(GRUB_ERR_NONE);
} }
static int ventoy_unix_search_magic(char *data, int len) static int ventoy_unix_search_magic(char *data, int len)
{ {
int i; int i;
grub_uint32_t *magic = NULL; grub_uint32_t *magic = NULL;
for (i = 0; i < len; i += 4096) for (i = 0; i < len; i += 4096)
{ {
magic = (grub_uint32_t *)(data + i); 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) 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)); 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; g_mod_override_offset = offset;
} }
else else
{ {
debug("Can't find replace ko file from %s\n", args[0]); debug("Can't find replace ko file from %s\n", args[0]);
return 1; return 1;
} }
@@ -928,18 +947,18 @@ grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char
if (!data) if (!data)
{ {
debug("Failed to alloc memory for new ko %d\n", (int)file->size); debug("Failed to alloc memory for new ko %d\n", (int)file->size);
grub_file_close(file); grub_file_close(file);
return 1; return 1;
} }
grub_file_read(file, data, file->size); grub_file_read(file, data, file->size);
grub_file_close(file); grub_file_close(file);
g_mod_new_data = data; g_mod_new_data = data;
g_mod_new_len = (int)file->size; g_mod_new_len = (int)file->size;
ventoy_unix_search_magic(g_mod_new_data, g_mod_new_len); ventoy_unix_search_magic(g_mod_new_data, g_mod_new_len);
VENTOY_CMD_RETURN(GRUB_ERR_NONE); 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); g_mod_override_offset = grub_iso9660_get_last_read_pos(file);
} }
else else
{ {
debug("Can't find replace ko file from %s\n", args[0]); debug("Can't find replace ko file from %s\n", args[0]);
return 1; 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; magic[0] = 0;
grub_file_seek(file, i); grub_file_seek(file, i);
grub_file_read(file, magic, sizeof(magic)); 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) 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)); 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); (sizeof(struct g_ventoy_seg) * g_img_chunk_list.cur_chunk);
g_ko_fillmap_len = (int)len; 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) if (grub_memcmp(flag, byte + i, 32) == 0)
{ {
debug("Find position flag at %d(0x%x)\n", i, i); 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 *pLastChain = NULL;
const char *compatible; const char *compatible;
ventoy_chain_head *chain; ventoy_chain_head *chain;
(void)ctxt; (void)ctxt;
(void)argc; (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]); 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); img_chunk_size = g_img_chunk_list.cur_chunk * sizeof(ventoy_img_chunk);
if (ventoy_compatible) if (ventoy_compatible)
{ {
size = sizeof(ventoy_chain_head) + img_chunk_size; 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_count = ventoy_unix_get_override_chunk_count();
override_size = override_count * sizeof(ventoy_override_chunk); override_size = override_count * sizeof(ventoy_override_chunk);
virt_chunk_size = ventoy_unix_get_virt_chunk_size(); virt_chunk_size = ventoy_unix_get_virt_chunk_size();
size = sizeof(ventoy_chain_head) + img_chunk_size + override_size + virt_chunk_size; size = sizeof(ventoy_chain_head) + img_chunk_size + override_size + virt_chunk_size;
} }
pLastChain = grub_env_get("vtoy_chain_mem_addr"); pLastChain = grub_env_get("vtoy_chain_mem_addr");
if (pLastChain) 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); ventoy_unix_fill_virt_data(isosize, chain);
grub_file_close(file); grub_file_close(file);
VENTOY_CMD_RETURN(GRUB_ERR_NONE); VENTOY_CMD_RETURN(GRUB_ERR_NONE);
} }
@@ -148,9 +148,10 @@ static int ventoy_vhd_patch_path(char *vhdpath, ventoy_patch_vhd *patch1, ventoy
return 0; return 0;
} }
static int ventoy_vhd_read_parttbl(const char *filename, ventoy_gpt_info *gpt, int *index) static int ventoy_vhd_read_parttbl(const char *filename, ventoy_gpt_info *gpt, int *index, grub_uint64_t *poffset)
{ {
int i; int i;
int find = 0;
int ret = 1; int ret = 1;
grub_uint64_t start; grub_uint64_t start;
grub_file_t file = NULL; grub_file_t file = NULL;
@@ -183,6 +184,7 @@ static int ventoy_vhd_read_parttbl(const char *filename, ventoy_gpt_info *gpt, i
if (start == gpt->PartTbl[i].StartLBA) if (start == gpt->PartTbl[i].StartLBA)
{ {
*index = i; *index = i;
find = 1;
break; break;
} }
} }
@@ -196,11 +198,22 @@ static int ventoy_vhd_read_parttbl(const char *filename, ventoy_gpt_info *gpt, i
if ((grub_uint32_t)start == gpt->MBR.PartTbl[i].StartSectorId) if ((grub_uint32_t)start == gpt->MBR.PartTbl[i].StartSectorId)
{ {
*index = i; *index = i;
find = 1;
break; break;
} }
} }
} }
if (find == 0) // MBR Logical partition
{
if (file->device->disk->partition->number > 0)
{
*index = file->device->disk->partition->number;
debug("Fall back part number: %d\n", *index);
}
}
*poffset = start;
ret = 0; ret = 0;
end: end:
@@ -226,7 +239,7 @@ static int ventoy_vhd_patch_disk(const char *vhdpath, ventoy_patch_vhd *patch1,
else else
{ {
gpt = grub_zalloc(sizeof(ventoy_gpt_info)); gpt = grub_zalloc(sizeof(ventoy_gpt_info));
ventoy_vhd_read_parttbl(vhdpath, gpt, &partIndex); ventoy_vhd_read_parttbl(vhdpath, gpt, &partIndex, &offset);
debug("This is HDD partIndex %d %s\n", partIndex, vhdpath); debug("This is HDD partIndex %d %s\n", partIndex, vhdpath);
} }
@@ -249,9 +262,11 @@ static int ventoy_vhd_patch_disk(const char *vhdpath, ventoy_patch_vhd *patch1,
} }
else else
{ {
offset = gpt->MBR.PartTbl[partIndex].StartSectorId; if (offset == 0)
{
offset = gpt->MBR.PartTbl[partIndex].StartSectorId;
}
offset *= 512; offset *= 512;
debug("MBR disk signature: %02x%02x%02x%02x Part(%d) offset:%llu\n", debug("MBR disk signature: %02x%02x%02x%02x Part(%d) offset:%llu\n",
gpt->MBR.BootCode[0x1b8 + 0], gpt->MBR.BootCode[0x1b8 + 1], gpt->MBR.BootCode[0x1b8 + 0], gpt->MBR.BootCode[0x1b8 + 1],
gpt->MBR.BootCode[0x1b8 + 2], gpt->MBR.BootCode[0x1b8 + 3], gpt->MBR.BootCode[0x1b8 + 2], gpt->MBR.BootCode[0x1b8 + 3],
@@ -489,7 +504,7 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
vhd_footer_t vhdfoot; vhd_footer_t vhdfoot;
VDIPREHEADER vdihdr; VDIPREHEADER vdihdr;
char type[16] = {0}; char type[16] = {0};
ventoy_gpt_info *gpt; ventoy_gpt_info *gpt = NULL;
(void)ctxt; (void)ctxt;
@@ -521,12 +536,25 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
{ {
grub_file_seek(file, 0); grub_file_seek(file, 0);
grub_file_read(file, &vdihdr, sizeof(vdihdr)); grub_file_read(file, &vdihdr, sizeof(vdihdr));
if (vdihdr.u32Signature == VDI_IMAGE_SIGNATURE && if (vdihdr.u32Signature == VDI_IMAGE_SIGNATURE)
grub_strncmp(vdihdr.szFileInfo, VDI_IMAGE_FILE_INFO, grub_strlen(VDI_IMAGE_FILE_INFO)) == 0)
{ {
offset = 2 * 1048576;
g_img_trim_head_secnum = offset / 512;
grub_snprintf(type, sizeof(type), "vdi"); grub_snprintf(type, sizeof(type), "vdi");
if (grub_strncmp(vdihdr.szFileInfo, VDI_IMAGE_FILE_INFO, grub_strlen(VDI_IMAGE_FILE_INFO)) == 0)
{
offset = 2 * 1048576;
g_img_trim_head_secnum = offset / 512;
debug("VDI V1\n");
}
else if (grub_strncmp(vdihdr.szFileInfo, VDI_IMAGE_FILE_INFO2, grub_strlen(VDI_IMAGE_FILE_INFO2)) == 0)
{
offset = 2 * 1048576;
g_img_trim_head_secnum = offset / 512;
debug("VDI V2\n");
}
else
{
debug("invalid file info <%s>\n", vdihdr.szFileInfo);
}
} }
else else
{ {
@@ -553,7 +581,7 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
if (gpt->MBR.Byte55 != 0x55 || gpt->MBR.ByteAA != 0xAA) if (gpt->MBR.Byte55 != 0x55 || gpt->MBR.ByteAA != 0xAA)
{ {
grub_env_set(args[1], "unknown"); grub_env_set(args[1], "unknown");
debug("invalid mbr signature: 0x%x 0x%x\n", gpt->MBR.Byte55, gpt->MBR.ByteAA); debug("invalid mbr signature: 0x%x 0x%x offset=%d\n", gpt->MBR.Byte55, gpt->MBR.ByteAA, offset);
goto end; goto end;
} }
@@ -1090,6 +1090,12 @@ static int ventoy_fill_windows_rtdata(void *buf, char *isopath, int dataflag)
{ {
data->windows11_bypass_check = 1; data->windows11_bypass_check = 1;
} }
env = grub_env_get("VTOY_WIN11_BYPASS_NRO");
if (env && env[0] == '1' && env[1] == 0)
{
data->windows11_bypass_nro = 1;
}
pos = grub_strstr(isopath, "/"); pos = grub_strstr(isopath, "/");
if (!pos) if (!pos)
@@ -1442,6 +1448,7 @@ grub_err_t ventoy_cmd_sel_winpe_wim(grub_extcmd_context_t ctxt, int argc, char *
g_ventoy_menu_esc = 1; g_ventoy_menu_esc = 1;
g_ventoy_suppress_esc = 1; g_ventoy_suppress_esc = 1;
g_ventoy_suppress_esc_default = 0; g_ventoy_suppress_esc_default = 0;
g_ventoy_secondary_menu_on = 1;
grub_snprintf(cfgfile, sizeof(cfgfile), "configfile mem:0x%llx:size:%d", (ulonglong)(ulong)cmd, pos); grub_snprintf(cfgfile, sizeof(cfgfile), "configfile mem:0x%llx:size:%d", (ulonglong)(ulong)cmd, pos);
grub_script_execute_sourcecode(cfgfile); grub_script_execute_sourcecode(cfgfile);
@@ -1449,6 +1456,7 @@ grub_err_t ventoy_cmd_sel_winpe_wim(grub_extcmd_context_t ctxt, int argc, char *
g_ventoy_menu_esc = 0; g_ventoy_menu_esc = 0;
g_ventoy_suppress_esc = 0; g_ventoy_suppress_esc = 0;
g_ventoy_suppress_esc_default = 1; g_ventoy_suppress_esc_default = 1;
g_ventoy_secondary_menu_on = 0;
for (node = g_wim_patch_head; node; node = node->next) for (node = g_wim_patch_head; node; node = node->next)
{ {
@@ -197,6 +197,8 @@ grub_disk_t EXPORT_FUNC(grub_disk_open) (const char *name);
void EXPORT_FUNC(grub_disk_close) (grub_disk_t disk); void EXPORT_FUNC(grub_disk_close) (grub_disk_t disk);
grub_err_t EXPORT_FUNC(grub_disk_blocklist_read)(void *chunklist, grub_uint64_t sector, grub_err_t EXPORT_FUNC(grub_disk_blocklist_read)(void *chunklist, grub_uint64_t sector,
grub_uint64_t size, grub_uint32_t log_sector_size); grub_uint64_t size, grub_uint32_t log_sector_size);
grub_err_t EXPORT_FUNC(grub_disk_blocklist_read2)(grub_disk_t disk, grub_uint64_t sector,
grub_uint64_t size, char *buf);
grub_err_t EXPORT_FUNC(grub_disk_read) (grub_disk_t disk, grub_err_t EXPORT_FUNC(grub_disk_read) (grub_disk_t disk,
grub_disk_addr_t sector, grub_disk_addr_t sector,
@@ -0,0 +1,78 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,2005,2006,2007,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/>.
*/
#ifndef GRUB_ENV_HEADER
#define GRUB_ENV_HEADER 1
#include <grub/symbol.h>
#include <grub/err.h>
#include <grub/types.h>
#include <grub/menu.h>
#define VTOY_SB_POLICY_BYPASS 0
#define VTOY_SB_POLICY_CHECK 1
extern grub_uint8_t EXPORT_VAR(g_sys_sb);
extern grub_uint8_t EXPORT_VAR(g_sb_policy);
struct grub_env_var;
typedef const char *(*grub_env_read_hook_t) (struct grub_env_var *var,
const char *val);
typedef char *(*grub_env_write_hook_t) (struct grub_env_var *var,
const char *val);
struct grub_env_var
{
char *name;
char *value;
grub_env_read_hook_t read_hook;
grub_env_write_hook_t write_hook;
struct grub_env_var *next;
struct grub_env_var **prevp;
struct grub_env_var *sorted_next;
int global;
};
grub_err_t EXPORT_FUNC(grub_env_set) (const char *name, const char *val);
const char *EXPORT_FUNC(grub_env_get) (const char *name);
void EXPORT_FUNC(grub_env_unset) (const char *name);
struct grub_env_var *EXPORT_FUNC(grub_env_update_get_sorted) (void);
#define FOR_SORTED_ENV(var) for (var = grub_env_update_get_sorted (); var; var = var->sorted_next)
grub_err_t EXPORT_FUNC(grub_register_variable_hook) (const char *name,
grub_env_read_hook_t read_hook,
grub_env_write_hook_t write_hook);
grub_err_t EXPORT_FUNC(grub_register_vtoy_menu_lang_hook) (grub_env_read_hook_t read_hook);
grub_err_t grub_env_context_open (void);
grub_err_t grub_env_context_close (void);
grub_err_t EXPORT_FUNC(grub_env_export) (const char *name);
void grub_env_unset_menu (void);
grub_menu_t grub_env_get_menu (void);
void grub_env_set_menu (grub_menu_t nmenu);
grub_err_t
grub_env_extractor_open (int source);
grub_err_t
grub_env_extractor_close (int source);
#endif /* ! GRUB_ENV_HEADER */
+32 -11
View File
@@ -7,12 +7,12 @@
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of the * published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>. * along with this program; if not, see <http://www.gnu.org/licenses/>.
* *
@@ -36,6 +36,7 @@ typedef enum ventoy_fs_type
ventoy_fs_xfs, /* 3: XFS */ ventoy_fs_xfs, /* 3: XFS */
ventoy_fs_udf, /* 4: UDF */ ventoy_fs_udf, /* 4: UDF */
ventoy_fs_fat, /* 5: FAT */ ventoy_fs_fat, /* 5: FAT */
ventoy_fs_btrfs, /* 6: BTRFS */
ventoy_fs_max ventoy_fs_max
}ventoy_fs_type; }ventoy_fs_type;
@@ -81,7 +82,7 @@ typedef struct ventoy_image_location
/* /*
* disk region data (region_count) * disk region data (region_count)
* 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. * there will be more than one region data here.
* *
*/ */
@@ -103,7 +104,7 @@ typedef struct ventoy_os_param
char vtoy_img_path[384]; // It seems to be enough, utf-8 format char vtoy_img_path[384]; // It seems to be enough, utf-8 format
grub_uint64_t vtoy_img_size; // image file size in bytes grub_uint64_t vtoy_img_size; // image file size in bytes
/* /*
* Ventoy will write a copy of ventoy_image_location data into runtime memory * Ventoy will write a copy of ventoy_image_location data into runtime memory
* this is the physically address and length of that memory. * this is the physically address and length of that memory.
* Address 0 means no such data exist. * Address 0 means no such data exist.
@@ -113,7 +114,7 @@ typedef struct ventoy_os_param
grub_uint64_t vtoy_img_location_addr; grub_uint64_t vtoy_img_location_addr;
grub_uint32_t vtoy_img_location_len; grub_uint32_t vtoy_img_location_len;
/* /*
* These 32 bytes are reserved by ventoy. * These 32 bytes are reserved by ventoy.
* *
* vtoy_reserved[0]: vtoy_break_level * vtoy_reserved[0]: vtoy_break_level
@@ -124,6 +125,7 @@ typedef struct ventoy_os_param
* vtoy_reserved[5]: vtoy_linux_remount * vtoy_reserved[5]: vtoy_linux_remount
* vtoy_reserved[6]: vtoy_vlnk * vtoy_reserved[6]: vtoy_vlnk
* vtoy_reserved[7~10]: vtoy_disk_sig[4] used for vlnk * vtoy_reserved[7~10]: vtoy_disk_sig[4] used for vlnk
* vtoy_reserved[11]: vtoy_win_uefi_max_res
* *
*/ */
grub_uint8_t vtoy_reserved[32]; // Internal use by ventoy grub_uint8_t vtoy_reserved[32]; // Internal use by ventoy
@@ -142,7 +144,9 @@ typedef struct ventoy_windows_data
grub_uint32_t auto_install_len; grub_uint32_t auto_install_len;
grub_uint8_t reserved[255 - 4]; grub_uint8_t windows11_bypass_nro;
grub_uint8_t reserved[255 - 5];
/* auto_intall file buf */ /* auto_intall file buf */
/* ...... + auto_install_len */ /* ...... + auto_install_len */
@@ -152,8 +156,8 @@ typedef struct ventoy_windows_data
typedef struct ventoy_secure_data typedef struct ventoy_secure_data
{ {
grub_uint8_t magic1[16]; /* VENTOY_GUID */ grub_uint8_t magic1[16]; /* VENTOY_GUID */
grub_uint8_t diskuuid[16]; grub_uint8_t diskuuid[16];
grub_uint8_t Checksum[16]; grub_uint8_t Checksum[16];
grub_uint8_t adminSHA256[32]; grub_uint8_t adminSHA256[32];
grub_uint8_t reserved[4000]; grub_uint8_t reserved[4000];
grub_uint8_t magic2[16]; /* VENTOY_GUID */ grub_uint8_t magic2[16]; /* VENTOY_GUID */
@@ -197,7 +201,7 @@ typedef struct ventoy_chain_head
grub_uint64_t virt_img_size_in_bytes; grub_uint64_t virt_img_size_in_bytes;
grub_uint32_t boot_catalog; grub_uint32_t boot_catalog;
grub_uint8_t boot_catalog_sector[2048]; grub_uint8_t boot_catalog_sector[2048];
grub_uint32_t img_chunk_offset; grub_uint32_t img_chunk_offset;
grub_uint32_t img_chunk_num; grub_uint32_t img_chunk_num;
@@ -250,12 +254,15 @@ typedef struct ventoy_virt_chunk
#define DEFAULT_CHUNK_NUM 1024 #define DEFAULT_CHUNK_NUM 1024
typedef struct ventoy_img_chunk_list typedef struct ventoy_img_chunk_list
{ {
char *buf;
grub_uint32_t last_off;
grub_uint32_t err_code;
grub_uint32_t max_chunk; grub_uint32_t max_chunk;
grub_uint32_t cur_chunk; grub_uint32_t cur_chunk;
ventoy_img_chunk *chunk; ventoy_img_chunk *chunk;
}ventoy_img_chunk_list; }ventoy_img_chunk_list;
#pragma pack() #pragma pack()
#define ventoy_filt_register grub_file_filter_register #define ventoy_filt_register grub_file_filter_register
@@ -289,7 +296,21 @@ typedef struct ventoy_grub_param
#pragma pack() #pragma pack()
#define VTOY_CHUNK_BUF_SIZE (4 * 1024 * 1024)
typedef enum vtoy_chunk_err
{
VTOY_CHUNK_ERR_NONE = 0,
VTOY_CHUNK_ERR_MULTI_DEV,
VTOY_CHUNK_ERR_RAID,
VTOY_CHUNK_ERR_COMPRESS,
VTOY_CHUNK_ERR_NOT_FLAT,
VTOY_CHUNK_ERR_OVER_FLOW,
VTOY_CHUNK_ERR_MAX
}vtoy_chunk_err;
int grub_ext_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_img_chunk_list *chunk_list); int grub_ext_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_img_chunk_list *chunk_list);
int grub_btrfs_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_img_chunk_list *chunk_list);
int grub_fat_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_img_chunk_list *chunk_list); int grub_fat_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_img_chunk_list *chunk_list);
void grub_iso9660_set_nojoliet(int nojoliet); void grub_iso9660_set_nojoliet(int nojoliet);
int grub_iso9660_is_joliet(void); int grub_iso9660_is_joliet(void);
@@ -299,7 +320,7 @@ grub_uint64_t grub_udf_get_file_offset(grub_file_t file);
grub_uint64_t grub_udf_get_last_pd_size_offset(void); grub_uint64_t grub_udf_get_last_pd_size_offset(void);
grub_uint64_t grub_udf_get_last_file_attr_offset grub_uint64_t grub_udf_get_last_file_attr_offset
( (
grub_file_t file, grub_file_t file,
grub_uint32_t *startBlock, grub_uint32_t *startBlock,
grub_uint64_t *fe_entry_size_offset grub_uint64_t *fe_entry_size_offset
); );
+1 -1
View File
@@ -12,7 +12,7 @@ make install
PATH=$VT_DIR/GRUB2/INSTALL/bin/:$VT_DIR/GRUB2/INSTALL/sbin/:$PATH PATH=$VT_DIR/GRUB2/INSTALL/bin/:$VT_DIR/GRUB2/INSTALL/sbin/:$PATH
net_modules_legacy="net tftp http" net_modules_legacy="net tftp http"
all_modules_legacy="file setkey date drivemap blocklist regexp newc vga_text ntldr search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio lspci pci ext2 xfs ventoy chain read halt iso9660 linux16 test true sleep reboot echo videotest videoinfo videotest_checksum video_colors video_cirrus video_bochs vga vbe video_fb font video gettext extcmd terminal linux minicmd help configfile tr trig boot biosdisk disk ls tar squash4 password_pbkdf2 all_video png jpeg part_gpt part_msdos fat exfat ntfs loopback gzio normal udf gfxmenu gfxterm gfxterm_background gfxterm_menu smbios zfs" all_modules_legacy="file date drivemap blocklist newc vga_text ntldr search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio lspci pci ext2 xfs ventoy chain read halt iso9660 linux16 test true sleep reboot echo videotest videoinfo videotest_checksum video_colors video_cirrus video_bochs vga vbe font video gettext extcmd terminal linux minicmd help configfile tr trig boot biosdisk disk ls tar squash4 password_pbkdf2 all_video png jpeg part_gpt part_msdos fat exfat ntfs loopback gzio normal video_fb udf gfxmenu gfxterm gfxterm_background gfxterm_menu smbios"
net_modules_uefi="efinet net tftp http" net_modules_uefi="efinet net tftp http"
all_modules_uefi="file setkey blocklist ventoy test true regexp newc search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux relocator jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop efi_uga video_bochs video_cirrus video video_fb gfxterm_background gfxterm_menu mouse fwload smbios zfs" all_modules_uefi="file setkey blocklist ventoy test true regexp newc search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux relocator jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop efi_uga video_bochs video_cirrus video video_fb gfxterm_background gfxterm_menu mouse fwload smbios zfs"
Binary file not shown.

After

Width:  |  Height:  |  Size: 437 KiB

+3
View File
@@ -48,3 +48,6 @@ else
fi fi
PATH=$VTPATH_OLD PATH=$VTPATH_OLD
set_ventoy_hook_finish
+1
View File
@@ -67,4 +67,5 @@ fi
if [ -f $VTOY_PATH/ventoy_persistent_map ]; then if [ -f $VTOY_PATH/ventoy_persistent_map ]; then
$SED "1 aexport cow_label=vtoycow" -i /init $SED "1 aexport cow_label=vtoycow" -i /init
$SED "/parse.*cmdline/aecho cow_label=vtoycow>>/tmp/cmdline" -i /init
fi fi
@@ -49,3 +49,6 @@ else
fi fi
PATH=$VTPATH_OLD PATH=$VTPATH_OLD
set_ventoy_hook_finish
@@ -20,7 +20,7 @@
. $VTOY_PATH/hook/ventoy-os-lib.sh . $VTOY_PATH/hook/ventoy-os-lib.sh
$BUSYBOX_PATH/mkdir /dev $BUSYBOX_PATH/mkdir /dev
$BUSYBOX_PATH/mknod -m 660 /dev/console b 5 1 $BUSYBOX_PATH/mknod -m 660 /dev/console c 5 1
$SED "/for device in/i $BUSYBOX_PATH/sh $VTOY_PATH/hook/aryalinux/disk_hook.sh" -i /init $SED "/for device in/i $BUSYBOX_PATH/sh $VTOY_PATH/hook/aryalinux/disk_hook.sh" -i /init
#$SED "/for device in/i exec $BUSYBOX_PATH/sh" -i /init #$SED "/for device in/i exec $BUSYBOX_PATH/sh" -i /init
@@ -52,3 +52,6 @@ ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
# fi # fi
PATH=$VTPATH_OLD PATH=$VTPATH_OLD
set_ventoy_hook_finish
@@ -36,3 +36,6 @@ ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
PATH=$VTPATH_OLD PATH=$VTPATH_OLD
set_ventoy_hook_finish
+35
View File
@@ -0,0 +1,35 @@
#!/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
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 3
else
break
fi
done
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
set_ventoy_hook_finish
@@ -0,0 +1,22 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. $VTOY_PATH/hook/ventoy-os-lib.sh
$SED "/maybe_break *premount/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/chimera/disk_hook.sh" -i /init
+3
View File
@@ -47,3 +47,6 @@ else
fi fi
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
set_ventoy_hook_finish
@@ -39,3 +39,6 @@ ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
$BUSYBOX_PATH/rm -f /dev/dm-* $BUSYBOX_PATH/rm -f /dev/dm-*
set_ventoy_hook_finish
+5 -2
View File
@@ -40,13 +40,13 @@ ventoy_os_install_dmsetup_by_unsquashfs() {
dmModPath="/usr/lib/modules/$vtKerVer/kernel/drivers/md/dm-mod.$vtKoPo" dmModPath="/usr/lib/modules/$vtKerVer/kernel/drivers/md/dm-mod.$vtKoPo"
echo $dmModPath > $VTOY_PATH/fsextract echo $dmModPath > $VTOY_PATH/fsextract
vtoy_unsquashfs -d $VTOY_PATH/sqfs -n -q -e $VTOY_PATH/fsextract $VTOY_PATH/fsdisk vtoy_unsquashfs -d $VTOY_PATH/sqfs -n -q -e $VTOY_PATH/fsextract $VTOY_PATH/fsdisk 2>>$VTLOG
if ! [ -e $VTOY_PATH/sqfs${dmModPath} ]; then if ! [ -e $VTOY_PATH/sqfs${dmModPath} ]; then
rm -rf $VTOY_PATH/sqfs rm -rf $VTOY_PATH/sqfs
dmModPath="/lib/modules/$vtKerVer/kernel/drivers/md/dm-mod.$vtKoPo" dmModPath="/lib/modules/$vtKerVer/kernel/drivers/md/dm-mod.$vtKoPo"
echo $dmModPath > $VTOY_PATH/fsextract echo $dmModPath > $VTOY_PATH/fsextract
vtoy_unsquashfs -d $VTOY_PATH/sqfs -n -q -e $VTOY_PATH/fsextract $VTOY_PATH/fsdisk vtoy_unsquashfs -d $VTOY_PATH/sqfs -n -q -e $VTOY_PATH/fsextract $VTOY_PATH/fsdisk 2>>$VTLOG
fi fi
if [ -e $VTOY_PATH/sqfs${dmModPath} ]; then if [ -e $VTOY_PATH/sqfs${dmModPath} ]; then
@@ -119,3 +119,6 @@ fi
PATH=$VTPATH_OLD PATH=$VTPATH_OLD
set_ventoy_hook_finish
@@ -0,0 +1,43 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. /ventoy/hook/ventoy-hook-lib.sh
if is_ventoy_hook_finished; then
exit 0
fi
vtlog "####### $0 $* ########"
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
wait_for_usb_disk_ready
vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "ventoy disk not found"
PATH=$VTPATH_OLD
exit 0
fi
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
PATH=$VTPATH_OLD
set_ventoy_hook_finish
@@ -0,0 +1,21 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
$SED "/Mount.*cdrom/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/devuan-disk.sh" -i /init
@@ -41,3 +41,6 @@ fi
PATH=$VTPATH_OLD PATH=$VTPATH_OLD
set_ventoy_hook_finish
@@ -80,3 +80,6 @@ ventoy_os_install_dmsetup $vtdiskname
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace" ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
PATH=$VTPATH_OLD PATH=$VTPATH_OLD
set_ventoy_hook_finish
@@ -75,3 +75,6 @@ ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
PATH=$VTPATH_OLD PATH=$VTPATH_OLD
set_ventoy_hook_finish
+4 -2
View File
@@ -33,11 +33,13 @@ echo "_vtRet1=$_vtRet1 _vtRet2=$_vtRet2 ..." >> $VTLOG
if [ $_vtRet1 -ne 0 -a $_vtRet2 -eq 0 ]; then if [ $_vtRet1 -ne 0 -a $_vtRet2 -eq 0 ]; then
vtFindFlag=0 vtFindFlag=0
$GREP '`value from`' /usr/* -r | $AWK -F: '{print $1}' | while read vtline; do $GREP '`value from`' /usr/* -r | $AWK -F: '{print $1}' > $VTOY_PATH/.porteus
while read vtline; do
echo "hooking $vtline ..." >> $VTLOG echo "hooking $vtline ..." >> $VTLOG
$SED "s#\`value from\`#$vtPath#g" -i $vtline $SED "s#\`value from\`#$vtPath#g" -i $vtline
vtFindFlag=1 vtFindFlag=1
done done < $VTOY_PATH/.porteus
rm -f $VTOY_PATH/.porteus
if [ $vtFindFlag -eq 0 ]; then if [ $vtFindFlag -eq 0 ]; then
if $GREP -q '`value from`' /linuxrc; then if $GREP -q '`value from`' /linuxrc; then
+9 -1
View File
@@ -37,12 +37,20 @@ ventoy_os_install_dmsetup_by_fuse() {
mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso $VTOY_PATH/mnt/iso mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso $VTOY_PATH/mnt/iso
sfsfile=$(ls $VTOY_PATH/mnt/iso/*.sfs) if ls $VTOY_PATH/mnt/iso/zdrv_*.sfs 2>/dev/null; then
sfsfile=$(ls $VTOY_PATH/mnt/iso/zdrv_*.sfs)
else
sfsfile=$(ls $VTOY_PATH/mnt/iso/*.sfs)
fi
mount -t squashfs $sfsfile $VTOY_PATH/mnt/squashfs mount -t squashfs $sfsfile $VTOY_PATH/mnt/squashfs
kVer=$(uname -r) kVer=$(uname -r)
KoName=$(ls $VTOY_PATH/mnt/squashfs/lib/modules/$kVer/kernel/drivers/md/dm-mod.ko*) KoName=$(ls $VTOY_PATH/mnt/squashfs/lib/modules/$kVer/kernel/drivers/md/dm-mod.ko*)
if [ -z "$KoName" ]; then
KoName=$(ls $VTOY_PATH/mnt/squashfs/usr/lib/modules/$kVer/kernel/drivers/md/dm-mod.ko*)
fi
vtlog "insmod $KoName" vtlog "insmod $KoName"
insmod $KoName insmod $KoName
+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 "/\/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 $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
+3
View File
@@ -81,3 +81,6 @@ ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
PATH=$VTPATH_OLD PATH=$VTPATH_OLD
set_ventoy_hook_finish
@@ -0,0 +1,25 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. /ventoy/hook/ventoy-hook-lib.sh
vtlog "mount ventoy.iso"
mkdir -p /root/cdrom >>$VTLOG 2>&1
mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso /root/cdrom >>$VTLOG 2>&1
@@ -0,0 +1,52 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. /ventoy/hook/ventoy-hook-lib.sh
vtlog "####### $0 $* ########"
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
ventoy_run_fuse() {
vtlog "ventoy_run_fuse $*"
mkdir -p $VTOY_PATH/mnt/fuse $VTOY_PATH/mnt/iso
vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_dm_table
vtoy_fuse_iso -f $VTOY_PATH/ventoy_dm_table -m $VTOY_PATH/mnt/fuse
mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso $VTOY_PATH/mnt/iso
}
wait_for_usb_disk_ready
vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "ventoy disk not found"
PATH=$VTPATH_OLD
exit 0
fi
ventoy_run_fuse $vtdiskname
if [ -f /ventoy/autoinstall ]; then
sh /ventoy/hook/default/auto_install_varexp.sh /ventoy/autoinstall
fi
@@ -0,0 +1,27 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
if [ -e /init ] && $GREP -q '^mountroot$' /init; then
echo "Here before mountroot ..." >> $VTLOG
$SED "/^mountroot$/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/truenas-disk.sh" -i /init
$SED "/^mountroot$/i\\export LIVEMEDIA=/dev/mapper/ventoy" -i /init
$SED "/^mountroot$/i\\export LIVE_MEDIA=/dev/mapper/ventoy" -i /init
$SED "/^mountroot$/i\\export FROMISO=$VTOY_PATH/mnt/fuse/ventoy.iso" -i /init
$SED "/exec *run-init/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/truenas-bottom.sh" -i /init
fi
+23 -2
View File
@@ -28,6 +28,7 @@ vtlog "####### $0 $* ########"
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
ventoy_os_install_dmsetup_by_fuse() { ventoy_os_install_dmsetup_by_fuse() {
local drvdir=""
vtlog "ventoy_os_install_dmsetup_by_fuse $*" vtlog "ventoy_os_install_dmsetup_by_fuse $*"
mkdir -p $VTOY_PATH/mnt/fuse $VTOY_PATH/mnt/iso $VTOY_PATH/mnt/squashfs mkdir -p $VTOY_PATH/mnt/fuse $VTOY_PATH/mnt/iso $VTOY_PATH/mnt/squashfs
@@ -37,11 +38,13 @@ ventoy_os_install_dmsetup_by_fuse() {
mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso $VTOY_PATH/mnt/iso mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso $VTOY_PATH/mnt/iso
for sfsfile in $(ls $VTOY_PATH/mnt/iso/*drv_veket*.sfs); do for sfsfile in $(ls $VTOY_PATH/mnt/iso/*drv_veket*.sfs); do
mount -t squashfs $sfsfile $VTOY_PATH/mnt/squashfs mount -t squashfs $sfsfile $VTOY_PATH/mnt/squashfs
if [ -d $VTOY_PATH/mnt/squashfs/lib/modules ]; then if [ -d $VTOY_PATH/mnt/squashfs/lib/modules ]; then
KoName=$(ls $VTOY_PATH/mnt/squashfs/lib/modules/$2/kernel/drivers/md/dm-mod.ko*) KoName=$(ls $VTOY_PATH/mnt/squashfs/lib/modules/$2/kernel/drivers/md/dm-mod.ko*)
if [ -n "$KoName" -a -f $KoName ]; then if [ -n "$KoName" -a -f $KoName ]; then
drvdir=$VTOY_PATH/mnt/squashfs/lib/modules/$2
break break
fi fi
fi fi
@@ -49,11 +52,29 @@ ventoy_os_install_dmsetup_by_fuse() {
umount $VTOY_PATH/mnt/squashfs umount $VTOY_PATH/mnt/squashfs
done done
KoName=$(ls $VTOY_PATH/mnt/squashfs/lib/modules/$2/kernel/drivers/dax/dax.ko*)
if [ -z "$drvdir" ]; then
vtlog "retry for usr/lib dir"
for sfsfile in $(ls $VTOY_PATH/mnt/iso/*drv_veket*.sfs); do
mount -t squashfs $sfsfile $VTOY_PATH/mnt/squashfs
if [ -d $VTOY_PATH/mnt/squashfs/usr/lib/modules ]; then
KoName=$(ls $VTOY_PATH/mnt/squashfs/usr/lib/modules/$2/kernel/drivers/md/dm-mod.ko*)
if [ -n "$KoName" -a -f $KoName ]; then
drvdir=$VTOY_PATH/mnt/squashfs/usr/lib/modules/$2
break
fi
fi
umount $VTOY_PATH/mnt/squashfs
done
fi
KoName=$(ls $drvdir/kernel/drivers/dax/dax.ko*)
vtlog "insmod $KoName" vtlog "insmod $KoName"
insmod $KoName insmod $KoName
KoName=$(ls $VTOY_PATH/mnt/squashfs/lib/modules/$2/kernel/drivers/md/dm-mod.ko*) KoName=$(ls $drvdir/kernel/drivers/md/dm-mod.ko*)
vtlog "insmod $KoName" vtlog "insmod $KoName"
insmod $KoName insmod $KoName
@@ -26,6 +26,10 @@ ventoy_get_debian_distro() {
if $EGREP -q "ID=.*antix|ID=.*mx" /etc/initrd-release; then if $EGREP -q "ID=.*antix|ID=.*mx" /etc/initrd-release; then
echo 'antix'; return echo 'antix'; return
fi fi
elif [ -e /etc/initrd_release ]; then
if $EGREP -q "ID=.*antix|ID=.*mx" /etc/initrd_release; then
echo 'antix'; return
fi
fi fi
if [ -e /DISTRO_SPECS ]; then if [ -e /DISTRO_SPECS ]; then
@@ -45,6 +49,8 @@ ventoy_get_debian_distro() {
echo 'mll'; return echo 'mll'; return
elif $GREP -m1 -q 'stratodesk.com' /init; then elif $GREP -m1 -q 'stratodesk.com' /init; then
echo 'stratodesk'; return echo 'stratodesk'; return
elif $GREP -q "\bPVE\b" /init; then
echo 'pve'; return
fi fi
fi fi
@@ -52,6 +58,9 @@ ventoy_get_debian_distro() {
if $GREP -q 'Tails' /etc/os-release; then if $GREP -q 'Tails' /etc/os-release; then
echo 'tails'; return echo 'tails'; return
fi fi
if $GREP -q 'NAME="Kylin"' /etc/os-release; then
echo 'kylin'; return
fi
fi fi
if $GREP -q 'slax/' /proc/cmdline; then if $GREP -q 'slax/' /proc/cmdline; then
@@ -104,6 +113,14 @@ ventoy_get_debian_distro() {
echo 'pyabr'; return echo 'pyabr'; return
fi fi
if [ -e /devuan-logo.txt ]; then
echo 'devuan'; return
fi
if $GREP -q 'truenas' /proc/version; then
echo 'truenas'; return
fi
echo 'default' echo 'default'
} }
@@ -0,0 +1,40 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. /ventoy/hook/ventoy-hook-lib.sh
vtlog "####### $0 $* ########"
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
wait_for_usb_disk_ready
vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "ventoy disk not found"
PATH=$VTPATH_OLD
exit 0
fi
vtlog "${vtdiskname#/dev/}2 found..."
$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/udev_disk_hook.sh "${vtdiskname#/dev/}2"
if [ -f /ventoy/autoinstall ]; then
sh /ventoy/hook/default/auto_install_varexp.sh /ventoy/autoinstall
fi
@@ -0,0 +1,151 @@
#!/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
ventoy_os_install_dmsetup() {
vtlog "ventoy_os_install_dmsetup $1 ..."
vt_usb_disk=$1
# dump iso file location
$VTOY_PATH/tool/vtoydm -i -f $VTOY_PATH/ventoy_image_map -d ${vt_usb_disk} > $VTOY_PATH/iso_file_list
# install dmsetup
LINE=$($GREP ' dmsetup.*\.udeb' $VTOY_PATH/iso_file_list)
if [ $? -eq 0 ]; then
install_udeb_from_line "$LINE" ${vt_usb_disk}
fi
# install libdevmapper
LINE=$($GREP ' libdevmapper.*\.udeb' $VTOY_PATH/iso_file_list)
if [ $? -eq 0 ]; then
install_udeb_from_line "$LINE" ${vt_usb_disk}
fi
# install md-modules
LINE=$($GREP -i ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list)
if [ $? -eq 0 ]; then
LINTCNT=$($GREP -i -c ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list)
if [ $LINTCNT -gt 1 ]; then
vtlog "more than one pkgs, need to filter..."
VER=$($BUSYBOX_PATH/uname -r)
LINE=$($GREP -i ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list | $GREP -i $VER)
LINTCNT=$($GREP -i ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list | $GREP -i -c $VER)
if [ $LINTCNT -gt 1 ]; then
vtlog "Still more than one pkgs, use the first one..."
LINE=$($GREP -i ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list | $GREP -i -m1 $VER)
fi
fi
install_udeb_from_line "$LINE" ${vt_usb_disk}
fi
# insmod md-mod if needed
if $GREP -q 'device-mapper' /proc/devices; then
vtlog "device mapper module is loaded"
else
vtlog "device mapper module is NOT loaded, now load it..."
VER=$($BUSYBOX_PATH/uname -r)
KO=$($FIND /lib/modules/$VER/kernel/drivers/md -name "dm-mod*")
vtlog "KO=$KO"
insmod $KO
fi
vtlog "dmsetup install finish, now check it..."
if dmsetup info >> $VTLOG 2>&1; then
vtlog "dmsetup work ok"
else
vtlog "dmsetup not work, now try to load eglibc ..."
# install eglibc (some ubuntu 32 bit version need it)
LINE=$($GREP 'libc6-.*\.udeb' $VTOY_PATH/iso_file_list)
if [ $? -eq 0 ]; then
install_udeb_from_line "$LINE" ${vt_usb_disk}
fi
if dmsetup info >> $VTLOG 2>&1; then
vtlog "dmsetup work ok after retry"
else
vtlog "dmsetup still not work after retry"
fi
fi
}
if is_ventoy_hook_finished || not_ventoy_disk "${1:0:-1}"; then
exit 0
fi
vtlog "==== $0 $* ===="
dmsetup_path=$(ventoy_find_bin_path dmsetup)
if [ -z "$dmsetup_path" ]; then
ventoy_os_install_dmsetup "/dev/${1:0:-1}"
fi
if ! $GREP -q 'device-mapper' /proc/devices; then
ventoy_os_install_dmsetup "/dev/${1:0:-1}"
fi
ventoy_udev_disk_common_hook $*
#
# Some distro default only accept usb partitions as install medium.
# So if ventoy is installed on a non-USB device, we just mount /cdrom here except
# for these has boot=live or boot=casper parameter in cmdline
#
VT_BUS_USB=""
if [ -n "$ID_BUS" ]; then
if echo $ID_BUS | $GREP -q -i usb; then
VT_BUS_USB="YES"
fi
else
if $BUSYBOX_PATH/ls -l /sys/class/block/${1:0:-1} | $GREP -q -i usb; then
VT_BUS_USB="YES"
fi
fi
if [ -n "$VT_BUS_USB" ]; then
vtlog "$1 is USB device"
echo /dev/$1 > /ventoy/list-devices-usb-part
else
vtlog "$1 is NOT USB device (bus $ID_BUS)"
if $EGREP -q 'boot=|casper' /proc/cmdline; then
vtlog "boot=, or casper, don't mount"
else
vtlog "No boot param, need to mount"
echo /dev/$1 > /ventoy/list-devices-usb-part
fi
fi
#special process for Linx
if $BUSYBOX_PATH/uname -r | $GREP -q "^2\.6"; then
if $GREP -q "linx" /proc/version; then
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | $GREP ventoy | $SED 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
vtDM=$(ventoy_find_dm_id ${blkdev_num})
echo "/dev/$vtDM" > /ventoy/list-devices-usb-part
fi
fi
# OK finish
set_ventoy_hook_finish
@@ -0,0 +1,46 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
$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 "/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
else
echo "Here use udev hook ..." >> $VTLOG
ventoy_systemd_udevd_work_around
ventoy_add_udev_rule "$VTOY_PATH/hook/deepin/udev_disk_hook.sh %k"
fi
if [ -f $VTOY_PATH/autoinstall ]; then
echo "Do auto install ..." >> $VTLOG
$SED '/maybe_break[[:space:]]*init/i\/ventoy/busybox/sh /ventoy/hook/deepin/ventoy_autoinstall.sh >>/ventoy/autoinstall.log 2>&1' -i /init
fi
@@ -0,0 +1,122 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy_hook_lib.sh
change_var_value() {
local vfile=$1
local vkey=$2
local vVal=$3
local quote=$4
local vline
if [ $quote -eq 0 ]; then
vline="$vkey = $vVal"
else
vline="$vkey = \"$vVal\""
fi
if grep -q -m1 "^$vkey[[:space:]]*=" $vfile; then
sed "s#^$vkey[[:space:]]*=.*#$vline#g" -i $vfile
else
echo "$vline" >> $vfile
fi
}
setting_script_process() {
local sfile=$1
local vItem
local vB64Item
vItem=$(grep '^language[[:space:]]*=' /ventoy/autoinstall | awk '{print $3}')
if [ -n "$vItem" ]; then
change_var_value $sfile 'select_language_default_locale' "$vItem" 0
fi
vItem=$(grep '^timezone[[:space:]]*=' /ventoy/autoinstall | awk '{print $3}')
if [ -n "$vItem" ]; then
change_var_value $sfile 'timezone_default' "$vItem" 0
fi
vItem=$(grep '^hostname[[:space:]]*=' /ventoy/autoinstall | awk '{print $3}')
if [ -n "$vItem" ]; then
change_var_value $sfile 'system_info_default_hostname' "$vItem" 1
change_var_value $sfile 'DI_HOSTNAME' "$vItem" 1
fi
vItem=$(grep '^root_password[[:space:]]*=' /ventoy/autoinstall | awk '{print $3}')
if [ -n "$vItem" ]; then
vB64Item=$(echo -n "$vItem" | base64)
change_var_value $sfile 'system_info_default_root_password' "$vB64Item" 1
change_var_value $sfile 'DI_ROOTPASSWORD' "$vB64Item" 1
fi
vItem=$(grep '^default_username[[:space:]]*=' /ventoy/autoinstall | awk '{print $3}')
if [ -n "$vItem" ]; then
change_var_value $sfile 'system_info_default_username' "$vItem" 1
change_var_value $sfile 'DI_USERNAME' "$vItem" 1
fi
vItem=$(grep '^default_password[[:space:]]*=' /ventoy/autoinstall | awk '{print $3}')
if [ -n "$vItem" ]; then
change_var_value $sfile 'system_info_default_password' "$vItem" 1
change_var_value $sfile 'DI_PASSWORD' "$vItem" 1
fi
vItem=$(grep '^install_disk[[:space:]]*=' /ventoy/autoinstall | awk '{print $3}')
if [ -n "$vItem" ]; then
echo "DI_FULLDISK_MULTIDISK_DEVICE = $vItem" >> $sfile
echo "DI_ROOTDISK = $vItem" >> $sfile
echo "DI_BOOTLOADER = $vItem" >> $sfile
fi
change_var_value $sfile 'skip_virtual_machine_page' 'true' 0
change_var_value $sfile 'skip_select_language_page' 'true' 0
change_var_value $sfile 'skip_select_language_page_on_first_boot' 'true' 0
change_var_value $sfile 'skip_system_keyboard_page' 'true' 0
change_var_value $sfile 'skip_system_info_page' 'true' 0
change_var_value $sfile 'skip_qr_code_system_info_page' 'true' 0
change_var_value $sfile 'skip_timezone_page' 'true' 0
change_var_value $sfile 'skip_partition_page' 'true' 0
change_var_value $sfile 'system_info_password_validate_required' '0' 0
change_var_value $sfile 'system_info_password_strong_check' 'false' 0
change_var_value $sfile 'partition_do_auto_part' 'true' 0
change_var_value $sfile 'system_info_disable_license' 'true' 0
change_var_value $sfile 'system_info_disable_experience' 'true' 0
change_var_value $sfile 'system_info_disable_privacy_license' 'true' 0
#filesystem.squashfs search ini
#first_page_state=0,表示不跳过首页,展示首页让用户自己选择
#first_page_state=1,表示跳过首页,并且自动点击一键安装
#first_page_state=2,表示跳过首页,并且自动点击自定义安装
#first_page_state=3,表示跳过首页,并且直接以全盘安装方式自动安装
change_var_value $sfile 'first_page_state' '3' 0
}
update_settings() {
local script=$1
local newscript
echo "update_settings for $script ..."
newscript=$(basename $script)
cp -a $script /ventoy/vini_${newscript}
setting_script_process /ventoy/vini_${newscript}
rm -f $script
cp -a /ventoy/vini_${newscript} $script
}
sh /ventoy/hook/common/auto_install_varexp.sh /ventoy/autoinstall
update_settings /root/usr/share/deepin-installer/resources/default_settings.ini
ls -1 /root/usr/share/deepin-installer/resources/override/ | while read line; do
update_settings /root/usr/share/deepin-installer/resources/override/$line
done
ls -1 /root/usr/share/deepin-installer/resources/oem/ | while read line; do
update_settings /root/usr/share/deepin-installer/resources/oem/$line
done
@@ -39,3 +39,6 @@ $BUSYBOX_PATH/insmod $vtLoopExDir/dm-mod/$(uname -r)/64/dm-mod.ko
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace" ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
PATH=$VTPATH_OLD PATH=$VTPATH_OLD
set_ventoy_hook_finish
@@ -84,3 +84,6 @@ cp -a /dev/$vtDM /dev/ventoy
ln -s /dev/$vtDM /dev/root ln -s /dev/$vtDM /dev/root
PATH=$VTPATH_OLD PATH=$VTPATH_OLD
set_ventoy_hook_finish
@@ -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
+75
View File
@@ -0,0 +1,75 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. /ventoy/hook/ventoy-hook-lib.sh
vtlog "######### $0 $* ############"
if is_ventoy_hook_finished; then
exit 0
fi
wait_for_usb_disk_ready
vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "ventoy disk not found"
exit 0
fi
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | $GREP ventoy | $SED 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
vtDM=$(ventoy_find_dm_id ${blkdev_num})
vtlog "blkdev_num=$blkdev_num vtDM=$vtDM ..."
while [ -n "Y" ]; do
if [ -b /dev/$vtDM ]; then
break
else
sleep 0.3
fi
done
if [ -n "$1" ]; then
vtlog "ln -s /dev/$vtDM $1"
if [ -e "$1" ]; then
vtlog "$1 already exist"
else
ln -s /dev/$vtDM "$1"
fi
else
vtLABEL=$($BUSYBOX_PATH/blkid /dev/$vtDM | $SED 's/.*LABEL="\([^"]*\)".*/\1/')
vtlog "vtLABEL is $vtLABEL"
if [ -z "$vtLABEL" ]; then
vtLABEL=$($SED "s/.*label=\([^ ]*\)/\1/" /proc/cmdline)
vtlog "vtLABEL is $vtLABEL from cmdline"
fi
if [ -e "/dev/disk/by-label/$vtLABEL" ]; then
vtlog "$1 already exist"
else
ln -s /dev/$vtDM "/dev/disk/by-label/$vtLABEL"
fi
fi
# OK finish
set_ventoy_hook_finish
+25
View File
@@ -0,0 +1,25 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. $VTOY_PATH/hook/ventoy-os-lib.sh
echo "hook live.init" >> $VTLOG
$SED "1i $BUSYBOX_PATH/sh $VTOY_PATH/hook/ewe/ventoy-disk.sh" -i /lib/tinyramfs/hook.d/live/live.init
+3
View File
@@ -34,3 +34,6 @@ for i in 0 1 2 3 4 5 6 7 8 9; do
done done
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace" ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
set_ventoy_hook_finish
+3
View File
@@ -48,3 +48,6 @@ else
fi fi
PATH=$VTPATH_OLD PATH=$VTPATH_OLD
set_ventoy_hook_finish
@@ -68,3 +68,6 @@ ventoy_os_install_dmsetup_by_unsquashfs $vtdiskname
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace" ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
PATH=$VTPATH_OLD PATH=$VTPATH_OLD
set_ventoy_hook_finish
+3
View File
@@ -72,3 +72,6 @@ ventoy_os_install_device_mapper $vtdiskname
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
PATH=$VTPATH_OLD PATH=$VTPATH_OLD
set_ventoy_hook_finish
@@ -36,3 +36,6 @@ blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\
mknod -m 0660 /dev/ventoy b $blkdev_num mknod -m 0660 /dev/ventoy b $blkdev_num
PATH=$VTPATH_OLD PATH=$VTPATH_OLD
set_ventoy_hook_finish
@@ -36,3 +36,6 @@ vtDM=$(ventoy_find_dm_id ${blkdev_num})
echo -n "/dev/$vtDM" > /ventoy/rootdev echo -n "/dev/$vtDM" > /ventoy/rootdev
PATH=$VTPATH_OLD PATH=$VTPATH_OLD
set_ventoy_hook_finish

Some files were not shown because too many files have changed in this diff Show More