Compare commits

..

119 Commits

Author SHA1 Message Date
longpanda
8b975b5e80 1.0.49 release 2021-08-03 17:31:39 +08:00
MELERIX
2ab717cc66 Updated Spanish Translation (#1039) 2021-08-03 14:53:57 +08:00
longpanda
88793d548a Compatibility improvement for some WinPE 2021-08-03 14:53:29 +08:00
longpanda
5fea6eab7e Add Bulgarian language 2021-08-03 10:05:01 +08:00
Ida Bagus
5d55dc68ae Indonesian update (#1038) 2021-08-03 08:58:17 +08:00
VlatkoS
2c320aad60 Updated Macedonian language (#1037)
Updated Macedonian language
2021-08-03 08:57:54 +08:00
Hoàng Điềm Tĩnh
b63034b2c7 Update languages.json (#1036) 2021-08-03 08:57:43 +08:00
longpanda
6c113880e5 Fixed the boot issue for "StorageCraft Recovery Environment CrossPlatform" in UEFI mode. 2021-08-02 22:50:38 +08:00
longpanda
e2656c287b Compatibility improvement for some WinPE 2021-08-02 21:03:43 +08:00
longpanda
d8433985e7 1.0.48 release 2021-08-01 21:50:36 +08:00
Diacius
b003105925 Improve English Language (#963)
Changed `clear` to `clearing` and `detail` to `details`
2021-07-31 09:21:57 +08:00
fossdd
2ca2c83b6b Let the link to build from source also work on gitee and local copies. (#1009)
The Link linked to a GitHub page. But markdown also support link in the directory: Now the link works in your local markdown viewer, github and gitee, to their own page instead that all redirect to GitHub
2021-07-31 09:21:02 +08:00
VenusGirl
dff7e495ca Update languages.json (#1003)
Update Korean
2021-07-31 09:20:43 +08:00
VenusGirl
cf0f395c56 Update languages.json (#1002)
Update Korean
2021-07-31 09:20:23 +08:00
Tayfun Akkoyun
69bc90da42 Update languages.json (#1004)
New Lines of language.json file was translated for Turkish language. Can you update language.json file?
2021-07-31 09:20:06 +08:00
Hoàng Điềm Tĩnh
ffc40234ca Update Vietnamese for languages.json (#1018)
* Update languages.json

Update Vietnamese for languages.json

* Update languages.json

* Update languages.json
2021-07-31 09:19:52 +08:00
Thomas De Rocker
e57daa5065 Update languages.json (#1014) 2021-07-31 09:19:32 +08:00
ensag-dev
5c733a20f8 Update occitan (#1012) 2021-07-31 09:19:13 +08:00
longpanda
069342ab9a change ownership when cpio pack 2021-07-27 22:18:39 +08:00
longpanda
32a964eded add vtoytool 01 2021-07-27 21:28:47 +08:00
longpanda
51b92f398a misc update 2021-07-27 19:10:30 +08:00
longpanda
5d0ebf4510 support custom arch iso (#1021) 2021-07-27 19:08:40 +08:00
longpanda
cf94487ad5 misc update 2021-07-26 15:31:56 +08:00
longpanda
af83f46a3d Merge branch 'master' of https://github.com/ventoy/Ventoy 2021-07-26 15:30:54 +08:00
啊o额iu鱼
4910e9f380 Mirror action check owner (#1016) 2021-07-25 20:00:23 +08:00
longpanda
fb38b321c2 Code Optimization 2021-07-24 19:03:09 +08:00
longpanda
7b78fe555e Support nested boot.
For example: Ventoy-->rEFInd.iso-->Ventoy-->Windows.iso
2021-07-24 18:47:39 +08:00
longpanda
094ba61848 Fix Windows boot issue when Ventoy is booted from rEFInd 2021-07-24 18:45:51 +08:00
longpanda
faa0e46d3a Fix the missing program issue for EasyU 2021-07-23 23:26:27 +08:00
longpanda
537f0eaa7e 1.0.47 release 2021-07-17 17:42:06 +08:00
longpanda
c8cf9b7ce2 Speedup md5sum/sha1sum/sha256sum/sha512sum command 2021-07-16 01:36:10 +08:00
longpanda
4c71d7c190 Support WinPE which contains pecmd.exe 2021-07-16 01:03:01 +08:00
longpanda
47f9f2c42c Add support for MocaccinoOS distro 2021-07-15 17:48:03 +08:00
longpanda
fc3a5fae36 Fixed HBCD boot issue. (#992) 2021-07-11 10:14:16 +08:00
longpanda
b3982d4930 Fixed a bug when booting big boot.wim file. 2021-07-11 01:02:00 +08:00
longpanda
c280baae27 Add Ventoy Sparse Image Option 2021-07-10 09:41:52 +08:00
longpanda
425d640480 Fixed a bug for ventoy_openwrt.xz check. 2021-07-10 09:20:54 +08:00
longpanda
07d4140cf4 Optimization for booting openwrt 2021-07-09 17:35:19 +08:00
longpanda
90ae07d227 Update README.md 2021-07-08 16:39:32 +08:00
longpanda
e3e21eb6e6 issue template 2021-07-06 22:52:26 +08:00
longpanda
c8ce2ae85a issue template 2021-07-06 22:51:27 +08:00
longpanda
c02a6955c3 Add check for the built-in browser in WebDeepin.sh 2021-07-06 10:10:59 +08:00
David P
6b78603dd3 fix Parabola rEFInd booting (#989)
newer Parabola rEFInd ISOs need to run vt_linux_get_main_initrd_index to actually work, just like the systemd-boot ISOs
2021-07-06 10:07:21 +08:00
longpanda
07a386c963 Add issue template 2021-07-05 16:49:31 +08:00
longpanda
eb048c0075 Remove the 2TB limit for the reserved space in Ventoy2Disk.exe 2021-07-05 13:40:19 +08:00
longpanda
37ac3f312f Optimization for booting openwrt 2021-06-28 15:15:39 +08:00
longpanda
092cff8429 Support some floppy image in Memdisk mode 2021-06-25 12:34:28 +08:00
longpanda
b347c1b5da Optimization for booting OpenWrt 2021-06-25 11:49:45 +08:00
longpanda
da746c608f Set hidden attribute for VTOYEFI part in GPT partition style 2021-06-21 13:27:41 +08:00
longpanda
81aa56955a optimization for boot openwrt 2021-06-20 21:44:37 +08:00
longpanda
d1679871a6 optimization for booting openwrt 2021-06-20 20:20:17 +08:00
longpanda
f383052013 add debug info 2021-06-20 11:28:19 +08:00
longpanda
667f5bcc1b Fix the Memdisk/WIMBOOT mode/... tip message display error
When VTOY_DEFAULT_IMAGE was set to F6>xxxx, if you press F1 or ctrl+w, the tip message will show ??
2021-06-18 10:41:41 +08:00
longpanda
af69cb7f44 1.0.46 release 2021-06-13 20:29:11 +08:00
longpanda
7bb13fc18a Merge branch 'master' of https://github.com/ventoy/Ventoy 2021-06-11 20:36:29 +08:00
longpanda
7fce7e0aba Fix a bug when booting nitrux-release-amd64_2021.05.28.iso (#953) 2021-06-11 20:36:17 +08:00
VlatkoS
2a435084c2 Updated and enhanced Macedonian translation (#930)
Updated and enhanced Macedonian translation
2021-06-11 10:52:01 +08:00
Silejonu
c0c454a436 Update French translation (#931)
Added missing French translation strings and corrected a few already existing ones.
2021-06-11 10:51:47 +08:00
longpanda
63924fa8bd optimize for CRUX 2021-06-09 22:40:08 +08:00
longpanda
3e47f5e8de Fix a bug about ventoy version message position when VTOY_DEFAULT_IMG is set to F6>xxx 2021-06-09 20:55:45 +08:00
longpanda
b5eb347244 Add support for Lakka 3.0/3.1 img file 2021-06-08 23:43:26 +08:00
longpanda
9225c940a6 optimization for cdlinux 2021-05-31 21:02:46 +08:00
longpanda
a8edb99d28 priority key>parent in menu class plugin 2021-05-31 20:46:45 +08:00
longpanda
ac3ab97686 1.0.45 release 2021-05-29 19:42:16 +08:00
longpanda
c42a8c6d93 misc update 2021-05-23 22:39:30 +08:00
longpanda
4b1dd4d3af print progress for md5sum/sha1sum/sha256sum/sha512sum 2021-05-22 19:39:59 +08:00
longpanda
f342be1d6c Merge branch 'master' of https://github.com/ventoy/Ventoy 2021-05-21 10:06:43 +08:00
longpanda
f4774ee0e4 Fix pack error in vDisk env (#912) 2021-05-21 10:06:16 +08:00
MELERIX
d3cfa73631 Updated Spanish Translation (#911) 2021-05-19 15:45:00 +08:00
longpanda
331080fb95 Add parent option in auto_install and injection plugin. 2021-05-16 18:12:07 +08:00
longpanda
99fbd14f08 1.0.44 release 2021-05-15 19:44:20 +08:00
longpanda
1c5aeb35dc Fix a bug about unaligned read in UEFI mode. 2021-05-15 14:23:46 +08:00
longpanda
f7b3bd1729 Add parent option in password plugin 2021-05-15 08:57:26 +08:00
longpanda
672632a0c2 Add isopwd wimpwd efipwd imgpwd vhdpwd vtoypwd option in password plugin (#898) 2021-05-14 22:27:26 +08:00
longpanda
d07aa6ce07 Add -o option in CreatePersistentImg.sh (#903) 2021-05-14 12:12:07 +08:00
longpanda
93996cf7e2 1. Optimization for WIMBOOT mode.
2. Add WIMBOOT for UEFI mode.
2021-05-13 23:05:42 +08:00
longpanda
ca62128f9b Add WIMBOOT mode 2021-05-12 22:49:12 +08:00
longpanda
265b70f1c7 misc update 2021-05-10 18:13:41 +08:00
longpanda
491f0bea8a Fix issue when install Fedora 34 Server Edition 2021-05-10 16:03:40 +08:00
longpanda
47e77e003c 1.0.43 release 2021-05-08 18:05:04 +08:00
longpanda
d05eab2be1 support boot Windows VHD(x) at local disk 2021-05-08 15:33:11 +08:00
longpanda
849dfb463d 1. Change the UTF-16 languages.ini to UTF-8 languages.json
2. The update button is available even if data corrupted in VTOYEFI partition.
3. Set the default focus to No when you click Install button in Ventoy2Disk.exe.
4. Fix a BUG when booting Windows VHD(x) with the latest ventoy_vhdboot.img.
5. Support boot Windows VHD(x) files in local disk.
2021-05-08 14:22:37 +08:00
longpanda
7715bd705c 1.0.42 release 2021-04-27 18:22:10 +08:00
panchenbo
042ca4b5e3 add support for UnionTechOS fuyu (#864) 2021-04-27 17:28:35 +08:00
longpanda
e1099e1e5b Add parent option in menu_class plugin. 2021-04-25 10:31:03 +08:00
longpanda
c6be35f2c0 Support * fuzzy matching for file path in some plugins 2021-04-24 16:03:38 +08:00
longpanda
b15a96b747 1.0.41 release 2021-04-21 21:12:43 +08:00
longpanda
6bd0463d34 Support openwrt IMG file 2021-04-21 19:40:54 +08:00
longpanda
1ce568d971 Support for new MidnightBSD release 2021-04-21 17:00:40 +08:00
longpanda
f82475d950 support new GhostBSD release 2021-04-20 13:10:35 +08:00
longpanda
aad154616c languages.ini update 2021-04-19 09:05:05 +08:00
longpanda
83c3a932d3 misc update 2021-04-14 16:59:57 +08:00
longpanda
0aff8f5109 update vtoytool 2021-04-14 10:26:27 +08:00
longpanda
2750f0c5a7 misc update 2021-04-13 19:42:19 +08:00
longpanda
f71a1fcce9 misc update 2021-04-13 16:46:23 +08:00
longpanda
e252fab9a4 boot iso file with ventoy in ventoy_grub.cfg 2021-04-12 22:30:14 +08:00
longpanda
37212a8ea4 1. Fix a bug about source media missing when boot CentOS8
2. Support RED OS
2021-04-12 18:56:26 +08:00
longpanda
e71221cdba Fix a bug about source media missing when boot openEuler 2021-04-12 11:53:25 +08:00
longpanda
65a2cb1685 1.0.40 release 2021-04-10 20:01:39 +08:00
longpanda
e23e76f54e grub2 boot mode for UEFI 2021-04-10 13:57:20 +08:00
longpanda
8ded032c92 Update vietnamese language (#836) 2021-04-09 19:54:24 +08:00
longpanda
fc5cd0a00a update languages.ini (#829 #834) 2021-04-07 13:37:52 +08:00
longpanda
6cc400b8d4 experimental persistent support for Fedora (#791) 2021-04-06 14:28:34 +08:00
longpanda
ffc915ca53 persistence support for ArchLinux series (Arch/ArchMan/ArchBang/ArchLabs/BlackArch...) 2021-04-04 22:25:26 +08:00
longpanda
8ebe972f6e Fixup a bug when booting special Windows/WinPE ISO file. 2021-04-02 14:11:47 +08:00
longpanda
39975dd1c3 update CI script 2021-04-02 10:08:23 +08:00
longpanda
1a648d8689 update tool chain download link 2021-04-02 09:51:42 +08:00
longpanda
8234961228 debug CI 2021-04-01 13:46:28 +08:00
longpanda
e1ffbad431 Support RHEL6/CentOS6 auto install 2021-04-01 12:02:32 +08:00
longpanda
4a66104c6e Clear input key before show main menu 2021-04-01 09:51:52 +08:00
longpanda
32bcd8f87b Clear input key before show main menu 2021-04-01 09:42:57 +08:00
longpanda
26c1756e8d languages.ini update (#809 #816 #818) 2021-04-01 09:21:42 +08:00
longpanda
f4bbec65ba 1.0.39 release 2021-03-28 17:18:23 +08:00
longpanda
58d387f732 supoort veket 20.10 2021-03-24 22:08:30 +08:00
longpanda
2e10aabe94 Add VTOY_DEFAULT_KBD_LAYOUT in global control plugin 2021-03-24 22:08:10 +08:00
longpanda
a63a41f79d Serbian UI Language Update (#806) 2021-03-24 10:11:20 +08:00
longpanda
64748308a3 Add a workaround for buggy bootloader's out-of-range access 2021-03-24 10:07:07 +08:00
longpanda
33cc1e271a Support latest CentOS Stream 8 distro. (#799) 2021-03-18 12:27:21 +08:00
longpanda
291e0a3a38 add debug info 2021-03-17 22:17:51 +08:00
242 changed files with 39590 additions and 4978 deletions

1
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1 @@
blank_issues_enabled: false

View File

@@ -0,0 +1,93 @@
name: Issue Report
description: File an issue report
title: "[issue]: "
assignees:
- octocat
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this issue report!
- type: checkboxes
id: faq
attributes:
label: Official FAQ
description: Have you checked the official FAQ at [https://www.ventoy.net/en/faq.html](https://www.ventoy.net/en/faq.html) ?
options:
- label: I have checked the official FAQ.
required: true
- type: input
id: version
attributes:
label: Ventoy Version
description: What version of ventoy are you running?
placeholder: 1.0.48
validations:
required: true
- type: dropdown
id: latestrelease
attributes:
label: What about latest release
description: Have you tried with the latest release of Ventoy?
options:
- Yes. I have tried the latest release, but the bug still exist.
- No. I didn't try the latest release.
validations:
required: true
- type: dropdown
id: bios
attributes:
label: BIOS Mode
description: In which BIOS mode did you find the bug?
options:
- Legacy BIOS Mode
- UEFI Mode
- Both
validations:
required: true
- type: dropdown
id: partstyle
attributes:
label: Partition Style
description: Which partition style did you select when you install Ventoy?
options:
- MBR
- GPT
validations:
required: true
- type: input
id: capacity
attributes:
label: Disk Capacity
description: What is the capacity of the disk installed with Ventoy?
placeholder: 32GB
validations:
required: true
- type: dropdown
id: checksum
attributes:
label: Image file checksum (if applicable)
description: Have you checked the image file in Ventoy's menu as [https://www.ventoy.net/en/faq.html#faq_boot_checksum](https://www.ventoy.net/en/faq.html#faq_boot_checksum) ?
options:
- Yes.
- No.
validations:
required: false
- type: input
id: link
attributes:
label: Image file download link (if applicable)
description: What is the image file download link?
placeholder: https://xxx
validations:
required: false
- type: textarea
id: what-happened
attributes:
label: What happened?
description: Tell me what happened. It's highly recommended to include some photo or video about the bug.
placeholder: Tell us what you see!
value: "A bug happened!"
validations:
required: true

View File

@@ -11,6 +11,7 @@ on:
jobs: jobs:
run: run:
name: Sync-GitHub-to-Gitee name: Sync-GitHub-to-Gitee
if: ${{ github.repository_owner == 'ventoy' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Mirror the Github repos to Gitee. - name: Mirror the Github repos to Gitee.

View File

@@ -34,6 +34,7 @@
#include <Protocol/BlockIo.h> #include <Protocol/BlockIo.h>
#include <Protocol/RamDisk.h> #include <Protocol/RamDisk.h>
#include <Protocol/SimpleFileSystem.h> #include <Protocol/SimpleFileSystem.h>
#include <Protocol/DriverBinding.h>
#include <Ventoy.h> #include <Ventoy.h>
BOOLEAN gDebugPrint = FALSE; BOOLEAN gDebugPrint = FALSE;
@@ -362,10 +363,22 @@ EFI_HANDLE EFIAPI ventoy_get_parent_handle(IN EFI_DEVICE_PATH_PROTOCOL *pDevPath
return Handle; return Handle;
} }
STATIC ventoy_ram_disk g_backup_ramdisk_param;
STATIC ventoy_os_param g_backup_os_param_var;
EFI_STATUS EFIAPI ventoy_save_ramdisk_param(VOID) EFI_STATUS EFIAPI ventoy_save_ramdisk_param(VOID)
{ {
UINTN DataSize;
EFI_STATUS Status = EFI_SUCCESS; EFI_STATUS Status = EFI_SUCCESS;
EFI_GUID VarGuid = VENTOY_GUID; EFI_GUID VarGuid = VENTOY_GUID;
DataSize = sizeof(g_backup_ramdisk_param);
Status = gRT->GetVariable(L"VentoyRamDisk", &VarGuid, NULL, &DataSize, &g_backup_ramdisk_param);
if (!EFI_ERROR(Status))
{
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,
@@ -379,21 +392,38 @@ EFI_STATUS EFIAPI ventoy_delete_ramdisk_param(VOID)
{ {
EFI_STATUS Status = EFI_SUCCESS; EFI_STATUS Status = EFI_SUCCESS;
EFI_GUID VarGuid = VENTOY_GUID; EFI_GUID VarGuid = VENTOY_GUID;
Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid, if (g_backup_ramdisk_param.DiskSize > 0 && g_backup_ramdisk_param.PhyAddr > 0)
{
Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(g_backup_ramdisk_param), &g_backup_ramdisk_param);
debug("resotre ramdisk variable %r", Status);
}
else
{
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 efi variable %r", Status); debug("delete ramdisk variable %r", Status);
}
return Status; return Status;
} }
EFI_STATUS EFIAPI ventoy_save_variable(VOID) EFI_STATUS EFIAPI ventoy_save_variable(VOID)
{ {
UINTN DataSize;
EFI_STATUS Status = EFI_SUCCESS; EFI_STATUS Status = EFI_SUCCESS;
EFI_GUID VarGuid = VENTOY_GUID; EFI_GUID VarGuid = VENTOY_GUID;
DataSize = sizeof(g_backup_os_param_var);
Status = gRT->GetVariable(L"VentoyOsParam", &VarGuid, NULL, &DataSize, &g_backup_os_param_var);
if (!EFI_ERROR(Status))
{
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));
@@ -406,11 +436,21 @@ EFI_STATUS EFIAPI ventoy_delete_variable(VOID)
{ {
EFI_STATUS Status = EFI_SUCCESS; EFI_STATUS Status = EFI_SUCCESS;
EFI_GUID VarGuid = VENTOY_GUID; EFI_GUID VarGuid = VENTOY_GUID;
Status = gRT->SetVariable(L"VentoyOsParam", &VarGuid, if (0 == CompareMem(&(g_backup_os_param_var.guid), &VarGuid, sizeof(EFI_GUID)))
{
Status = gRT->SetVariable(L"VentoyOsParam", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(g_backup_os_param_var), &(g_backup_os_param_var));
debug("restore efi variable %r", Status);
}
else
{
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);
}
return Status; return Status;
} }
@@ -1085,6 +1125,8 @@ EFI_STATUS EFIAPI VentoyEfiMain
return Status; return Status;
} }
ventoy_disable_ex_filesystem();
if (gMemdiskMode) if (gMemdiskMode)
{ {
g_ramdisk_param.PhyAddr = (UINT64)(UINTN)g_iso_data_buf; g_ramdisk_param.PhyAddr = (UINT64)(UINTN)g_iso_data_buf;
@@ -1159,6 +1201,8 @@ EFI_STATUS EFIAPI VentoyEfiMain
grub_env_set("vtoy_dotefi_retry", "YES"); grub_env_set("vtoy_dotefi_retry", "YES");
} }
ventoy_enable_ex_filesystem();
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@@ -169,7 +169,6 @@ typedef struct ventoy_virt_chunk
{ 0x37b87ac6, 0xc180, 0x4583, { 0xa7, 0x05, 0x41, 0x4d, 0xa8, 0xf7, 0x7e, 0xd2 }} { 0x37b87ac6, 0xc180, 0x4583, { 0xa7, 0x05, 0x41, 0x4d, 0xa8, 0xf7, 0x7e, 0xd2 }}
#define VTOY_BLOCK_DEVICE_PATH_NAME L"ventoy"
#if defined (MDE_CPU_IA32) #if defined (MDE_CPU_IA32)
#define VENTOY_UEFI_DESC L"IA32 UEFI" #define VENTOY_UEFI_DESC L"IA32 UEFI"
@@ -344,6 +343,14 @@ typedef struct ventoy_system_wrapper
EFI_LOCATE_DEVICE_PATH OriLocateDevicePath; EFI_LOCATE_DEVICE_PATH OriLocateDevicePath;
} ventoy_system_wrapper; } ventoy_system_wrapper;
#define MAX_DRIVER_BIND_WRAPPER 64
typedef struct DriverBindWrapper
{
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
EFI_DRIVER_BINDING_SUPPORTED pfOldSupport;
}DRIVER_BIND_WRAPPER;
#define ventoy_wrapper(bs, wrapper, func, newfunc) \ #define ventoy_wrapper(bs, wrapper, func, newfunc) \
{\ {\
wrapper.Ori##func = bs->func;\ wrapper.Ori##func = bs->func;\
@@ -351,6 +358,22 @@ typedef struct ventoy_system_wrapper
bs->func = wrapper.New##func;\ bs->func = wrapper.New##func;\
} }
#define VENTOY_GET_COMPONENT_NAME(Protocol, DriverName) \
{\
DriverName = NULL;\
Status = Protocol->GetDriverName(Protocol, "en", &DriverName);\
if (EFI_ERROR(Status) || NULL == DriverName) \
{\
DriverName = NULL;\
Status = Protocol->GetDriverName(Protocol, "eng", &DriverName);\
if (EFI_ERROR(Status) || NULL == DriverName) \
{\
continue;\
}\
}\
}
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);
@@ -396,6 +419,8 @@ EFI_STATUS ventoy_hook_keyboard_stop(VOID);
BOOLEAN ventoy_is_cdrom_dp_exist(VOID); BOOLEAN ventoy_is_cdrom_dp_exist(VOID);
EFI_STATUS ventoy_hook_1st_cdrom_start(VOID); 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_enable_ex_filesystem(VOID);
#endif #endif

View File

@@ -34,6 +34,7 @@
#include <Protocol/BlockIo.h> #include <Protocol/BlockIo.h>
#include <Protocol/RamDisk.h> #include <Protocol/RamDisk.h>
#include <Protocol/SimpleFileSystem.h> #include <Protocol/SimpleFileSystem.h>
#include <Protocol/DriverBinding.h>
#include <Ventoy.h> #include <Ventoy.h>
#define PROCOTOL_SLEEP_MSECONDS 0 #define PROCOTOL_SLEEP_MSECONDS 0

View File

@@ -34,6 +34,7 @@
#include <Protocol/BlockIo.h> #include <Protocol/BlockIo.h>
#include <Protocol/RamDisk.h> #include <Protocol/RamDisk.h>
#include <Protocol/SimpleFileSystem.h> #include <Protocol/SimpleFileSystem.h>
#include <Protocol/DriverBinding.h>
#include <Ventoy.h> #include <Ventoy.h>
UINT8 *g_iso_data_buf = NULL; UINT8 *g_iso_data_buf = NULL;
@@ -73,6 +74,9 @@ STATIC UINT8 g_sector_buf[2048];
STATIC EFI_BLOCK_READ g_sector_2048_read = NULL; STATIC EFI_BLOCK_READ g_sector_2048_read = NULL;
STATIC EFI_BLOCK_WRITE g_sector_2048_write = NULL; STATIC EFI_BLOCK_WRITE g_sector_2048_write = NULL;
STATIC UINTN g_DriverBindWrapperCnt = 0;
STATIC DRIVER_BIND_WRAPPER g_DriverBindWrapperList[MAX_DRIVER_BIND_WRAPPER];
BOOLEAN ventoy_is_cdrom_dp_exist(VOID) BOOLEAN ventoy_is_cdrom_dp_exist(VOID)
{ {
UINTN i = 0; UINTN i = 0;
@@ -148,7 +152,7 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
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", Sector, Count); debug("read iso sector %lu count %u Buffer:%p Align:%u", Sector, Count, Buffer, pRawBlockIo->Media->IoAlign);
ReadStart = Sector * 2048; ReadStart = Sector * 2048;
ReadEnd = (Sector + Count) * 2048; ReadEnd = (Sector + Count) * 2048;
@@ -173,7 +177,6 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
{ {
MapLba = ((Sector - pchunk->img_start_sector) >> 1) + pchunk->disk_start_sector; MapLba = ((Sector - pchunk->img_start_sector) >> 1) + pchunk->disk_start_sector;
} }
secLeft = pchunk->img_end_sector + 1 - Sector; secLeft = pchunk->img_end_sector + 1 - Sector;
secRead = (Count < secLeft) ? Count : secLeft; secRead = (Count < secLeft) ? Count : secLeft;
@@ -182,7 +185,7 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
MapLba, secRead * 2048, pCurBuf); MapLba, secRead * 2048, pCurBuf);
if (EFI_ERROR(Status)) if (EFI_ERROR(Status))
{ {
debug("Raw disk read block failed %r LBA:%lu Count:%u", Status, MapLba, secRead); debug("Raw disk read block failed %r LBA:%lu Count:%u %p", Status, MapLba, secRead, pCurBuf);
return Status; return Status;
} }
@@ -425,7 +428,7 @@ end:
return Lba; return Lba;
} }
EFI_STATUS EFIAPI ventoy_block_io_read 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,
@@ -438,6 +441,8 @@ EFI_STATUS EFIAPI ventoy_block_io_read
UINT32 j = 0; UINT32 j = 0;
UINT32 lbacount = 0; UINT32 lbacount = 0;
UINT32 secNum = 0; UINT32 secNum = 0;
UINT32 TmpNum = 0;
UINT64 VirtSec = 0;
UINT64 offset = 0; UINT64 offset = 0;
EFI_LBA curlba = 0; EFI_LBA curlba = 0;
EFI_LBA lastlba = 0; EFI_LBA lastlba = 0;
@@ -445,7 +450,7 @@ EFI_STATUS EFIAPI ventoy_block_io_read
ventoy_sector_flag *cur_flag; ventoy_sector_flag *cur_flag;
ventoy_virt_chunk *node; ventoy_virt_chunk *node;
//debug("### ventoy_block_io_read sector:%u count:%u", (UINT32)Lba, (UINT32)BufferSize / 2048); debug("### block_io_read_real sector:%u count:%u Buffer:%p", (UINT32)Lba, (UINT32)BufferSize / 2048, Buffer);
secNum = BufferSize / 2048; secNum = BufferSize / 2048;
@@ -461,6 +466,28 @@ EFI_STATUS EFIAPI ventoy_block_io_read
{ {
return ventoy_read_iso_sector(Lba, secNum, Buffer); return ventoy_read_iso_sector(Lba, secNum, Buffer);
} }
else if (offset < g_chain->real_img_size_in_bytes)
{
TmpNum = (g_chain->real_img_size_in_bytes - offset) / 2048;
ventoy_read_iso_sector(Lba, TmpNum, Buffer);
Lba += TmpNum;
secNum -= TmpNum;
Buffer = (UINT8 *)Buffer + (g_chain->real_img_size_in_bytes - offset);
offset = Lba * 2048;
}
VirtSec = g_chain->virt_img_size_in_bytes / 2048;
if (Lba >= VirtSec)
{
return EFI_SUCCESS;
}
else if (Lba + secNum > VirtSec)
{
secNum = VirtSec - Lba;
}
debug("XXX block_io_read_real sector:%u count:%u Buffer:%p", (UINT32)Lba, (UINT32)BufferSize / 2048, Buffer);
if (secNum > g_sector_flag_num) if (secNum > g_sector_flag_num)
{ {
@@ -529,6 +556,42 @@ EFI_STATUS EFIAPI ventoy_block_io_read
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFIAPI ventoy_block_io_read
(
IN EFI_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId,
IN EFI_LBA Lba,
IN UINTN BufferSize,
OUT VOID *Buffer
)
{
UINT32 IoAlign = 0;
VOID *NewBuf = NULL;
EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
if (gBlockData.pRawBlockIo && gBlockData.pRawBlockIo->Media)
{
IoAlign = gBlockData.pRawBlockIo->Media->IoAlign;
}
if ((IoAlign == 0) || (((UINTN) Buffer & (IoAlign - 1)) == 0))
{
Status = ventoy_block_io_read_real(This, MediaId, Lba, BufferSize, Buffer);
}
else
{
NewBuf = AllocatePages(EFI_SIZE_TO_PAGES(BufferSize + IoAlign));
if (NewBuf)
{
Status = ventoy_block_io_read_real(This, MediaId, Lba, BufferSize, NewBuf);
CopyMem(Buffer, NewBuf, BufferSize);
FreePages(NewBuf, EFI_SIZE_TO_PAGES(BufferSize + IoAlign));
}
}
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,
@@ -561,26 +624,74 @@ EFI_STATUS EFIAPI ventoy_block_io_flush(IN EFI_BLOCK_IO_PROTOCOL *This)
return EFI_SUCCESS; return EFI_SUCCESS;
} }
STATIC UINTN ventoy_get_current_device_path_id(VOID)
{
UINTN i = 0;
UINTN Count = 0;
UINTN MaxId = 0;
UINTN CurId = 0;
BOOLEAN Find = FALSE;
EFI_HANDLE *Handles = NULL;
EFI_STATUS Status = EFI_SUCCESS;
EFI_DEVICE_PATH_PROTOCOL *DevicePath = NULL;
VENDOR_DEVICE_PATH *venPath = NULL;
Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiDevicePathProtocolGuid,
NULL, &Count, &Handles);
if (EFI_ERROR(Status))
{
return 0;
}
for (i = 0; i < Count; i++)
{
Status = gBS->HandleProtocol(Handles[i], &gEfiDevicePathProtocolGuid, (VOID **)&DevicePath);
if (EFI_ERROR(Status))
{
continue;
}
if (DevicePath->Type == HARDWARE_DEVICE_PATH && DevicePath->SubType == HW_VENDOR_DP)
{
venPath = (VENDOR_DEVICE_PATH *)DevicePath;
if (CompareGuid(&venPath->Guid, &gVtoyBlockDevicePathGuid))
{
CurId = StrDecimalToUintn((CHAR16 *)(venPath + 1) + StrLen(L"ventoy_"));
MaxId = MAX(MaxId, CurId);
Find = TRUE;
}
}
}
FreePool(Handles);
return Find ? (MaxId + 1) : 0;
}
EFI_STATUS EFIAPI ventoy_fill_device_path(VOID) EFI_STATUS EFIAPI ventoy_fill_device_path(VOID)
{ {
UINTN CurVtoyDpId = 0;
UINTN NameLen = 0; UINTN NameLen = 0;
UINT8 TmpBuf[128] = {0}; UINT8 TmpBuf[128] = {0};
VENDOR_DEVICE_PATH *venPath = NULL; VENDOR_DEVICE_PATH *venPath = NULL;
CHAR16 VtoyDpName[32];
CurVtoyDpId = ventoy_get_current_device_path_id();
UnicodeSPrintAsciiFormat(VtoyDpName, sizeof(VtoyDpName), "ventoy_%03lu", CurVtoyDpId);
venPath = (VENDOR_DEVICE_PATH *)TmpBuf; venPath = (VENDOR_DEVICE_PATH *)TmpBuf;
NameLen = StrSize(VTOY_BLOCK_DEVICE_PATH_NAME); NameLen = StrSize(VtoyDpName);
venPath->Header.Type = HARDWARE_DEVICE_PATH; venPath->Header.Type = HARDWARE_DEVICE_PATH;
venPath->Header.SubType = HW_VENDOR_DP; venPath->Header.SubType = HW_VENDOR_DP;
venPath->Header.Length[0] = sizeof(VENDOR_DEVICE_PATH) + NameLen; venPath->Header.Length[0] = sizeof(VENDOR_DEVICE_PATH) + NameLen;
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, VTOY_BLOCK_DEVICE_PATH_NAME, 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;
debug("gBlockData.Path=<%s>\n", ConvertDevicePathToText(gBlockData.Path, FALSE, FALSE)); debug("gBlockData.Path=<%lu><%s>\n", CurVtoyDpId, ConvertDevicePathToText(gBlockData.Path, FALSE, FALSE));
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@@ -613,11 +724,7 @@ EFI_STATUS EFIAPI ventoy_connect_driver(IN EFI_HANDLE ControllerHandle, IN CONST
continue; continue;
} }
Status = Name2Protocol->GetDriverName(Name2Protocol, "en", &DriverName); VENTOY_GET_COMPONENT_NAME(Name2Protocol, DriverName);
if (EFI_ERROR(Status) || NULL == DriverName)
{
continue;
}
if (StrStr(DriverName, DrvName)) if (StrStr(DriverName, DrvName))
{ {
@@ -655,11 +762,7 @@ EFI_STATUS EFIAPI ventoy_connect_driver(IN EFI_HANDLE ControllerHandle, IN CONST
continue; continue;
} }
Status = NameProtocol->GetDriverName(NameProtocol, "en", &DriverName); VENTOY_GET_COMPONENT_NAME(NameProtocol, DriverName);
if (EFI_ERROR(Status))
{
continue;
}
if (StrStr(DriverName, DrvName)) if (StrStr(DriverName, DrvName))
{ {
@@ -684,6 +787,229 @@ end:
return Status; return Status;
} }
STATIC BOOLEAN ventoy_filesystem_need_wrapper(IN CONST CHAR16 *DrvName)
{
UINTN i;
CHAR16 UpperDrvName[256];
StrCpyS(UpperDrvName, 256, DrvName);
for (i = 0; i < 256 && UpperDrvName[i]; i++)
{
if (UpperDrvName[i] >= 'a' && UpperDrvName[i] <= 'z')
{
UpperDrvName[i] = 'A' + (UpperDrvName[i] - 'a');
}
}
/*
* suppress some file system drivers
* 1. rEFInd File System Driver
*
*/
if (StrStr(UpperDrvName, L"ISO9660") || StrStr(UpperDrvName, L"UDF"))
{
return TRUE;
}
if (StrStr(UpperDrvName, L"REFIND") && StrStr(UpperDrvName, L"FILE SYSTEM"))
{
return TRUE;
}
return FALSE;
}
STATIC VOID ventoy_add_filesystem_wrapper
(
IN EFI_DRIVER_BINDING_PROTOCOL *DriverBindProtocol,
IN CONST CHAR16 *DriverName
)
{
UINTN j;
if (g_DriverBindWrapperCnt >= MAX_DRIVER_BIND_WRAPPER)
{
debug("driver binding wrapper overflow %lu", g_DriverBindWrapperCnt);
return;
}
if (!ventoy_filesystem_need_wrapper(DriverName))
{
return;
}
for (j = 0; j < g_DriverBindWrapperCnt; j++)
{
if (g_DriverBindWrapperList[j].DriverBinding == DriverBindProtocol)
{
debug("Duplicate driverbinding <%s> %p %lu %lu", DriverName, DriverBindProtocol, j, g_DriverBindWrapperCnt);
break;
}
}
if (j >= g_DriverBindWrapperCnt)
{
g_DriverBindWrapperList[g_DriverBindWrapperCnt].DriverBinding = DriverBindProtocol;
g_DriverBindWrapperList[g_DriverBindWrapperCnt].pfOldSupport = DriverBindProtocol->Supported;
g_DriverBindWrapperCnt++;
debug("Add driverbinding <%s> %p %lu", DriverName, DriverBindProtocol, g_DriverBindWrapperCnt);
}
}
STATIC EFI_STATUS ventoy_find_filesystem_driverbind(VOID)
{
UINTN i = 0;
UINTN Count = 0;
CHAR16 *DriverName = NULL;
EFI_HANDLE *Handles = NULL;
EFI_STATUS Status = EFI_SUCCESS;
EFI_COMPONENT_NAME_PROTOCOL *NameProtocol = NULL;
EFI_COMPONENT_NAME2_PROTOCOL *Name2Protocol = NULL;
EFI_DRIVER_BINDING_PROTOCOL *DriverBindProtocol = NULL;
debug("ventoy_find_filesystem_driverbind...");
Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentName2ProtocolGuid,
NULL, &Count, &Handles);
if (EFI_ERROR(Status))
{
return Status;
}
for (i = 0; i < Count; i++)
{
Status = gBS->HandleProtocol(Handles[i], &gEfiComponentName2ProtocolGuid, (VOID **)&Name2Protocol);
if (EFI_ERROR(Status))
{
continue;
}
VENTOY_GET_COMPONENT_NAME(Name2Protocol, DriverName);
Status = gBS->HandleProtocol(Handles[i], &gEfiDriverBindingProtocolGuid, (VOID **)&DriverBindProtocol);
if (EFI_ERROR(Status))
{
debug("### 2 No DriverBind <%s> <%r>", DriverName, Status);
continue;
}
ventoy_add_filesystem_wrapper(DriverBindProtocol, DriverName);
}
Count = 0;
FreePool(Handles);
Handles = NULL;
Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentNameProtocolGuid,
NULL, &Count, &Handles);
if (EFI_ERROR(Status))
{
return Status;
}
for (i = 0; i < Count; i++)
{
Status = gBS->HandleProtocol(Handles[i], &gEfiComponentNameProtocolGuid, (VOID **)&NameProtocol);
if (EFI_ERROR(Status))
{
debug();
continue;
}
VENTOY_GET_COMPONENT_NAME(NameProtocol, DriverName);
Status = gBS->HandleProtocol(Handles[i], &gEfiDriverBindingProtocolGuid, (VOID **)&DriverBindProtocol);
if (EFI_ERROR(Status))
{
debug("### 1 No DriverBind <%s> <%r>", DriverName, Status);
continue;
}
ventoy_add_filesystem_wrapper(DriverBindProtocol, DriverName);
}
FreePool(Handles);
return EFI_SUCCESS;
}
STATIC EFI_STATUS EFIAPI ventoy_wrapper_driver_bind_support
(
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
UINTN i;
EFI_STATUS Status = EFI_SUCCESS;
EFI_DEVICE_PATH_PROTOCOL *DevicePath = NULL;
EFI_DRIVER_BINDING_SUPPORTED pfOldSupport = NULL;
for (i = 0; i < g_DriverBindWrapperCnt; i++)
{
if (g_DriverBindWrapperList[i].DriverBinding == This)
{
pfOldSupport = g_DriverBindWrapperList[i].pfOldSupport;
break;
}
}
debug("ventoy_wrapper_driver_bind_support %lu %p", i, pfOldSupport);
if (!pfOldSupport)
{
return EFI_UNSUPPORTED;
}
Status = gBS->HandleProtocol(ControllerHandle, &gEfiDevicePathProtocolGuid, (VOID **)&DevicePath);
if (EFI_ERROR(Status))
{
goto out;
}
if (0 == CompareMem(gBlockData.Path, DevicePath, gBlockData.DevicePathCompareLen))
{
debug("return EFI_UNSUPPORTED for ventoy");
return EFI_UNSUPPORTED;
}
out:
return pfOldSupport(This, ControllerHandle, RemainingDevicePath);
}
EFI_STATUS ventoy_disable_ex_filesystem(VOID)
{
UINTN i;
ventoy_find_filesystem_driverbind();
for (i = 0; i < g_DriverBindWrapperCnt; i++)
{
g_DriverBindWrapperList[i].DriverBinding->Supported = ventoy_wrapper_driver_bind_support;
}
debug("Wrapper Ex Driver Binding %lu", g_DriverBindWrapperCnt);
ventoy_debug_pause();
return EFI_SUCCESS;
}
EFI_STATUS ventoy_enable_ex_filesystem(VOID)
{
UINTN i;
for (i = 0; i < g_DriverBindWrapperCnt; i++)
{
g_DriverBindWrapperList[i].DriverBinding->Supported = g_DriverBindWrapperList[i].pfOldSupport;
}
g_DriverBindWrapperCnt = 0;
return EFI_SUCCESS;
}
EFI_STATUS EFIAPI ventoy_block_io_read_512 EFI_STATUS EFIAPI ventoy_block_io_read_512
( (
IN EFI_BLOCK_IO_PROTOCOL *This, IN EFI_BLOCK_IO_PROTOCOL *This,
@@ -698,7 +1024,7 @@ EFI_STATUS EFIAPI ventoy_block_io_read_512
UINT8 *CurBuf = NULL; UINT8 *CurBuf = NULL;
EFI_STATUS Status = EFI_SUCCESS; EFI_STATUS Status = EFI_SUCCESS;
debug("ventoy_block_io_read_512 %lu %lu\n", Lba, BufferSize / 512); debug("ventoy_block_io_read_512 %lu %lu Buffer:%p\n", Lba, BufferSize / 512, Buffer);
CurBuf = (UINT8 *)Buffer; CurBuf = (UINT8 *)Buffer;

View File

@@ -1603,6 +1603,7 @@ module = {
module = { module = {
name = ventoy; name = ventoy;
common = ventoy/ventoy.c; common = ventoy/ventoy.c;
common = ventoy/ventoy_cmd.c;
common = ventoy/ventoy_linux.c; common = ventoy/ventoy_linux.c;
common = ventoy/ventoy_unix.c; common = ventoy/ventoy_unix.c;
common = ventoy/ventoy_windows.c; common = ventoy/ventoy_windows.c;

View File

@@ -0,0 +1,343 @@
/*
* 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/dl.h>
#include <grub/extcmd.h>
#include <grub/file.h>
#include <grub/disk.h>
#include <grub/mm.h>
#include <grub/misc.h>
#include <grub/crypto.h>
#include <grub/normal.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+");
static const struct grub_arg_option options[] = {
{"hash", 'h', 0, N_("Specify hash to use."), N_("HASH"), ARG_TYPE_STRING},
{"check", 'c', 0, N_("Check hashes of files with hash list FILE."),
N_("FILE"), ARG_TYPE_STRING},
{"prefix", 'p', 0, N_("Base directory for hash list."), N_("DIR"),
ARG_TYPE_STRING},
{"keep-going", 'k', 0, N_("Don't stop after first error."), 0, 0},
{"uncompress", 'u', 0, N_("Uncompress file before checksumming."), 0, 0},
{0, 0, 0, 0, 0, 0}
};
static struct { const char *name; const char *hashname; } aliases[] =
{
{"sha256sum", "sha256"},
{"sha512sum", "sha512"},
{"sha1sum", "sha1"},
{"md5sum", "md5"},
{"crc", "crc32"},
};
static inline int
hextoval (char c)
{
if (c >= '0' && c <= '9')
return c - '0';
if (c >= 'a' && c <= 'f')
return c - 'a' + 10;
if (c >= 'A' && c <= 'F')
return c - 'A' + 10;
return -1;
}
static grub_err_t
hash_file (grub_file_t file, const gcry_md_spec_t *hash, void *result)
{
int progress = 0;
grub_uint64_t ro = 0;
grub_uint64_t div = 0;
grub_uint64_t total = 0;
void *context;
grub_uint8_t *readbuf;
#define BUF_SIZE 1024 * 1024
readbuf = grub_malloc (BUF_SIZE);
if (!readbuf)
return grub_errno;
context = grub_zalloc (hash->contextsize);
if (!readbuf || !context)
goto fail;
if (file->size > 16 * 1024 * 1024)
progress = 1;
hash->init (context);
while (1)
{
grub_ssize_t r;
r = grub_file_read (file, readbuf, BUF_SIZE);
if (r < 0)
goto fail;
if (r == 0)
break;
hash->write (context, readbuf, r);
if (progress)
{
total += r;
div = grub_divmod64(total * 100, (grub_uint64_t)file->size, &ro);
grub_printf("\rCalculating %d%% ", (int)div);
grub_refresh();
}
}
hash->final (context);
grub_memcpy (result, hash->read (context), hash->mdlen);
grub_free (readbuf);
grub_free (context);
if (progress)
{
grub_printf("\rCalculating 100%% \n\r\n");
grub_refresh();
}
return GRUB_ERR_NONE;
fail:
grub_free (readbuf);
grub_free (context);
return grub_errno;
}
static grub_err_t
check_list (const gcry_md_spec_t *hash, const char *hashfilename,
const char *prefix, int keep, int uncompress)
{
grub_file_t hashlist, file;
char *buf = NULL;
grub_uint8_t expected[GRUB_CRYPTO_MAX_MDLEN];
grub_uint8_t actual[GRUB_CRYPTO_MAX_MDLEN];
grub_err_t err;
unsigned i;
unsigned unread = 0, mismatch = 0;
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
return grub_error (GRUB_ERR_BUG, "mdlen is too long");
hashlist = grub_file_open (hashfilename, GRUB_FILE_TYPE_HASHLIST);
if (!hashlist)
return grub_errno;
while (grub_free (buf), (buf = grub_file_getline (hashlist)))
{
const char *p = buf;
while (grub_isspace (p[0]))
p++;
for (i = 0; i < hash->mdlen; i++)
{
int high, low;
high = hextoval (*p++);
low = hextoval (*p++);
if (high < 0 || low < 0)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid hash list");
expected[i] = (high << 4) | low;
}
if ((p[0] != ' ' && p[0] != '\t') || (p[1] != ' ' && p[1] != '\t'))
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid hash list");
p += 2;
if (prefix)
{
char *filename;
filename = grub_xasprintf ("%s/%s", prefix, p);
if (!filename)
return grub_errno;
file = grub_file_open (filename, GRUB_FILE_TYPE_TO_HASH
| (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
: GRUB_FILE_TYPE_NONE));
grub_free (filename);
}
else
file = grub_file_open (p, GRUB_FILE_TYPE_TO_HASH
| (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
: GRUB_FILE_TYPE_NONE));
if (!file)
{
grub_file_close (hashlist);
grub_free (buf);
return grub_errno;
}
err = hash_file (file, hash, actual);
grub_file_close (file);
if (err)
{
grub_printf_ (N_("%s: READ ERROR\n"), p);
if (!keep)
{
grub_file_close (hashlist);
grub_free (buf);
return err;
}
grub_print_error ();
grub_errno = GRUB_ERR_NONE;
unread++;
continue;
}
if (grub_crypto_memcmp (expected, actual, hash->mdlen) != 0)
{
grub_printf_ (N_("%s: HASH MISMATCH\n"), p);
if (!keep)
{
grub_file_close (hashlist);
grub_free (buf);
return grub_error (GRUB_ERR_TEST_FAILURE,
"hash of '%s' mismatches", p);
}
mismatch++;
continue;
}
grub_printf_ (N_("%s: OK\n"), p);
}
if (mismatch || unread)
return grub_error (GRUB_ERR_TEST_FAILURE,
"%d files couldn't be read and hash "
"of %d files mismatches", unread, mismatch);
return GRUB_ERR_NONE;
}
static grub_err_t
grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
int argc, char **args)
{
struct grub_arg_list *state = ctxt->state;
const char *hashname = NULL;
const char *prefix = NULL;
const gcry_md_spec_t *hash;
unsigned i;
int keep = state[3].set;
int uncompress = state[4].set;
unsigned unread = 0;
for (i = 0; i < ARRAY_SIZE (aliases); i++)
if (grub_strcmp (ctxt->extcmd->cmd->name, aliases[i].name) == 0)
hashname = aliases[i].hashname;
if (state[0].set)
hashname = state[0].arg;
if (!hashname)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no hash specified");
hash = grub_crypto_lookup_md_by_name (hashname);
if (!hash)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown hash");
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
return grub_error (GRUB_ERR_BUG, "mdlen is too long");
if (state[2].set)
prefix = state[2].arg;
if (state[1].set)
{
if (argc != 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"--check is incompatible with file list");
return check_list (hash, state[1].arg, prefix, keep, uncompress);
}
for (i = 0; i < (unsigned) argc; i++)
{
GRUB_PROPERLY_ALIGNED_ARRAY (result, GRUB_CRYPTO_MAX_MDLEN);
grub_file_t file;
grub_err_t err;
unsigned j;
file = grub_file_open (args[i], GRUB_FILE_TYPE_TO_HASH
| (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
: GRUB_FILE_TYPE_NONE));
if (!file)
{
if (!keep)
return grub_errno;
grub_print_error ();
grub_errno = GRUB_ERR_NONE;
unread++;
continue;
}
err = hash_file (file, hash, result);
grub_file_close (file);
if (err)
{
if (!keep)
return err;
grub_print_error ();
grub_errno = GRUB_ERR_NONE;
unread++;
continue;
}
for (j = 0; j < hash->mdlen; j++)
grub_printf ("%02x", ((grub_uint8_t *) result)[j]);
grub_printf (" %s\n", args[i]);
}
if (unread)
return grub_error (GRUB_ERR_TEST_FAILURE, "%d files couldn't be read",
unread);
return GRUB_ERR_NONE;
}
static grub_extcmd_t cmd, cmd_md5, cmd_sha1, cmd_sha256, cmd_sha512, cmd_crc;
GRUB_MOD_INIT(hashsum)
{
cmd = grub_register_extcmd ("hashsum", grub_cmd_hashsum, 0,
N_("-h HASH [-c FILE [-p PREFIX]] "
"[FILE1 [FILE2 ...]]"),
/* TRANSLATORS: "hash checksum" is just to
be a bit more precise, you can treat it as
just "hash". */
N_("Compute or check hash checksum."),
options);
cmd_md5 = grub_register_extcmd ("md5sum", grub_cmd_hashsum, 0,
N_("[-c FILE [-p PREFIX]] "
"[FILE1 [FILE2 ...]]"),
N_("Compute or check hash checksum."),
options);
cmd_sha1 = grub_register_extcmd ("sha1sum", grub_cmd_hashsum, 0,
N_("[-c FILE [-p PREFIX]] "
"[FILE1 [FILE2 ...]]"),
N_("Compute or check hash checksum."),
options);
cmd_sha256 = grub_register_extcmd ("sha256sum", grub_cmd_hashsum, 0,
N_("[-c FILE [-p PREFIX]] "
"[FILE1 [FILE2 ...]]"),
N_("Compute or check hash checksum."),
options);
cmd_sha512 = grub_register_extcmd ("sha512sum", grub_cmd_hashsum, 0,
N_("[-c FILE [-p PREFIX]] "
"[FILE1 [FILE2 ...]]"),
N_("Compute or check hash checksum."),
options);
cmd_crc = grub_register_extcmd ("crc", grub_cmd_hashsum, 0,
N_("[-c FILE [-p PREFIX]] "
"[FILE1 [FILE2 ...]]"),
N_("Compute or check hash checksum."),
options);
}
GRUB_MOD_FINI(hashsum)
{
grub_unregister_extcmd (cmd);
grub_unregister_extcmd (cmd_md5);
grub_unregister_extcmd (cmd_sha1);
grub_unregister_extcmd (cmd_sha256);
grub_unregister_extcmd (cmd_sha512);
grub_unregister_extcmd (cmd_crc);
}

View File

@@ -0,0 +1,257 @@
/* loopback.c - command to add loopback devices. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2005,2006,2007 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/dl.h>
#include <grub/misc.h>
#include <grub/file.h>
#include <grub/disk.h>
#include <grub/mm.h>
#include <grub/extcmd.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+");
struct grub_loopback
{
char *devname;
grub_file_t file;
struct grub_loopback *next;
unsigned long id;
grub_off_t skip;
};
static struct grub_loopback *loopback_list;
static unsigned long last_id = 0;
static const struct grub_arg_option options[] =
{
/* TRANSLATORS: The disk is simply removed from the list of available ones,
not wiped, avoid to scare user. */
{"delete", 'd', 0, N_("Delete the specified loopback drive."), 0, 0},
{"skip", 's', 0, "skip sectors of the file.", "SECTORS", ARG_TYPE_INT },
{0, 0, 0, 0, 0, 0}
};
/* Delete the loopback device NAME. */
static grub_err_t
delete_loopback (const char *name)
{
struct grub_loopback *dev;
struct grub_loopback **prev;
/* Search for the device. */
for (dev = loopback_list, prev = &loopback_list;
dev;
prev = &dev->next, dev = dev->next)
if (grub_strcmp (dev->devname, name) == 0)
break;
if (! dev)
return grub_error (GRUB_ERR_BAD_DEVICE, "device not found");
/* Remove the device from the list. */
*prev = dev->next;
grub_free (dev->devname);
grub_file_close (dev->file);
grub_free (dev);
return 0;
}
/* The command to add and remove loopback devices. */
static grub_err_t
grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args)
{
struct grub_arg_list *state = ctxt->state;
grub_file_t file;
struct grub_loopback *newdev;
grub_err_t ret;
grub_off_t skip = 0;
if (argc < 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "device name required");
/* Check if `-d' was used. */
if (state[0].set)
return delete_loopback (args[0]);
if (state[1].set)
skip = (grub_off_t)grub_strtoull(state[1].arg, NULL, 10);
if (argc < 2)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
file = grub_file_open (args[1], GRUB_FILE_TYPE_LOOPBACK
| GRUB_FILE_TYPE_NO_DECOMPRESS);
if (! file)
return grub_errno;
/* First try to replace the old device. */
for (newdev = loopback_list; newdev; newdev = newdev->next)
if (grub_strcmp (newdev->devname, args[0]) == 0)
break;
if (newdev)
{
grub_file_close (newdev->file);
newdev->file = file;
newdev->skip = skip;
return 0;
}
/* Unable to replace it, make a new entry. */
newdev = grub_malloc (sizeof (struct grub_loopback));
if (! newdev)
goto fail;
newdev->devname = grub_strdup (args[0]);
if (! newdev->devname)
{
grub_free (newdev);
goto fail;
}
newdev->file = file;
newdev->skip = skip;
newdev->id = last_id++;
/* Add the new entry to the list. */
newdev->next = loopback_list;
loopback_list = newdev;
return 0;
fail:
ret = grub_errno;
grub_file_close (file);
return ret;
}
static int
grub_loopback_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
grub_disk_pull_t pull)
{
struct grub_loopback *d;
if (pull != GRUB_DISK_PULL_NONE)
return 0;
for (d = loopback_list; d; d = d->next)
{
if (hook (d->devname, hook_data))
return 1;
}
return 0;
}
static grub_err_t
grub_loopback_open (const char *name, grub_disk_t disk)
{
struct grub_loopback *dev;
for (dev = loopback_list; dev; dev = dev->next)
if (grub_strcmp (dev->devname, name) == 0)
break;
if (! dev)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
/* Use the filesize for the disk size, round up to a complete sector. */
if (dev->file->size != GRUB_FILE_SIZE_UNKNOWN)
disk->total_sectors = ((dev->file->size + GRUB_DISK_SECTOR_SIZE - 1)
/ GRUB_DISK_SECTOR_SIZE);
else
disk->total_sectors = GRUB_DISK_SIZE_UNKNOWN;
/* Avoid reading more than 512M. */
disk->max_agglomerate = 1 << (29 - GRUB_DISK_SECTOR_BITS
- GRUB_DISK_CACHE_BITS);
disk->id = dev->id;
disk->data = dev;
return 0;
}
static grub_err_t
grub_loopback_read (grub_disk_t disk, grub_disk_addr_t sector,
grub_size_t size, char *buf)
{
grub_file_t file = ((struct grub_loopback *) disk->data)->file;
grub_off_t skip = ((struct grub_loopback *) disk->data)->skip;
grub_off_t pos;
grub_file_seek (file, (sector + skip) << GRUB_DISK_SECTOR_BITS);
grub_file_read (file, buf, size << GRUB_DISK_SECTOR_BITS);
if (grub_errno)
return grub_errno;
/* In case there is more data read than there is available, in case
of files that are not a multiple of GRUB_DISK_SECTOR_SIZE, fill
the rest with zeros. */
pos = (sector + skip + size) << GRUB_DISK_SECTOR_BITS;
if (pos > file->size)
{
grub_size_t amount = pos - file->size;
grub_memset (buf + (size << GRUB_DISK_SECTOR_BITS) - amount, 0, amount);
}
return 0;
}
static grub_err_t
grub_loopback_write (grub_disk_t disk __attribute ((unused)),
grub_disk_addr_t sector __attribute ((unused)),
grub_size_t size __attribute ((unused)),
const char *buf __attribute ((unused)))
{
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"loopback write is not supported");
}
static struct grub_disk_dev grub_loopback_dev =
{
.name = "loopback",
.id = GRUB_DISK_DEVICE_LOOPBACK_ID,
.disk_iterate = grub_loopback_iterate,
.disk_open = grub_loopback_open,
.disk_read = grub_loopback_read,
.disk_write = grub_loopback_write,
.next = 0
};
static grub_extcmd_t cmd;
GRUB_MOD_INIT(loopback)
{
cmd = grub_register_extcmd ("loopback", grub_cmd_loopback, 0,
N_("[-d] DEVICENAME FILE."),
/* TRANSLATORS: The file itself is not destroyed
or transformed into drive. */
N_("Make a virtual drive from a file."), options);
grub_disk_dev_register (&grub_loopback_dev);
}
GRUB_MOD_FINI(loopback)
{
grub_unregister_extcmd (cmd);
grub_disk_dev_unregister (&grub_loopback_dev);
}

View File

@@ -28,6 +28,8 @@
extern int g_ventoy_memdisk_mode; extern int g_ventoy_memdisk_mode;
extern int g_ventoy_iso_raw; extern int g_ventoy_iso_raw;
extern int g_ventoy_grub2_mode;
extern int g_ventoy_wimboot_mode;
extern int g_ventoy_iso_uefi_drv; extern int g_ventoy_iso_uefi_drv;
static const char *align_options[] = static const char *align_options[] =
@@ -205,6 +207,12 @@ label_set_property (void *vself, const char *name, const char *value)
else if (grub_strcmp (value, "@VTOY_ISO_RAW@") == 0) { else if (grub_strcmp (value, "@VTOY_ISO_RAW@") == 0) {
value = g_ventoy_iso_raw ? grub_env_get("VTOY_ISO_RAW_STR") : " "; value = g_ventoy_iso_raw ? grub_env_get("VTOY_ISO_RAW_STR") : " ";
} }
else if (grub_strcmp (value, "@VTOY_GRUB2_MODE@") == 0) {
value = g_ventoy_grub2_mode ? grub_env_get("VTOY_GRUB2_MODE_STR") : " ";
}
else if (grub_strcmp (value, "@VTOY_WIMBOOT_MODE@") == 0) {
value = g_ventoy_wimboot_mode ? grub_env_get("VTOY_WIMBOOT_MODE_STR") : " ";
}
else if (grub_strcmp (value, "@VTOY_ISO_UEFI_DRV@") == 0) { else if (grub_strcmp (value, "@VTOY_ISO_UEFI_DRV@") == 0) {
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") : " ";
} }

View File

@@ -964,3 +964,20 @@ void * grub_efi_allocate_iso_buf(grub_uint64_t size)
return (void *)(unsigned long)address; return (void *)(unsigned long)address;
} }
void * grub_efi_allocate_chain_buf(grub_uint64_t size)
{
grub_efi_boot_services_t *b;
grub_efi_status_t status;
grub_efi_physical_address_t address = 0;
grub_efi_uintn_t pages = GRUB_EFI_BYTES_TO_PAGES(size);
b = grub_efi_system_table->boot_services;
status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_ANY_PAGES, GRUB_EFI_LOADER_DATA, pages, &address);
if (status != GRUB_EFI_SUCCESS)
{
return NULL;
}
return (void *)(unsigned long)address;
}

View File

@@ -0,0 +1,316 @@
#include <grub/types.h>
#include <grub/err.h>
#include <grub/linux.h>
#include <grub/misc.h>
#include <grub/file.h>
#include <grub/mm.h>
#include <grub/env.h>
#include <grub/term.h>
struct newc_head
{
char magic[6];
char ino[8];
char mode[8];
char uid[8];
char gid[8];
char nlink[8];
char mtime[8];
char filesize[8];
char devmajor[8];
char devminor[8];
char rdevmajor[8];
char rdevminor[8];
char namesize[8];
char check[8];
} GRUB_PACKED;
struct grub_linux_initrd_component
{
grub_file_t file;
char *newc_name;
grub_off_t size;
};
struct dir
{
char *name;
struct dir *next;
struct dir *child;
};
static char
hex (grub_uint8_t val)
{
if (val < 10)
return '0' + val;
return 'a' + val - 10;
}
static void
set_field (char *var, grub_uint32_t val)
{
int i;
char *ptr = var;
for (i = 28; i >= 0; i -= 4)
*ptr++ = hex((val >> i) & 0xf);
}
static grub_uint8_t *
make_header (grub_uint8_t *ptr,
const char *name, grub_size_t len,
grub_uint32_t mode,
grub_off_t fsize)
{
struct newc_head *head = (struct newc_head *) ptr;
grub_uint8_t *optr;
grub_size_t oh = 0;
grub_memcpy (head->magic, "070701", 6);
set_field (head->ino, 0);
set_field (head->mode, mode);
set_field (head->uid, 0);
set_field (head->gid, 0);
set_field (head->nlink, 1);
set_field (head->mtime, 0);
set_field (head->filesize, fsize);
set_field (head->devmajor, 0);
set_field (head->devminor, 0);
set_field (head->rdevmajor, 0);
set_field (head->rdevminor, 0);
set_field (head->namesize, len);
set_field (head->check, 0);
optr = ptr;
ptr += sizeof (struct newc_head);
grub_memcpy (ptr, name, len);
ptr += len;
oh = ALIGN_UP_OVERHEAD (ptr - optr, 4);
grub_memset (ptr, 0, oh);
ptr += oh;
return ptr;
}
static void
free_dir (struct dir *root)
{
if (!root)
return;
free_dir (root->next);
free_dir (root->child);
grub_free (root->name);
grub_free (root);
}
static grub_size_t
insert_dir (const char *name, struct dir **root,
grub_uint8_t *ptr)
{
struct dir *cur, **head = root;
const char *cb, *ce = name;
grub_size_t size = 0;
while (1)
{
for (cb = ce; *cb == '/'; cb++);
for (ce = cb; *ce && *ce != '/'; ce++);
if (!*ce)
break;
for (cur = *root; cur; cur = cur->next)
if (grub_memcmp (cur->name, cb, ce - cb)
&& cur->name[ce - cb] == 0)
break;
if (!cur)
{
struct dir *n;
n = grub_zalloc (sizeof (*n));
if (!n)
return 0;
n->next = *head;
n->name = grub_strndup (cb, ce - cb);
if (ptr)
{
grub_dprintf ("linux", "Creating directory %s, %s\n", name, ce);
ptr = make_header (ptr, name, ce - name,
040777, 0);
}
size += ALIGN_UP ((ce - (char *) name)
+ sizeof (struct newc_head), 4);
*head = n;
cur = n;
}
root = &cur->next;
}
return size;
}
grub_err_t
grub_initrd_init (int argc, char *argv[],
struct grub_linux_initrd_context *initrd_ctx)
{
int i;
int newc = 0;
struct dir *root = 0;
initrd_ctx->nfiles = 0;
initrd_ctx->components = 0;
initrd_ctx->components = grub_zalloc (argc
* sizeof (initrd_ctx->components[0]));
if (!initrd_ctx->components)
return grub_errno;
initrd_ctx->size = 0;
for (i = 0; i < argc; i++)
{
const char *fname = argv[i];
initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4);
if (grub_memcmp (argv[i], "newc:", 5) == 0)
{
const char *ptr, *eptr;
ptr = argv[i] + 5;
while (*ptr == '/')
ptr++;
eptr = grub_strchr (ptr, ':');
if (eptr)
{
initrd_ctx->components[i].newc_name = grub_strndup (ptr, eptr - ptr);
if (!initrd_ctx->components[i].newc_name)
{
grub_initrd_close (initrd_ctx);
return grub_errno;
}
initrd_ctx->size
+= ALIGN_UP (sizeof (struct newc_head)
+ grub_strlen (initrd_ctx->components[i].newc_name),
4);
initrd_ctx->size += insert_dir (initrd_ctx->components[i].newc_name,
&root, 0);
newc = 1;
fname = eptr + 1;
}
}
else if (newc)
{
initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
+ sizeof ("TRAILER!!!") - 1, 4);
free_dir (root);
root = 0;
newc = 0;
}
initrd_ctx->components[i].file = grub_file_open (fname,
GRUB_FILE_TYPE_LINUX_INITRD
| GRUB_FILE_TYPE_NO_DECOMPRESS);
if (!initrd_ctx->components[i].file)
{
grub_initrd_close (initrd_ctx);
return grub_errno;
}
initrd_ctx->nfiles++;
initrd_ctx->components[i].size
= grub_file_size (initrd_ctx->components[i].file);
initrd_ctx->size += initrd_ctx->components[i].size;
}
if (newc)
{
initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4);
initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
+ sizeof ("TRAILER!!!") - 1, 4);
free_dir (root);
root = 0;
}
return GRUB_ERR_NONE;
}
grub_size_t
grub_get_initrd_size (struct grub_linux_initrd_context *initrd_ctx)
{
return initrd_ctx->size;
}
void
grub_initrd_close (struct grub_linux_initrd_context *initrd_ctx)
{
int i;
if (!initrd_ctx->components)
return;
for (i = 0; i < initrd_ctx->nfiles; i++)
{
grub_free (initrd_ctx->components[i].newc_name);
grub_file_close (initrd_ctx->components[i].file);
}
grub_free (initrd_ctx->components);
initrd_ctx->components = 0;
}
extern int ventoy_need_prompt_load_file(void);
extern grub_ssize_t ventoy_load_file_with_prompt(grub_file_t file, void *buf, grub_ssize_t size);
grub_err_t
grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
char *argv[], void *target)
{
grub_uint8_t *ptr = target;
int i;
int newc = 0;
struct dir *root = 0;
grub_ssize_t cursize = 0;
grub_ssize_t readsize = 0;
for (i = 0; i < initrd_ctx->nfiles; i++)
{
grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
ptr += ALIGN_UP_OVERHEAD (cursize, 4);
if (initrd_ctx->components[i].newc_name)
{
ptr += insert_dir (initrd_ctx->components[i].newc_name,
&root, ptr);
ptr = make_header (ptr, initrd_ctx->components[i].newc_name,
grub_strlen (initrd_ctx->components[i].newc_name),
0100777,
initrd_ctx->components[i].size);
newc = 1;
}
else if (newc)
{
ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1,
0, 0);
free_dir (root);
root = 0;
newc = 0;
}
cursize = initrd_ctx->components[i].size;
if (ventoy_need_prompt_load_file() && initrd_ctx->components[i].newc_name &&
grub_strcmp(initrd_ctx->components[i].newc_name, "boot.wim") == 0)
{
readsize = ventoy_load_file_with_prompt(initrd_ctx->components[i].file, ptr, cursize);
}
else
{
readsize = grub_file_read (initrd_ctx->components[i].file, ptr, cursize);
}
if (readsize != cursize)
{
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
argv[i]);
grub_initrd_close (initrd_ctx);
return grub_errno;
}
ptr += cursize;
}
if (newc)
{
grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
ptr += ALIGN_UP_OVERHEAD (cursize, 4);
ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0);
}
free_dir (root);
root = 0;
return GRUB_ERR_NONE;
}

View File

@@ -37,11 +37,14 @@
int g_ventoy_menu_refresh = 0; int g_ventoy_menu_refresh = 0;
int g_ventoy_memdisk_mode = 0; int g_ventoy_memdisk_mode = 0;
int g_ventoy_iso_raw = 0; int g_ventoy_iso_raw = 0;
int g_ventoy_grub2_mode = 0;
int g_ventoy_wimboot_mode = 0;
int g_ventoy_iso_uefi_drv = 0; int g_ventoy_iso_uefi_drv = 0;
int g_ventoy_last_entry = -1; int g_ventoy_last_entry = -1;
int g_ventoy_suppress_esc = 0; int g_ventoy_suppress_esc = 0;
int g_ventoy_menu_esc = 0; int g_ventoy_menu_esc = 0;
int g_ventoy_fn_mutex = 0; int g_ventoy_fn_mutex = 0;
int g_ventoy_terminal_output = 0;
/* Time to delay after displaying an error message about a default/fallback /* Time to delay after displaying an error message about a default/fallback
entry failing to boot. */ entry failing to boot. */
@@ -871,15 +874,18 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
} }
break; break;
case GRUB_TERM_KEY_F7: case GRUB_TERM_KEY_F7:
case '7': menu_fini ();
cmdstr = grub_env_get("VTOY_F7_CMD"); if (g_ventoy_terminal_output == 0)
if (cmdstr)
{ {
menu_fini (); grub_script_execute_sourcecode("terminal_output console");
grub_script_execute_sourcecode(cmdstr); g_ventoy_terminal_output = 1;
goto refresh;
} }
break; else
{
grub_script_execute_sourcecode("terminal_output gfxterm");
g_ventoy_terminal_output = 0;
}
goto refresh;
case GRUB_TERM_KEY_F1: case GRUB_TERM_KEY_F1:
case '1': case '1':
menu_fini (); menu_fini ();
@@ -893,6 +899,18 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
g_ventoy_menu_refresh = 1; g_ventoy_menu_refresh = 1;
goto refresh; goto refresh;
case (GRUB_TERM_CTRL | 'r'):
menu_fini ();
g_ventoy_grub2_mode = 1 - g_ventoy_grub2_mode;
g_ventoy_menu_refresh = 1;
goto refresh;
case (GRUB_TERM_CTRL | 'w'):
menu_fini ();
g_ventoy_wimboot_mode = 1 - g_ventoy_wimboot_mode;
g_ventoy_menu_refresh = 1;
goto refresh;
case (GRUB_TERM_CTRL | 'u'): case (GRUB_TERM_CTRL | 'u'):
menu_fini (); menu_fini ();
g_ventoy_iso_uefi_drv = 1 - g_ventoy_iso_uefi_drv; g_ventoy_iso_uefi_drv = 1 - g_ventoy_iso_uefi_drv;

View File

@@ -0,0 +1,795 @@
#define ventoy_keyboard_set_layout(name) if (grub_strcmp(layout, #name) == 0) return ventoy_keyboard_layout_##name()
static void ventoy_keyboard_layout_QWERTY_USA(void) {
grub_keymap_reset();
grub_keymap_disable();
}
static void ventoy_keyboard_layout_AZERTY(void) {
grub_keymap_reset();
grub_keymap_add_by_string("a", "q");
grub_keymap_add_by_string("A", "Q");
grub_keymap_add_by_string("z", "w");
grub_keymap_add_by_string("Z", "W");
grub_keymap_add_by_string("q", "a");
grub_keymap_add_by_string("Q", "A");
grub_keymap_add_by_string("m", "semicolon");
grub_keymap_add_by_string("M", "colon");
grub_keymap_add_by_string("w", "z");
grub_keymap_add_by_string("W", "Z");
grub_keymap_add_by_string("comma", "m");
grub_keymap_add_by_string("question", "M");
grub_keymap_add_by_string("semicolon", "comma");
grub_keymap_add_by_string("period", "less");
grub_keymap_add_by_string("colon", "period");
grub_keymap_add_by_string("slash", "greater");
grub_keymap_add_by_string("exclam", "slash");
grub_keymap_add_by_string("dollar", "bracketright");
grub_keymap_add_by_string("asterisk", "backslash");
grub_keymap_add_by_string("percent", "doublequote");
grub_keymap_add_by_string("ampersand", "1");
grub_keymap_add_by_string("1", "exclam");
grub_keymap_add_by_string("tilde", "2");
grub_keymap_add_by_string("2", "at");
grub_keymap_add_by_string("doublequote", "3");
grub_keymap_add_by_string("3", "numbersign");
grub_keymap_add_by_string("quote", "4");
grub_keymap_add_by_string("4", "dollar");
grub_keymap_add_by_string("parenleft", "5");
grub_keymap_add_by_string("5", "percent");
grub_keymap_add_by_string("minus", "6");
grub_keymap_add_by_string("6", "caret");
grub_keymap_add_by_string("backquote", "7");
grub_keymap_add_by_string("7", "ampersand");
grub_keymap_add_by_string("underscore", "8");
grub_keymap_add_by_string("8", "asterisk");
grub_keymap_add_by_string("caret", "9");
grub_keymap_add_by_string("9", "parenleft");
grub_keymap_add_by_string("at", "0");
grub_keymap_add_by_string("0", "parenright");
grub_keymap_add_by_string("parenright", "minus");
grub_keymap_add_by_string("less", "backquote");
grub_keymap_add_by_string("greater", "tilde");
grub_keymap_add_by_string("numbersign", "braceright");
grub_keymap_add_by_string("backslash", "question");
grub_keymap_add_by_string("bracketright", "braceleft");
grub_keymap_add_by_string("braceleft", "quote");
grub_keymap_add_by_string("braceright", "underscore");
grub_keymap_enable();
}
static void ventoy_keyboard_layout_CZECH_QWERTY(void) {
grub_keymap_reset();
grub_keymap_add_by_string("semicolon", "backquote");
grub_keymap_add_by_string("plus", "1");
grub_keymap_add_by_string("equal", "minus");
grub_keymap_add_by_string("quote", "equal");
grub_keymap_add_by_string("parenright", "bracketright");
grub_keymap_add_by_string("doublequote", "backslash");
grub_keymap_add_by_string("minus", "slash");
grub_keymap_add_by_string("1", "exclam");
grub_keymap_add_by_string("2", "at");
grub_keymap_add_by_string("3", "numbersign");
grub_keymap_add_by_string("4", "dollar");
grub_keymap_add_by_string("5", "percent");
grub_keymap_add_by_string("6", "caret");
grub_keymap_add_by_string("7", "ampersand");
grub_keymap_add_by_string("8", "asterisk");
grub_keymap_add_by_string("9", "parenleft");
grub_keymap_add_by_string("0", "parenright");
grub_keymap_add_by_string("percent", "underscore");
grub_keymap_add_by_string("slash", "braceleft");
grub_keymap_add_by_string("parenleft", "braceright");
grub_keymap_add_by_string("doublequote", "colon");
grub_keymap_add_by_string("exclam", "doublequote");
grub_keymap_add_by_string("quote", "bar");
grub_keymap_add_by_string("question", "less");
grub_keymap_add_by_string("colon", "greater");
grub_keymap_add_by_string("underscore", "question");
grub_keymap_add_by_string("backquote", "Abackquote");
grub_keymap_add_by_string("exclam", "A1");
grub_keymap_add_by_string("at", "A2");
grub_keymap_add_by_string("numbersign", "A3");
grub_keymap_add_by_string("dollar", "A4");
grub_keymap_add_by_string("percent", "A5");
grub_keymap_add_by_string("caret", "A6");
grub_keymap_add_by_string("ampersand", "A7");
grub_keymap_add_by_string("asterisk", "A8");
grub_keymap_add_by_string("parenleft", "A9");
grub_keymap_add_by_string("parenright", "A0");
grub_keymap_add_by_string("minus", "Aminus");
grub_keymap_add_by_string("equal", "Aequal");
grub_keymap_add_by_string("bracketleft", "Abracketleft");
grub_keymap_add_by_string("bracketright", "Abracketright");
grub_keymap_add_by_string("semicolon", "Asemicolon");
grub_keymap_add_by_string("backslash", "Abackslash");
grub_keymap_add_by_string("less", "Acomma");
grub_keymap_add_by_string("greater", "Aperiod");
grub_keymap_add_by_string("slash", "Aslash");
grub_keymap_add_by_string("tilde", "Atilde");
grub_keymap_add_by_string("underscore", "Aunderscore");
grub_keymap_add_by_string("plus", "Aplus");
grub_keymap_add_by_string("braceleft", "Abraceleft");
grub_keymap_add_by_string("braceright", "Abraceright");
grub_keymap_add_by_string("caret", "Adoublequote");
grub_keymap_add_by_string("colon", "Acolon");
grub_keymap_add_by_string("question", "Aquestion");
grub_keymap_add_by_string("bar", "Abar");
grub_keymap_enable();
}
static void ventoy_keyboard_layout_CZECH_QWERTZ(void) {
grub_keymap_reset();
grub_keymap_add_by_string("y", "z");
grub_keymap_add_by_string("z", "y");
grub_keymap_add_by_string("Y", "Z");
grub_keymap_add_by_string("Z", "Y");
grub_keymap_add_by_string("semicolon", "backquote");
grub_keymap_add_by_string("plus", "1");
grub_keymap_add_by_string("equal", "minus");
grub_keymap_add_by_string("quote", "equal");
grub_keymap_add_by_string("parenright", "bracketright");
grub_keymap_add_by_string("doublequote", "backslash");
grub_keymap_add_by_string("minus", "slash");
grub_keymap_add_by_string("1", "exclam");
grub_keymap_add_by_string("2", "at");
grub_keymap_add_by_string("3", "numbersign");
grub_keymap_add_by_string("4", "dollar");
grub_keymap_add_by_string("5", "percent");
grub_keymap_add_by_string("6", "caret");
grub_keymap_add_by_string("7", "ampersand");
grub_keymap_add_by_string("8", "asterisk");
grub_keymap_add_by_string("9", "parenleft");
grub_keymap_add_by_string("0", "parenright");
grub_keymap_add_by_string("percent", "underscore");
grub_keymap_add_by_string("slash", "braceleft");
grub_keymap_add_by_string("parenleft", "braceright");
grub_keymap_add_by_string("doublequote", "colon");
grub_keymap_add_by_string("exclam", "doublequote");
grub_keymap_add_by_string("quote", "bar");
grub_keymap_add_by_string("question", "less");
grub_keymap_add_by_string("colon", "greater");
grub_keymap_add_by_string("underscore", "question");
grub_keymap_add_by_string("tilde", "A1");
grub_keymap_add_by_string("caret", "A3");
grub_keymap_add_by_string("backslash", "Aq");
grub_keymap_add_by_string("bar", "Aw");
grub_keymap_add_by_string("bracketleft", "Af");
grub_keymap_add_by_string("bracketright", "Ag");
grub_keymap_add_by_string("dollar", "Asemicolon");
grub_keymap_add_by_string("numbersign", "Ax");
grub_keymap_add_by_string("ampersand", "Ac");
grub_keymap_add_by_string("at", "Av");
grub_keymap_add_by_string("braceleft", "Ab");
grub_keymap_add_by_string("braceright", "An");
grub_keymap_add_by_string("less", "Acomma");
grub_keymap_add_by_string("greater", "Aperiod");
grub_keymap_add_by_string("asterisk", "Aslash");
grub_keymap_enable();
}
static void ventoy_keyboard_layout_DANISH(void) {
grub_keymap_reset();
grub_keymap_add_by_string("plus", "minus");
grub_keymap_add_by_string("quote", "equal");
grub_keymap_add_by_string("doublequote", "bracketright");
grub_keymap_add_by_string("quote", "backslash");
grub_keymap_add_by_string("minus", "slash");
grub_keymap_add_by_string("doublequote", "at");
grub_keymap_add_by_string("ampersand", "caret");
grub_keymap_add_by_string("slash", "ampersand");
grub_keymap_add_by_string("parenleft", "asterisk");
grub_keymap_add_by_string("parenright", "parenleft");
grub_keymap_add_by_string("equal", "parenright");
grub_keymap_add_by_string("question", "underscore");
grub_keymap_add_by_string("caret", "braceright");
grub_keymap_add_by_string("asterisk", "bar");
grub_keymap_add_by_string("backquote", "plus");
grub_keymap_add_by_string("semicolon", "less");
grub_keymap_add_by_string("colon", "greater");
grub_keymap_add_by_string("underscore", "question");
grub_keymap_add_by_string("bar", "Atilde");
grub_keymap_add_by_string("backslash", "Abackquote");
grub_keymap_add_by_string("greater", "tilde");
grub_keymap_add_by_string("at", "A2");
grub_keymap_add_by_string("dollar", "A4");
grub_keymap_add_by_string("braceleft", "A7");
grub_keymap_add_by_string("bracketleft", "A8");
grub_keymap_add_by_string("bracketright", "A9");
grub_keymap_add_by_string("braceright", "A0");
grub_keymap_add_by_string("backslash", "Aminus");
grub_keymap_add_by_string("less", "quote");
grub_keymap_add_by_string("greater", "doublequote");
grub_keymap_add_by_string("tilde", "Abracketright");
grub_keymap_enable();
}
static void ventoy_keyboard_layout_DVORAK_USA(void) {
grub_keymap_reset();
grub_keymap_add_by_string("[", "minus");
grub_keymap_add_by_string("braceleft", "underscore");
grub_keymap_add_by_string("quote", "q");
grub_keymap_add_by_string("doublequote", "Q");
grub_keymap_add_by_string("comma", "w");
grub_keymap_add_by_string("less", "W");
grub_keymap_add_by_string("s", "semicolon");
grub_keymap_add_by_string("S", "colon");
grub_keymap_add_by_string("semicolon", "z");
grub_keymap_add_by_string("colon", "Z");
grub_keymap_add_by_string("w", "comma");
grub_keymap_add_by_string("W", "less");
grub_keymap_add_by_string("v", "period");
grub_keymap_add_by_string("z", "greater");
grub_keymap_add_by_string("z", "slash");
grub_keymap_add_by_string("equal", "bracketright");
grub_keymap_add_by_string("backslash", "backslash");
grub_keymap_add_by_string("underscore", "doublequote");
grub_keymap_add_by_string("quote", "q");
grub_keymap_add_by_string("doublequote", "Q");
grub_keymap_add_by_string("comma", "w");
grub_keymap_add_by_string("less", "W");
grub_keymap_add_by_string("period", "e");
grub_keymap_add_by_string("greater", "E");
grub_keymap_add_by_string("p", "r");
grub_keymap_add_by_string("P", "R");
grub_keymap_add_by_string("y", "t");
grub_keymap_add_by_string("Y", "T");
grub_keymap_add_by_string("f", "y");
grub_keymap_add_by_string("F", "Y");
grub_keymap_add_by_string("g", "u");
grub_keymap_add_by_string("G", "U");
grub_keymap_add_by_string("c", "c");
grub_keymap_add_by_string("C", "I");
grub_keymap_add_by_string("r", "o");
grub_keymap_add_by_string("R", "O");
grub_keymap_add_by_string("l", "p");
grub_keymap_add_by_string("L", "P");
grub_keymap_add_by_string("bracketright", "equal");
grub_keymap_add_by_string("braceright", "plus");
grub_keymap_add_by_string("a", "a");
grub_keymap_add_by_string("A", "A");
grub_keymap_add_by_string("o", "s");
grub_keymap_add_by_string("O", "S");
grub_keymap_add_by_string("e", "d");
grub_keymap_add_by_string("E", "D");
grub_keymap_add_by_string("u", "f");
grub_keymap_add_by_string("U", "F");
grub_keymap_add_by_string("i", "g");
grub_keymap_add_by_string("I", "G");
grub_keymap_add_by_string("d", "h");
grub_keymap_add_by_string("D", "H");
grub_keymap_add_by_string("h", "j");
grub_keymap_add_by_string("H", "J");
grub_keymap_add_by_string("t", "k");
grub_keymap_add_by_string("T", "K");
grub_keymap_add_by_string("n", "l");
grub_keymap_add_by_string("N", "L");
grub_keymap_add_by_string("s", "semicolon");
grub_keymap_add_by_string("S", "colon");
grub_keymap_add_by_string("minus", "quote");
grub_keymap_add_by_string("underscore", "doublequote");
grub_keymap_add_by_string("semicolon", "z");
grub_keymap_add_by_string("colon", "Z");
grub_keymap_add_by_string("q", "x");
grub_keymap_add_by_string("Q", "X");
grub_keymap_add_by_string("j", "c");
grub_keymap_add_by_string("J", "C");
grub_keymap_add_by_string("k", "v");
grub_keymap_add_by_string("K", "V");
grub_keymap_add_by_string("x", "b");
grub_keymap_add_by_string("X", "B");
grub_keymap_add_by_string("b", "n");
grub_keymap_add_by_string("B", "N");
grub_keymap_add_by_string("w", "comma");
grub_keymap_add_by_string("W", "less");
grub_keymap_add_by_string("v", "period");
grub_keymap_add_by_string("V", "greater");
grub_keymap_add_by_string("z", "slash");
grub_keymap_add_by_string("Z", "question");
grub_keymap_add_by_string("slash", "bracketleft");
grub_keymap_add_by_string("question", "braceleft");
grub_keymap_add_by_string("equal", "bracketright");
grub_keymap_add_by_string("plus", "braceright");
grub_keymap_enable();
}
static void ventoy_keyboard_layout_FRENCH(void) {
grub_keymap_reset();
grub_keymap_add_by_string("less", "backquote");
grub_keymap_add_by_string("greater", "tilde");
grub_keymap_add_by_string("ampersand", "1");
grub_keymap_add_by_string("1", "exclam");
grub_keymap_add_by_string("tilde", "2");
grub_keymap_add_by_string("2", "at");
grub_keymap_add_by_string("doublequote", "3");
grub_keymap_add_by_string("3", "numbersign");
grub_keymap_add_by_string("quote", "4");
grub_keymap_add_by_string("4", "dollar");
grub_keymap_add_by_string("parenleft", "5");
grub_keymap_add_by_string("5", "percent");
grub_keymap_add_by_string("minus", "6");
grub_keymap_add_by_string("6", "caret");
grub_keymap_add_by_string("backquote", "7");
grub_keymap_add_by_string("7", "ampersand");
grub_keymap_add_by_string("underscore", "8");
grub_keymap_add_by_string("8", "asterisk");
grub_keymap_add_by_string("backslash", "9");
grub_keymap_add_by_string("9", "parenleft");
grub_keymap_add_by_string("at", "0");
grub_keymap_add_by_string("0", "parenright");
grub_keymap_add_by_string("parenright", "minus");
grub_keymap_add_by_string("numbersign", "underscore");
grub_keymap_add_by_string("a", "q");
grub_keymap_add_by_string("A", "Q");
grub_keymap_add_by_string("z", "w");
grub_keymap_add_by_string("Z", "W");
grub_keymap_add_by_string("caret", "bracketleft");
grub_keymap_add_by_string("dollar", "bracketright");
grub_keymap_add_by_string("q", "a");
grub_keymap_add_by_string("Q", "A");
grub_keymap_add_by_string("m", "semicolon");
grub_keymap_add_by_string("M", "colon");
grub_keymap_add_by_string("bracketleft", "quote");
grub_keymap_add_by_string("percent", "doublequote");
grub_keymap_add_by_string("asterisk", "backslash");
grub_keymap_add_by_string("bracketright", "bar");
grub_keymap_add_by_string("w", "z");
grub_keymap_add_by_string("W", "Z");
grub_keymap_add_by_string("comma", "m");
grub_keymap_add_by_string("question", "M");
grub_keymap_add_by_string("semicolon", "comma");
grub_keymap_add_by_string("period", "less");
grub_keymap_add_by_string("colon", "period");
grub_keymap_add_by_string("slash", "greater");
grub_keymap_add_by_string("exclam", "slash");
grub_keymap_add_by_string("bar", "question");
grub_keymap_add_by_string("tilde", "A2");
grub_keymap_add_by_string("numbersign", "A3");
grub_keymap_add_by_string("braceleft", "A4");
grub_keymap_add_by_string("bracketleft", "A5");
grub_keymap_add_by_string("bar", "A6");
grub_keymap_add_by_string("quote", "A7");
grub_keymap_add_by_string("backslash", "A8");
grub_keymap_add_by_string("caret", "A9");
grub_keymap_add_by_string("at", "A0");
grub_keymap_add_by_string("bracketright", "Aminus");
grub_keymap_add_by_string("braceright", "Aequal");
grub_keymap_enable();
}
static void ventoy_keyboard_layout_GERMAN(void) {
grub_keymap_reset();
grub_keymap_add_by_string("doublequote", "at");
grub_keymap_add_by_string("ampersand", "caret");
grub_keymap_add_by_string("slash", "ampersand");
grub_keymap_add_by_string("parenleft", "asterisk");
grub_keymap_add_by_string("parenright", "parenleft");
grub_keymap_add_by_string("equal", "parenright");
grub_keymap_add_by_string("question", "underscore");
grub_keymap_add_by_string("backslash", "minus");
grub_keymap_add_by_string("z", "y");
grub_keymap_add_by_string("Z", "Y");
grub_keymap_add_by_string("y", "z");
grub_keymap_add_by_string("Y", "Z");
grub_keymap_add_by_string("plus", "bracketright");
grub_keymap_add_by_string("asterisk", "braceright");
grub_keymap_add_by_string("semicolon", "less");
grub_keymap_add_by_string("colon", "greater");
grub_keymap_add_by_string("minus", "slash");
grub_keymap_add_by_string("backslash", "Aminus");
grub_keymap_add_by_string("underscore", "question");
grub_keymap_add_by_string("caret", "backquote");
grub_keymap_add_by_string("quote", "equal");
grub_keymap_add_by_string("backquote", "plus");
grub_keymap_add_by_string("braceright", "doublequote");
grub_keymap_add_by_string("bar", "bracketleft");
grub_keymap_add_by_string("at", "braceleft");
grub_keymap_add_by_string("numbersign", "backslash");
grub_keymap_add_by_string("at", "Aq");
grub_keymap_add_by_string("less", "backquote");
grub_keymap_add_by_string("greater", "tilde");
grub_keymap_add_by_string("braceleft", "A7");
grub_keymap_add_by_string("bracketleft", "A8");
grub_keymap_add_by_string("bracketright", "A9");
grub_keymap_add_by_string("braceright", "A0");
grub_keymap_add_by_string("tilde", "Abracketright");
grub_keymap_add_by_string("backslash", "Aminus");
grub_keymap_add_by_string("quote", "bar");
grub_keymap_add_by_string("greater", "semicolon");
grub_keymap_add_by_string("less", "colon");
grub_keymap_add_by_string("bar", "quote");
grub_keymap_enable();
}
static void ventoy_keyboard_layout_ITALIANO(void) {
grub_keymap_reset();
grub_keymap_add_by_string("backslash", "backquote");
grub_keymap_add_by_string("bar", "tilde");
grub_keymap_add_by_string("doublequote", "at");
grub_keymap_add_by_string("tilde", "numbersign");
grub_keymap_add_by_string("ampersand", "caret");
grub_keymap_add_by_string("slash", "ampersand");
grub_keymap_add_by_string("parenleft", "asterisk");
grub_keymap_add_by_string("parenright", "parenleft");
grub_keymap_add_by_string("equal", "parenright");
grub_keymap_add_by_string("quote", "minus");
grub_keymap_add_by_string("question", "underscore");
grub_keymap_add_by_string("caret", "plus");
grub_keymap_add_by_string("bracketleft", "bracketleft");
grub_keymap_add_by_string("bracketright", "braceleft");
grub_keymap_add_by_string("plus", "bracketright");
grub_keymap_add_by_string("asterisk", "braceright");
grub_keymap_add_by_string("at", "semicolon");
grub_keymap_add_by_string("braceleft", "colon");
grub_keymap_add_by_string("numbersign", "quote");
grub_keymap_add_by_string("braceright", "doublequote");
grub_keymap_add_by_string("less", "backslash");
grub_keymap_add_by_string("greater", "bar");
grub_keymap_add_by_string("minus", "slash");
grub_keymap_add_by_string("underscore", "question");
grub_keymap_add_by_string("semicolon", "less");
grub_keymap_add_by_string("colon", "greater");
grub_keymap_add_by_string("bracketleft", "Abracketleft");
grub_keymap_add_by_string("bracketright", "Abracketright");
grub_keymap_add_by_string("at", "Asemicolon");
grub_keymap_add_by_string("numbersign", "Aquote");
grub_keymap_add_by_string("braceright", "Abraceright");
grub_keymap_add_by_string("braceleft", "Abraceleft");
grub_keymap_enable();
}
static void ventoy_keyboard_layout_JAPAN_106(void) {
grub_keymap_reset();
grub_keymap_add_by_string("at", "bracketleft");
grub_keymap_add_by_string("doublequote", "at");
grub_keymap_add_by_string("ampersand", "caret");
grub_keymap_add_by_string("quote", "ampersand");
grub_keymap_add_by_string("parenleft", "asterisk");
grub_keymap_add_by_string("parenright", "parenleft");
grub_keymap_add_by_string("underscore", "parenright");
grub_keymap_add_by_string("equal", "underscore");
grub_keymap_add_by_string("plus", "colon");
grub_keymap_add_by_string("colon", "quote");
grub_keymap_add_by_string("asterisk", "doublequote");
grub_keymap_add_by_string("bracketleft", "bracketright");
grub_keymap_add_by_string("braceleft", "braceright");
grub_keymap_add_by_string("bracketright", "backslash");
grub_keymap_add_by_string("braceright", "bar");
grub_keymap_add_by_string("backslash", "backquote");
grub_keymap_add_by_string("tilde", "plus");
grub_keymap_add_by_string("caret", "equal");
grub_keymap_add_by_string("backquote", "braceleft");
grub_keymap_add_by_string("bar", "tilde");
grub_keymap_enable();
}
static void ventoy_keyboard_layout_LATIN_USA(void) {
grub_keymap_reset();
grub_keymap_add_by_string("bar", "backquote");
grub_keymap_add_by_string("quote", "minus");
grub_keymap_add_by_string("question", "underscore");
grub_keymap_add_by_string("backquote", "bracketleft");
grub_keymap_add_by_string("plus", "bracketright");
grub_keymap_add_by_string("braceleft", "quote");
grub_keymap_add_by_string("braceright", "backslash");
grub_keymap_add_by_string("minus", "slash");
grub_keymap_add_by_string("ampersand", "caret");
grub_keymap_add_by_string("doublequote", "at");
grub_keymap_add_by_string("slash", "ampersand");
grub_keymap_add_by_string("parenleft", "asterisk");
grub_keymap_add_by_string("parenright", "parenleft");
grub_keymap_add_by_string("equal", "parenright");
grub_keymap_add_by_string("asterisk", "braceright");
grub_keymap_add_by_string("bracketleft", "doublequote");
grub_keymap_add_by_string("bracketright", "bar");
grub_keymap_add_by_string("semicolon", "less");
grub_keymap_add_by_string("colon", "greater");
grub_keymap_add_by_string("underscore", "question");
grub_keymap_add_by_string("caret", "Aquote");
grub_keymap_add_by_string("doublequote", "braceleft");
grub_keymap_add_by_string("at", "Aq");
grub_keymap_add_by_string("backquote", "Abackslash");
grub_keymap_add_by_string("backslash", "Aminus");
grub_keymap_add_by_string("greater", "plus");
grub_keymap_add_by_string("less", "equal");
grub_keymap_add_by_string("backslash", "Aminus");
grub_keymap_add_by_string("backquote", "Abackslash");
grub_keymap_add_by_string("tilde", "Abracketright");
grub_keymap_add_by_string("caret", "Aquote");
grub_keymap_enable();
}
static void ventoy_keyboard_layout_PORTU_BRAZIL(void) {
grub_keymap_reset();
grub_keymap_add_by_string("quote", "backquote");
grub_keymap_add_by_string("quote", "bracketleft");
grub_keymap_add_by_string("bracketleft", "bracketright");
grub_keymap_add_by_string("tilde", "quote");
grub_keymap_add_by_string("bracketright", "backslash");
grub_keymap_add_by_string("semicolon", "slash");
grub_keymap_add_by_string("bar", "colon");
grub_keymap_add_by_string("doublequote", "tilde");
grub_keymap_add_by_string("backquote", "braceleft");
grub_keymap_add_by_string("braceleft", "braceright");
grub_keymap_add_by_string("caret", "doublequote");
grub_keymap_add_by_string("braceright", "bar");
grub_keymap_add_by_string("colon", "question");
grub_keymap_add_by_string("backslash", "semicolon");
grub_keymap_add_by_string("bar", "Atilde");
grub_keymap_add_by_string("backslash", "Abackquote");
grub_keymap_add_by_string("slash", "Aq");
grub_keymap_add_by_string("question", "Aw");
grub_keymap_enable();
}
static void ventoy_keyboard_layout_QWERTY_UK(void) {
grub_keymap_reset();
grub_keymap_add_by_string("at", "doublequote");
grub_keymap_add_by_string("doublequote", "at");
grub_keymap_add_by_string("tilde", "bar");
grub_keymap_add_by_string("numbersign", "backslash");
grub_keymap_add_by_string("backslash", "numbersign");
grub_keymap_add_by_string("bar", "tilde");
grub_keymap_add_by_string("backslash", "Atilde");
grub_keymap_add_by_string("backslash", "Abackquote");
grub_keymap_enable();
}
static void ventoy_keyboard_layout_QWERTZ(void) {
grub_keymap_reset();
grub_keymap_add_by_string("doublequote", "at");
grub_keymap_add_by_string("ampersand", "percent");
grub_keymap_add_by_string("slash", "ampersand");
grub_keymap_add_by_string("equal", "parenright");
grub_keymap_add_by_string("question", "underscore");
grub_keymap_add_by_string("backslash", "minus");
grub_keymap_add_by_string("z", "y");
grub_keymap_add_by_string("Z", "Y");
grub_keymap_add_by_string("y", "z");
grub_keymap_add_by_string("Y", "Z");
grub_keymap_add_by_string("plus", "bracketright");
grub_keymap_add_by_string("asterisk", "braceright");
grub_keymap_add_by_string("semicolon", "less");
grub_keymap_add_by_string("colon", "greater");
grub_keymap_add_by_string("minus", "slash");
grub_keymap_add_by_string("underscore", "question");
grub_keymap_add_by_string("caret", "backquote");
grub_keymap_add_by_string("backquote", "equal");
grub_keymap_add_by_string("numbersign", "backslash");
grub_keymap_add_by_string("parenright", "parenleft");
grub_keymap_add_by_string("parenleft", "asterisk");
grub_keymap_add_by_string("percent", "caret");
grub_keymap_add_by_string("less", "numbersign");
grub_keymap_add_by_string("greater", "bar");
grub_keymap_enable();
}
static void ventoy_keyboard_layout_QWERTZ_HUN(void) {
grub_keymap_reset();
grub_keymap_add_by_string("y", "z");
grub_keymap_add_by_string("z", "y");
grub_keymap_add_by_string("Y", "Z");
grub_keymap_add_by_string("Z", "Y");
grub_keymap_add_by_string("0", "backquote");
grub_keymap_add_by_string("quote", "exclam");
grub_keymap_add_by_string("doublequote", "at");
grub_keymap_add_by_string("plus", "numbersign");
grub_keymap_add_by_string("exclam", "dollar");
grub_keymap_add_by_string("slash", "caret");
grub_keymap_add_by_string("equal", "ampersand");
grub_keymap_add_by_string("parenleft", "asterisk");
grub_keymap_add_by_string("parenright", "parenleft");
grub_keymap_add_by_string("backslash", "Aq");
grub_keymap_add_by_string("bar", "Aw");
grub_keymap_add_by_string("bracketleft", "Af");
grub_keymap_add_by_string("bracketright", "Ag");
grub_keymap_add_by_string("greater", "Az");
grub_keymap_add_by_string("numbersign", "Ax");
grub_keymap_add_by_string("ampersand", "Ac");
grub_keymap_add_by_string("at", "Av");
grub_keymap_add_by_string("braceleft", "Ab");
grub_keymap_add_by_string("braceright", "An");
grub_keymap_add_by_string("less", "Am");
grub_keymap_add_by_string("dollar", "colon");
grub_keymap_add_by_string("question", "less");
grub_keymap_add_by_string("colon", "greater");
grub_keymap_add_by_string("minus", "slash");
grub_keymap_add_by_string("underscore", "question");
grub_keymap_add_by_string("at", "doublequote");
grub_keymap_add_by_string("tilde", "A1");
grub_keymap_add_by_string("caret", "A3");
grub_keymap_add_by_string("backquote", "A7");
grub_keymap_add_by_string("asterisk", "0");
grub_keymap_add_by_string("dollar", "Asemicolon");
grub_keymap_add_by_string("semicolon", "Acomma");
grub_keymap_add_by_string("greater", "Aperiod");
grub_keymap_add_by_string("asterisk", "Aslash");
grub_keymap_add_by_string("backquote", "A9");
grub_keymap_add_by_string("doublequote", "A0");
grub_keymap_enable();
}
static void ventoy_keyboard_layout_QWERTZ_SLOV_CROAT(void) {
grub_keymap_reset();
grub_keymap_add_by_string("quote", "minus");
grub_keymap_add_by_string("plus", "equal");
grub_keymap_add_by_string("y", "z");
grub_keymap_add_by_string("minus", "slash");
grub_keymap_add_by_string("doublequote", "tilde");
grub_keymap_add_by_string("doublequote", "at");
grub_keymap_add_by_string("ampersand", "caret");
grub_keymap_add_by_string("slash", "ampersand");
grub_keymap_add_by_string("parenleft", "asterisk");
grub_keymap_add_by_string("parenright", "parenleft");
grub_keymap_add_by_string("equal", "parenright");
grub_keymap_add_by_string("question", "underscore");
grub_keymap_add_by_string("asterisk", "plus");
grub_keymap_add_by_string("Y", "Z");
grub_keymap_add_by_string("semicolon", "less");
grub_keymap_add_by_string("colon", "greater");
grub_keymap_add_by_string("underscore", "question");
grub_keymap_add_by_string("tilde", "A1");
grub_keymap_add_by_string("caret", "A3");
grub_keymap_add_by_string("backquote", "A7");
grub_keymap_add_by_string("backslash", "Aq");
grub_keymap_add_by_string("bar", "Aw");
grub_keymap_add_by_string("bracketleft", "Af");
grub_keymap_add_by_string("bracketright", "Ag");
grub_keymap_add_by_string("at", "Av");
grub_keymap_add_by_string("braceleft", "Ab");
grub_keymap_add_by_string("braceright", "An");
grub_keymap_add_by_string("less", "Acomma");
grub_keymap_add_by_string("greater", "Aperiod");
grub_keymap_enable();
}
static void ventoy_keyboard_layout_SPANISH(void) {
grub_keymap_reset();
grub_keymap_add_by_string("slash", "ampersand");
grub_keymap_add_by_string("ampersand", "caret");
grub_keymap_add_by_string("caret", "braceleft");
grub_keymap_add_by_string("asterisk", "braceright");
grub_keymap_add_by_string("parenleft", "asterisk");
grub_keymap_add_by_string("parenright", "parenleft");
grub_keymap_add_by_string("minus", "slash");
grub_keymap_add_by_string("equal", "parenright");
grub_keymap_add_by_string("quote", "minus");
grub_keymap_add_by_string("underscore", "question");
grub_keymap_add_by_string("question", "underscore");
grub_keymap_add_by_string("colon", "greater");
grub_keymap_add_by_string("greater", "bar");
grub_keymap_add_by_string("doublequote", "at");
grub_keymap_add_by_string("backslash", "backquote");
grub_keymap_add_by_string("less", "backslash");
grub_keymap_add_by_string("semicolon", "less");
grub_keymap_add_by_string("backquote", "bracketleft");
grub_keymap_add_by_string("plus", "bracketright");
grub_keymap_add_by_string("plus", "colon");
grub_keymap_add_by_string("at", "semicolon");
grub_keymap_add_by_string("bar", "A1");
grub_keymap_add_by_string("at", "A2");
grub_keymap_add_by_string("numbersign", "A3");
grub_keymap_add_by_string("tilde", "A4");
grub_keymap_add_by_string("bracketleft", "Abracketleft");
grub_keymap_add_by_string("bracketright", "Abracketright");
grub_keymap_add_by_string("braceleft", "Aquote");
grub_keymap_add_by_string("braceright", "Abackslash");
grub_keymap_add_by_string("greater", "bar");
grub_keymap_add_by_string("less", "backslash");
grub_keymap_add_by_string("backslash", "Abackquote");
grub_keymap_enable();
}
static void ventoy_keyboard_layout_SWEDISH(void) {
grub_keymap_reset();
grub_keymap_add_by_string("plus", "minus");
grub_keymap_add_by_string("quote", "equal");
grub_keymap_add_by_string("doublequote", "bracketright");
grub_keymap_add_by_string("quote", "backslash");
grub_keymap_add_by_string("minus", "slash");
grub_keymap_add_by_string("doublequote", "at");
grub_keymap_add_by_string("ampersand", "caret");
grub_keymap_add_by_string("slash", "ampersand");
grub_keymap_add_by_string("parenleft", "asterisk");
grub_keymap_add_by_string("parenright", "parenleft");
grub_keymap_add_by_string("equal", "parenright");
grub_keymap_add_by_string("question", "underscore");
grub_keymap_add_by_string("caret", "braceright");
grub_keymap_add_by_string("asterisk", "bar");
grub_keymap_add_by_string("backquote", "plus");
grub_keymap_add_by_string("semicolon", "less");
grub_keymap_add_by_string("colon", "greater");
grub_keymap_add_by_string("underscore", "question");
grub_keymap_add_by_string("bar", "Atilde");
grub_keymap_add_by_string("backslash", "Abackquote");
grub_keymap_add_by_string("greater", "tilde");
grub_keymap_add_by_string("at", "A2");
grub_keymap_add_by_string("dollar", "A4");
grub_keymap_add_by_string("braceleft", "A7");
grub_keymap_add_by_string("bracketleft", "A8");
grub_keymap_add_by_string("bracketright", "A9");
grub_keymap_add_by_string("braceright", "A0");
grub_keymap_add_by_string("backslash", "Aminus");
grub_keymap_add_by_string("less", "quote");
grub_keymap_add_by_string("greater", "doublequote");
grub_keymap_add_by_string("tilde", "Abracketright");
grub_keymap_enable();
}
static void ventoy_keyboard_layout_TURKISH_Q(void) {
grub_keymap_reset();
grub_keymap_add_by_string("doublequote", "backquote");
grub_keymap_add_by_string("asterisk", "minus");
grub_keymap_add_by_string("minus", "equal");
grub_keymap_add_by_string("comma", "backslash");
grub_keymap_add_by_string("period", "slash");
grub_keymap_add_by_string("quote", "at");
grub_keymap_add_by_string("caret", "numbersign");
grub_keymap_add_by_string("plus", "dollar");
grub_keymap_add_by_string("ampersand", "caret");
grub_keymap_add_by_string("slash", "ampersand");
grub_keymap_add_by_string("parenleft", "asterisk");
grub_keymap_add_by_string("parenright", "parenleft");
grub_keymap_add_by_string("equal", "parenright");
grub_keymap_add_by_string("question", "underscore");
grub_keymap_add_by_string("underscore", "plus");
grub_keymap_add_by_string("semicolon", "bar");
grub_keymap_add_by_string("colon", "question");
grub_keymap_add_by_string("less", "Abackquote");
grub_keymap_add_by_string("greater", "A1");
grub_keymap_add_by_string("numbersign", "A3");
grub_keymap_add_by_string("dollar", "A4");
grub_keymap_add_by_string("braceleft", "A7");
grub_keymap_add_by_string("bracketleft", "A8");
grub_keymap_add_by_string("bracketright", "A9");
grub_keymap_add_by_string("braceright", "A0");
grub_keymap_add_by_string("backslash", "Aminus");
grub_keymap_add_by_string("bar", "Aequal");
grub_keymap_add_by_string("at", "Aq");
grub_keymap_add_by_string("doublequote", "Abracketleft");
grub_keymap_add_by_string("tilde", "Abracketright");
grub_keymap_enable();
}
static void ventoy_keyboard_layout_VIETNAMESE(void) {
grub_keymap_reset();
grub_keymap_add_by_string("exclam", "A1");
grub_keymap_add_by_string("at", "A2");
grub_keymap_add_by_string("numbersign", "A3");
grub_keymap_add_by_string("dollar", "A4");
grub_keymap_add_by_string("percent", "A5");
grub_keymap_add_by_string("caret", "A6");
grub_keymap_add_by_string("ampersand", "A7");
grub_keymap_add_by_string("asterisk", "A8");
grub_keymap_add_by_string("parenleft", "A9");
grub_keymap_add_by_string("parenright", "A0");
grub_keymap_add_by_string("plus", "Aplus");
grub_keymap_add_by_string("equal", "Aequal");
grub_keymap_add_by_string("braceleft", "Abraceleft");
grub_keymap_add_by_string("braceright", "Abraceright");
grub_keymap_add_by_string("colon", "Acolon");
grub_keymap_add_by_string("semicolon", "Asemicolon");
grub_keymap_add_by_string("quote", "Aquote");
grub_keymap_add_by_string("backslash", "Abackslash");
grub_keymap_add_by_string("less", "Aless");
grub_keymap_add_by_string("greater", "Agreater");
grub_keymap_add_by_string("comma", "Acomma");
grub_keymap_add_by_string("period", "Aperiod");
grub_keymap_add_by_string("question", "Aquestion");
grub_keymap_add_by_string("slash", "Aslash");
grub_keymap_add_by_string("tilde", "Atilde");
grub_keymap_add_by_string("backquote", "Abackquote");
grub_keymap_add_by_string("bracketright", "Abracketright");
grub_keymap_add_by_string("bracketleft", "Abracketleft");
grub_keymap_add_by_string("bar", "Abar");
grub_keymap_add_by_string("doublequote", "Adoublequote");
grub_keymap_add_by_string("colon", "Acolon");
grub_keymap_add_by_string("minus", "Aminus");
grub_keymap_add_by_string("underscore", "Aunderscore");
grub_keymap_enable();
}
void ventoy_set_keyboard_layout(const char *layout);
void ventoy_set_keyboard_layout(const char *layout) {
ventoy_keyboard_set_layout(QWERTY_USA);
ventoy_keyboard_set_layout(AZERTY);
ventoy_keyboard_set_layout(CZECH_QWERTY);
ventoy_keyboard_set_layout(CZECH_QWERTZ);
ventoy_keyboard_set_layout(DANISH);
ventoy_keyboard_set_layout(DVORAK_USA);
ventoy_keyboard_set_layout(FRENCH);
ventoy_keyboard_set_layout(GERMAN);
ventoy_keyboard_set_layout(ITALIANO);
ventoy_keyboard_set_layout(JAPAN_106);
ventoy_keyboard_set_layout(LATIN_USA);
ventoy_keyboard_set_layout(PORTU_BRAZIL);
ventoy_keyboard_set_layout(QWERTY_UK);
ventoy_keyboard_set_layout(QWERTZ);
ventoy_keyboard_set_layout(QWERTZ_HUN);
ventoy_keyboard_set_layout(QWERTZ_SLOV_CROAT);
ventoy_keyboard_set_layout(SPANISH);
ventoy_keyboard_set_layout(SWEDISH);
ventoy_keyboard_set_layout(TURKISH_Q);
ventoy_keyboard_set_layout(VIETNAMESE);
}

View File

@@ -348,12 +348,38 @@ out:
return grub_errno; return grub_errno;
} }
static grub_extcmd_t cmd; static void grub_keymap_add_by_string(const char *src, const char *dst)
{
int in = 0;
int out = 0;
in = parse_key(dst);
out = parse_key(src);
if (in && out)
{
grub_keymap_add (in, out);
}
}
#include "keyboard_layout.c"
static grub_err_t grub_cmd_set_keylayout (grub_extcmd_context_t ctxt, int argc, char **args)
{
(void)ctxt;
(void)argc;
ventoy_set_keyboard_layout(args[0]);
return 0;
}
static grub_extcmd_t cmd, setcmd;
GRUB_MOD_INIT(setkey) GRUB_MOD_INIT(setkey)
{ {
cmd = grub_register_extcmd ("setkey", grub_cmd_setkey, 0, N_("NEW_KEY USA_KEY"), cmd = grub_register_extcmd ("setkey", grub_cmd_setkey, 0, N_("NEW_KEY USA_KEY"),
N_("Map default USA_KEY to NEW_KEY."), options); N_("Map default USA_KEY to NEW_KEY."), options);
setcmd = grub_register_extcmd ("set_keyboard_layout", grub_cmd_set_keylayout, 0, N_("layout"),
N_("Set keyboard layout."), NULL);
} }
GRUB_MOD_FINI(setkey) GRUB_MOD_FINI(setkey)

View File

@@ -462,6 +462,8 @@ static int lzx_uncompressed ( struct lzx *lzx ) {
if ( len % 2 ) if ( len % 2 )
lzx->input.offset++; lzx->input.offset++;
lzx->output.offset += len;
return 0; return 0;
} }
@@ -614,7 +616,7 @@ ssize_t lzx_decompress ( const void *data, size_t len, void *buf ) {
/* Sanity check */ /* Sanity check */
if ( len % 2 ) { if ( len % 2 ) {
DBG ( "LZX cannot handle odd-length input data\n" ); DBG ( "LZX cannot handle odd-length input data\n" );
return -1; //return -1;
} }
/* Initialise global state, if required */ /* Initialise global state, if required */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -29,6 +29,8 @@
#define VTOY_SIZE_1GB 1073741824 #define VTOY_SIZE_1GB 1073741824
#define VTOY_SIZE_1MB (1024 * 1024) #define VTOY_SIZE_1MB (1024 * 1024)
#define VTOY_SIZE_2MB (2 * 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
@@ -67,6 +69,9 @@
#define VTOY_ARCH_CPIO "ventoy_x86.cpio" #define VTOY_ARCH_CPIO "ventoy_x86.cpio"
#endif #endif
#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 VTOY_PWD_CORRUPTED(err) \ #define VTOY_PWD_CORRUPTED(err) \
{\ {\
grub_printf("\n\n Password corrupted, will reboot after 5 seconds.\n\n"); \ grub_printf("\n\n Password corrupted, will reboot after 5 seconds.\n\n"); \
@@ -140,6 +145,7 @@ typedef struct cpio_newc_header
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)
#define OFFSET_OF(TYPE, MEMBER) ((grub_size_t) &((TYPE *)0)->MEMBER)
#pragma pack(1) #pragma pack(1)
typedef struct ventoy_patch_vhd typedef struct ventoy_patch_vhd
@@ -193,12 +199,14 @@ typedef struct ventoy_iso9660_vd
#pragma pack() #pragma pack()
#define img_type_iso 0 #define img_type_start 0
#define img_type_wim 1 #define img_type_iso 0
#define img_type_efi 2 #define img_type_wim 1
#define img_type_img 3 #define img_type_efi 2
#define img_type_vhd 4 #define img_type_img 3
#define img_type_vtoy 5 #define img_type_vhd 4
#define img_type_vtoy 5
#define img_type_max 6
typedef struct img_info typedef struct img_info
{ {
@@ -281,10 +289,11 @@ extern ventoy_img_chunk_list g_img_chunk_list;
extern ventoy_img_chunk_list g_wimiso_chunk_list; extern ventoy_img_chunk_list g_wimiso_chunk_list;
extern char *g_wimiso_path; extern char *g_wimiso_path;
extern char g_arch_mode_suffix[64]; extern char g_arch_mode_suffix[64];
extern const char *g_menu_prefix[img_type_max];
extern int g_ventoy_debug; extern int g_ventoy_debug;
void ventoy_debug(const char *fmt, ...); void ventoy_debug(const char *fmt, ...);
#define debug(fmt, ...) if (g_ventoy_debug) ventoy_debug("[VTOY]: "fmt, __VA_ARGS__) #define debug(fmt, args...) if (g_ventoy_debug) ventoy_debug("[VTOY]: "fmt, ##args)
#define vtoy_ssprintf(buf, pos, fmt, ...) \ #define vtoy_ssprintf(buf, pos, fmt, ...) \
pos += grub_snprintf(buf + pos, VTOY_MAX_SCRIPT_BUF - pos, fmt, __VA_ARGS__) pos += grub_snprintf(buf + pos, VTOY_MAX_SCRIPT_BUF - pos, fmt, __VA_ARGS__)
@@ -390,6 +399,15 @@ typedef struct wim_security_header
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
{
grub_uint64_t len;
grub_uint64_t unused1;
wim_hash hash;
grub_uint16_t name_len;
/* name */
}wim_stream_entry;
/* Directory entry */ /* Directory entry */
typedef struct wim_directory_entry typedef struct wim_directory_entry
{ {
@@ -518,7 +536,19 @@ typedef struct plugin_entry
ventoy_plugin_check_pf checkfunc; ventoy_plugin_check_pf checkfunc;
}plugin_entry; }plugin_entry;
typedef struct replace_fs_dir
{
grub_device_t dev;
grub_fs_t fs;
char fullpath[512];
char initrd[512];
int curpos;
int dircnt;
int filecnt;
}replace_fs_dir;
int ventoy_strcmp(const char *pattern, const char *str);
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);
grub_err_t ventoy_cmd_isolinux_initrd_collect(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_isolinux_initrd_collect(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_grub_initrd_collect(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_grub_initrd_collect(grub_extcmd_context_t ctxt, int argc, char **args);
@@ -543,10 +573,16 @@ int ventoy_is_dir_exist(const char *fmt, ...);
int ventoy_fill_data(grub_uint32_t buflen, char *buffer); int ventoy_fill_data(grub_uint32_t buflen, char *buffer);
grub_err_t ventoy_cmd_load_plugin(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_load_plugin(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_wimdows_reset(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_wimdows_reset(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_is_pe64(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_windows_wimboot_data(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_wim_chain_data(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_wim_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_wim_check_bootable(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_wim_check_bootable(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_dump_wim_patch(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_dump_wim_patch(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_sel_wimboot(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_set_wim_prompt(grub_extcmd_context_t ctxt, int argc, char **args);
grub_ssize_t ventoy_load_file_with_prompt(grub_file_t file, void *buf, grub_ssize_t size);
int ventoy_need_prompt_load_file(void);
VTOY_JSON *vtoy_json_find_item VTOY_JSON *vtoy_json_find_item
( (
@@ -756,8 +792,17 @@ typedef struct file_fullpath
char path[256]; char path[256];
}file_fullpath; }file_fullpath;
typedef struct theme_list
{
file_fullpath theme;
struct theme_list *next;
}theme_list;
#define auto_install_type_file 0
#define auto_install_type_parent 1
typedef struct install_template typedef struct install_template
{ {
int type;
int pathlen; int pathlen;
char isopath[256]; char isopath[256];
@@ -820,6 +865,7 @@ typedef struct menu_class
{ {
int type; int type;
int patlen; int patlen;
int parent;
char pattern[256]; char pattern[256];
char class[64]; char class[64];
@@ -850,8 +896,11 @@ typedef struct conf_replace
struct conf_replace *next; struct conf_replace *next;
}conf_replace; }conf_replace;
#define injection_type_file 0
#define injection_type_parent 1
typedef struct injection_config typedef struct injection_config
{ {
int type;
int pathlen; int pathlen;
char isopath[256]; char isopath[256];
char archive[256]; char archive[256];
@@ -888,8 +937,12 @@ typedef struct vtoy_password
grub_uint8_t md5[16]; grub_uint8_t md5[16];
}vtoy_password; }vtoy_password;
#define vtoy_menu_pwd_file 0
#define vtoy_menu_pwd_parent 1
typedef struct menu_password typedef struct menu_password
{ {
int type;
int pathlen; int pathlen;
char isopath[256]; char isopath[256];
@@ -903,6 +956,8 @@ extern int g_ventoy_suppress_esc;
extern int g_ventoy_last_entry; extern int g_ventoy_last_entry;
extern int g_ventoy_memdisk_mode; extern int g_ventoy_memdisk_mode;
extern int g_ventoy_iso_raw; extern int g_ventoy_iso_raw;
extern int g_ventoy_grub2_mode;
extern int g_ventoy_wimboot_mode;
extern int g_ventoy_iso_uefi_drv; extern int g_ventoy_iso_uefi_drv;
extern int g_ventoy_case_insensitive; extern int g_ventoy_case_insensitive;
extern grub_uint8_t g_ventoy_chain_type; extern grub_uint8_t g_ventoy_chain_type;
@@ -920,6 +975,8 @@ extern grub_uint8_t *g_conf_replace_new_buf;
extern int g_conf_replace_new_len; extern int g_conf_replace_new_len;
extern int g_conf_replace_new_len_align; extern int g_conf_replace_new_len_align;
extern grub_uint64_t g_ventoy_disk_size; extern grub_uint64_t g_ventoy_disk_size;
extern grub_uint64_t g_ventoy_disk_part_size[2];
extern grub_uint32_t g_ventoy_plat_data;
#define ventoy_unix_fill_virt(new_data, new_len) \ #define ventoy_unix_fill_virt(new_data, new_len) \
{ \ { \
@@ -937,19 +994,23 @@ extern grub_uint64_t g_ventoy_disk_size;
chain->virt_img_size_in_bytes += data_secs * 2048; \ chain->virt_img_size_in_bytes += data_secs * 2048; \
} }
#define ventoy_syscall0(name) grub_##name()
#define ventoy_syscall1(name, a) grub_##name(a)
char * ventoy_get_line(char *start); char * ventoy_get_line(char *start);
int ventoy_cmp_img(img_info *img1, img_info *img2); int ventoy_cmp_img(img_info *img1, img_info *img2);
void ventoy_swap_img(img_info *img1, img_info *img2); void ventoy_swap_img(img_info *img1, img_info *img2);
char * ventoy_plugin_get_cur_install_template(const char *isopath); char * ventoy_plugin_get_cur_install_template(const char *isopath);
install_template * ventoy_plugin_find_install_template(const char *isopath); install_template * ventoy_plugin_find_install_template(const char *isopath);
persistence_config * ventoy_plugin_find_persistent(const char *isopath); persistence_config * ventoy_plugin_find_persistent(const char *isopath);
grub_uint64_t ventoy_get_vtoy_partsize(int part);
void ventoy_plugin_dump_injection(void); void ventoy_plugin_dump_injection(void);
void ventoy_plugin_dump_auto_install(void); void ventoy_plugin_dump_auto_install(void);
int ventoy_fill_windows_rtdata(void *buf, char *isopath); int ventoy_fill_windows_rtdata(void *buf, char *isopath);
int ventoy_plugin_get_persistent_chunklist(const char *isopath, int index, ventoy_img_chunk_list *chunk_list); int ventoy_plugin_get_persistent_chunklist(const char *isopath, int index, ventoy_img_chunk_list *chunk_list);
const char * ventoy_plugin_get_injection(const char *isopath); const char * ventoy_plugin_get_injection(const char *isopath);
const char * ventoy_plugin_get_menu_alias(int type, const char *isopath); const char * ventoy_plugin_get_menu_alias(int type, const char *isopath);
const char * ventoy_plugin_get_menu_class(int type, const char *name); const char * ventoy_plugin_get_menu_class(int type, const char *name, const char *path);
int ventoy_plugin_check_memdisk(const char *isopath); int ventoy_plugin_check_memdisk(const char *isopath);
int ventoy_plugin_get_image_list_index(int type, const char *name); int ventoy_plugin_get_image_list_index(int type, const char *name);
conf_replace * ventoy_plugin_find_conf_replace(const char *iso); conf_replace * ventoy_plugin_find_conf_replace(const char *iso);
@@ -958,6 +1019,7 @@ 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);
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_plugin_check_json(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_plugin_check_json(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_check_password(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_check_password(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_linux_get_main_initrd_index(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_linux_get_main_initrd_index(grub_extcmd_context_t ctxt, int argc, char **args);
@@ -973,6 +1035,7 @@ grub_err_t ventoy_cmd_unix_fill_image_desc(grub_extcmd_context_t ctxt, int argc,
grub_err_t ventoy_cmd_unix_gzip_newko(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_unix_gzip_newko(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_freebsd_ver(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_unix_freebsd_ver(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_parse_freenas_ver(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_parse_freenas_ver(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 ventoy_check_device_result(int ret); int ventoy_check_device_result(int ret);
int ventoy_check_device(grub_device_t dev); int ventoy_check_device(grub_device_t dev);
void ventoy_debug_dump_guid(const char *prefix, grub_uint8_t *guid); void ventoy_debug_dump_guid(const char *prefix, grub_uint8_t *guid);
@@ -981,11 +1044,28 @@ grub_err_t ventoy_cmd_patch_vhdboot(grub_extcmd_context_t ctxt, int argc, char *
grub_err_t ventoy_cmd_raw_chain_data(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_raw_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char **args);
int ventoy_check_password(const vtoy_password *pwd, int retry); int ventoy_check_password(const vtoy_password *pwd, int retry);
int ventoy_gzip_compress(void *mem_in, int mem_in_len, void *mem_out, int mem_out_len);
grub_uint64_t ventoy_get_part1_size(ventoy_gpt_info *gpt);
int ventoy_plugin_add_custom_boot(const char *vcfgpath); int ventoy_plugin_add_custom_boot(const char *vcfgpath);
const char * ventoy_plugin_get_custom_boot(const char *isopath); const char * ventoy_plugin_get_custom_boot(const char *isopath);
grub_err_t ventoy_cmd_dump_custom_boot(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_dump_custom_boot(grub_extcmd_context_t ctxt, int argc, char **args);
int ventoy_gzip_compress(void *mem_in, int mem_in_len, void *mem_out, int mem_out_len);
int ventoy_load_part_table(const char *diskname);
int ventoy_env_init(void);
int ventoy_register_all_cmd(void);
int ventoy_unregister_all_cmd(void);
int ventoy_chain_file_size(const char *path);
int ventoy_chain_file_read(const char *path, int offset, int len, void *buf);
#define VTOY_CMD_CHECK(a) if (33554432 != g_ventoy_disk_part_size[a]) ventoy_syscall0(exit)
#define vtoy_theme_random_boot_second 0
#define vtoy_theme_random_boot_day 1
#define vtoy_theme_random_boot_month 2
#define ventoy_env_export(env, name) \
{\
grub_env_set((env), (name));\
grub_env_export(env);\
}
#endif /* __VENTOY_DEF_H__ */ #endif /* __VENTOY_DEF_H__ */

View File

@@ -333,7 +333,9 @@ end:
static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName) static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName)
{ {
int i = 0; int i = 0;
int len = 0;
int dollar = 0; int dollar = 0;
int quotation = 0;
grub_file_t file = NULL; grub_file_t file = NULL;
char *buf = NULL; char *buf = NULL;
char *start = NULL; char *start = NULL;
@@ -382,6 +384,12 @@ static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName)
start++; start++;
} }
if (*start == '"')
{
quotation = 1;
start++;
}
while (*start) while (*start)
{ {
img = grub_zalloc(sizeof(initrd_info)); img = grub_zalloc(sizeof(initrd_info));
@@ -400,6 +408,16 @@ static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName)
} }
} }
if (quotation)
{
len = (int)grub_strlen(img->name);
if (len > 2 && img->name[len - 1] == '"')
{
img->name[len - 1] = 0;
}
debug("Remove quotation <%s>\n", img->name);
}
if (dollar == 1 || ventoy_find_initrd_by_name(g_initrd_img_list, img->name)) if (dollar == 1 || ventoy_find_initrd_by_name(g_initrd_img_list, img->name))
{ {
grub_free(img); grub_free(img);

View File

@@ -43,6 +43,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
char g_arch_mode_suffix[64]; char g_arch_mode_suffix[64];
static char g_iso_disk_name[128]; static char g_iso_disk_name[128];
static vtoy_password g_boot_pwd; static vtoy_password g_boot_pwd;
static vtoy_password g_file_type_pwd[img_type_max];
static install_template *g_install_template_head = NULL; static install_template *g_install_template_head = NULL;
static dud *g_dud_head = NULL; static dud *g_dud_head = NULL;
static menu_password *g_pwd_head = NULL; static menu_password *g_pwd_head = NULL;
@@ -55,6 +56,32 @@ static auto_memdisk *g_auto_memdisk_head = NULL;
static image_list *g_image_list_head = NULL; static image_list *g_image_list_head = NULL;
static conf_replace *g_conf_replace_head = NULL; static conf_replace *g_conf_replace_head = NULL;
static int g_theme_num = 0;
static theme_list *g_theme_head = NULL;
static int g_theme_random = vtoy_theme_random_boot_second;
static char g_theme_single_file[256];
static int ventoy_plugin_is_parent(const char *pat, int patlen, const char *isopath)
{
if (patlen > 1)
{
if (isopath[patlen] == '/' && ventoy_strncmp(pat, isopath, patlen) == 0 &&
grub_strchr(isopath + patlen + 1, '/') == NULL)
{
return 1;
}
}
else
{
if (pat[0] == '/' && grub_strchr(isopath + 1, '/') == NULL)
{
return 1;
}
}
return 0;
}
static int ventoy_plugin_control_check(VTOY_JSON *json, const char *isodisk) static int ventoy_plugin_control_check(VTOY_JSON *json, const char *isodisk)
{ {
int rc = 0; int rc = 0;
@@ -155,6 +182,38 @@ static int ventoy_plugin_theme_check(VTOY_JSON *json, const char *isodisk)
return 1; return 1;
} }
} }
else
{
node = vtoy_json_find_item(json->pstChild, JSON_TYPE_ARRAY, "file");
if (node)
{
for (node = node->pstChild; node; node = node->pstNext)
{
value = node->unData.pcStrVal;
grub_printf("file: %s\n", value);
if (value[0] == '/')
{
exist = ventoy_is_file_exist("%s%s", isodisk, value);
}
else
{
exist = ventoy_is_file_exist("%s/ventoy/%s", isodisk, value);
}
if (exist == 0)
{
grub_printf("Theme file %s does NOT exist\n", value);
return 1;
}
}
value = vtoy_json_get_string_ex(json->pstChild, "random");
if (value)
{
grub_printf("random: %s\n", value);
}
}
}
value = vtoy_json_get_string_ex(json->pstChild, "gfxmode"); value = vtoy_json_get_string_ex(json->pstChild, "gfxmode");
if (value) if (value)
@@ -222,8 +281,10 @@ static int ventoy_plugin_theme_entry(VTOY_JSON *json, const char *isodisk)
{ {
const char *value; const char *value;
char filepath[256]; char filepath[256];
VTOY_JSON *node; VTOY_JSON *node = NULL;
theme_list *tail = NULL;
theme_list *themenode = NULL;
value = vtoy_json_get_string_ex(json->pstChild, "file"); value = vtoy_json_get_string_ex(json->pstChild, "file");
if (value) if (value)
{ {
@@ -236,53 +297,112 @@ static int ventoy_plugin_theme_entry(VTOY_JSON *json, const char *isodisk)
grub_snprintf(filepath, sizeof(filepath), "%s/ventoy/%s", isodisk, value); grub_snprintf(filepath, sizeof(filepath), "%s/ventoy/%s", isodisk, value);
} }
if (ventoy_is_file_exist(filepath) == 0) if (ventoy_check_file_exist(filepath) == 0)
{ {
debug("Theme file %s does not exist\n", filepath); debug("Theme file %s does not exist\n", filepath);
return 0; return 0;
} }
debug("vtoy_theme %s\n", filepath); debug("vtoy_theme %s\n", filepath);
grub_env_set("vtoy_theme", filepath); ventoy_env_export("vtoy_theme", filepath);
grub_snprintf(g_theme_single_file, sizeof(g_theme_single_file), "%s", filepath);
}
else
{
node = vtoy_json_find_item(json->pstChild, JSON_TYPE_ARRAY, "file");
if (node)
{
for (node = node->pstChild; node; node = node->pstNext)
{
value = node->unData.pcStrVal;
if (value[0] == '/')
{
grub_snprintf(filepath, sizeof(filepath), "%s%s", isodisk, value);
}
else
{
grub_snprintf(filepath, sizeof(filepath), "%s/ventoy/%s", isodisk, value);
}
if (ventoy_check_file_exist(filepath) == 0)
{
continue;
}
themenode = grub_zalloc(sizeof(theme_list));
if (themenode)
{
grub_snprintf(themenode->theme.path, sizeof(themenode->theme.path), "%s", filepath);
if (g_theme_head)
{
tail->next = themenode;
}
else
{
g_theme_head = themenode;
}
tail = themenode;
g_theme_num++;
}
}
ventoy_env_export("vtoy_theme", "random");
value = vtoy_json_get_string_ex(json->pstChild, "random");
if (value)
{
if (grub_strcmp(value, "boot_second") == 0)
{
g_theme_random = vtoy_theme_random_boot_second;
}
else if (grub_strcmp(value, "boot_day") == 0)
{
g_theme_random = vtoy_theme_random_boot_day;
}
else if (grub_strcmp(value, "boot_month") == 0)
{
g_theme_random = vtoy_theme_random_boot_month;
}
}
}
} }
value = vtoy_json_get_string_ex(json->pstChild, "gfxmode"); value = vtoy_json_get_string_ex(json->pstChild, "gfxmode");
if (value) if (value)
{ {
debug("vtoy_gfxmode %s\n", value); debug("vtoy_gfxmode %s\n", value);
grub_env_set("vtoy_gfxmode", value); ventoy_env_export("vtoy_gfxmode", value);
} }
value = vtoy_json_get_string_ex(json->pstChild, "display_mode"); value = vtoy_json_get_string_ex(json->pstChild, "display_mode");
if (value) if (value)
{ {
debug("display_mode %s\n", value); debug("display_mode %s\n", value);
grub_env_set("vtoy_display_mode", value); ventoy_env_export("vtoy_display_mode", value);
} }
value = vtoy_json_get_string_ex(json->pstChild, "serial_param"); value = vtoy_json_get_string_ex(json->pstChild, "serial_param");
if (value) if (value)
{ {
debug("serial_param %s\n", value); debug("serial_param %s\n", value);
grub_env_set("vtoy_serial_param", value); ventoy_env_export("vtoy_serial_param", value);
} }
value = vtoy_json_get_string_ex(json->pstChild, "ventoy_left"); value = vtoy_json_get_string_ex(json->pstChild, "ventoy_left");
if (value) if (value)
{ {
grub_env_set("VTLE_LFT", value); ventoy_env_export("VTLE_LFT", value);
} }
value = vtoy_json_get_string_ex(json->pstChild, "ventoy_top"); value = vtoy_json_get_string_ex(json->pstChild, "ventoy_top");
if (value) if (value)
{ {
grub_env_set("VTLE_TOP", value); ventoy_env_export("VTLE_TOP", value);
} }
value = vtoy_json_get_string_ex(json->pstChild, "ventoy_color"); value = vtoy_json_get_string_ex(json->pstChild, "ventoy_color");
if (value) if (value)
{ {
grub_env_set("VTLE_CLR", value); ventoy_env_export("VTLE_CLR", value);
} }
node = vtoy_json_find_item(json->pstChild, JSON_TYPE_ARRAY, "fonts"); node = vtoy_json_find_item(json->pstChild, JSON_TYPE_ARRAY, "fonts");
@@ -481,6 +601,7 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
{ {
int pathnum = 0; int pathnum = 0;
int autosel = 0; int autosel = 0;
char *pos = NULL;
const char *iso = NULL; const char *iso = NULL;
VTOY_JSON *pNode = NULL; VTOY_JSON *pNode = NULL;
@@ -497,12 +618,12 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
grub_printf("NOT object type\n"); grub_printf("NOT object type\n");
} }
iso = vtoy_json_get_string_ex(pNode->pstChild, "image"); if ((iso = vtoy_json_get_string_ex(pNode->pstChild, "image")) != NULL)
if (iso)
{ {
if (0 == ventoy_plugin_check_path(isodisk, iso)) pos = grub_strchr(iso, '*');
if (pos || 0 == ventoy_plugin_check_path(isodisk, iso))
{ {
grub_printf("image: %s [OK]\n", iso); grub_printf("image: %s [%s]\n", iso, (pos ? "*" : "OK"));
ventoy_plugin_check_fullpath(pNode->pstChild, isodisk, "template", &pathnum); ventoy_plugin_check_fullpath(pNode->pstChild, isodisk, "template", &pathnum);
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "autosel", &autosel)) if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "autosel", &autosel))
@@ -522,6 +643,30 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
grub_printf("image: %s [FAIL]\n", iso); grub_printf("image: %s [FAIL]\n", iso);
} }
} }
else if ((iso = vtoy_json_get_string_ex(pNode->pstChild, "parent")) != NULL)
{
if (ventoy_is_dir_exist("%s%s", isodisk, iso))
{
grub_printf("parent: %s [OK]\n", iso);
ventoy_plugin_check_fullpath(pNode->pstChild, isodisk, "template", &pathnum);
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "autosel", &autosel))
{
if (autosel >= 0 && autosel <= pathnum)
{
grub_printf("autosel: %d [OK]\n", autosel);
}
else
{
grub_printf("autosel: %d [FAIL]\n", autosel);
}
}
}
else
{
grub_printf("parent: %s [FAIL]\n", iso);
}
}
else else
{ {
grub_printf("image not found\n"); grub_printf("image not found\n");
@@ -533,6 +678,7 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk) static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk)
{ {
int type = 0;
int pathnum = 0; int pathnum = 0;
int autosel = 0; int autosel = 0;
const char *iso = NULL; const char *iso = NULL;
@@ -561,7 +707,14 @@ static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext) for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
{ {
type = auto_install_type_file;
iso = vtoy_json_get_string_ex(pNode->pstChild, "image"); iso = vtoy_json_get_string_ex(pNode->pstChild, "image");
if (!iso)
{
type = auto_install_type_parent;
iso = vtoy_json_get_string_ex(pNode->pstChild, "parent");
}
if (iso && iso[0] == '/') if (iso && iso[0] == '/')
{ {
if (0 == ventoy_plugin_parse_fullpath(pNode->pstChild, isodisk, "template", &templatepath, &pathnum)) if (0 == ventoy_plugin_parse_fullpath(pNode->pstChild, isodisk, "template", &templatepath, &pathnum))
@@ -569,6 +722,7 @@ static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk
node = grub_zalloc(sizeof(install_template)); node = grub_zalloc(sizeof(install_template));
if (node) if (node)
{ {
node->type = type;
node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", iso); node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", iso);
node->templatepath = templatepath; node->templatepath = templatepath;
node->templatenum = pathnum; node->templatenum = pathnum;
@@ -599,6 +753,7 @@ static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk
static int ventoy_plugin_dud_check(VTOY_JSON *json, const char *isodisk) static int ventoy_plugin_dud_check(VTOY_JSON *json, const char *isodisk)
{ {
int pathnum = 0; int pathnum = 0;
char *pos = NULL;
const char *iso = NULL; const char *iso = NULL;
VTOY_JSON *pNode = NULL; VTOY_JSON *pNode = NULL;
@@ -618,9 +773,10 @@ static int ventoy_plugin_dud_check(VTOY_JSON *json, const char *isodisk)
iso = vtoy_json_get_string_ex(pNode->pstChild, "image"); iso = vtoy_json_get_string_ex(pNode->pstChild, "image");
if (iso) if (iso)
{ {
if (0 == ventoy_plugin_check_path(isodisk, iso)) pos = grub_strchr(iso, '*');
if (pos || 0 == ventoy_plugin_check_path(isodisk, iso))
{ {
grub_printf("image: %s [OK]\n", iso); grub_printf("image: %s [%s]\n", iso, (pos ? "*" : "OK"));
ventoy_plugin_check_fullpath(pNode->pstChild, isodisk, "dud", &pathnum); ventoy_plugin_check_fullpath(pNode->pstChild, isodisk, "dud", &pathnum);
} }
else else
@@ -805,8 +961,26 @@ static int ventoy_plugin_parse_pwdstr(char *pwdstr, vtoy_password *pwd)
return 0; return 0;
} }
static int ventoy_plugin_get_pwd_type(const char *pwd)
{
int i;
char pwdtype[64];
for (i = 0; pwd && i < (int)ARRAY_SIZE(g_menu_prefix); i++)
{
grub_snprintf(pwdtype, sizeof(pwdtype), "%spwd", g_menu_prefix[i]);
if (grub_strcmp(pwdtype, pwd) == 0)
{
return img_type_start + i;
}
}
return -1;
}
static int ventoy_plugin_pwd_entry(VTOY_JSON *json, const char *isodisk) static int ventoy_plugin_pwd_entry(VTOY_JSON *json, const char *isodisk)
{ {
int type = -1;
const char *iso = NULL; const char *iso = NULL;
const char *pwd = NULL; const char *pwd = NULL;
VTOY_JSON *pNode = NULL; VTOY_JSON *pNode = NULL;
@@ -840,6 +1014,10 @@ static int ventoy_plugin_pwd_entry(VTOY_JSON *json, const char *isodisk)
{ {
ventoy_plugin_parse_pwdstr(pNode->unData.pcStrVal, &g_boot_pwd); ventoy_plugin_parse_pwdstr(pNode->unData.pcStrVal, &g_boot_pwd);
} }
else if ((type = ventoy_plugin_get_pwd_type(pNode->pcName)) >= 0)
{
ventoy_plugin_parse_pwdstr(pNode->unData.pcStrVal, g_file_type_pwd + type);
}
else if (pNode->pcName && grub_strcmp("menupwd", pNode->pcName) == 0) else if (pNode->pcName && grub_strcmp("menupwd", pNode->pcName) == 0)
{ {
for (pCNode = pNode->pstChild; pCNode; pCNode = pCNode->pstNext) for (pCNode = pNode->pstChild; pCNode; pCNode = pCNode->pstNext)
@@ -849,13 +1027,21 @@ static int ventoy_plugin_pwd_entry(VTOY_JSON *json, const char *isodisk)
continue; continue;
} }
type = vtoy_menu_pwd_file;
iso = vtoy_json_get_string_ex(pCNode->pstChild, "file"); iso = vtoy_json_get_string_ex(pCNode->pstChild, "file");
if (!iso)
{
type = vtoy_menu_pwd_parent;
iso = vtoy_json_get_string_ex(pCNode->pstChild, "parent");
}
pwd = vtoy_json_get_string_ex(pCNode->pstChild, "pwd"); pwd = vtoy_json_get_string_ex(pCNode->pstChild, "pwd");
if (iso && pwd && iso[0] == '/') if (iso && pwd && iso[0] == '/')
{ {
node = grub_zalloc(sizeof(menu_password)); node = grub_zalloc(sizeof(menu_password));
if (node) if (node)
{ {
node->type = type;
node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", iso); node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", iso);
if (ventoy_plugin_parse_pwdstr((char *)pwd, &(node->password))) if (ventoy_plugin_parse_pwdstr((char *)pwd, &(node->password)))
@@ -884,6 +1070,8 @@ static int ventoy_plugin_pwd_entry(VTOY_JSON *json, const char *isodisk)
static int ventoy_plugin_pwd_check(VTOY_JSON *json, const char *isodisk) static int ventoy_plugin_pwd_check(VTOY_JSON *json, const char *isodisk)
{ {
int type = -1;
char *pos = NULL;
const char *iso = NULL; const char *iso = NULL;
const char *pwd = NULL; const char *pwd = NULL;
VTOY_JSON *pNode = NULL; VTOY_JSON *pNode = NULL;
@@ -908,6 +1096,17 @@ static int ventoy_plugin_pwd_check(VTOY_JSON *json, const char *isodisk)
grub_printf("Invalid bootpwd.\n"); grub_printf("Invalid bootpwd.\n");
} }
} }
else if ((type = ventoy_plugin_get_pwd_type(pNode->pcName)) >= 0)
{
if (0 == ventoy_plugin_parse_pwdstr(pNode->unData.pcStrVal, NULL))
{
grub_printf("%s:<%s>\n", pNode->pcName, pNode->unData.pcStrVal);
}
else
{
grub_printf("Invalid pwd <%s>\n", pNode->unData.pcStrVal);
}
}
else if (pNode->pcName && grub_strcmp("menupwd", pNode->pcName) == 0) else if (pNode->pcName && grub_strcmp("menupwd", pNode->pcName) == 0)
{ {
grub_printf("\n"); grub_printf("\n");
@@ -919,16 +1118,36 @@ static int ventoy_plugin_pwd_check(VTOY_JSON *json, const char *isodisk)
continue; continue;
} }
iso = vtoy_json_get_string_ex(pCNode->pstChild, "file"); if ((iso = vtoy_json_get_string_ex(pCNode->pstChild, "file")) != NULL)
if (iso)
{ {
if (0 == ventoy_plugin_check_path(isodisk, iso)) pos = grub_strchr(iso, '*');
if (pos || 0 == ventoy_plugin_check_path(isodisk, iso))
{ {
pwd = vtoy_json_get_string_ex(pCNode->pstChild, "pwd"); pwd = vtoy_json_get_string_ex(pCNode->pstChild, "pwd");
if (0 == ventoy_plugin_parse_pwdstr((char *)pwd, NULL)) if (0 == ventoy_plugin_parse_pwdstr((char *)pwd, NULL))
{ {
grub_printf("file:<%s> [OK]\n", iso); grub_printf("file:<%s> [%s]\n", iso, (pos ? "*" : "OK"));
grub_printf("pwd:<%s>\n\n", pwd);
}
else
{
grub_printf("Invalid password for <%s>\n", iso);
}
}
else
{
grub_printf("<%s%s> not found\n", isodisk, iso);
}
}
else if ((iso = vtoy_json_get_string_ex(pCNode->pstChild, "parent")) != NULL)
{
if (ventoy_is_dir_exist("%s%s", isodisk, iso))
{
pwd = vtoy_json_get_string_ex(pCNode->pstChild, "pwd");
if (0 == ventoy_plugin_parse_pwdstr((char *)pwd, NULL))
{
grub_printf("dir:<%s> [%s]\n", iso, (pos ? "*" : "OK"));
grub_printf("pwd:<%s>\n\n", pwd); grub_printf("pwd:<%s>\n\n", pwd);
} }
else else
@@ -956,6 +1175,7 @@ static int ventoy_plugin_persistence_check(VTOY_JSON *json, const char *isodisk)
{ {
int autosel = 0; int autosel = 0;
int pathnum = 0; int pathnum = 0;
char *pos = NULL;
const char *iso = NULL; const char *iso = NULL;
VTOY_JSON *pNode = NULL; VTOY_JSON *pNode = NULL;
@@ -975,9 +1195,10 @@ static int ventoy_plugin_persistence_check(VTOY_JSON *json, const char *isodisk)
iso = vtoy_json_get_string_ex(pNode->pstChild, "image"); iso = vtoy_json_get_string_ex(pNode->pstChild, "image");
if (iso) if (iso)
{ {
if (0 == ventoy_plugin_check_path(isodisk, iso)) pos = grub_strchr(iso, '*');
if (pos || 0 == ventoy_plugin_check_path(isodisk, iso))
{ {
grub_printf("image: %s [OK]\n", iso); grub_printf("image: %s [%s]\n", iso, (pos ? "*" : "OK"));
ventoy_plugin_check_fullpath(pNode->pstChild, isodisk, "backend", &pathnum); ventoy_plugin_check_fullpath(pNode->pstChild, isodisk, "backend", &pathnum);
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "autosel", &autosel)) if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "autosel", &autosel))
@@ -1102,8 +1323,12 @@ static int ventoy_plugin_menualias_check(VTOY_JSON *json, const char *isodisk)
if (path && path[0] == '/' && alias) if (path && path[0] == '/' && alias)
{ {
if (vtoy_alias_image_file == type) if (vtoy_alias_image_file == type)
{ {
if (ventoy_is_file_exist("%s%s", isodisk, path)) if (grub_strchr(path, '*'))
{
grub_printf("image: <%s> [ * ]\n", path);
}
else if (ventoy_is_file_exist("%s%s", isodisk, path))
{ {
grub_printf("image: <%s> [ OK ]\n", path); grub_printf("image: <%s> [ OK ]\n", path);
} }
@@ -1195,6 +1420,7 @@ static int ventoy_plugin_menualias_entry(VTOY_JSON *json, const char *isodisk)
static int ventoy_plugin_injection_check(VTOY_JSON *json, const char *isodisk) static int ventoy_plugin_injection_check(VTOY_JSON *json, const char *isodisk)
{ {
int type = 0;
const char *path = NULL; const char *path = NULL;
const char *archive = NULL; const char *archive = NULL;
VTOY_JSON *pNode = NULL; VTOY_JSON *pNode = NULL;
@@ -1209,11 +1435,17 @@ static int ventoy_plugin_injection_check(VTOY_JSON *json, const char *isodisk)
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext) for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
{ {
type = injection_type_file;
path = vtoy_json_get_string_ex(pNode->pstChild, "image"); path = vtoy_json_get_string_ex(pNode->pstChild, "image");
if (!path) if (!path)
{ {
grub_printf("image not found\n"); type = injection_type_parent;
continue; path = vtoy_json_get_string_ex(pNode->pstChild, "parent");
if (!path)
{
grub_printf("image/parent not found\n");
continue;
}
} }
archive = vtoy_json_get_string_ex(pNode->pstChild, "archive"); archive = vtoy_json_get_string_ex(pNode->pstChild, "archive");
@@ -1223,7 +1455,23 @@ static int ventoy_plugin_injection_check(VTOY_JSON *json, const char *isodisk)
continue; continue;
} }
grub_printf("image: <%s> [%s]\n", path, ventoy_check_file_exist("%s%s", isodisk, path) ? "OK" : "NOT EXIST"); if (type == injection_type_file)
{
if (grub_strchr(path, '*'))
{
grub_printf("image: <%s> [*]\n", path);
}
else
{
grub_printf("image: <%s> [%s]\n", path, ventoy_check_file_exist("%s%s", isodisk, path) ? "OK" : "NOT EXIST");
}
}
else
{
grub_printf("parent: <%s> [%s]\n", path,
ventoy_is_dir_exist("%s%s", isodisk, path) ? "OK" : "NOT EXIST");
}
grub_printf("archive: <%s> [%s]\n\n", archive, ventoy_check_file_exist("%s%s", isodisk, archive) ? "OK" : "NOT EXIST"); grub_printf("archive: <%s> [%s]\n\n", archive, ventoy_check_file_exist("%s%s", isodisk, archive) ? "OK" : "NOT EXIST");
} }
@@ -1232,6 +1480,7 @@ static int ventoy_plugin_injection_check(VTOY_JSON *json, const char *isodisk)
static int ventoy_plugin_injection_entry(VTOY_JSON *json, const char *isodisk) static int ventoy_plugin_injection_entry(VTOY_JSON *json, const char *isodisk)
{ {
int type = 0;
const char *path = NULL; const char *path = NULL;
const char *archive = NULL; const char *archive = NULL;
VTOY_JSON *pNode = NULL; VTOY_JSON *pNode = NULL;
@@ -1259,13 +1508,21 @@ static int ventoy_plugin_injection_entry(VTOY_JSON *json, const char *isodisk)
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext) for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
{ {
type = injection_type_file;
path = vtoy_json_get_string_ex(pNode->pstChild, "image"); path = vtoy_json_get_string_ex(pNode->pstChild, "image");
if (!path)
{
type = injection_type_parent;
path = vtoy_json_get_string_ex(pNode->pstChild, "parent");
}
archive = vtoy_json_get_string_ex(pNode->pstChild, "archive"); archive = vtoy_json_get_string_ex(pNode->pstChild, "archive");
if (path && path[0] == '/' && archive && archive[0] == '/') if (path && path[0] == '/' && archive && archive[0] == '/')
{ {
node = grub_zalloc(sizeof(injection_config)); node = grub_zalloc(sizeof(injection_config));
if (node) if (node)
{ {
node->type = type;
node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", path); node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", path);
grub_snprintf(node->archive, sizeof(node->archive), "%s", archive); grub_snprintf(node->archive, sizeof(node->archive), "%s", archive);
@@ -1285,6 +1542,7 @@ static int ventoy_plugin_injection_entry(VTOY_JSON *json, const char *isodisk)
static int ventoy_plugin_menuclass_entry(VTOY_JSON *json, const char *isodisk) static int ventoy_plugin_menuclass_entry(VTOY_JSON *json, const char *isodisk)
{ {
int type; int type;
int parent = 0;
const char *key = NULL; const char *key = NULL;
const char *class = NULL; const char *class = NULL;
VTOY_JSON *pNode = NULL; VTOY_JSON *pNode = NULL;
@@ -1313,12 +1571,21 @@ static int ventoy_plugin_menuclass_entry(VTOY_JSON *json, const char *isodisk)
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext) for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
{ {
parent = 0;
type = vtoy_class_image_file; type = vtoy_class_image_file;
key = vtoy_json_get_string_ex(pNode->pstChild, "key"); key = vtoy_json_get_string_ex(pNode->pstChild, "key");
if (!key) if (!key)
{ {
key = vtoy_json_get_string_ex(pNode->pstChild, "dir"); key = vtoy_json_get_string_ex(pNode->pstChild, "parent");
type = vtoy_class_directory; if (key)
{
parent = 1;
}
else
{
key = vtoy_json_get_string_ex(pNode->pstChild, "dir");
type = vtoy_class_directory;
}
} }
class = vtoy_json_get_string_ex(pNode->pstChild, "class"); class = vtoy_json_get_string_ex(pNode->pstChild, "class");
@@ -1328,6 +1595,7 @@ static int ventoy_plugin_menuclass_entry(VTOY_JSON *json, const char *isodisk)
if (node) if (node)
{ {
node->type = type; node->type = type;
node->parent = parent;
node->patlen = grub_snprintf(node->pattern, sizeof(node->pattern), "%s", key); node->patlen = grub_snprintf(node->pattern, sizeof(node->pattern), "%s", key);
grub_snprintf(node->class, sizeof(node->class), "%s", class); grub_snprintf(node->class, sizeof(node->class), "%s", class);
@@ -1349,7 +1617,7 @@ static int ventoy_plugin_menuclass_entry(VTOY_JSON *json, const char *isodisk)
static int ventoy_plugin_menuclass_check(VTOY_JSON *json, const char *isodisk) static int ventoy_plugin_menuclass_check(VTOY_JSON *json, const char *isodisk)
{ {
int type; const char *name = NULL;
const char *key = NULL; const char *key = NULL;
const char *class = NULL; const char *class = NULL;
VTOY_JSON *pNode = NULL; VTOY_JSON *pNode = NULL;
@@ -1364,18 +1632,23 @@ static int ventoy_plugin_menuclass_check(VTOY_JSON *json, const char *isodisk)
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext) for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
{ {
type = vtoy_class_image_file; name = "key";
key = vtoy_json_get_string_ex(pNode->pstChild, "key"); key = vtoy_json_get_string_ex(pNode->pstChild, "key");
if (!key) if (!key)
{ {
key = vtoy_json_get_string_ex(pNode->pstChild, "dir"); name = "parent";
type = vtoy_class_directory; key = vtoy_json_get_string_ex(pNode->pstChild, "parent");
if (!key)
{
name = "dir";
key = vtoy_json_get_string_ex(pNode->pstChild, "dir");
}
} }
class = vtoy_json_get_string_ex(pNode->pstChild, "class"); class = vtoy_json_get_string_ex(pNode->pstChild, "class");
if (key && class) if (key && class)
{ {
grub_printf("%s: <%s>\n", (type == vtoy_class_directory) ? "dir" : "key", key); grub_printf("%s: <%s>\n", name, key);
grub_printf("class: <%s>\n\n", class); grub_printf("class: <%s>\n\n", class);
} }
} }
@@ -1611,6 +1884,11 @@ static int ventoy_plugin_conf_replace_check(VTOY_JSON *json, const char *isodisk
grub_script_execute_sourcecode("loopback -d vtisocheck"); grub_script_execute_sourcecode("loopback -d vtisocheck");
} }
else if (grub_strchr(isof, '*'))
{
grub_printf("iso:<%s> [*]\n", isof);
grub_printf("org:<%s>\n", orgf);
}
else else
{ {
grub_printf("iso:<%s> [NOT Exist]\n", isof); grub_printf("iso:<%s> [NOT Exist]\n", isof);
@@ -1704,7 +1982,11 @@ static int ventoy_plugin_auto_memdisk_check(VTOY_JSON *json, const char *isodisk
{ {
grub_printf("<%s> ", pNode->unData.pcStrVal); grub_printf("<%s> ", pNode->unData.pcStrVal);
if (ventoy_check_file_exist("%s%s", isodisk, pNode->unData.pcStrVal)) if (grub_strchr(pNode->unData.pcStrVal, '*'))
{
grub_printf(" [*]\n");
}
else if (ventoy_check_file_exist("%s%s", isodisk, pNode->unData.pcStrVal))
{ {
grub_printf(" [OK]\n"); grub_printf(" [OK]\n");
} }
@@ -1794,7 +2076,11 @@ static int ventoy_plugin_image_list_check(VTOY_JSON *json, const char *isodisk)
{ {
grub_printf("<%s> ", pNode->unData.pcStrVal); grub_printf("<%s> ", pNode->unData.pcStrVal);
if (ventoy_check_file_exist("%s%s", isodisk, pNode->unData.pcStrVal)) if (grub_strchr(pNode->unData.pcStrVal, '*'))
{
grub_printf(" [*]\n");
}
else if (ventoy_check_file_exist("%s%s", isodisk, pNode->unData.pcStrVal))
{ {
grub_printf(" [OK]\n"); grub_printf(" [OK]\n");
} }
@@ -1928,7 +2214,7 @@ void ventoy_plugin_dump_injection(void)
for (node = g_injection_head; node; node = node->next) for (node = g_injection_head; node; node = node->next)
{ {
grub_printf("\nIMAGE:<%s>\n", node->isopath); grub_printf("\n%s:<%s>\n", (node->type == injection_type_file) ? "IMAGE" : "PARENT", node->isopath);
grub_printf("ARCHIVE:<%s>\n", node->archive); grub_printf("ARCHIVE:<%s>\n", node->archive);
} }
@@ -1943,7 +2229,9 @@ void ventoy_plugin_dump_auto_install(void)
for (node = g_install_template_head; node; node = node->next) for (node = g_install_template_head; node; node = node->next)
{ {
grub_printf("\nIMAGE:<%s> <%d>\n", node->isopath, node->templatenum); grub_printf("\n%s:<%s> <%d>\n",
(node->type == auto_install_type_file) ? "IMAGE" : "PARENT",
node->isopath, node->templatenum);
for (i = 0; i < node->templatenum; i++) for (i = 0; i < node->templatenum; i++)
{ {
grub_printf("SCRIPT %d:<%s>\n", i, node->templatepath[i].path); grub_printf("SCRIPT %d:<%s>\n", i, node->templatepath[i].path);
@@ -1996,9 +2284,23 @@ install_template * ventoy_plugin_find_install_template(const char *isopath)
len = (int)grub_strlen(isopath); len = (int)grub_strlen(isopath);
for (node = g_install_template_head; node; node = node->next) for (node = g_install_template_head; node; node = node->next)
{ {
if (node->pathlen == len && grub_strcmp(node->isopath, isopath) == 0) if (node->type == auto_install_type_file)
{ {
return node; if (node->pathlen == len && ventoy_strcmp(node->isopath, isopath) == 0)
{
return node;
}
}
}
for (node = g_install_template_head; node; node = node->next)
{
if (node->type == auto_install_type_parent)
{
if (node->pathlen < len && ventoy_plugin_is_parent(node->isopath, node->pathlen, isopath))
{
return node;
}
} }
} }
@@ -2036,7 +2338,7 @@ persistence_config * ventoy_plugin_find_persistent(const char *isopath)
len = (int)grub_strlen(isopath); len = (int)grub_strlen(isopath);
for (node = g_persistence_head; node; node = node->next) for (node = g_persistence_head; node; node = node->next)
{ {
if ((len == node->pathlen) && (grub_strcmp(node->isopath, isopath) == 0)) if ((len == node->pathlen) && (ventoy_strcmp(node->isopath, isopath) == 0))
{ {
return node; return node;
} }
@@ -2117,9 +2419,23 @@ const char * ventoy_plugin_get_injection(const char *isopath)
len = (int)grub_strlen(isopath); len = (int)grub_strlen(isopath);
for (node = g_injection_head; node; node = node->next) for (node = g_injection_head; node; node = node->next)
{ {
if (node->pathlen == len && grub_strcmp(node->isopath, isopath) == 0) if (node->type == injection_type_file)
{ {
return node->archive; if (node->pathlen == len && ventoy_strcmp(node->isopath, isopath) == 0)
{
return node->archive;
}
}
}
for (node = g_injection_head; node; node = node->next)
{
if (node->type == injection_type_parent)
{
if (node->pathlen < len && ventoy_plugin_is_parent(node->isopath, node->pathlen, isopath))
{
return node->archive;
}
} }
} }
@@ -2140,7 +2456,7 @@ const char * ventoy_plugin_get_menu_alias(int type, const char *isopath)
for (node = g_menu_alias_head; node; node = node->next) for (node = g_menu_alias_head; node; node = node->next)
{ {
if (node->type == type && node->pathlen && if (node->type == type && node->pathlen &&
node->pathlen == len && grub_strcmp(node->isopath, isopath) == 0) node->pathlen == len && ventoy_strcmp(node->isopath, isopath) == 0)
{ {
return node->alias; return node->alias;
} }
@@ -2149,25 +2465,51 @@ const char * ventoy_plugin_get_menu_alias(int type, const char *isopath)
return NULL; return NULL;
} }
const char * ventoy_plugin_get_menu_class(int type, const char *name) const char * ventoy_plugin_get_menu_class(int type, const char *name, const char *path)
{ {
int len; int namelen;
int pathlen;
menu_class *node = NULL; menu_class *node = NULL;
if (!g_menu_class_head) if (!g_menu_class_head)
{ {
return NULL; return NULL;
} }
len = (int)grub_strlen(name); namelen = (int)grub_strlen(name);
pathlen = (int)grub_strlen(path);
if (vtoy_class_image_file == type) if (vtoy_class_image_file == type)
{ {
for (node = g_menu_class_head; node; node = node->next) for (node = g_menu_class_head; node; node = node->next)
{ {
if (node->type == type && node->patlen <= len && grub_strstr(name, node->pattern)) if (node->type != type)
{ {
return node->class; continue;
}
if (node->parent == 0)
{
if ((node->patlen < namelen) && grub_strstr(name, node->pattern))
{
return node->class;
}
}
}
for (node = g_menu_class_head; node; node = node->next)
{
if (node->type != type)
{
continue;
}
if (node->parent)
{
if ((node->patlen < pathlen) && ventoy_plugin_is_parent(node->pattern, node->patlen, path))
{
return node->class;
}
} }
} }
} }
@@ -2175,7 +2517,7 @@ const char * ventoy_plugin_get_menu_class(int type, const char *name)
{ {
for (node = g_menu_class_head; node; node = node->next) for (node = g_menu_class_head; node; node = node->next)
{ {
if (node->type == type && node->patlen == len && grub_strncmp(name, node->pattern, len) == 0) if (node->type == type && node->patlen == namelen && grub_strncmp(name, node->pattern, namelen) == 0)
{ {
return node->class; return node->class;
} }
@@ -2288,7 +2630,7 @@ int ventoy_plugin_check_memdisk(const char *isopath)
len = (int)grub_strlen(isopath); len = (int)grub_strlen(isopath);
for (node = g_auto_memdisk_head; node; node = node->next) for (node = g_auto_memdisk_head; node; node = node->next)
{ {
if (node->pathlen == len && grub_strncmp(isopath, node->isopath, len) == 0) if (node->pathlen == len && ventoy_strncmp(node->isopath, isopath, len) == 0)
{ {
return 1; return 1;
} }
@@ -2314,14 +2656,14 @@ int ventoy_plugin_get_image_list_index(int type, const char *name)
{ {
if (vtoy_class_directory == type) if (vtoy_class_directory == type)
{ {
if (len < node->pathlen && grub_strncmp(name, node->isopath, len) == 0) if (len < node->pathlen && ventoy_strncmp(node->isopath, name, len) == 0)
{ {
return index; return index;
} }
} }
else else
{ {
if (len == node->pathlen && grub_strncmp(name, node->isopath, len) == 0) if (len == node->pathlen && ventoy_strncmp(node->isopath, name, len) == 0)
{ {
return index; return index;
} }
@@ -2345,7 +2687,7 @@ conf_replace * ventoy_plugin_find_conf_replace(const char *iso)
for (node = g_conf_replace_head; node; node = node->next) for (node = g_conf_replace_head; node; node = node->next)
{ {
if (node->pathlen == len && grub_strncmp(iso, node->isopath, len) == 0) if (node->pathlen == len && ventoy_strncmp(node->isopath, iso, len) == 0)
{ {
return node; return node;
} }
@@ -2367,7 +2709,7 @@ dud * ventoy_plugin_find_dud(const char *iso)
len = (int)grub_strlen(iso); len = (int)grub_strlen(iso);
for (node = g_dud_head; node; node = node->next) for (node = g_dud_head; node; node = node->next)
{ {
if (node->pathlen == len && grub_strncmp(iso, node->isopath, len) == 0) if (node->pathlen == len && ventoy_strncmp(node->isopath, iso, len) == 0)
{ {
return node; return node;
} }
@@ -2409,20 +2751,59 @@ int ventoy_plugin_load_dud(dud *node, const char *isopart)
static const vtoy_password * ventoy_plugin_get_password(const char *isopath) static const vtoy_password * ventoy_plugin_get_password(const char *isopath)
{ {
int i;
int len; int len;
const char *pos = NULL;
menu_password *node = NULL; menu_password *node = NULL;
if ((!g_pwd_head) || (!isopath)) if (!isopath)
{ {
return NULL; return NULL;
} }
len = (int)grub_strlen(isopath); if (g_pwd_head)
for (node = g_pwd_head; node; node = node->next)
{ {
if (node->pathlen == len && grub_strncmp(isopath, node->isopath, len) == 0) len = (int)grub_strlen(isopath);
for (node = g_pwd_head; node; node = node->next)
{ {
return &(node->password); if (node->type == vtoy_menu_pwd_file)
{
if (node->pathlen == len && ventoy_strncmp(node->isopath, isopath, len) == 0)
{
return &(node->password);
}
}
}
for (node = g_pwd_head; node; node = node->next)
{
if (node->type == vtoy_menu_pwd_parent)
{
if (node->pathlen < len && ventoy_plugin_is_parent(node->isopath, node->pathlen, isopath))
{
return &(node->password);
}
}
}
}
while (*isopath)
{
if (*isopath == '.')
{
pos = isopath;
}
isopath++;
}
if (pos)
{
for (i = 0; i < (int)ARRAY_SIZE(g_menu_prefix); i++)
{
if (g_file_type_pwd[i].type && 0 == grub_strcasecmp(pos + 1, g_menu_prefix[i]))
{
return g_file_type_pwd + i;
}
} }
} }
@@ -2542,3 +2923,62 @@ end:
return 0; return 0;
} }
grub_err_t ventoy_cmd_set_theme(grub_extcmd_context_t ctxt, int argc, char **args)
{
grub_uint32_t i = 0;
grub_uint32_t mod = 0;
theme_list *node = g_theme_head;
struct grub_datetime datetime;
(void)argc;
(void)args;
(void)ctxt;
if (g_theme_single_file[0])
{
debug("single theme %s\n", g_theme_single_file);
grub_env_set("theme", g_theme_single_file);
goto end;
}
debug("g_theme_num = %d\n", g_theme_num);
if (g_theme_num == 0)
{
goto end;
}
grub_memset(&datetime, 0, sizeof(datetime));
grub_get_datetime(&datetime);
if (g_theme_random == vtoy_theme_random_boot_second)
{
grub_divmod32((grub_uint32_t)datetime.second, (grub_uint32_t)g_theme_num, &mod);
}
else if (g_theme_random == vtoy_theme_random_boot_day)
{
grub_divmod32((grub_uint32_t)datetime.day, (grub_uint32_t)g_theme_num, &mod);
}
else if (g_theme_random == vtoy_theme_random_boot_month)
{
grub_divmod32((grub_uint32_t)datetime.month, (grub_uint32_t)g_theme_num, &mod);
}
debug("%04d/%02d/%02d %02d:%02d:%02d radom:%d mod:%d\n",
datetime.year, datetime.month, datetime.day,
datetime.hour, datetime.minute, datetime.second,
g_theme_random, mod);
for (i = 0; i < mod && node; i++)
{
node = node->next;
}
debug("random theme %s\n", node->theme.path);
grub_env_set("theme", node->theme.path);
end:
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}

View File

@@ -33,6 +33,8 @@
#include <grub/i18n.h> #include <grub/i18n.h>
#include <grub/net.h> #include <grub/net.h>
#include <grub/time.h> #include <grub/time.h>
#include <grub/elf.h>
#include <grub/elfload.h>
#include <grub/ventoy.h> #include <grub/ventoy.h>
#include "ventoy_def.h" #include "ventoy_def.h"
@@ -383,6 +385,174 @@ grub_err_t ventoy_cmd_unix_freebsd_ver(grub_extcmd_context_t ctxt, int argc, cha
VENTOY_CMD_RETURN(GRUB_ERR_NONE); VENTOY_CMD_RETURN(GRUB_ERR_NONE);
} }
grub_err_t ventoy_cmd_unix_freebsd_ver_elf(grub_extcmd_context_t ctxt, int argc, char **args)
{
int j;
int k;
grub_elf_t elf = NULL;
grub_off_t offset = 0;
grub_uint32_t len = 0;
char *str = NULL;
char *data = NULL;
void *hdr = NULL;
char ver[64] = {0};
(void)ctxt;
(void)argc;
(void)args;
if (argc != 3)
{
debug("Invalid argc %d\n", argc);
return 1;
}
data = grub_zalloc(8192);
if (!data)
{
goto out;
}
elf = grub_elf_open(args[0], GRUB_FILE_TYPE_LINUX_INITRD);
if (!elf)
{
debug("Failed to open file %s\n", args[0]);
goto out;
}
if (args[1][0] == '6')
{
Elf64_Ehdr *e = &(elf->ehdr.ehdr64);
Elf64_Shdr *h;
Elf64_Shdr *s;
Elf64_Shdr *t;
Elf64_Half i;
h = hdr = grub_zalloc(e->e_shnum * e->e_shentsize);
if (!h)
{
goto out;
}
debug("read section header %u %u %u\n", e->e_shnum, e->e_shentsize, e->e_shstrndx);
grub_file_seek(elf->file, e->e_shoff);
grub_file_read(elf->file, h, e->e_shnum * e->e_shentsize);
s = (Elf64_Shdr *)((char *)h + e->e_shstrndx * e->e_shentsize);
str = grub_malloc(s->sh_size + 1);
if (!str)
{
goto out;
}
str[s->sh_size] = 0;
debug("read string table %u %u\n", (grub_uint32_t)s->sh_offset, (grub_uint32_t)s->sh_size);
grub_file_seek(elf->file, s->sh_offset);
grub_file_read(elf->file, str, s->sh_size);
for (t = h, i = 0; i < e->e_shnum; i++)
{
if (grub_strcmp(str + t->sh_name, ".data") == 0)
{
offset = t->sh_offset;
len = t->sh_size;
debug("find .data section at %u %u\n", (grub_uint32_t)offset, len);
break;
}
t = (Elf64_Shdr *)((char *)t + e->e_shentsize);
}
}
else
{
Elf32_Ehdr *e = &(elf->ehdr.ehdr32);
Elf32_Shdr *h;
Elf32_Shdr *s;
Elf32_Shdr *t;
Elf32_Half i;
h = hdr = grub_zalloc(e->e_shnum * e->e_shentsize);
if (!h)
{
goto out;
}
debug("read section header %u %u %u\n", e->e_shnum, e->e_shentsize, e->e_shstrndx);
grub_file_seek(elf->file, e->e_shoff);
grub_file_read(elf->file, h, e->e_shnum * e->e_shentsize);
s = (Elf32_Shdr *)((char *)h + e->e_shstrndx * e->e_shentsize);
str = grub_malloc(s->sh_size + 1);
if (!str)
{
goto out;
}
str[s->sh_size] = 0;
debug("read string table %u %u\n", (grub_uint32_t)s->sh_offset, (grub_uint32_t)s->sh_size);
grub_file_seek(elf->file, s->sh_offset);
grub_file_read(elf->file, str, s->sh_size);
for (t = h, i = 0; i < e->e_shnum; i++)
{
if (grub_strcmp(str + t->sh_name, ".data") == 0)
{
offset = t->sh_offset;
len = t->sh_size;
debug("find .data section at %u %u\n", (grub_uint32_t)offset, len);
break;
}
t = (Elf32_Shdr *)((char *)t + e->e_shentsize);
}
}
if (offset == 0 || len == 0)
{
debug(".data section not found %s\n", args[0]);
goto out;
}
grub_file_seek(elf->file, offset + len - 8192);
grub_file_read(elf->file, data, 8192);
for (j = 0; j < 8192 - 12; j++)
{
if (grub_strncmp(data + j, "@(#)FreeBSD ", 12) == 0)
{
for (k = j + 12; k < 8192; k++)
{
if (0 == grub_isdigit(data[k]) && data[k] != '.')
{
data[k] = 0;
break;
}
}
grub_snprintf(ver, sizeof(ver), "%s", data + j + 12);
break;
}
}
if (ver[0])
{
k = (int)grub_strtoul(ver, NULL, 10);
debug("freebsd version:<%s> <%d.x>\n", ver, k);
grub_snprintf(ver, sizeof(ver), "%d.x", k);
ventoy_set_env(args[2], ver);
}
else
{
debug("freebsd version:<%s>\n", "NOT FOUND");
}
out:
grub_check_free(str);
grub_check_free(hdr);
grub_check_free(data);
check_free(elf, grub_elf_close);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, char **args) grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, char **args)
{ {
grub_uint32_t i; grub_uint32_t i;
@@ -550,7 +720,7 @@ grub_err_t ventoy_cmd_unix_fill_image_desc(grub_extcmd_context_t ctxt, int argc,
desc = (ventoy_image_desc *)(byte + i); desc = (ventoy_image_desc *)(byte + i);
desc->disk_size = g_ventoy_disk_size; desc->disk_size = g_ventoy_disk_size;
desc->part1_size = ventoy_get_part1_size(g_ventoy_part_info); desc->part1_size = g_ventoy_disk_part_size[0];
grub_memcpy(desc->disk_uuid, g_ventoy_part_info->MBR.BootCode + 0x180, 16); grub_memcpy(desc->disk_uuid, g_ventoy_part_info->MBR.BootCode + 0x180, 16);
grub_memcpy(desc->disk_signature, g_ventoy_part_info->MBR.BootCode + 0x1B8, 4); grub_memcpy(desc->disk_signature, g_ventoy_part_info->MBR.BootCode + 0x1B8, 4);

View File

@@ -44,14 +44,12 @@
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
static int g_vhdboot_bcd_offset = 0;
static int g_vhdboot_bcd_len = 0;
static int g_vhdboot_isolen = 0; static int g_vhdboot_isolen = 0;
static char *g_vhdboot_totbuf = NULL; static char *g_vhdboot_totbuf = NULL;
static char *g_vhdboot_isobuf = NULL; static char *g_vhdboot_isobuf = NULL;
static grub_uint64_t g_img_trim_head_secnum = 0; static grub_uint64_t g_img_trim_head_secnum = 0;
static int ventoy_vhd_find_bcd(int *bcdoffset, int *bcdlen) static int ventoy_vhd_find_bcd(int *bcdoffset, int *bcdlen, const char *path)
{ {
grub_uint32_t offset; grub_uint32_t offset;
grub_file_t file; grub_file_t file;
@@ -61,10 +59,9 @@ static int ventoy_vhd_find_bcd(int *bcdoffset, int *bcdlen)
grub_script_execute_sourcecode(cmdbuf); grub_script_execute_sourcecode(cmdbuf);
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", "(vhdiso)/boot/bcd"); file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "(vhdiso)%s", path);
if (!file) if (!file)
{ {
grub_printf("Failed to open bcd file in the image file\n");
return 1; return 1;
} }
@@ -83,13 +80,15 @@ static int ventoy_vhd_find_bcd(int *bcdoffset, int *bcdlen)
return 0; return 0;
} }
static int ventoy_vhd_patch_path(char *vhdpath, ventoy_patch_vhd *patch1, ventoy_patch_vhd *patch2) static int ventoy_vhd_patch_path(char *vhdpath, ventoy_patch_vhd *patch1, ventoy_patch_vhd *patch2,
int bcdoffset, int bcdlen)
{ {
int i; int i;
int cnt = 0; int cnt = 0;
char *pos; char *pos;
grub_size_t pathlen; grub_size_t pathlen;
const char *plat; const char *plat;
char *newpath = NULL;
grub_uint16_t *unicode_path; grub_uint16_t *unicode_path;
const grub_uint8_t winloadexe[] = const grub_uint8_t winloadexe[] =
{ {
@@ -97,6 +96,11 @@ static int ventoy_vhd_patch_path(char *vhdpath, ventoy_patch_vhd *patch1, ventoy
0x65, 0x00, 0x78, 0x00, 0x65, 0x00 0x65, 0x00, 0x78, 0x00, 0x65, 0x00
}; };
while ((*vhdpath) != '/')
{
vhdpath++;
}
pathlen = sizeof(grub_uint16_t) * (grub_strlen(vhdpath) + 1); pathlen = sizeof(grub_uint16_t) * (grub_strlen(vhdpath) + 1);
debug("unicode path for <%s> len:%d\n", vhdpath, (int)pathlen); debug("unicode path for <%s> len:%d\n", vhdpath, (int)pathlen);
@@ -110,10 +114,10 @@ static int ventoy_vhd_patch_path(char *vhdpath, ventoy_patch_vhd *patch1, ventoy
if (plat && (plat[0] == 'e')) /* UEFI */ if (plat && (plat[0] == 'e')) /* UEFI */
{ {
pos = g_vhdboot_isobuf + g_vhdboot_bcd_offset; pos = g_vhdboot_isobuf + bcdoffset;
/* winload.exe ==> winload.efi */ /* winload.exe ==> winload.efi */
for (i = 0; i + (int)sizeof(winloadexe) < g_vhdboot_bcd_len; i++) for (i = 0; i + (int)sizeof(winloadexe) < bcdlen; i++)
{ {
if (*((grub_uint32_t *)(pos + i)) == 0x00690077 && if (*((grub_uint32_t *)(pos + i)) == 0x00690077 &&
grub_memcmp(pos + i, winloadexe, sizeof(winloadexe)) == 0) grub_memcmp(pos + i, winloadexe, sizeof(winloadexe)) == 0)
@@ -127,7 +131,8 @@ static int ventoy_vhd_patch_path(char *vhdpath, ventoy_patch_vhd *patch1, ventoy
debug("winload patch %d times\n", cnt); debug("winload patch %d times\n", cnt);
} }
for (pos = vhdpath; *pos; pos++) newpath = grub_strdup(vhdpath);
for (pos = newpath; *pos; pos++)
{ {
if (*pos == '/') if (*pos == '/')
{ {
@@ -135,40 +140,159 @@ static int ventoy_vhd_patch_path(char *vhdpath, ventoy_patch_vhd *patch1, ventoy
} }
} }
grub_utf8_to_utf16(unicode_path, pathlen, (grub_uint8_t *)vhdpath, -1, NULL); grub_utf8_to_utf16(unicode_path, pathlen, (grub_uint8_t *)newpath, -1, NULL);
grub_memcpy(patch1->vhd_file_path, unicode_path, pathlen); grub_memcpy(patch1->vhd_file_path, unicode_path, pathlen);
grub_memcpy(patch2->vhd_file_path, unicode_path, pathlen); grub_memcpy(patch2->vhd_file_path, unicode_path, pathlen);
grub_free(newpath);
return 0; return 0;
} }
static int ventoy_vhd_patch_disk(ventoy_patch_vhd *patch1, ventoy_patch_vhd *patch2) static int ventoy_vhd_read_parttbl(const char *filename, ventoy_gpt_info *gpt, int *index)
{ {
int i;
int ret = 1;
grub_uint64_t start;
grub_file_t file = NULL;
grub_disk_t disk = NULL;
grub_uint8_t zeroguid[16] = {0};
file = grub_file_open(filename, VENTOY_FILE_TYPE);
if (!file)
{
goto end;
}
disk = grub_disk_open(file->device->disk->name);
if (!disk)
{
goto end;
}
grub_disk_read(disk, 0, 0, sizeof(ventoy_gpt_info), gpt);
start = file->device->disk->partition->start;
if (grub_memcmp(gpt->Head.Signature, "EFI PART", 8) == 0)
{
debug("GPT part start: %llu\n", (ulonglong)start);
for (i = 0; i < 128; i++)
{
if (grub_memcmp(gpt->PartTbl[i].PartGuid, zeroguid, 16))
{
if (start == gpt->PartTbl[i].StartLBA)
{
*index = i;
break;
}
}
}
}
else
{
debug("MBR part start: %llu\n", (ulonglong)start);
for (i = 0; i < 4; i++)
{
if ((grub_uint32_t)start == gpt->MBR.PartTbl[i].StartSectorId)
{
*index = i;
break;
}
}
}
ret = 0;
end:
check_free(file, grub_file_close);
check_free(disk, grub_disk_close);
return ret;
}
static int ventoy_vhd_patch_disk(const char *vhdpath, ventoy_patch_vhd *patch1, ventoy_patch_vhd *patch2)
{
int partIndex = 0;
grub_uint64_t offset = 0;
char efipart[16] = {0}; char efipart[16] = {0};
ventoy_gpt_info *gpt = NULL;
grub_memcpy(efipart, g_ventoy_part_info->Head.Signature, sizeof(g_ventoy_part_info->Head.Signature)); if (vhdpath[0] == '/')
{
gpt = g_ventoy_part_info;
partIndex = 0;
debug("This is Ventoy ISO partIndex %d %s\n", partIndex, vhdpath);
}
else
{
gpt = grub_zalloc(sizeof(ventoy_gpt_info));
ventoy_vhd_read_parttbl(vhdpath, gpt, &partIndex);
debug("This is HDD partIndex %d %s\n", partIndex, vhdpath);
}
debug("part1 type: 0x%x <%s>\n", g_ventoy_part_info->MBR.PartTbl[0].FsFlag, efipart); grub_memcpy(efipart, gpt->Head.Signature, sizeof(gpt->Head.Signature));
grub_memset(patch1, 0, OFFSET_OF(ventoy_patch_vhd, vhd_file_path));
grub_memset(patch2, 0, OFFSET_OF(ventoy_patch_vhd, vhd_file_path));
if (grub_strncmp(efipart, "EFI PART", 8) == 0) if (grub_strncmp(efipart, "EFI PART", 8) == 0)
{ {
ventoy_debug_dump_guid("GPT disk GUID: ", g_ventoy_part_info->Head.DiskGuid); ventoy_debug_dump_guid("GPT disk GUID: ", gpt->Head.DiskGuid);
ventoy_debug_dump_guid("GPT part GUID: ", g_ventoy_part_info->PartTbl[0].PartGuid); ventoy_debug_dump_guid("GPT partIndex GUID: ", gpt->PartTbl[partIndex].PartGuid);
grub_memcpy(patch1->disk_signature_or_guid, g_ventoy_part_info->Head.DiskGuid, 16); grub_memcpy(patch1->disk_signature_or_guid, gpt->Head.DiskGuid, 16);
grub_memcpy(patch1->part_offset_or_guid, g_ventoy_part_info->PartTbl[0].PartGuid, 16); grub_memcpy(patch1->part_offset_or_guid, gpt->PartTbl[partIndex].PartGuid, 16);
grub_memcpy(patch2->disk_signature_or_guid, g_ventoy_part_info->Head.DiskGuid, 16); grub_memcpy(patch2->disk_signature_or_guid, gpt->Head.DiskGuid, 16);
grub_memcpy(patch2->part_offset_or_guid, g_ventoy_part_info->PartTbl[0].PartGuid, 16); grub_memcpy(patch2->part_offset_or_guid, gpt->PartTbl[partIndex].PartGuid, 16);
patch1->part_type = patch2->part_type = 0; patch1->part_type = patch2->part_type = 0;
} }
else else
{ {
debug("MBR disk signature: %02x%02x%02x%02x\n", offset = gpt->MBR.PartTbl[partIndex].StartSectorId;
g_ventoy_part_info->MBR.BootCode[0x1b8 + 0], g_ventoy_part_info->MBR.BootCode[0x1b8 + 1], offset *= 512;
g_ventoy_part_info->MBR.BootCode[0x1b8 + 2], g_ventoy_part_info->MBR.BootCode[0x1b8 + 3]);
grub_memcpy(patch1->disk_signature_or_guid, g_ventoy_part_info->MBR.BootCode + 0x1b8, 4); debug("MBR disk signature: %02x%02x%02x%02x Part(%d) offset:%llu\n",
grub_memcpy(patch2->disk_signature_or_guid, g_ventoy_part_info->MBR.BootCode + 0x1b8, 4); gpt->MBR.BootCode[0x1b8 + 0], gpt->MBR.BootCode[0x1b8 + 1],
gpt->MBR.BootCode[0x1b8 + 2], gpt->MBR.BootCode[0x1b8 + 3],
partIndex + 1, offset);
grub_memcpy(patch1->part_offset_or_guid, &offset, 8);
grub_memcpy(patch2->part_offset_or_guid, &offset, 8);
grub_memcpy(patch1->disk_signature_or_guid, gpt->MBR.BootCode + 0x1b8, 4);
grub_memcpy(patch2->disk_signature_or_guid, gpt->MBR.BootCode + 0x1b8, 4);
patch1->part_type = patch2->part_type = 1;
}
if (gpt != g_ventoy_part_info)
{
grub_free(gpt);
}
return 0;
}
static int ventoy_find_vhdpatch_offset(int bcdoffset, int bcdlen, int *offset)
{
int i;
int cnt = 0;
grub_uint8_t *buf = (grub_uint8_t *)(g_vhdboot_isobuf + bcdoffset);
grub_uint8_t magic[16] = {
0x5C, 0x00, 0x58, 0x00, 0x58, 0x00, 0x58, 0x00, 0x58, 0x00, 0x58, 0x00, 0x58, 0x00, 0x58, 0x00
};
for (i = 0; i < bcdlen - 16 && cnt < 2; i++)
{
if (*(grub_uint32_t *)(buf + i) == 0x0058005C)
{
if (grub_memcmp(magic, buf + i, 16) == 0)
{
*offset++ = i - (int)OFFSET_OF(ventoy_patch_vhd, vhd_file_path);
cnt++;
}
}
} }
return 0; return 0;
@@ -177,6 +301,8 @@ static int ventoy_vhd_patch_disk(ventoy_patch_vhd *patch1, ventoy_patch_vhd *pat
grub_err_t ventoy_cmd_patch_vhdboot(grub_extcmd_context_t ctxt, int argc, char **args) grub_err_t ventoy_cmd_patch_vhdboot(grub_extcmd_context_t ctxt, int argc, char **args)
{ {
int rc; int rc;
int bcdoffset, bcdlen;
int patchoffset[2];
ventoy_patch_vhd *patch1; ventoy_patch_vhd *patch1;
ventoy_patch_vhd *patch2; ventoy_patch_vhd *patch2;
char envbuf[64]; char envbuf[64];
@@ -194,18 +320,39 @@ grub_err_t ventoy_cmd_patch_vhdboot(grub_extcmd_context_t ctxt, int argc, char *
return 0; return 0;
} }
rc = ventoy_vhd_find_bcd(&g_vhdboot_bcd_offset, &g_vhdboot_bcd_len); rc = ventoy_vhd_find_bcd(&bcdoffset, &bcdlen, "/boot/bcd");
if (rc) if (rc)
{ {
debug("failed to get bcd location %d\n", rc); debug("failed to get bcd location %d\n", rc);
return 0; }
else
{
ventoy_find_vhdpatch_offset(bcdoffset, bcdlen, patchoffset);
patch1 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + bcdoffset + patchoffset[0]);
patch2 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + bcdoffset + patchoffset[1]);
debug("Find /boot/bcd (%d %d) now patch it (offset: 0x%x 0x%x) ...\n",
bcdoffset, bcdlen, patchoffset[0], patchoffset[1]);
ventoy_vhd_patch_disk(args[0], patch1, patch2);
ventoy_vhd_patch_path(args[0], patch1, patch2, bcdoffset, bcdlen);
} }
patch1 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + g_vhdboot_bcd_offset + 0x495a); rc = ventoy_vhd_find_bcd(&bcdoffset, &bcdlen, "/boot/BCD");
patch2 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + g_vhdboot_bcd_offset + 0x50aa); if (rc)
{
ventoy_vhd_patch_disk(patch1, patch2); debug("No file /boot/BCD \n");
ventoy_vhd_patch_path(args[0], patch1, patch2); }
else
{
ventoy_find_vhdpatch_offset(bcdoffset, bcdlen, patchoffset);
patch1 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + bcdoffset + patchoffset[0]);
patch2 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + bcdoffset + patchoffset[1]);
debug("Find /boot/BCD (%d %d) now patch it (offset: 0x%x 0x%x) ...\n",
bcdoffset, bcdlen, patchoffset[0], patchoffset[1]);
ventoy_vhd_patch_disk(args[0], patch1, patch2);
ventoy_vhd_patch_path(args[0], patch1, patch2, bcdoffset, bcdlen);
}
/* set buffer and size */ /* set buffer and size */
#ifdef GRUB_MACHINE_EFI #ifdef GRUB_MACHINE_EFI
@@ -220,7 +367,7 @@ grub_err_t ventoy_cmd_patch_vhdboot(grub_extcmd_context_t ctxt, int argc, char *
grub_env_set("vtoy_vhd_buf_size", envbuf); grub_env_set("vtoy_vhd_buf_size", envbuf);
#endif #endif
return 0; VENTOY_CMD_RETURN(GRUB_ERR_NONE);
} }
grub_err_t ventoy_cmd_load_vhdboot(grub_extcmd_context_t ctxt, int argc, char **args) grub_err_t ventoy_cmd_load_vhdboot(grub_extcmd_context_t ctxt, int argc, char **args)
@@ -396,7 +543,7 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
} }
grub_env_set(args[1], type); grub_env_set(args[1], type);
debug("<%s> vtoy type: <%s> ", args[0], type); debug("<%s> vtoy type: <%s> offset:%d\n", args[0], type, offset);
if (offset >= 0) if (offset >= 0)
{ {
@@ -451,6 +598,14 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
altboot = 1; altboot = 1;
grub_env_set(args[3], "1"); grub_env_set(args[3], "1");
} }
else
{
debug("offset data=0x%x\n", data);
}
}
else
{
debug("BootCode: 0x%x\n", gpt->MBR.BootCode[92]);
} }
} }
} }

View File

@@ -314,6 +314,90 @@ static int ventoy_is_pe64(grub_uint8_t *buffer)
return 0; return 0;
} }
grub_err_t ventoy_cmd_is_pe64(grub_extcmd_context_t ctxt, int argc, char **args)
{
int ret = 1;
grub_file_t file;
grub_uint8_t buf[512];
(void)ctxt;
(void)argc;
file = grub_file_open(args[0], VENTOY_FILE_TYPE);
if (!file)
{
return 1;
}
grub_memset(buf, 0, 512);
grub_file_read(file, buf, 512);
if (ventoy_is_pe64(buf))
{
debug("%s is PE64\n", args[0]);
ret = 0;
}
else
{
debug("%s is PE32\n", args[0]);
}
grub_file_close(file);
return ret;
}
grub_err_t ventoy_cmd_sel_wimboot(grub_extcmd_context_t ctxt, int argc, char **args)
{
int size;
char *buf = NULL;
char configfile[128];
(void)ctxt;
(void)argc;
(void)args;
debug("select wimboot argc:%d\n", argc);
buf = (char *)grub_malloc(8192);
if (!buf)
{
return 0;
}
size = (int)grub_snprintf(buf, 8192,
"menuentry \"Windows Setup (32-bit)\" {\n"
" set vtoy_wimboot_sel=32\n"
"}\n"
"menuentry \"Windows Setup (64-bit)\" {\n"
" set vtoy_wimboot_sel=64\n"
"}\n"
);
buf[size] = 0;
g_ventoy_menu_esc = 1;
g_ventoy_suppress_esc = 1;
grub_snprintf(configfile, sizeof(configfile), "configfile mem:0x%llx:size:%d", (ulonglong)(ulong)buf, size);
grub_script_execute_sourcecode(configfile);
g_ventoy_menu_esc = 0;
g_ventoy_suppress_esc = 0;
grub_free(buf);
if (g_ventoy_last_entry == 0)
{
debug("last entry=%d %s=32\n", g_ventoy_last_entry, args[0]);
grub_env_set(args[0], "32");
}
else
{
debug("last entry=%d %s=64\n", g_ventoy_last_entry, args[0]);
grub_env_set(args[0], "64");
}
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_wimdows_reset(grub_extcmd_context_t ctxt, int argc, char **args) grub_err_t ventoy_cmd_wimdows_reset(grub_extcmd_context_t ctxt, int argc, char **args)
{ {
wim_patch *next = NULL; wim_patch *next = NULL;
@@ -464,6 +548,8 @@ static int ventoy_read_resource(grub_file_t fp, wim_header *wimhdr, wim_resource
chunk_num = (head->raw_size + WIM_CHUNK_LEN - 1) / WIM_CHUNK_LEN; chunk_num = (head->raw_size + WIM_CHUNK_LEN - 1) / WIM_CHUNK_LEN;
cur_offset = (chunk_num - 1) * 4; cur_offset = (chunk_num - 1) * 4;
chunk_offset = (grub_uint32_t *)buffer_compress; chunk_offset = (grub_uint32_t *)buffer_compress;
//debug("%llu %llu chunk_num=%lu", (ulonglong)head->size_in_wim, (ulonglong)head->raw_size, chunk_num);
cur_dst = buffer_decompress; cur_dst = buffer_decompress;
@@ -516,9 +602,11 @@ static int ventoy_read_resource(grub_file_t fp, wim_header *wimhdr, wim_resource
decompress_len = (int)lzx_decompress(buffer_compress + cur_offset, head->size_in_wim - cur_offset, cur_dst); decompress_len = (int)lzx_decompress(buffer_compress + cur_offset, head->size_in_wim - cur_offset, cur_dst);
} }
} }
cur_dst += decompress_len; cur_dst += decompress_len;
total_decompress += decompress_len; total_decompress += decompress_len;
//debug("last chunk_size:%u decompresslen:%d tot:%d\n", last_chunk_size, decompress_len, total_decompress);
if (cur_dst != buffer_decompress + head->raw_size) if (cur_dst != buffer_decompress + head->raw_size)
{ {
@@ -573,8 +661,15 @@ static wim_directory_entry * search_full_wim_dirent
static wim_directory_entry * search_replace_wim_dirent(void *meta_data, wim_directory_entry *dir) static wim_directory_entry * search_replace_wim_dirent(void *meta_data, wim_directory_entry *dir)
{ {
wim_directory_entry *wim_dirent = NULL; wim_directory_entry *wim_dirent = NULL;
const char *pecmd_path[] = { "Windows", "System32", "pecmd.exe", NULL };
const char *winpeshl_path[] = { "Windows", "System32", "winpeshl.exe", NULL }; const char *winpeshl_path[] = { "Windows", "System32", "winpeshl.exe", NULL };
//const char *native_path[] = { "Windows", "System32", "native.exe", NULL };
wim_dirent = search_full_wim_dirent(meta_data, dir, pecmd_path);
debug("search pecmd.exe %p\n", wim_dirent);
if (wim_dirent)
{
return wim_dirent;
}
wim_dirent = search_full_wim_dirent(meta_data, dir, winpeshl_path); wim_dirent = search_full_wim_dirent(meta_data, dir, winpeshl_path);
debug("search winpeshl.exe %p\n", wim_dirent); debug("search winpeshl.exe %p\n", wim_dirent);
@@ -583,15 +678,6 @@ static wim_directory_entry * search_replace_wim_dirent(void *meta_data, wim_dire
return wim_dirent; return wim_dirent;
} }
#if 0
wim_dirent = search_full_wim_dirent(meta_data, dir, native_path);
debug("search native.exe %p\n", wim_dirent);
if (wim_dirent)
{
return wim_dirent;
}
#endif
return NULL; return NULL;
} }
@@ -636,6 +722,42 @@ static wim_lookup_entry * ventoy_find_meta_entry(wim_header *header, wim_lookup_
return NULL; return NULL;
} }
static grub_uint64_t ventoy_get_stream_len(wim_directory_entry *dir)
{
grub_uint16_t i;
grub_uint64_t offset = 0;
wim_stream_entry *stream = (wim_stream_entry *)((char *)dir + dir->len);
for (i = 0; i < dir->streams; i++)
{
offset += stream->len;
stream = (wim_stream_entry *)((char *)stream + stream->len);
}
return offset;
}
static int ventoy_update_stream_hash(wim_patch *patch, wim_directory_entry *dir)
{
grub_uint16_t i;
grub_uint64_t offset = 0;
wim_stream_entry *stream = (wim_stream_entry *)((char *)dir + dir->len);
for (i = 0; i < dir->streams; i++)
{
if (grub_memcmp(stream->hash.sha1, patch->old_hash.sha1, sizeof(wim_hash)) == 0)
{
debug("find target stream %u, name_len:%u upadte hash\n", i, stream->name_len);
grub_memcpy(stream->hash.sha1, &(patch->wim_data.bin_hash), sizeof(wim_hash));
}
offset += stream->len;
stream = (wim_stream_entry *)((char *)stream + stream->len);
}
return offset;
}
static int ventoy_update_all_hash(wim_patch *patch, void *meta_data, wim_directory_entry *dir) static int ventoy_update_all_hash(wim_patch *patch, void *meta_data, wim_directory_entry *dir)
{ {
if ((meta_data == NULL) || (dir == NULL)) if ((meta_data == NULL) || (dir == NULL))
@@ -660,8 +782,16 @@ static int ventoy_update_all_hash(wim_patch *patch, void *meta_data, wim_directo
{ {
ventoy_update_all_hash(patch, meta_data, (wim_directory_entry *)((char *)meta_data + dir->subdir)); ventoy_update_all_hash(patch, meta_data, (wim_directory_entry *)((char *)meta_data + dir->subdir));
} }
dir = (wim_directory_entry *)((char *)dir + dir->len); if (dir->streams)
{
ventoy_update_stream_hash(patch, dir);
dir = (wim_directory_entry *)((char *)dir + dir->len + ventoy_get_stream_len(dir));
}
else
{
dir = (wim_directory_entry *)((char *)dir + dir->len);
}
} while (dir->len >= sizeof(wim_directory_entry)); } while (dir->len >= sizeof(wim_directory_entry));
return 0; return 0;
@@ -776,7 +906,14 @@ static int ventoy_update_before_chain(ventoy_os_param *param, char *isopath)
grub_crypto_hash(GRUB_MD_SHA1, wim_data->bin_hash.sha1, wim_data->jump_bin_data, wim_data->bin_raw_len); grub_crypto_hash(GRUB_MD_SHA1, wim_data->bin_hash.sha1, wim_data->jump_bin_data, wim_data->bin_raw_len);
security = (wim_security_header *)wim_data->new_meta_data; security = (wim_security_header *)wim_data->new_meta_data;
rootdir = (wim_directory_entry *)(wim_data->new_meta_data + ((security->len + 7) & 0xFFFFFFF8U)); if (security->len > 0)
{
rootdir = (wim_directory_entry *)(wim_data->new_meta_data + ((security->len + 7) & 0xFFFFFFF8U));
}
else
{
rootdir = (wim_directory_entry *)(wim_data->new_meta_data + 8);
}
/* update all winpeshl.exe dirent entry's hash */ /* update all winpeshl.exe dirent entry's hash */
ventoy_update_all_hash(node, wim_data->new_meta_data, rootdir); ventoy_update_all_hash(node, wim_data->new_meta_data, rootdir);
@@ -809,6 +946,7 @@ static int ventoy_update_before_chain(ventoy_os_param *param, char *isopath)
static int ventoy_wimdows_locate_wim(const char *disk, wim_patch *patch) static int ventoy_wimdows_locate_wim(const char *disk, wim_patch *patch)
{ {
int rc; int rc;
grub_uint16_t i;
grub_file_t file; grub_file_t file;
grub_uint32_t exe_len; grub_uint32_t exe_len;
grub_uint8_t *exe_data = NULL; grub_uint8_t *exe_data = NULL;
@@ -817,6 +955,7 @@ static int ventoy_wimdows_locate_wim(const char *disk, wim_patch *patch)
wim_security_header *security = NULL; wim_security_header *security = NULL;
wim_directory_entry *rootdir = NULL; wim_directory_entry *rootdir = NULL;
wim_directory_entry *search = NULL; wim_directory_entry *search = NULL;
wim_stream_entry *stream = NULL;
wim_header *head = &(patch->wim_data.wim_header); wim_header *head = &(patch->wim_data.wim_header);
wim_tail *wim_data = &patch->wim_data; wim_tail *wim_data = &patch->wim_data;
@@ -860,7 +999,14 @@ static int ventoy_wimdows_locate_wim(const char *disk, wim_patch *patch)
} }
security = (wim_security_header *)decompress_data; security = (wim_security_header *)decompress_data;
rootdir = (wim_directory_entry *)(decompress_data + ((security->len + 7) & 0xFFFFFFF8U)); if (security->len > 0)
{
rootdir = (wim_directory_entry *)(decompress_data + ((security->len + 7) & 0xFFFFFFF8U));
}
else
{
rootdir = (wim_directory_entry *)(decompress_data + 8);
}
/* search winpeshl.exe dirent entry */ /* search winpeshl.exe dirent entry */
search = search_replace_wim_dirent(decompress_data, rootdir); search = search_replace_wim_dirent(decompress_data, rootdir);
@@ -872,8 +1018,28 @@ static int ventoy_wimdows_locate_wim(const char *disk, wim_patch *patch)
} }
debug("find replace file at %p\n", search); debug("find replace file at %p\n", search);
grub_memcpy(&patch->old_hash, search->hash.sha1, sizeof(wim_hash)); grub_memset(&patch->old_hash, 0, sizeof(wim_hash));
if (grub_memcmp(&patch->old_hash, search->hash.sha1, sizeof(wim_hash)) == 0)
{
debug("search hash all 0, now do deep search\n");
stream = (wim_stream_entry *)((char *)search + search->len);
for (i = 0; i < search->streams; i++)
{
if (stream->name_len == 0)
{
grub_memcpy(&patch->old_hash, stream->hash.sha1, sizeof(wim_hash));
debug("new search hash: %02x %02x %02x %02x %02x %02x %02x %02x\n",
ventoy_varg_8(patch->old_hash.sha1));
break;
}
stream = (wim_stream_entry *)((char *)stream + stream->len);
}
}
else
{
grub_memcpy(&patch->old_hash, search->hash.sha1, sizeof(wim_hash));
}
debug("read lookup offset:%llu size:%llu\n", (ulonglong)head->lookup.offset, (ulonglong)head->lookup.raw_size); debug("read lookup offset:%llu size:%llu\n", (ulonglong)head->lookup.offset, (ulonglong)head->lookup.raw_size);
lookup = grub_malloc(head->lookup.raw_size); lookup = grub_malloc(head->lookup.raw_size);
@@ -900,8 +1066,8 @@ static int ventoy_wimdows_locate_wim(const char *disk, wim_patch *patch)
} }
else else
{ {
debug("failed to find lookup entry for replace file 0x%02x 0x%02x\n", debug("failed to find lookup entry for replace file %02x %02x %02x %02x\n",
patch->old_hash.sha1[0], patch->old_hash.sha1[1]); ventoy_varg_4(patch->old_hash.sha1));
} }
wim_data->wim_raw_size = (grub_uint32_t)file->size; wim_data->wim_raw_size = (grub_uint32_t)file->size;
@@ -1054,7 +1220,48 @@ static void ventoy_windows_fill_override_data_iso9660( grub_uint64_t isosize,
return; return;
} }
static void ventoy_windows_fill_override_data_udf( grub_uint64_t isosize, void *override) static int ventoy_windows_fill_udf_short_ad(grub_file_t isofile, grub_uint32_t curpos,
wim_tail *wim_data, grub_uint32_t new_wim_size)
{
int i;
grub_uint32_t total = 0;
grub_uint32_t left_size = 0;
ventoy_udf_override *udf = NULL;
ventoy_udf_override tmp[4];
grub_memset(tmp, 0, sizeof(tmp));
grub_file_seek(isofile, wim_data->override_offset);
grub_file_read(isofile, tmp, sizeof(tmp));
left_size = new_wim_size;
udf = (ventoy_udf_override *)wim_data->override_data;
for (i = 0; i < 4; i++)
{
total += tmp[i].length;
if (total >= wim_data->wim_raw_size)
{
udf->length = left_size;
udf->position = curpos;
return 0;
}
else
{
udf->length = tmp[i].length;
udf->position = curpos;
}
left_size -= tmp[i].length;
curpos += udf->length / 2048;
udf++;
wim_data->override_len += sizeof(ventoy_udf_override);
}
debug("######## Too many udf ad ######\n");
return 1;
}
static void ventoy_windows_fill_override_data_udf(grub_file_t isofile, void *override)
{ {
grub_uint32_t data32; grub_uint32_t data32;
grub_uint64_t data64; grub_uint64_t data64;
@@ -1065,9 +1272,8 @@ static void ventoy_windows_fill_override_data_udf( grub_uint64_t isosize, voi
ventoy_override_chunk *cur; ventoy_override_chunk *cur;
wim_patch *node = NULL; wim_patch *node = NULL;
wim_tail *wim_data = NULL; wim_tail *wim_data = NULL;
ventoy_udf_override *udf = NULL;
sector = (isosize + 2047) / 2048; sector = (isofile->size + 2047) / 2048;
cur = (ventoy_override_chunk *)override; cur = (ventoy_override_chunk *)override;
@@ -1077,7 +1283,7 @@ static void ventoy_windows_fill_override_data_udf( grub_uint64_t isosize, voi
cur++; cur++;
} }
debug("ventoy_windows_fill_override_data_udf %lu\n", (ulong)isosize); debug("ventoy_windows_fill_override_data_udf %lu\n", (ulong)isofile->size);
for (node = g_wim_patch_head; node; node = node->next) for (node = g_wim_patch_head; node; node = node->next)
{ {
@@ -1118,13 +1324,11 @@ static void ventoy_windows_fill_override_data_udf( grub_uint64_t isosize, voi
data64 = new_wim_size; data64 = new_wim_size;
grub_memcpy(cur->override_data, &(data64), 8); grub_memcpy(cur->override_data, &(data64), 8);
udf = (ventoy_udf_override *)wim_data->override_data; /* override 3: position and length in extend data */
udf->length = new_wim_size; ventoy_windows_fill_udf_short_ad(isofile, (grub_uint32_t)sector - udf_start_block, wim_data, new_wim_size);
udf->position = (grub_uint32_t)sector - udf_start_block;
sector += (new_wim_size / 2048); sector += (new_wim_size / 2048);
/* override 3: position and length in extend data */
cur++; cur++;
cur->img_offset = wim_data->override_offset; cur->img_offset = wim_data->override_offset;
cur->override_size = wim_data->override_len; cur->override_size = wim_data->override_len;
@@ -1301,6 +1505,54 @@ end:
return rc; return rc;
} }
grub_err_t ventoy_cmd_windows_wimboot_data(grub_extcmd_context_t ctxt, int argc, char **args)
{
grub_uint32_t size = 0;
const char *addr = NULL;
ventoy_chain_head *chain = NULL;
ventoy_os_param *param = NULL;
char envbuf[64];
(void)ctxt;
(void)argc;
(void)args;
addr = grub_env_get("vtoy_chain_mem_addr");
if (!addr)
{
debug("Failed to find vtoy_chain_mem_addr\n");
return 1;
}
chain = (ventoy_chain_head *)(void *)grub_strtoul(addr, NULL, 16);
if (grub_memcmp(&g_ventoy_guid, &chain->os_param.guid, 16) != 0)
{
debug("os_param.guid not match\n");
return 1;
}
size = sizeof(ventoy_os_param) + sizeof(ventoy_windows_data);
param = (ventoy_os_param *)grub_zalloc(size);
if (!param)
{
return 1;
}
grub_memcpy(param, &chain->os_param, sizeof(ventoy_os_param));
ventoy_fill_windows_rtdata(param + 1, param->vtoy_img_path);
grub_snprintf(envbuf, sizeof(envbuf), "0x%lx", (unsigned long)param);
grub_env_set("vtoy_wimboot_mem_addr", envbuf);
debug("vtoy_wimboot_mem_addr: %s\n", envbuf);
grub_snprintf(envbuf, sizeof(envbuf), "%u", size);
grub_env_set("vtoy_wimboot_mem_size", envbuf);
debug("vtoy_wimboot_mem_size: %s\n", envbuf);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, char **args) grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, char **args)
{ {
int unknown_image = 0; int unknown_image = 0;
@@ -1470,7 +1722,7 @@ grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, c
} }
else else
{ {
ventoy_windows_fill_override_data_udf(isosize, (char *)chain + chain->override_chunk_offset); ventoy_windows_fill_override_data_udf(file, (char *)chain + chain->override_chunk_offset);
} }
/* part 5: virt chunk */ /* part 5: virt chunk */
@@ -1733,3 +1985,29 @@ grub_err_t ventoy_cmd_wim_chain_data(grub_extcmd_context_t ctxt, int argc, char
VENTOY_CMD_RETURN(GRUB_ERR_NONE); VENTOY_CMD_RETURN(GRUB_ERR_NONE);
} }
int ventoy_chain_file_size(const char *path)
{
int size;
grub_file_t file;
file = grub_file_open(path, VENTOY_FILE_TYPE);
size = (int)(file->size);
grub_file_close(file);
return size;
}
int ventoy_chain_file_read(const char *path, int offset, int len, void *buf)
{
int size;
grub_file_t file;
file = grub_file_open(path, VENTOY_FILE_TYPE);
grub_file_seek(file, offset);
size = grub_file_read(file, buf, len);
grub_file_close(file);
return size;
}

View File

@@ -87,6 +87,7 @@ EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1,
const grub_efi_device_path_t *dp2); const grub_efi_device_path_t *dp2);
void * EXPORT_FUNC (grub_efi_allocate_iso_buf) (grub_uint64_t size); void * EXPORT_FUNC (grub_efi_allocate_iso_buf) (grub_uint64_t size);
void * EXPORT_FUNC (grub_efi_allocate_chain_buf) (grub_uint64_t size);
extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd, extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd,

View File

@@ -12,14 +12,14 @@ make install
PATH=$PATH:$VT_DIR/GRUB2/INSTALL/bin/:$VT_DIR/GRUB2/INSTALL/sbin/ PATH=$PATH:$VT_DIR/GRUB2/INSTALL/bin/:$VT_DIR/GRUB2/INSTALL/sbin/
net_modules_legacy="net tftp http" net_modules_legacy="net tftp http"
all_modules_legacy="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" 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"
net_modules_uefi="efinet net tftp http" net_modules_uefi="efinet net tftp http"
all_modules_uefi="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" 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"
all_modules_arm64_uefi="setkey blocklist ventoy test true regexp newc search 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 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 video video_fb gfxterm_background gfxterm_menu" all_modules_arm64_uefi="file setkey blocklist ventoy test true regexp newc search 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 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 video video_fb gfxterm_background gfxterm_menu"
all_modules_mips64el_uefi="setkey blocklist ventoy test true regexp newc search 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 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 video video_fb gfxterm_background gfxterm_menu" all_modules_mips64el_uefi="file setkey blocklist ventoy test true regexp newc search 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 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 video video_fb gfxterm_background gfxterm_menu"
if [ "$1" = "uefi" ]; then if [ "$1" = "uefi" ]; then

View File

@@ -0,0 +1,878 @@
/* grub-setup.c - make GRUB usable */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011 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 <config.h>
#include <grub/types.h>
#include <grub/emu/misc.h>
#include <grub/util/misc.h>
#include <grub/device.h>
#include <grub/disk.h>
#include <grub/file.h>
#include <grub/fs.h>
#include <grub/partition.h>
#include <grub/env.h>
#include <grub/emu/hostdisk.h>
#include <grub/term.h>
#include <grub/i18n.h>
#ifdef GRUB_SETUP_SPARC64
#include <grub/util/ofpath.h>
#include <grub/sparc64/ieee1275/boot.h>
#include <grub/sparc64/ieee1275/kernel.h>
#else
#include <grub/i386/pc/boot.h>
#include <grub/i386/pc/kernel.h>
#endif
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <assert.h>
#include <grub/emu/getroot.h>
#include "progname.h"
#include <grub/reed_solomon.h>
#include <grub/msdos_partition.h>
#include <grub/crypto.h>
#include <grub/util/install.h>
#include <grub/emu/hostfile.h>
#include <errno.h>
/* On SPARC this program fills in various fields inside of the 'boot' and 'core'
* image files.
*
* The 'boot' image needs to know the OBP path name of the root
* device. It also needs to know the initial block number of
* 'core' (which is 'diskboot' concatenated with 'kernel' and
* all the modules, this is created by grub-mkimage). This resulting
* 'boot' image is 512 bytes in size and is placed in the second block
* of a partition.
*
* The initial 'diskboot' block acts as a loader for the actual GRUB
* kernel. It contains the loading code and then a block list.
*
* The block list of 'core' starts at the end of the 'diskboot' image
* and works it's way backwards towards the end of the code of 'diskboot'.
*
* We patch up the images with the necessary values and write out the
* result.
*/
#ifdef GRUB_SETUP_SPARC64
#define grub_target_to_host16(x) grub_be_to_cpu16(x)
#define grub_target_to_host32(x) grub_be_to_cpu32(x)
#define grub_target_to_host64(x) grub_be_to_cpu64(x)
#define grub_host_to_target16(x) grub_cpu_to_be16(x)
#define grub_host_to_target32(x) grub_cpu_to_be32(x)
#define grub_host_to_target64(x) grub_cpu_to_be64(x)
#elif defined (GRUB_SETUP_BIOS)
#define grub_target_to_host16(x) grub_le_to_cpu16(x)
#define grub_target_to_host32(x) grub_le_to_cpu32(x)
#define grub_target_to_host64(x) grub_le_to_cpu64(x)
#define grub_host_to_target16(x) grub_cpu_to_le16(x)
#define grub_host_to_target32(x) grub_cpu_to_le32(x)
#define grub_host_to_target64(x) grub_cpu_to_le64(x)
#else
#error Complete this
#endif
static void
write_rootdev (grub_device_t root_dev,
char *boot_img, grub_uint64_t first_sector)
{
#ifdef GRUB_SETUP_BIOS
{
grub_uint8_t *boot_drive;
void *kernel_sector;
boot_drive = (grub_uint8_t *) (boot_img + GRUB_BOOT_MACHINE_BOOT_DRIVE);
kernel_sector = (boot_img + GRUB_BOOT_MACHINE_KERNEL_SECTOR);
/* FIXME: can this be skipped? */
*boot_drive = 0xFF;
grub_set_unaligned64 (kernel_sector, grub_cpu_to_le64 (first_sector));
}
#endif
#ifdef GRUB_SETUP_SPARC64
{
void *kernel_byte;
kernel_byte = (boot_img + GRUB_BOOT_AOUT_HEADER_SIZE
+ GRUB_BOOT_MACHINE_KERNEL_BYTE);
grub_set_unaligned64 (kernel_byte,
grub_cpu_to_be64 (first_sector << GRUB_DISK_SECTOR_BITS));
}
#endif
}
#ifdef GRUB_SETUP_SPARC64
#define BOOT_SECTOR 1
#else
#define BOOT_SECTOR 0
#endif
/* Helper for setup. */
struct blocklists
{
struct grub_boot_blocklist *first_block, *block;
#ifdef GRUB_SETUP_BIOS
grub_uint16_t current_segment;
#endif
#ifdef GRUB_SETUP_SPARC64
grub_uint64_t gpt_offset;
#endif
grub_uint16_t last_length;
grub_disk_addr_t first_sector;
};
/* Helper for setup. */
static void
save_blocklists (grub_disk_addr_t sector, unsigned offset, unsigned length,
void *data)
{
struct blocklists *bl = data;
struct grub_boot_blocklist *prev = bl->block + 1;
grub_uint64_t seclen;
#ifdef GRUB_SETUP_SPARC64
sector -= bl->gpt_offset;
#endif
grub_util_info ("saving <%" GRUB_HOST_PRIuLONG_LONG ",%u,%u>",
(unsigned long long) sector, offset, length);
if (bl->first_sector == (grub_disk_addr_t) -1)
{
if (offset != 0 || length < GRUB_DISK_SECTOR_SIZE)
grub_util_error ("%s", _("the first sector of the core file is not sector-aligned"));
bl->first_sector = sector;
sector++;
length -= GRUB_DISK_SECTOR_SIZE;
if (!length)
return;
}
if (offset != 0 || bl->last_length != 0)
grub_util_error ("%s", _("non-sector-aligned data is found in the core file"));
seclen = (length + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS;
if (bl->block != bl->first_block
&& (grub_target_to_host64 (prev->start)
+ grub_target_to_host16 (prev->len)) == sector)
{
grub_uint16_t t = grub_target_to_host16 (prev->len);
t += seclen;
prev->len = grub_host_to_target16 (t);
}
else
{
bl->block->start = grub_host_to_target64 (sector);
bl->block->len = grub_host_to_target16 (seclen);
#ifdef GRUB_SETUP_BIOS
bl->block->segment = grub_host_to_target16 (bl->current_segment);
#endif
bl->block--;
if (bl->block->len)
grub_util_error ("%s", _("the sectors of the core file are too fragmented"));
}
bl->last_length = length & (GRUB_DISK_SECTOR_SIZE - 1);
#ifdef GRUB_SETUP_BIOS
bl->current_segment += seclen << (GRUB_DISK_SECTOR_BITS - 4);
#endif
}
/* Context for setup/identify_partmap. */
struct identify_partmap_ctx
{
grub_partition_map_t dest_partmap;
grub_partition_t container;
int multiple_partmaps;
};
/* Helper for setup.
Unlike root_dev, with dest_dev we're interested in the partition map even
if dest_dev itself is a whole disk. */
static int
identify_partmap (grub_disk_t disk __attribute__ ((unused)),
const grub_partition_t p, void *data)
{
struct identify_partmap_ctx *ctx = data;
if (p->parent != ctx->container)
return 0;
/* NetBSD and OpenBSD subpartitions have metadata inside a partition,
so they are safe to ignore.
*/
if (grub_strcmp (p->partmap->name, "netbsd") == 0
|| grub_strcmp (p->partmap->name, "openbsd") == 0)
return 0;
if (ctx->dest_partmap == NULL)
{
ctx->dest_partmap = p->partmap;
return 0;
}
if (ctx->dest_partmap == p->partmap)
return 0;
ctx->multiple_partmaps = 1;
return 1;
}
#ifdef GRUB_SETUP_BIOS
#define SETUP grub_util_bios_setup
#elif GRUB_SETUP_SPARC64
#define SETUP grub_util_sparc_setup
#else
#error "Shouldn't happen"
#endif
void
SETUP (const char *dir,
const char *boot_file, const char *core_file,
const char *dest, int force,
int fs_probe, int allow_floppy,
int add_rs_codes __attribute__ ((unused))) /* unused on sparc64 */
{
char *core_path;
char *boot_img, *core_img, *boot_path;
char *root = 0;
size_t boot_size, core_size;
grub_uint16_t core_sectors;
grub_device_t root_dev = 0, dest_dev, core_dev;
grub_util_fd_t fp;
struct blocklists bl;
bl.first_sector = (grub_disk_addr_t) -1;
#ifdef GRUB_SETUP_BIOS
bl.current_segment =
GRUB_BOOT_I386_PC_KERNEL_SEG + (GRUB_DISK_SECTOR_SIZE >> 4);
#endif
bl.last_length = 0;
/* Read the boot image by the OS service. */
boot_path = grub_util_get_path (dir, boot_file);
boot_size = grub_util_get_image_size (boot_path);
if (boot_size != GRUB_DISK_SECTOR_SIZE)
grub_util_error (_("the size of `%s' is not %u"),
boot_path, GRUB_DISK_SECTOR_SIZE);
boot_img = grub_util_read_image (boot_path);
free (boot_path);
core_path = grub_util_get_path (dir, core_file);
core_size = grub_util_get_image_size (core_path);
core_sectors = ((core_size + GRUB_DISK_SECTOR_SIZE - 1)
>> GRUB_DISK_SECTOR_BITS);
if (core_size < GRUB_DISK_SECTOR_SIZE)
grub_util_error (_("the size of `%s' is too small"), core_path);
#ifdef GRUB_SETUP_BIOS
if (core_size > 0xFFFF * GRUB_DISK_SECTOR_SIZE)
grub_util_error (_("the size of `%s' is too large"), core_path);
#endif
core_img = grub_util_read_image (core_path);
/* Have FIRST_BLOCK to point to the first blocklist. */
bl.first_block = (struct grub_boot_blocklist *) (core_img
+ GRUB_DISK_SECTOR_SIZE
- sizeof (*bl.block));
grub_util_info ("Opening dest `%s'", dest);
dest_dev = grub_device_open (dest);
if (! dest_dev)
grub_util_error ("%s", grub_errmsg);
core_dev = dest_dev;
{
char **root_devices = grub_guess_root_devices (dir);
char **cur;
int found = 0;
if (!root_devices)
grub_util_error (_("cannot find a device for %s (is /dev mounted?)"), dir);
for (cur = root_devices; *cur; cur++)
{
char *drive;
grub_device_t try_dev;
drive = grub_util_get_grub_dev (*cur);
if (!drive)
continue;
try_dev = grub_device_open (drive);
if (! try_dev)
{
free (drive);
continue;
}
if (!found && try_dev->disk->id == dest_dev->disk->id
&& try_dev->disk->dev->id == dest_dev->disk->dev->id)
{
if (root_dev)
grub_device_close (root_dev);
free (root);
root_dev = try_dev;
root = drive;
found = 1;
continue;
}
if (!root_dev)
{
root_dev = try_dev;
root = drive;
continue;
}
grub_device_close (try_dev);
free (drive);
}
if (!root_dev)
{
root = grub_util_get_grub_dev ("/dev/sda");
root_dev = grub_device_open (root);
if (root_dev)
grub_util_info ("guessing the root device failed, because of `%s'", grub_errmsg);
else
grub_util_error ("guessing the root device failed, because of `%s'", grub_errmsg);
}
grub_util_info ("guessed root_dev `%s' from "
"dir `%s'", root_dev->disk->name, dir);
for (cur = root_devices; *cur; cur++)
free (*cur);
free (root_devices);
}
grub_util_info ("setting the root device to `%s'", root);
if (grub_env_set ("root", root) != GRUB_ERR_NONE)
grub_util_error ("%s", grub_errmsg);
{
#ifdef GRUB_SETUP_BIOS
char *tmp_img;
grub_uint8_t *boot_drive_check;
/* Read the original sector from the disk. */
tmp_img = xmalloc (GRUB_DISK_SECTOR_SIZE);
if (grub_disk_read (dest_dev->disk, 0, 0, GRUB_DISK_SECTOR_SIZE, tmp_img))
grub_util_error ("%s", grub_errmsg);
boot_drive_check = (grub_uint8_t *) (boot_img
+ GRUB_BOOT_MACHINE_DRIVE_CHECK);
/* Copy the possible DOS BPB. */
memcpy (boot_img + GRUB_BOOT_MACHINE_BPB_START,
tmp_img + GRUB_BOOT_MACHINE_BPB_START,
GRUB_BOOT_MACHINE_BPB_END - GRUB_BOOT_MACHINE_BPB_START);
/* If DEST_DRIVE is a hard disk, enable the workaround, which is
for buggy BIOSes which don't pass boot drive correctly. Instead,
they pass 0x00 or 0x01 even when booted from 0x80. */
if (!allow_floppy && !grub_util_biosdisk_is_floppy (dest_dev->disk))
{
/* Replace the jmp (2 bytes) with double nop's. */
boot_drive_check[0] = 0x90;
boot_drive_check[1] = 0x90;
}
#endif
struct identify_partmap_ctx ctx = {
.dest_partmap = NULL,
.container = dest_dev->disk->partition,
.multiple_partmaps = 0
};
int is_ldm;
grub_err_t err;
grub_disk_addr_t *sectors;
int i;
grub_fs_t fs;
unsigned int nsec, maxsec;
grub_partition_iterate (dest_dev->disk, identify_partmap, &ctx);
#ifdef GRUB_SETUP_BIOS
/* Copy the partition table. */
if (ctx.dest_partmap ||
(!allow_floppy && !grub_util_biosdisk_is_floppy (dest_dev->disk)))
memcpy (boot_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
tmp_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
GRUB_BOOT_MACHINE_PART_END - GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC);
free (tmp_img);
#endif
if (ctx.container
&& grub_strcmp (ctx.container->partmap->name, "msdos") == 0
&& ctx.dest_partmap
&& (ctx.container->msdostype == GRUB_PC_PARTITION_TYPE_NETBSD
|| ctx.container->msdostype == GRUB_PC_PARTITION_TYPE_OPENBSD))
{
grub_util_warn ("%s", _("Attempting to install GRUB to a disk with multiple partition labels or both partition label and filesystem. This is not supported yet."));
goto unable_to_embed;
}
fs = grub_fs_probe (dest_dev);
if (!fs)
grub_errno = GRUB_ERR_NONE;
is_ldm = grub_util_is_ldm (dest_dev->disk);
if (fs_probe)
{
if (!fs && !ctx.dest_partmap)
grub_util_error (_("unable to identify a filesystem in %s; safety check can't be performed"),
dest_dev->disk->name);
if (fs && !fs->reserved_first_sector)
/* TRANSLATORS: Filesystem may reserve the space just GRUB isn't sure about it. */
grub_util_error (_("%s appears to contain a %s filesystem which isn't known to "
"reserve space for DOS-style boot. Installing GRUB there could "
"result in FILESYSTEM DESTRUCTION if valuable data is overwritten "
"by grub-setup (--skip-fs-probe disables this "
"check, use at your own risk)"), dest_dev->disk->name, fs->name);
if (ctx.dest_partmap && strcmp (ctx.dest_partmap->name, "msdos") != 0
&& strcmp (ctx.dest_partmap->name, "gpt") != 0
&& strcmp (ctx.dest_partmap->name, "bsd") != 0
&& strcmp (ctx.dest_partmap->name, "netbsd") != 0
&& strcmp (ctx.dest_partmap->name, "openbsd") != 0
&& strcmp (ctx.dest_partmap->name, "sunpc") != 0)
/* TRANSLATORS: Partition map may reserve the space just GRUB isn't sure about it. */
grub_util_error (_("%s appears to contain a %s partition map which isn't known to "
"reserve space for DOS-style boot. Installing GRUB there could "
"result in FILESYSTEM DESTRUCTION if valuable data is overwritten "
"by grub-setup (--skip-fs-probe disables this "
"check, use at your own risk)"), dest_dev->disk->name, ctx.dest_partmap->name);
if (is_ldm && ctx.dest_partmap && strcmp (ctx.dest_partmap->name, "msdos") != 0
&& strcmp (ctx.dest_partmap->name, "gpt") != 0)
grub_util_error (_("%s appears to contain a %s partition map and "
"LDM which isn't known to be a safe combination."
" Installing GRUB there could "
"result in FILESYSTEM DESTRUCTION if valuable data"
" is overwritten "
"by grub-setup (--skip-fs-probe disables this "
"check, use at your own risk)"),
dest_dev->disk->name, ctx.dest_partmap->name);
}
if (! ctx.dest_partmap && ! fs && !is_ldm)
{
grub_util_warn ("%s", _("Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea."));
goto unable_to_embed;
}
if (ctx.multiple_partmaps || (ctx.dest_partmap && fs) || (is_ldm && fs))
{
grub_util_warn ("%s", _("Attempting to install GRUB to a disk with multiple partition labels. This is not supported yet."));
goto unable_to_embed;
}
if (ctx.dest_partmap && !ctx.dest_partmap->embed)
{
grub_util_warn (_("Partition style `%s' doesn't support embedding"),
ctx.dest_partmap->name);
goto unable_to_embed;
}
if (fs && !fs->fs_embed)
{
grub_util_warn (_("File system `%s' doesn't support embedding"),
fs->name);
goto unable_to_embed;
}
nsec = core_sectors;
if (add_rs_codes)
maxsec = 2 * core_sectors;
else
maxsec = core_sectors;
#ifdef GRUB_SETUP_BIOS
if (maxsec > ((0x78000 - GRUB_KERNEL_I386_PC_LINK_ADDR)
>> GRUB_DISK_SECTOR_BITS))
maxsec = ((0x78000 - GRUB_KERNEL_I386_PC_LINK_ADDR)
>> GRUB_DISK_SECTOR_BITS);
#endif
#ifdef GRUB_SETUP_SPARC64
/*
* On SPARC we need two extra. One is because we are combining the
* core.img with the boot.img. The other is because the boot sector
* starts at 1.
*/
nsec += 2;
maxsec += 2;
#endif
if (is_ldm)
err = grub_util_ldm_embed (dest_dev->disk, &nsec, maxsec,
GRUB_EMBED_PCBIOS, &sectors);
else if (ctx.dest_partmap)
err = ctx.dest_partmap->embed (dest_dev->disk, &nsec, maxsec,
GRUB_EMBED_PCBIOS, &sectors);
else
err = fs->fs_embed (dest_dev, &nsec, maxsec,
GRUB_EMBED_PCBIOS, &sectors);
if (!err && nsec < core_sectors)
{
err = grub_error (GRUB_ERR_OUT_OF_RANGE,
N_("Your embedding area is unusually small. "
"core.img won't fit in it."));
}
if (err)
{
grub_util_warn ("%s", grub_errmsg);
grub_errno = GRUB_ERR_NONE;
goto unable_to_embed;
}
assert (nsec <= maxsec);
/* Clean out the blocklists. */
bl.block = bl.first_block;
while (bl.block->len)
{
grub_memset (bl.block, 0, sizeof (*bl.block));
bl.block--;
if ((char *) bl.block <= core_img)
grub_util_error ("%s", _("no terminator in the core image"));
}
bl.block = bl.first_block;
for (i = 0; i < nsec; i++)
save_blocklists (sectors[i] + grub_partition_get_start (ctx.container),
0, GRUB_DISK_SECTOR_SIZE, &bl);
/* Make sure that the last blocklist is a terminator. */
if (bl.block == bl.first_block)
bl.block--;
bl.block->start = 0;
bl.block->len = 0;
#ifdef GRUB_SETUP_BIOS
bl.block->segment = 0;
#endif
#ifdef GRUB_SETUP_SPARC64
{
/*
* On SPARC, the block-list entries need to be based off the beginning
* of the parition, not the beginning of the disk.
*/
struct grub_boot_blocklist *block;
block = bl.first_block;
while (block->len)
{
block->start -= bl.first_sector;
block--;
}
}
/*
* Reserve space for the boot block since it can not be in the
* Parition table on SPARC.
*/
assert (bl.first_block->len > 2);
bl.first_block->start += 2;
bl.first_block->len -= 2;
write_rootdev (root_dev, boot_img, sectors[BOOT_SECTOR + 1] - bl.first_sector);
#endif
#ifdef GRUB_SETUP_BIOS
write_rootdev (root_dev, boot_img, bl.first_sector);
#endif
/* Round up to the nearest sector boundary, and zero the extra memory */
core_img = xrealloc (core_img, nsec * GRUB_DISK_SECTOR_SIZE);
assert (core_img && (nsec * GRUB_DISK_SECTOR_SIZE >= core_size));
memset (core_img + core_size, 0, nsec * GRUB_DISK_SECTOR_SIZE - core_size);
bl.first_block = (struct grub_boot_blocklist *) (core_img
+ GRUB_DISK_SECTOR_SIZE
- sizeof (*bl.block));
#if GRUB_SETUP_BIOS
grub_size_t no_rs_length;
no_rs_length = grub_target_to_host16
(grub_get_unaligned16 (core_img
+ GRUB_DISK_SECTOR_SIZE
+ GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH));
if (no_rs_length == 0xffff)
grub_util_error ("%s", _("core.img version mismatch"));
if (add_rs_codes)
{
grub_set_unaligned32 ((core_img + GRUB_DISK_SECTOR_SIZE
+ GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY),
grub_host_to_target32 (nsec * GRUB_DISK_SECTOR_SIZE - core_size));
void *tmp = xmalloc (core_size);
grub_memcpy (tmp, core_img, core_size);
grub_reed_solomon_add_redundancy (core_img + no_rs_length + GRUB_DISK_SECTOR_SIZE,
core_size - no_rs_length - GRUB_DISK_SECTOR_SIZE,
nsec * GRUB_DISK_SECTOR_SIZE
- core_size);
assert (grub_memcmp (tmp, core_img, core_size) == 0);
free (tmp);
}
/* Write the core image onto the disk. */
for (i = 0; i < nsec; i++)
grub_disk_write (dest_dev->disk, sectors[i], 0,
GRUB_DISK_SECTOR_SIZE,
core_img + i * GRUB_DISK_SECTOR_SIZE);
#endif
#ifdef GRUB_SETUP_SPARC64
{
int isec = BOOT_SECTOR;
/* Write the boot image onto the disk. */
if (grub_disk_write (dest_dev->disk, sectors[isec++], 0,
GRUB_DISK_SECTOR_SIZE, boot_img))
grub_util_error ("%s", grub_errmsg);
/* Write the core image onto the disk. */
for (i = 0 ; isec < nsec; i++, isec++)
{
if (grub_disk_write (dest_dev->disk, sectors[isec], 0,
GRUB_DISK_SECTOR_SIZE,
core_img + i * GRUB_DISK_SECTOR_SIZE))
grub_util_error ("%s", grub_errmsg);
}
}
#endif
grub_free (sectors);
goto finish;
}
unable_to_embed:
if (dest_dev->disk->dev->id != root_dev->disk->dev->id)
grub_util_error ("%s", _("embedding is not possible, but this is required for "
"RAID and LVM install"));
{
grub_fs_t fs;
fs = grub_fs_probe (root_dev);
if (!fs)
grub_util_error (_("can't determine filesystem on %s"), root);
if (!fs->blocklist_install)
grub_util_error (_("filesystem `%s' doesn't support blocklists"),
fs->name);
}
#ifdef GRUB_SETUP_BIOS
if (dest_dev->disk->id != root_dev->disk->id
|| dest_dev->disk->dev->id != root_dev->disk->dev->id)
/* TRANSLATORS: cross-disk refers to /boot being on one disk
but MBR on another. */
grub_util_error ("%s", _("embedding is not possible, but this is required for "
"cross-disk install"));
#else
core_dev = root_dev;
#endif
grub_util_warn ("%s", _("Embedding is not possible. GRUB can only be installed in this "
"setup by using blocklists. However, blocklists are UNRELIABLE and "
"their use is discouraged."));
if (! force)
/* TRANSLATORS: Here GRUB refuses to continue with blocklist install. */
grub_util_error ("%s", _("will not proceed with blocklists"));
/* The core image must be put on a filesystem unfortunately. */
grub_util_info ("will leave the core image on the filesystem");
grub_util_biosdisk_flush (root_dev->disk);
/* Clean out the blocklists. */
bl.block = bl.first_block;
while (bl.block->len)
{
bl.block->start = 0;
bl.block->len = 0;
#ifdef GRUB_SETUP_BIOS
bl.block->segment = 0;
#endif
bl.block--;
if ((char *) bl.block <= core_img)
grub_util_error ("%s", _("no terminator in the core image"));
}
bl.block = bl.first_block;
#ifdef GRUB_SETUP_SPARC64
{
grub_partition_t container = root_dev->disk->partition;
bl.gpt_offset = 0;
if (grub_strstr (container->partmap->name, "gpt"))
bl.gpt_offset = grub_partition_get_start (container);
}
#endif
grub_install_get_blocklist (root_dev, core_path, core_img, core_size,
save_blocklists, &bl);
if (bl.first_sector == (grub_disk_addr_t)-1)
grub_util_error ("%s", _("can't retrieve blocklists"));
#ifdef GRUB_SETUP_SPARC64
{
char *boot_devpath;
boot_devpath = (char *) (boot_img
+ GRUB_BOOT_AOUT_HEADER_SIZE
+ GRUB_BOOT_MACHINE_BOOT_DEVPATH);
if (dest_dev->disk->id != root_dev->disk->id
|| dest_dev->disk->dev->id != root_dev->disk->dev->id)
{
char *dest_ofpath;
dest_ofpath
= grub_util_devname_to_ofpath (grub_util_biosdisk_get_osdev (root_dev->disk));
/* FIXME handle NULL result */
grub_util_info ("dest_ofpath is `%s'", dest_ofpath);
strncpy (boot_devpath, dest_ofpath,
GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
- GRUB_BOOT_MACHINE_BOOT_DEVPATH - 1);
boot_devpath[GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
- GRUB_BOOT_MACHINE_BOOT_DEVPATH - 1] = 0;
free (dest_ofpath);
}
else
{
grub_util_info ("non cross-disk install");
memset (boot_devpath, 0, GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
- GRUB_BOOT_MACHINE_BOOT_DEVPATH);
}
grub_util_info ("boot device path %s", boot_devpath);
}
#endif
write_rootdev (root_dev, boot_img, bl.first_sector);
/* Write the first two sectors of the core image onto the disk. */
grub_util_info ("opening the core image `%s'", core_path);
fp = grub_util_fd_open (core_path, GRUB_UTIL_FD_O_WRONLY);
if (! GRUB_UTIL_FD_IS_VALID (fp))
grub_util_error (_("cannot open `%s': %s"), core_path,
grub_util_fd_strerror ());
if (grub_util_fd_write (fp, core_img, GRUB_DISK_SECTOR_SIZE * 2)
!= GRUB_DISK_SECTOR_SIZE * 2)
grub_util_error (_("cannot write to `%s': %s"),
core_path, strerror (errno));
if (grub_util_fd_sync (fp) < 0)
grub_util_error (_("cannot sync `%s': %s"), core_path, strerror (errno));
if (grub_util_fd_close (fp) < 0)
grub_util_error (_("cannot close `%s': %s"), core_path, strerror (errno));
grub_util_biosdisk_flush (root_dev->disk);
grub_disk_cache_invalidate_all ();
{
char *buf, *ptr = core_img;
size_t len = core_size;
grub_uint64_t blk, offset = 0;
grub_partition_t container = core_dev->disk->partition;
grub_err_t err;
core_dev->disk->partition = 0;
#ifdef GRUB_SETUP_SPARC64
offset = bl.gpt_offset;
#endif
buf = xmalloc (core_size);
blk = bl.first_sector;
err = grub_disk_read (core_dev->disk, blk + offset, 0, GRUB_DISK_SECTOR_SIZE, buf);
if (err)
grub_util_error (_("cannot read `%s': %s"), core_dev->disk->name,
grub_errmsg);
if (grub_memcmp (buf, ptr, GRUB_DISK_SECTOR_SIZE) != 0)
grub_util_error ("%s", _("blocklists are invalid"));
ptr += GRUB_DISK_SECTOR_SIZE;
len -= GRUB_DISK_SECTOR_SIZE;
bl.block = bl.first_block;
while (bl.block->len)
{
size_t cur = grub_target_to_host16 (bl.block->len) << GRUB_DISK_SECTOR_BITS;
blk = grub_target_to_host64 (bl.block->start);
if (cur > len)
cur = len;
err = grub_disk_read (core_dev->disk, blk + offset, 0, cur, buf);
if (err)
grub_util_error (_("cannot read `%s': %s"), core_dev->disk->name,
grub_errmsg);
if (grub_memcmp (buf, ptr, cur) != 0)
grub_util_error ("%s", _("blocklists are invalid"));
ptr += cur;
len -= cur;
bl.block--;
if ((char *) bl.block <= core_img)
grub_util_error ("%s", _("no terminator in the core image"));
}
if (len)
grub_util_error ("%s", _("blocklists are incomplete"));
core_dev->disk->partition = container;
free (buf);
}
#ifdef GRUB_SETUP_BIOS
finish:
#endif
/* Write the boot image onto the disk. */
if (grub_disk_write (dest_dev->disk, BOOT_SECTOR,
0, GRUB_DISK_SECTOR_SIZE, boot_img))
grub_util_error ("%s", grub_errmsg);
#ifdef GRUB_SETUP_SPARC64
finish:
#endif
grub_util_biosdisk_flush (root_dev->disk);
grub_util_biosdisk_flush (dest_dev->disk);
free (core_path);
free (core_img);
free (boot_img);
grub_device_close (dest_dev);
grub_device_close (root_dev);
}

View File

@@ -121,6 +121,11 @@ elif [ "$VTOY_ARCH" = "i386" ]; then
ln -s $VTOY_PATH/tool/dmsetup32 $VTOY_PATH/tool/dmsetup ln -s $VTOY_PATH/tool/dmsetup32 $VTOY_PATH/tool/dmsetup
ln -s $VTOY_PATH/tool/lunzip32 $VTOY_PATH/tool/lunzip ln -s $VTOY_PATH/tool/lunzip32 $VTOY_PATH/tool/lunzip
if uname -a | egrep -q 'x86_64|amd64'; then
echo "zstdcat use 64bit ..." >>$VTLOG
rm -f $VTOY_PATH/tool/zstdcat
ln -s $VTOY_PATH/tool/zstdcat64 $VTOY_PATH/tool/zstdcat
fi
elif [ "$VTOY_ARCH" = "mips64el" ]; then elif [ "$VTOY_ARCH" = "mips64el" ]; then
echo "Use MIPS64 busybox toolkit ..." >>$VTLOG echo "Use MIPS64 busybox toolkit ..." >>$VTLOG
ln -s $BUSYBOX_PATH/xzminidecm64e $BUSYBOX_PATH/xzminidec ln -s $BUSYBOX_PATH/xzminidecm64e $BUSYBOX_PATH/xzminidec

View File

@@ -61,3 +61,7 @@ else
ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k" ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k"
fi fi
if [ -f $VTOY_PATH/ventoy_persistent_map ]; then
$SED "1 aexport cow_label=vtoycow" -i /init
fi

View File

@@ -36,6 +36,10 @@ done
$BUSYBOX_PATH/umount /vtmnt && $BUSYBOX_PATH/rm -rf /vtmnt $BUSYBOX_PATH/umount /vtmnt && $BUSYBOX_PATH/rm -rf /vtmnt
$BUSYBOX_PATH/cp -a /ventoy /ventoy_rdroot $BUSYBOX_PATH/cp -a /ventoy /ventoy_rdroot
if [ -f /etc/default/cdlinux ]; then
echo "CDL_WAIT=60" >> /etc/default/cdlinux
fi
echo 'echo "CDL_DEV=/dev/mapper/ventoy" >>"$VAR_FILE"' >> /ventoy_rdroot/etc/rc.d/rc.var echo 'echo "CDL_DEV=/dev/mapper/ventoy" >>"$VAR_FILE"' >> /ventoy_rdroot/etc/rc.d/rc.var
ventoy_set_rule_dir_prefix /ventoy_rdroot ventoy_set_rule_dir_prefix /ventoy_rdroot

View File

@@ -31,10 +31,11 @@ done
ventoy_extract_vtloopex ${vtdiskname}2 crux ventoy_extract_vtloopex ${vtdiskname}2 crux
vtKver=$(uname -r)
vtLoopExDir=$VTOY_PATH/vtloopex/crux/vtloopex vtLoopExDir=$VTOY_PATH/vtloopex/crux/vtloopex
$BUSYBOX_PATH/xz -d $vtLoopExDir/dm-mod/$(uname -r)/64/dax.ko.xz
$BUSYBOX_PATH/xz -d $vtLoopExDir/dm-mod/$(uname -r)/64/dm-mod.ko.xz ventoy_check_install_module_xz $vtLoopExDir/dm-mod/$vtKver/64/dax.ko
$BUSYBOX_PATH/insmod $vtLoopExDir/dm-mod/$(uname -r)/64/dax.ko ventoy_check_install_module_xz $vtLoopExDir/dm-mod/$vtKver/64/dm-mod.ko
$BUSYBOX_PATH/insmod $vtLoopExDir/dm-mod/$(uname -r)/64/dm-mod.ko
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"

View File

@@ -0,0 +1,79 @@
#!/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
ventoy_os_install_dmsetup_by_ko() {
vtlog "ventoy_os_install_dmsetup_by_ko $1"
vtVer=$(uname -r)
if uname -m | $GREP -q 64; then
vtBit=64
else
vtBit=32
fi
ventoy_extract_vtloopex $1 kerio
vtLoopExDir=$VTOY_PATH/vtloopex/kerio/vtloopex
if [ -e $vtLoopExDir/dm-mod/$vtVer/$vtBit/dm-mod.ko.xz ]; then
$BUSYBOX_PATH/xz -d $vtLoopExDir/dm-mod/$vtVer/$vtBit/dm-mod.ko.xz
insmod $vtLoopExDir/dm-mod/$vtVer/$vtBit/dm-mod.ko
fi
}
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
if echo $vtdiskname | $EGREP -q "nvme|mmc|nbd"; then
ventoy_os_install_dmsetup_by_ko "${vtdiskname}p2"
else
ventoy_os_install_dmsetup_by_ko "${vtdiskname}2"
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 "/dev/$vtDM"
mount -t iso9660 /dev/$vtDM /cdrom
modprobe squashfs
echo "/dev/$vtDM" > /ventoy/vtDM
PATH=$VTPATH_OLD
set_ventoy_hook_finish

View File

@@ -0,0 +1,20 @@
#!/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 "/for drive in/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/kerio-disk.sh >/dev/null 2>&1; cat /ventoy/vtDM; exit 0" -i /installer/install_init

View File

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

View File

@@ -0,0 +1,20 @@
#!/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_system *$/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/mocaccino-disk.sh" -i /loader

View File

@@ -37,9 +37,17 @@ 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/adrv_veket*.sfs) 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
KoName=$(ls $VTOY_PATH/mnt/squashfs/lib/modules/$2/kernel/drivers/md/dm-mod.ko*)
if [ -n "$KoName" -a -f $KoName ]; then
break
fi
fi
umount $VTOY_PATH/mnt/squashfs
done
KoName=$(ls $VTOY_PATH/mnt/squashfs/lib/modules/$2/kernel/drivers/dax/dax.ko*) KoName=$(ls $VTOY_PATH/mnt/squashfs/lib/modules/$2/kernel/drivers/dax/dax.ko*)
vtlog "insmod $KoName" vtlog "insmod $KoName"

View File

@@ -86,7 +86,13 @@ ventoy_get_debian_distro() {
fi fi
fi fi
if [ -e /opt/kerio ]; then
echo 'kerio'; return
fi
if $GREP -q 'mocaccino' /proc/version; then
echo 'mocaccino'; return
fi
echo 'default' echo 'default'
} }

View File

@@ -49,7 +49,12 @@ done
if [ -n "$1" ]; then if [ -n "$1" ]; then
vtlog "ln -s /dev/$vtDM $1" vtlog "ln -s /dev/$vtDM $1"
ln -s /dev/$vtDM "$1"
if [ -e "$1" ]; then
vtlog "$1 already exist"
else
ln -s /dev/$vtDM "$1"
fi
else else
vtLABEL=$($BUSYBOX_PATH/blkid /dev/$vtDM | $SED 's/.*LABEL="\([^"]*\)".*/\1/') vtLABEL=$($BUSYBOX_PATH/blkid /dev/$vtDM | $SED 's/.*LABEL="\([^"]*\)".*/\1/')
vtlog "vtLABEL is $vtLABEL" vtlog "vtLABEL is $vtLABEL"

View File

@@ -19,9 +19,6 @@
. $VTOY_PATH/hook/ventoy-os-lib.sh . $VTOY_PATH/hook/ventoy-os-lib.sh
#ventoy_systemd_udevd_work_around
#ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k noreplace"
if [ -f $VTOY_PATH/autoinstall ]; then if [ -f $VTOY_PATH/autoinstall ]; then
VTKS="inst.ks=file:$VTOY_PATH/autoinstall" VTKS="inst.ks=file:$VTOY_PATH/autoinstall"
else else
@@ -40,7 +37,25 @@ else
done done
fi fi
echo "VTKS=$VTKS" >> $VTLOG if [ -f $VTOY_PATH/ventoy_persistent_map ]; then
VTOVERLAY="rd.live.overlay=/dev/dm-1:/vtoyoverlayfs/overlayfs"
if [ -e /sbin/dmsquash-live-root ]; then
echo "patch /sbin/dmsquash-live-root for persistent ..." >> $VTLOG
$SED "/mount.*devspec.*\/run\/initramfs\/overlayfs/a . /ventoy/hook/openEuler/ventoy-overlay.sh" -i /sbin/dmsquash-live-root
fi
#close selinux
$BUSYBOX_PATH/mkdir -p $VTOY_PATH/selinuxfs
if $BUSYBOX_PATH/mount -t selinuxfs selinuxfs $VTOY_PATH/selinuxfs; then
echo 1 > $VTOY_PATH/selinuxfs/disable
$BUSYBOX_PATH/umount $VTOY_PATH/selinuxfs
fi
$BUSYBOX_PATH/rm -rf $VTOY_PATH/selinuxfs
fi
echo "VTKS=$VTKS VTOVERLAY=$VTOVERLAY" >> $VTLOG
if ls $VTOY_PATH | $GREP -q 'ventoy_dud[0-9]'; then if ls $VTOY_PATH | $GREP -q 'ventoy_dud[0-9]'; then
for vtDud in $(ls $VTOY_PATH/ventoy_dud*); do for vtDud in $(ls $VTOY_PATH/ventoy_dud*); do
@@ -49,11 +64,7 @@ if ls $VTOY_PATH | $GREP -q 'ventoy_dud[0-9]'; then
fi fi
echo "vtInstDD=$vtInstDD" >> $VTLOG echo "vtInstDD=$vtInstDD" >> $VTLOG
if $GREP -q 'root=live' /proc/cmdline; then $SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/dm-0 $VTKS $vtInstDD#" -i /lib/dracut-lib.sh
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE root=live:/dev/dm-0 $VTKS $vtInstDD#" -i /lib/dracut-lib.sh
else
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/dm-0 $VTKS $vtInstDD#" -i /lib/dracut-lib.sh
fi
ventoy_set_inotify_script openEuler/ventoy-inotifyd-hook.sh ventoy_set_inotify_script openEuler/ventoy-inotifyd-hook.sh
@@ -66,14 +77,15 @@ fi
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/openEuler/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/${vtPriority}-ventoy-inotifyd-start.sh $BUSYBOX_PATH/cp -a $VTOY_PATH/hook/openEuler/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/${vtPriority}-ventoy-inotifyd-start.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/openEuler/ventoy-timeout.sh /lib/dracut/hooks/initqueue/timeout/${vtPriority}-ventoy-timeout.sh $BUSYBOX_PATH/cp -a $VTOY_PATH/hook/openEuler/ventoy-timeout.sh /lib/dracut/hooks/initqueue/timeout/${vtPriority}-ventoy-timeout.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/openEuler/ventoy-repo.sh /lib/dracut/hooks/pre-pivot/99-ventoy-repo.sh
if [ -e /sbin/dmsquash-live-root ]; then if [ -f /sbin/dmsquash-live-root ]; then
echo "patch /sbin/dmsquash-live-root ..." >> $VTLOG echo "patch /sbin/dmsquash-live-root ..." >> $VTLOG
$SED "1 a $BUSYBOX_PATH/sh $VTOY_PATH/hook/openEuler/ventoy-make-link.sh" -i /sbin/dmsquash-live-root $SED "1 a $BUSYBOX_PATH/sh $VTOY_PATH/hook/openEuler/ventoy-make-link.sh" -i /sbin/dmsquash-live-root
fi fi
# suppress write protected mount warning # suppress write protected mount warning
if [ -e /usr/sbin/anaconda-diskroot ]; then if [ -f /usr/sbin/anaconda-diskroot ]; then
$SED 's/^mount $dev $repodir/mount -oro $dev $repodir/' -i /usr/sbin/anaconda-diskroot $SED 's/^mount $dev $repodir/mount -oro $dev $repodir/' -i /usr/sbin/anaconda-diskroot
fi fi

View File

@@ -29,20 +29,11 @@ if is_inotify_ventoy_part $3; then
vtlog "##### INOTIFYD: $2/$3 is created (YES) ..." vtlog "##### INOTIFYD: $2/$3 is created (YES) ..."
vtGenRulFile='/etc/udev/rules.d/99-live-squash.rules'
if [ -e $vtGenRulFile ] && $GREP -q dmsquash $vtGenRulFile; then
vtScript=$($GREP -m1 'RUN.=' $vtGenRulFile | $AWK -F'RUN.=' '{print $2}' | $SED 's/"\(.*\)".*/\1/')
vtlog "vtScript=$vtScript"
$vtScript
else
vtlog "$vtGenRulFile not exist..."
fi
vtlog "find ventoy partition ..." vtlog "find ventoy partition ..."
vtReplaceOpt=noreplace #vtReplaceOpt=noreplace
$BUSYBOX_PATH/sh $VTOY_PATH/hook/default/udev_disk_hook.sh $3 $vtReplaceOpt $BUSYBOX_PATH/sh $VTOY_PATH/hook/default/udev_disk_hook.sh $3
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/') 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}) vtDM=$(ventoy_find_dm_id ${blkdev_num})

View File

@@ -0,0 +1,21 @@
#!/bin/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/>.
#
#************************************************************************************
[ -d /run/initramfs/overlayfs$pathspec ] || mkdir -p /run/initramfs/overlayfs$pathspec
[ -d /run/initramfs/overlayfs$pathspec/../ovlwork ] || mkdir -p /run/initramfs/overlayfs$pathspec/../ovlwork

View File

@@ -0,0 +1,29 @@
#!/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
repodev=$(ls $VTOY_PATH/dev_backup*)
echo "inst.repo=hd:/dev/${repodev#*dev_backup_}" >> /sysroot/etc/cmdline
PATH=$VTPATH_OLD

View File

@@ -26,3 +26,13 @@ ventoy_add_udev_rule "$VTOY_PATH/hook/rhel6/udev_disk_hook.sh %k"
#loop7 was used by loader #loop7 was used by loader
ventoy_add_kernel_udev_rule "loop6" "$VTOY_PATH/hook/rhel6/udev_disk_hook.sh %k" ventoy_add_kernel_udev_rule "loop6" "$VTOY_PATH/hook/rhel6/udev_disk_hook.sh %k"
if [ -f $VTOY_PATH/autoinstall ]; then
$BUSYBOX_PATH/mv /sbin/loader /sbin/loader_bk
$BUSYBOX_PATH/mv $VTOY_PATH/tool/loader /sbin/loader
RawCmdLine=$($BUSYBOX_PATH/cat /proc/cmdline)
echo -n "/sbin/loader_bk" > "/ventoy/loader_exec_file"
echo -n "--cmdline=$RawCmdLine ks=file:$VTOY_PATH/autoinstall" > "/ventoy/loader_exec_cmdline"
#echo 111 > "/ventoy/loader_debug"
fi

View File

@@ -40,7 +40,26 @@ else
done done
fi fi
echo "VTKS=$VTKS" >> $VTLOG if [ -f $VTOY_PATH/ventoy_persistent_map ]; then
VTOVERLAY="rd.live.overlay=/dev/dm-1:/vtoyoverlayfs/overlayfs"
if [ -e /sbin/dmsquash-live-root ]; then
echo "patch /sbin/dmsquash-live-root for persistent ..." >> $VTLOG
$SED "/mount.*devspec.*\/run\/initramfs\/overlayfs/a . /ventoy/hook/rhel7/ventoy-overlay.sh" -i /sbin/dmsquash-live-root
$SED "s/osmin.img/osmin.imgxxxx/g" -i /sbin/dmsquash-live-root
fi
#close selinux
$BUSYBOX_PATH/mkdir -p $VTOY_PATH/selinuxfs
if $BUSYBOX_PATH/mount -t selinuxfs selinuxfs $VTOY_PATH/selinuxfs; then
echo 1 > $VTOY_PATH/selinuxfs/disable
$BUSYBOX_PATH/umount $VTOY_PATH/selinuxfs
fi
$BUSYBOX_PATH/rm -rf $VTOY_PATH/selinuxfs
fi
echo "VTKS=$VTKS VTOVERLAY=$VTOVERLAY" >> $VTLOG
if ls $VTOY_PATH | $GREP -q 'ventoy_dud[0-9]'; then if ls $VTOY_PATH | $GREP -q 'ventoy_dud[0-9]'; then
for vtDud in $(ls $VTOY_PATH/ventoy_dud*); do for vtDud in $(ls $VTOY_PATH/ventoy_dud*); do
@@ -50,9 +69,9 @@ fi
echo "vtInstDD=$vtInstDD" >> $VTLOG echo "vtInstDD=$vtInstDD" >> $VTLOG
if $GREP -q 'root=live' /proc/cmdline; then if $GREP -q 'root=live' /proc/cmdline; then
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE root=live:/dev/dm-0 $VTKS $vtInstDD#" -i /lib/dracut-lib.sh $SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE root=live:/dev/dm-0 $VTKS $VTOVERLAY $vtInstDD#" -i /lib/dracut-lib.sh
else else
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/dm-0 $VTKS $vtInstDD#" -i /lib/dracut-lib.sh $SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/dm-0 $VTKS $VTOVERLAY $vtInstDD#" -i /lib/dracut-lib.sh
fi fi
ventoy_set_inotify_script rhel7/ventoy-inotifyd-hook.sh ventoy_set_inotify_script rhel7/ventoy-inotifyd-hook.sh
@@ -67,6 +86,26 @@ fi
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/${vtPriority}-ventoy-inotifyd-start.sh $BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/${vtPriority}-ventoy-inotifyd-start.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-timeout.sh /lib/dracut/hooks/initqueue/timeout/${vtPriority}-ventoy-timeout.sh $BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-timeout.sh /lib/dracut/hooks/initqueue/timeout/${vtPriority}-ventoy-timeout.sh
vtNeedRepo=
if [ -f /etc/system-release ]; then
if $GREP -q 'RED OS' /etc/system-release; then
vtNeedRepo="yes"
fi
fi
if $GREP -q el8 /proc/version; then
vtNeedRepo="yes"
fi
if $GREP -i -q Fedora /proc/version; then
if $GREP -q 'Server Edition' /etc/os-release; then
vtNeedRepo="yes"
fi
fi
if [ "$vtNeedRepo" = "yes" ]; then
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-repo.sh /lib/dracut/hooks/pre-pivot/99-ventoy-repo.sh
fi
if [ -e /sbin/dmsquash-live-root ]; then if [ -e /sbin/dmsquash-live-root ]; then
echo "patch /sbin/dmsquash-live-root ..." >> $VTLOG echo "patch /sbin/dmsquash-live-root ..." >> $VTLOG
$SED "1 a $BUSYBOX_PATH/sh $VTOY_PATH/hook/rhel7/ventoy-make-link.sh" -i /sbin/dmsquash-live-root $SED "1 a $BUSYBOX_PATH/sh $VTOY_PATH/hook/rhel7/ventoy-make-link.sh" -i /sbin/dmsquash-live-root

View File

@@ -41,12 +41,8 @@ if is_inotify_ventoy_part $3; then
vtlog "find ventoy partition ..." vtlog "find ventoy partition ..."
vtReplaceOpt=noreplace vtReplaceOpt=noreplace
if [ -f /lib/dracut/hooks/pre-pivot/99-ventoy-repo.sh ]; then
if $GREP -q el8 /proc/version && [ -f /etc/system-release ]; then vtReplaceOpt=""
vtRhel8Ver=$($SED "s#.*8\.\([0-9]*\).*#\1#" /etc/system-release)
if [ $vtRhel8Ver -ge 3 ]; then
vtReplaceOpt=""
fi
fi fi
$BUSYBOX_PATH/sh $VTOY_PATH/hook/default/udev_disk_hook.sh $3 $vtReplaceOpt $BUSYBOX_PATH/sh $VTOY_PATH/hook/default/udev_disk_hook.sh $3 $vtReplaceOpt

View File

@@ -0,0 +1,21 @@
#!/bin/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/>.
#
#************************************************************************************
[ -d /run/initramfs/overlayfs$pathspec ] || mkdir -p /run/initramfs/overlayfs$pathspec
[ -d /run/initramfs/overlayfs$pathspec/../ovlwork ] || mkdir -p /run/initramfs/overlayfs$pathspec/../ovlwork

View File

@@ -0,0 +1,29 @@
#!/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
repodev=$(ls $VTOY_PATH/dev_backup*)
echo "inst.repo=hd:/dev/${repodev#*dev_backup_}" >> /sysroot/etc/cmdline
PATH=$VTPATH_OLD

View File

@@ -0,0 +1,38 @@
#!/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
wait_for_usb_disk_ready
vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "ventoy disk not found"
exit 0
fi
vtlog "wait_for_usb_disk_ready $vtdiskname ..."
if echo $vtdiskname | $EGREP -q "nvme|mmc|nbd"; then
vtpart2=${vtdiskname}p2
else
vtpart2=${vtdiskname}2
fi
/ventoy/busybox/sh /ventoy/hook/suse/udev_disk_hook.sh "${vtpart2#/dev/}"

View File

@@ -63,6 +63,9 @@ if [ -e /etc/initrd.functions ] && $GREP -q 'HPIP' /etc/initrd.functions; then
$BUSYBOX_PATH/mknod -m 660 /dev/console b 5 1 $BUSYBOX_PATH/mknod -m 660 /dev/console b 5 1
$SED "/CD_DEVICES=/a $BUSYBOX_PATH/sh $VTOY_PATH/hook/suse/disk_hook.sh" -i /etc/initrd.functions $SED "/CD_DEVICES=/a $BUSYBOX_PATH/sh $VTOY_PATH/hook/suse/disk_hook.sh" -i /etc/initrd.functions
$SED "/CD_DEVICES=/a CD_DEVICES=\"/dev/ventoy \$CD_DEVICES\"" -i /etc/initrd.functions $SED "/CD_DEVICES=/a CD_DEVICES=\"/dev/ventoy \$CD_DEVICES\"" -i /etc/initrd.functions
elif [ -f /scripts/udev_setup ]; then
echo "udev_setup" >> $VTLOG
echo "/ventoy/busybox/sh /ventoy/hook/suse/udev_setup_hook.sh" >> /scripts/udev_setup
else else
echo "SUSE" >> $VTLOG echo "SUSE" >> $VTLOG
ventoy_systemd_udevd_work_around ventoy_systemd_udevd_work_around

View File

@@ -57,14 +57,14 @@ vterr() {
is_ventoy_hook_finished() { is_ventoy_hook_finished() {
[ -e $VTOY_PATH/hook_finish ] [ -e $VTOY_PATH/hook_finish ]
} }
set_ventoy_hook_finish() { set_ventoy_hook_finish() {
echo 'Y' > $VTOY_PATH/hook_finish echo 'Y' > $VTOY_PATH/hook_finish
} }
get_ventoy_disk_name() { get_ventoy_disk_name() {
line=$($VTOY_PATH/tool/vtoydump -f /ventoy/ventoy_os_param) line=$($VTOY_PATH/tool/vtoydump -f /ventoy/ventoy_os_param)
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo ${line%%#*} echo ${line%%#*}
@@ -74,7 +74,7 @@ get_ventoy_disk_name() {
} }
get_ventoy_iso_name() { get_ventoy_iso_name() {
line=$($VTOY_PATH/tool/vtoydump -f /ventoy/ventoy_os_param) line=$($VTOY_PATH/tool/vtoydump -f /ventoy/ventoy_os_param)
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo ${line##*#} echo ${line##*#}
else else
@@ -83,8 +83,9 @@ get_ventoy_iso_name() {
} }
wait_for_usb_disk_ready() { wait_for_usb_disk_ready() {
while [ -n "Y" ]; do vtloop=0
usb_disk=$(get_ventoy_disk_name) while [ -n "Y" ]; do
usb_disk=$(get_ventoy_disk_name)
vtlog "wait_for_usb_disk_ready $usb_disk ..." vtlog "wait_for_usb_disk_ready $usb_disk ..."
if echo $usb_disk | $EGREP -q "nvme|mmc|nbd"; then if echo $usb_disk | $EGREP -q "nvme|mmc|nbd"; then
@@ -95,13 +96,20 @@ wait_for_usb_disk_ready() {
if [ -e "${vtpart2}" ]; then if [ -e "${vtpart2}" ]; then
vtlog "wait_for_usb_disk_ready $usb_disk finish" vtlog "wait_for_usb_disk_ready $usb_disk finish"
break break
else else
$SLEEP 0.3 let vtloop=vtloop+1
fi if [ $vtloop -gt 2 ]; then
done if [ "$VTLOG" != "$VTOY_PATH/log" ]; then
$VTOY_PATH/tool/vtoydump -f /ventoy/ventoy_os_param -v > $VTLOG
fi
fi
$SLEEP 0.3
fi
done
} }
check_usb_disk_ready() { check_usb_disk_ready() {
if echo $1 | $EGREP -q "nvme|mmc|nbd"; then if echo $1 | $EGREP -q "nvme|mmc|nbd"; then
vtpart2=${1}p2 vtpart2=${1}p2
@@ -610,3 +618,10 @@ ventoy_extract_vtloopex() {
cd $vtCurPwd cd $vtCurPwd
} }
ventoy_check_install_module_xz() {
if [ -f "${1}.xz" ]; then
$BUSYBOX_PATH/xz -d "${1}.xz"
$BUSYBOX_PATH/insmod "$1"
fi
}

View File

@@ -34,9 +34,19 @@ else
vtBit=32 vtBit=32
fi fi
xz -d $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko.xz if grep -q "device-mapper" /proc/devices; then
insmod $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko vtlog "device-mapper enabled by system"
else
if [ -f $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dax.ko.xz ]; then
xz -d $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dax.ko.xz
insmod $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dax.ko
fi
if [ -f $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko.xz ]; then
xz -d $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko.xz
insmod $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko
fi
fi
wait_for_usb_disk_ready wait_for_usb_disk_ready

View File

@@ -27,7 +27,83 @@ vtlog "####### $0 $* ########"
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
wait_for_usb_disk_ready check_mkdev_node() {
for i in $(ls /sys/class/block/); do
if ! [ -e /dev/$i ]; then
blkdev_num=$(sed 's/:/ /g' /sys/class/block/$i/dev)
vtlog "mknod -m 0666 /dev/$i b $blkdev_num"
mknod -m 0666 /dev/$i b $blkdev_num
fi
done
}
check_insmod() {
if [ -f "$1" ]; then
vtlog "insmod $1"
insmod "$1" >> $VTOY_PATH/log 2>&1
else
vtlog "$1 not exist"
fi
}
wrt_insmod() {
kbit=$1
kv=$(uname -r)
vtlog "insmod $kv $kbit"
check_insmod /ventoy_openwrt/$kv/$kbit/dax.ko
check_insmod /ventoy_openwrt/$kv/$kbit/dm-mod.ko
}
insmod_dm_mod() {
if grep -q "device-mapper" /proc/devices; then
vtlog "device-mapper enabled by system 0"
return
fi
check_insmod /ventoy/modules/dax.ko
check_insmod /ventoy/modules/dm-mod.ko
if grep -q "device-mapper" /proc/devices; then
vtlog "device-mapper enabled by system 1"
return
fi
if [ -f /ventoy_openwrt.xz ]; then
tar xf /ventoy_openwrt.xz -C /
rm -f /ventoy_openwrt.xz
fi
if uname -m | egrep -q "amd64|x86_64"; then
wrt_insmod 64
else
wrt_insmod generic
if lsmod | grep -q 'dm-mod'; then
vterr "insmod generic failed"
else
wrt_insmod legacy
fi
fi
}
insmod_dm_mod
check_mkdev_node
sleep 1
while [ -n "Y" ]; do
vtusb_disk=$(get_ventoy_disk_name)
if check_usb_disk_ready "$vtusb_disk"; then
vtlog "get_ventoy_disk_name $vtusb_disk ready"
break;
else
vtlog "get_ventoy_disk_name $vtusb_disk not ready"
sleep 2
check_mkdev_node
fi
done
vtdiskname=$(get_ventoy_disk_name) vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then if [ "$vtdiskname" = "unknown" ]; then
@@ -44,6 +120,11 @@ echo -n $vtDM > /ventoy/vtDM
ventoy_create_dev_ventoy_part ventoy_create_dev_ventoy_part
mdev -s mdev -s
check_mkdev_node
mkdir /ventoy_rdroot
mount /dev/ventoy2 /ventoy_rdroot
PATH=$VTPATH_OLD PATH=$VTPATH_OLD

View File

@@ -19,12 +19,10 @@
. $VTOY_PATH/hook/ventoy-os-lib.sh . $VTOY_PATH/hook/ventoy-os-lib.sh
$BUSYBOX_PATH/mkdir /sys VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
$BUSYBOX_PATH/mount -t proc proc /proc
$BUSYBOX_PATH/mount -t sysfs sys /sys
$BUSYBOX_PATH/mdev -s mkdir /sys
mount -t sysfs sys /sys
mdev -s
#$BUSYBOX_PATH/sh $VTOY_PATH/loop/openwrt/ventoy-disk.sh sh $VTOY_PATH/loop/openwrt/ventoy-disk.sh
exec $BUSYBOX_PATH/sh

View File

@@ -153,6 +153,8 @@ ventoy_get_os_type() {
echo 'rhel7'; return echo 'rhel7'; return
elif $GREP -q 'openEuler' /etc/os-release; then elif $GREP -q 'openEuler' /etc/os-release; then
echo 'openEuler'; return echo 'openEuler'; return
elif $GREP -q 'fuyu' /etc/os-release; then
echo 'openEuler'; return
fi fi
fi fi

View File

@@ -198,6 +198,8 @@ ventoy_get_os_type() {
echo 'rhel7'; return echo 'rhel7'; return
elif $GREP -q 'openEuler' /etc/os-release; then elif $GREP -q 'openEuler' /etc/os-release; then
echo 'openEuler'; return echo 'openEuler'; return
elif $GREP -q 'fuyu' /etc/os-release; then
echo 'openEuler'; return
fi fi
fi fi

View File

@@ -21,19 +21,19 @@ ln -s sbin/init linuxrc
cd ventoy cd ventoy
find ./loop | cpio -o -H newc>loop.cpio find ./loop | cpio -o -H newc --owner=root:root >loop.cpio
xz loop.cpio xz loop.cpio
rm -rf loop rm -rf loop
xz ventoy_chain.sh xz ventoy_chain.sh
xz ventoy_loop.sh xz ventoy_loop.sh
find ./hook | cpio -o -H newc>hook.cpio find ./hook | cpio -o -H newc --owner=root:root >hook.cpio
xz hook.cpio xz hook.cpio
rm -rf hook rm -rf hook
cd .. cd ..
find .| cpio -o -H newc>../ventoy.cpio find .| cpio -o -H newc --owner=root:root >../ventoy.cpio
cd .. cd ..
rm -rf cpio_tmp rm -rf cpio_tmp
@@ -64,12 +64,12 @@ cp -a $VENTOY_PATH/LZIP/lunzip64 tool/
chmod -R 777 ./tool chmod -R 777 ./tool
find ./tool | cpio -o -H newc>tool.cpio find ./tool | cpio -o -H newc --owner=root:root >tool.cpio
xz tool.cpio xz tool.cpio
rm -rf tool rm -rf tool
cd .. cd ..
find .| cpio -o -H newc>../ventoy_x86.cpio find .| cpio -o -H newc --owner=root:root >../ventoy_x86.cpio
cd .. cd ..
rm -rf cpio_tmp rm -rf cpio_tmp
@@ -95,12 +95,12 @@ cp -a $VENTOY_PATH/LZIP/lunzipaa64 tool/
chmod -R 777 ./tool chmod -R 777 ./tool
find ./tool | cpio -o -H newc>tool.cpio find ./tool | cpio -o -H newc --owner=root:root >tool.cpio
xz tool.cpio xz tool.cpio
rm -rf tool rm -rf tool
cd .. cd ..
find .| cpio -o -H newc>../ventoy_arm64.cpio find .| cpio -o -H newc --owner=root:root >../ventoy_arm64.cpio
cd .. cd ..
rm -rf cpio_tmp rm -rf cpio_tmp
@@ -127,12 +127,12 @@ rm -f tool/vtoytool/00/vtoytool_aa64
chmod -R 777 ./tool chmod -R 777 ./tool
find ./tool | cpio -o -H newc>tool.cpio find ./tool | cpio -o -H newc --owner=root:root >tool.cpio
xz tool.cpio xz tool.cpio
rm -rf tool rm -rf tool
cd .. cd ..
find .| cpio -o -H newc>../ventoy_mips64.cpio find .| cpio -o -H newc --owner=root:root >../ventoy_mips64.cpio
cd .. cd ..
rm -rf cpio_tmp rm -rf cpio_tmp

View File

@@ -14,7 +14,7 @@ for dir in $(ls); do
cd .. cd ..
done done
find . | cpio -o -H newc>../vtloopex.cpio find . | cpio -o -H newc --owner=root:root >../vtloopex.cpio
cd .. cd ..

View File

@@ -4,6 +4,7 @@ size=1024
fstype=ext4 fstype=ext4
label=casper-rw label=casper-rw
config='' config=''
outputfile=persistence.dat
print_usage() { print_usage() {
echo 'Usage: CreatePersistentImg.sh [ -s size ] [ -t fstype ] [ -l LABEL ] [ -c CFG ]' echo 'Usage: CreatePersistentImg.sh [ -s size ] [ -t fstype ] [ -l LABEL ] [ -c CFG ]'
@@ -12,6 +13,7 @@ print_usage() {
echo ' -t filesystem type, default is ext4 ext2/ext3/ext4/xfs are supported now' echo ' -t filesystem type, default is ext4 ext2/ext3/ext4/xfs are supported now'
echo ' -l label, default is casper-rw' echo ' -l label, default is casper-rw'
echo ' -c configfile name inside the persistence file. File content is "/ union"' echo ' -c configfile name inside the persistence file. File content is "/ union"'
echo ' -o outputfile name, default is persistence.dat'
echo '' echo ''
} }
@@ -28,6 +30,9 @@ while [ -n "$1" ]; do
elif [ "$1" = "-c" ]; then elif [ "$1" = "-c" ]; then
shift shift
config=$1 config=$1
elif [ "$1" = "-o" ]; then
shift
outputfile=$1
elif [ "$1" = "-h" ] || [ "$1" = "--help" ]; then elif [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
print_usage print_usage
exit 0 exit 0
@@ -69,13 +74,17 @@ else
exit 1 exit 1
fi fi
if [ "$outputdir" != "persistence.dat" ]; then
mkdir -p "$(dirname "$outputfile")"
fi
# 00->ff avoid sparse file # 00->ff avoid sparse file
dd if=/dev/zero bs=1M count=$size | tr '\000' '\377' > persistence.dat dd if=/dev/zero bs=1M count=$size | tr '\000' '\377' > "$outputfile"
sync sync
freeloop=$(losetup -f) freeloop=$(losetup -f)
losetup $freeloop persistence.dat losetup $freeloop "$outputfile"
mkfs -t $fstype $fsopt -L $label $freeloop mkfs -t $fstype $fsopt -L $label $freeloop

View File

@@ -0,0 +1,97 @@
#!/bin/sh
print_usage() {
echo 'Usage: ExtendPersistentImg.sh file size'
echo ' file persistent dat file'
echo ' size extend size in MB'
echo 'Example:'
echo ' sh ExtendPersistentImg.sh ubuntu.dat 2048'
echo ''
}
if [ -z "$1" -o "$1" = "-h" ]; then
print_usage
exit 1
fi
if [ -z "$2" ]; then
print_usage
exit 1
fi
file=$1
size=$2
if [ ! -f "$file" ]; then
echo "$file not exist."
exit 1
fi
if echo $size | grep -q "[^0-9]"; then
print_usage
exit 1
fi
fsize=$(stat -c '%s' $file)
fsmod=$(expr $fsize % 1024)
if [ $fsmod -ne 0 ]; then
echo "File size of $file is not aligned by 1MB, please check."
exit 1
fi
fsMB=$(expr $fsize / 1024 / 1024)
total=$(expr $fsMB + $size)
magic=$(hexdump -n3 -e '3/1 "%02X"' $file)
if [ "$magic" = "584653" ]; then
if which xfs_growfs >/dev/null 2>&1; then
cmd=xfs_growfs
else
echo 'xfs_growfs not found, please install xfsprogs first'
exit 1
fi
else
if which resize2fs >/dev/null 2>&1; then
cmd=resize2fs
else
echo 'resize2fs not found, please install e2fsprogs first'
exit 1
fi
fi
echo "Extend dat file... (current is ${fsMB}MB, append ${size}MB, total ${total}MB)"
dd if=/dev/zero bs=1M count=$size status=none >> "$file"
sync
freeloop=$(losetup -f)
losetup $freeloop "$file"
if [ "$cmd" = "resize2fs" ]; then
echo "Extend ext filesystem by resize2fs ..."
echo "resize2fs $freeloop ${total}M"
e2fsck -f $freeloop
resize2fs $freeloop ${total}M
ret=$?
else
echo "Extend xfs filesystem by xfs_growfs ..."
tmpdir=$(mktemp -d)
mount $freeloop $tmpdir
xfs_growfs $freeloop
ret=$?
umount $tmpdir && rm -rf $tmpdir
fi
losetup -d $freeloop
echo ""
if [ $ret -eq 0 ]; then
echo "======= SUCCESS ========="
else
echo "======= FAILED ========="
fi
echo ""

View File

@@ -21,9 +21,6 @@ Please refer https://www.ventoy.net/en/doc_start.html for details.
1. sudo sh VentoyWeb.sh 1. sudo sh VentoyWeb.sh
2. open your browser and visit http://127.0.0.1:24680 2. open your browser and visit http://127.0.0.1:24680
========== VentoyWebDeepin.sh ===============
1. sudo sh VentoyWebDeepin.sh
========== CreatePersistentImg.sh =============== ========== CreatePersistentImg.sh ===============
@@ -38,5 +35,12 @@ Please refer https://www.ventoy.net/en/plugin_persistence.html for details.
========== ExtendPersistentImg.sh ===============
sudo sh ExtendPersistentImg.sh file size
For example:
sh ExtendPersistentImg.sh persistence.dat 2048 ----> Extend persistence.dat by 2048MB
That is to say, persistence.dat file will grow to 3GB size (assume that it is 1GB size before extend)
Please refer https://www.ventoy.net/en/plugin_persistence.html for details.

Binary file not shown.

View File

@@ -45,6 +45,7 @@ if [ ! -f ./boot/boot.img ]; then
if [ -d ./grub ]; then if [ -d ./grub ]; then
echo "Don't run VentoyWeb.sh here, please download the released install package, and run the script in it." echo "Don't run VentoyWeb.sh here, please download the released install package, and run the script in it."
else else
echo "Current directory is $PWD"
echo "Please run under the correct directory!" echo "Please run under the correct directory!"
fi fi
exit 1 exit 1

View File

@@ -2,25 +2,29 @@
VTOY_PATH=$PWD/.. VTOY_PATH=$PWD/..
cilog() {
datestr=$(date +"%Y/%m/%d %H:%M:%S")
echo "$datestr $*"
}
LOG=$VTOY_PATH/DOC/build.log LOG=$VTOY_PATH/DOC/build.log
[ -f $LOG ] && rm -f $LOG [ -f $LOG ] && rm -f $LOG
cd $VTOY_PATH/DOC cd $VTOY_PATH/DOC
echo "prepare_env ..." cilog "prepare_env ..."
sh prepare_env.sh sh prepare_env.sh
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/mips-loongson-gcc7.3-linux-gnu/2019.06-29/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/mips-loongson-gcc7.3-linux-gnu/2019.06-29/bin/:/opt/mips64el-linux-musl-gcc730/bin/
cilog "build grub2 ..."
echo "build grub2 ..."
cd $VTOY_PATH/GRUB2 cd $VTOY_PATH/GRUB2
sh buildgrub.sh >> $LOG 2>&1 || exit 1 sh buildgrub.sh >> $LOG 2>&1 || exit 1
echo "build ipxe ..." cilog "build ipxe ..."
cd $VTOY_PATH/IPXE cd $VTOY_PATH/IPXE
sh buildipxe.sh >> $LOG 2>&1 || exit 1 sh buildipxe.sh >> $LOG 2>&1 || exit 1
echo "build edk2 ..." cilog "build edk2 ..."
cd $VTOY_PATH/EDK2 cd $VTOY_PATH/EDK2
sh buildedk.sh >> $LOG 2>&1 || exit 1 sh buildedk.sh >> $LOG 2>&1 || exit 1
@@ -74,7 +78,7 @@ if [ "$1" = "CI" ]; then
sed "s/VENTOY_VERSION=.*/VENTOY_VERSION=\"$Ver\"/" -i ./grub/grub.cfg sed "s/VENTOY_VERSION=.*/VENTOY_VERSION=\"$Ver\"/" -i ./grub/grub.cfg
fi fi
echo "packing ventoy-$Ver ..." cilog "packing ventoy-$Ver ..."
sh ventoy_pack.sh $1 >> $LOG 2>&1 || exit 1 sh ventoy_pack.sh $1 >> $LOG 2>&1 || exit 1
echo -e '\n============== SUCCESS ==================\n' echo -e '\n============== SUCCESS ==================\n'

View File

@@ -2,12 +2,18 @@
VTOY_PATH=$PWD/.. VTOY_PATH=$PWD/..
wget -q -P $VTOY_PATH/DOC/ https://www.fefe.de/dietlibc/dietlibc-0.34.tar.xz date +"%Y/%m/%d %H:%M:%S"
wget -q -P $VTOY_PATH/DOC/ https://musl.libc.org/releases/musl-1.2.1.tar.gz echo downloading envrionment ...
wget -q -P $VTOY_PATH/GRUB2/ https://ftp.gnu.org/gnu/grub/grub-2.04.tar.xz
wget -q -P $VTOY_PATH/DOC/ https://github.com/ventoy/vtoytoolchain/releases/download/1.0/dietlibc-0.34.tar.xz
wget -q -P $VTOY_PATH/DOC/ https://github.com/ventoy/vtoytoolchain/releases/download/1.0/musl-1.2.1.tar.gz
wget -q -P $VTOY_PATH/GRUB2/ https://github.com/ventoy/vtoytoolchain/releases/download/1.0/grub-2.04.tar.xz
wget -q -O $VTOY_PATH/EDK2/edk2-edk2-stable201911.zip https://codeload.github.com/tianocore/edk2/zip/edk2-stable201911 wget -q -O $VTOY_PATH/EDK2/edk2-edk2-stable201911.zip https://codeload.github.com/tianocore/edk2/zip/edk2-stable201911
wget -q -P /opt/ 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 wget -q -P /opt/ https://github.com/ventoy/vtoytoolchain/releases/download/1.0/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz
wget -q -P /opt/ https://toolchains.bootlin.com/downloads/releases/toolchains/aarch64/tarballs/aarch64--uclibc--stable-2020.08-1.tar.bz2 wget -q -P /opt/ https://github.com/ventoy/vtoytoolchain/releases/download/1.0/aarch64--uclibc--stable-2020.08-1.tar.bz2
wget -q -P /opt/ http://ftp.loongnix.org/toolchain/gcc/release/mips-loongson-gcc7.3-2019.06-29-linux-gnu.tar.gz wget -q -P /opt/ https://github.com/ventoy/vtoytoolchain/releases/download/1.0/mips-loongson-gcc7.3-2019.06-29-linux-gnu.tar.gz
date +"%Y/%m/%d %H:%M:%S"
echo downloading envrionment finish...
sh all_in_one.sh CI sh all_in_one.sh CI

View File

@@ -32,6 +32,7 @@
*save_env: loadenv *save_env: loadenv
*search: search *search: search
*serial: serial *serial: serial
*set_keyboard_layout: setkey
*setkey: setkey *setkey: setkey
*sha1sum: hashsum *sha1sum: hashsum
*sha256sum: hashsum *sha256sum: hashsum

Binary file not shown.

View File

@@ -1,7 +1,7 @@
videotest: font video gfxmenu videotest: font video gfxmenu
setkey: extcmd
odc: archelp odc: archelp
loopback: extcmd loopback: extcmd
setkey: extcmd
macho: macho:
gcry_des: crypto gcry_des: crypto
memrw: extcmd memrw: extcmd
@@ -23,7 +23,7 @@ sfs: fshelp
reiserfs: fshelp reiserfs: fshelp
part_sunpc: part_sunpc:
zstd: zstd:
gfxmenu: video_colors trig bitmap_scale gfxterm font normal bitmap video gfxmenu: trig video_colors bitmap_scale gfxterm font normal bitmap video
jfs: jfs:
help: extcmd normal help: extcmd normal
configfile: normal configfile: normal
@@ -68,7 +68,7 @@ gfxterm_background: video_colors bitmap_scale gfxterm extcmd video bitmap
search_fs_uuid: search_fs_uuid:
gcry_dsa: pgp mpi gcry_dsa: pgp mpi
keystatus: extcmd keystatus: extcmd
linux: verifiers boot fdt linux: ventoy verifiers boot fdt
geli: cryptodisk crypto gcry_sha512 pbkdf2 gcry_sha256 geli: cryptodisk crypto gcry_sha512 pbkdf2 gcry_sha256
cmdline_cat_test: font functional_test normal procfs video_fb cmdline_cat_test: font functional_test normal procfs video_fb
part_sun: part_sun:
@@ -93,7 +93,7 @@ terminal:
div: div:
crypto: crypto:
part_bsd: part_msdos part_bsd: part_msdos
ventoy: ext2 fshelp btrfs font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660 ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd datetime div normal video gcry_sha1 iso9660
gcry_sha512: crypto gcry_sha512: crypto
password: crypto normal password: crypto normal
fshelp: fshelp:

View File

@@ -1,7 +1,7 @@
source $prefix/keyboard.cfg.gz source $prefix/keyboard.cfg
submenu "Resolution Configuration" --class=debug_resolution { submenu "Resolution Configuration" --class=debug_resolution --class=F5tool {
menuentry 'Return to previous menu [Esc]' --class=vtoyret VTOY_RET { menuentry 'Return to previous menu [Esc]' --class=vtoyret VTOY_RET {
echo 'Return ...' echo 'Return ...'
} }
@@ -16,7 +16,7 @@ submenu "Resolution Configuration" --class=debug_resolution {
set vtActive="[*]" set vtActive="[*]"
fi fi
menuentry "$vtCurMode $vtActive" --class=debug_videomode VTOY_RUN_RET { menuentry "$vtCurMode $vtActive" --class=debug_videomode --class=debug_resolution --class=F5tool VTOY_RUN_RET {
terminal_output console terminal_output console
set gfxmode=$1 set gfxmode=$1
terminal_output gfxterm terminal_output gfxterm
@@ -26,11 +26,11 @@ submenu "Resolution Configuration" --class=debug_resolution {
done done
} }
submenu "Screen Display Mode" --class=debug_screen_mode { submenu "Screen Display Mode" --class=debug_screen_mode --class=F5tool {
menuentry 'Force Text Mode' --class=debug_text_mode { menuentry 'Force Text Mode' --class=debug_text_mode --class=debug_screen_mode --class=F5tool {
terminal_output console terminal_output console
} }
menuentry 'Force Graphics Mode' --class=debug_gui_mode { menuentry 'Force Graphics Mode' --class=debug_gui_mode --class=debug_screen_mode --class=F5tool {
terminal_output gfxterm terminal_output gfxterm
} }
menuentry 'Return to previous menu [Esc]' --class=vtoyret VTOY_RET { menuentry 'Return to previous menu [Esc]' --class=vtoyret VTOY_RET {
@@ -39,8 +39,8 @@ submenu "Screen Display Mode" --class=debug_screen_mode {
} }
if [ "$grub_platform" != "pc" ]; then if [ "$grub_platform" != "pc" ]; then
submenu 'Ventoy UEFI Utilities' --class=debug_util { submenu 'Ventoy UEFI Utilities' --class=debug_util --class=F5tool {
menuentry 'Fixup Windows BlinitializeLibrary Failure' --class=debug_util_blinit { menuentry 'Fixup Windows BlinitializeLibrary Failure' --class=debug_util_blinit --class=debug_util --class=F5tool {
chainloader ${vtoy_path}/vtoyutil_${VTOY_EFI_ARCH}.efi env_param=${env_param} ${vtdebug_flag} feature=fix_windows_mmap chainloader ${vtoy_path}/vtoyutil_${VTOY_EFI_ARCH}.efi env_param=${env_param} ${vtdebug_flag} feature=fix_windows_mmap
boot boot
echo -e "\npress ENTER to exit ..." echo -e "\npress ENTER to exit ..."
@@ -54,8 +54,8 @@ if [ "$grub_platform" != "pc" ]; then
fi fi
submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json { submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json --class=F5tool {
menuentry 'Check global control plugin configuration' --class=debug_control { menuentry 'Check global control plugin configuration' --class=debug_control --class=debug_json --class=F5tool {
set pager=1 set pager=1
vt_check_plugin_json $vt_plugin_path control $vtoy_iso_part vt_check_plugin_json $vt_plugin_path control $vtoy_iso_part
@@ -64,7 +64,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
unset pager unset pager
} }
menuentry 'Check theme plugin configuration' --class=debug_theme { menuentry 'Check theme plugin configuration' --class=debug_theme --class=debug_json --class=F5tool {
set pager=1 set pager=1
vt_check_plugin_json $vt_plugin_path theme $vtoy_iso_part vt_check_plugin_json $vt_plugin_path theme $vtoy_iso_part
@@ -73,7 +73,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
unset pager unset pager
} }
menuentry 'Check auto install plugin configuration' --class=debug_autoinstall { menuentry 'Check auto install plugin configuration' --class=debug_autoinstall --class=debug_json --class=F5tool {
set pager=1 set pager=1
vt_check_plugin_json $vt_plugin_path auto_install $vtoy_iso_part vt_check_plugin_json $vt_plugin_path auto_install $vtoy_iso_part
@@ -82,7 +82,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
unset pager unset pager
} }
menuentry 'Check persistence plugin configuration' --class=debug_persistence { menuentry 'Check persistence plugin configuration' --class=debug_persistence --class=debug_json --class=F5tool {
set pager=1 set pager=1
vt_check_plugin_json $vt_plugin_path persistence $vtoy_iso_part vt_check_plugin_json $vt_plugin_path persistence $vtoy_iso_part
@@ -94,7 +94,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
unset pager unset pager
} }
menuentry 'Check menu alias plugin configuration' --class=debug_menualias { menuentry 'Check menu alias plugin configuration' --class=debug_menualias --class=debug_json --class=F5tool {
set pager=1 set pager=1
vt_check_plugin_json $vt_plugin_path menu_alias $vtoy_iso_part vt_check_plugin_json $vt_plugin_path menu_alias $vtoy_iso_part
@@ -103,7 +103,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
unset pager unset pager
} }
menuentry 'Check menu class plugin configuration' --class=debug_menuclass { menuentry 'Check menu class plugin configuration' --class=debug_menuclass --class=debug_json --class=F5tool {
set pager=1 set pager=1
vt_check_plugin_json $vt_plugin_path menu_class $vtoy_iso_part vt_check_plugin_json $vt_plugin_path menu_class $vtoy_iso_part
@@ -112,7 +112,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
unset pager unset pager
} }
menuentry 'Check injection plugin configuration' --class=debug_injection { menuentry 'Check injection plugin configuration' --class=debug_injection --class=debug_json --class=F5tool {
set pager=1 set pager=1
vt_check_plugin_json $vt_plugin_path injection $vtoy_iso_part vt_check_plugin_json $vt_plugin_path injection $vtoy_iso_part
@@ -121,7 +121,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
unset pager unset pager
} }
menuentry 'Check auto memdisk plugin configuration' --class=debug_automemdisk { menuentry 'Check auto memdisk plugin configuration' --class=debug_automemdisk --class=debug_json --class=F5tool {
set pager=1 set pager=1
vt_check_plugin_json $vt_plugin_path auto_memdisk $vtoy_iso_part vt_check_plugin_json $vt_plugin_path auto_memdisk $vtoy_iso_part
@@ -130,7 +130,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
unset pager unset pager
} }
menuentry 'Check image list plugin configuration' --class=debug_imagelist { menuentry 'Check image list plugin configuration' --class=debug_imagelist --class=debug_json --class=F5tool {
set pager=1 set pager=1
vt_check_plugin_json $vt_plugin_path image_list $vtoy_iso_part vt_check_plugin_json $vt_plugin_path image_list $vtoy_iso_part
@@ -139,7 +139,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
unset pager unset pager
} }
menuentry 'Check image blacklist plugin configuration' --class=debug_imageblacklist { menuentry 'Check image blacklist plugin configuration' --class=debug_imageblacklist --class=debug_json --class=F5tool {
set pager=1 set pager=1
vt_check_plugin_json $vt_plugin_path image_blacklist $vtoy_iso_part vt_check_plugin_json $vt_plugin_path image_blacklist $vtoy_iso_part
@@ -148,7 +148,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
unset pager unset pager
} }
menuentry 'Check boot conf replace plugin configuration' --class=debug_bootconf_replace { menuentry 'Check boot conf replace plugin configuration' --class=debug_bootconf_replace --class=debug_json --class=F5tool {
set pager=1 set pager=1
vt_check_plugin_json $vt_plugin_path conf_replace $vtoy_iso_part vt_check_plugin_json $vt_plugin_path conf_replace $vtoy_iso_part
@@ -157,7 +157,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
unset pager unset pager
} }
menuentry 'Check dud plugin configuration' --class=debug_dud { menuentry 'Check dud plugin configuration' --class=debug_dud --class=debug_json --class=F5tool {
set pager=1 set pager=1
vt_check_plugin_json $vt_plugin_path dud $vtoy_iso_part vt_check_plugin_json $vt_plugin_path dud $vtoy_iso_part
@@ -166,7 +166,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
unset pager unset pager
} }
menuentry 'Check password plugin configuration' --class=debug_pwd { menuentry 'Check password plugin configuration' --class=debug_pwd --class=debug_json --class=F5tool {
set pager=1 set pager=1
vt_check_plugin_json $vt_plugin_path password $vtoy_iso_part vt_check_plugin_json $vt_plugin_path password $vtoy_iso_part
@@ -175,7 +175,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
unset pager unset pager
} }
menuentry 'Check custom boot plugin configuration' --class=debug_custom_boot { menuentry 'Check custom boot plugin configuration' --class=debug_custom_boot --class=debug_json --class=F5tool {
set pager=1 set pager=1
vt_check_plugin_json $vt_plugin_path custom_boot $vtoy_iso_part vt_check_plugin_json $vt_plugin_path custom_boot $vtoy_iso_part

View File

@@ -130,9 +130,7 @@ function get_os_type {
function vt_check_compatible_pe { function vt_check_compatible_pe {
#Check for PE without external tools #Check for PE without external tools
if [ -f "$1/HBCD_PE.ini" ]; then return
set ventoy_compatible=YES
fi
} }
function locate_initrd { function locate_initrd {
@@ -161,7 +159,7 @@ function distro_specify_wim_patch {
vt_windows_collect_wim_patch wim /BOOT/H3_7PE.WIM vt_windows_collect_wim_patch wim /BOOT/H3_7PE.WIM
vt_windows_collect_wim_patch wim /BOOT/H3_8PE.WIM vt_windows_collect_wim_patch wim /BOOT/H3_8PE.WIM
vt_windows_collect_wim_patch wim /BOOT/H3_81PE.WIM vt_windows_collect_wim_patch wim /BOOT/H3_81PE.WIM
fi fi
} }
function distro_specify_wim_patch_phase2 { function distro_specify_wim_patch_phase2 {
@@ -311,18 +309,15 @@ function distro_specify_initrd_file_phase2 {
vt_linux_specify_initrd_file /antiX/initrd.gz vt_linux_specify_initrd_file /antiX/initrd.gz
elif [ -f (loop)/360Disk/initrd.gz ]; then elif [ -f (loop)/360Disk/initrd.gz ]; then
vt_linux_specify_initrd_file /360Disk/initrd.gz vt_linux_specify_initrd_file /360Disk/initrd.gz
elif [ -f (loop)/porteus/initrd.xz ]; then
vt_linux_specify_initrd_file /porteus/initrd.xz
fi fi
} }
function ventoy_get_ghostbsd_ver { function ventoy_get_ghostbsd_ver {
# fallback to parse version from elf /boot/kernel/kernel
# vt_parse_iso_create_date "$1/${chosen_path}" vt_create_date set vt_freebsd_ver=xx
# if regexp "^202005" "$vt_create_date"; then
# set vt_freebsd_ver=12.x
# fi
set vt_freebsd_ver=12.x
} }
function ventoy_get_furybsd_ver { function ventoy_get_furybsd_ver {
@@ -364,11 +359,18 @@ function ventoy_get_truenas_ver {
} }
function ventoy_get_midnightbsd_ver { function ventoy_get_midnightbsd_ver {
set vt_freebsd_ver=11.x if vt_str_begin "$vt_volume_id" "1_"; then
set vt_freebsd_ver=11.x
elif vt_str_begin "$vt_volume_id" "2_"; then
set vt_freebsd_ver=2.x
elif vt_str_begin "$vt_volume_id" "3_"; then
set vt_freebsd_ver=3.x
fi
} }
function ventoy_freebsd_proc { function ventoy_freebsd_proc {
set vtFreeBsdDistro=FreeBSD set vtFreeBsdDistro=FreeBSD
set vt_freebsd_ver=xx
if vt_strstr "$vt_volume_id" "GHOSTBSD"; then if vt_strstr "$vt_volume_id" "GHOSTBSD"; then
ventoy_get_ghostbsd_ver "$1" "${chosen_path}" ventoy_get_ghostbsd_ver "$1" "${chosen_path}"
@@ -419,8 +421,11 @@ function ventoy_freebsd_proc {
fi fi
elif vt_strstr "${chosen_path}" "MidnightBSD"; then elif vt_strstr "${chosen_path}" "MidnightBSD"; then
set vt_freebsd_ver=9.x set vt_freebsd_ver=9.x
else fi
set vt_freebsd_ver=12.x
if [ -e (loop)/usr/freebsd-dist/cloninst.sh ]; then
set vtFreeBsdDistro=ClonOS
fi fi
set vt_freebsd_bit=64 set vt_freebsd_bit=64
@@ -431,10 +436,20 @@ function ventoy_freebsd_proc {
fi fi
break break
fi fi
done done
if [ "$vt_freebsd_ver" = "xx" ]; then
if [ -e (loop)/boot/kernel/kernel ]; then
vt_unix_parse_freebsd_ver_elf (loop)/boot/kernel/kernel $vt_freebsd_bit vt_freebsd_ver
fi
if [ "$vt_freebsd_ver" = "xx" ]; then
set vt_freebsd_ver=13.x
fi
fi
if [ -n "${vtdebug_flag}" ]; then if [ -n "${vtdebug_flag}" ]; then
echo "This is FreeBSD $vt_freebsd_ver ${vt_freebsd_bit}bit" echo "This is $vtFreeBsdDistro $vt_freebsd_ver ${vt_freebsd_bit}bit"
fi fi
unset vt_unix_mod_path unset vt_unix_mod_path
@@ -445,10 +460,6 @@ function ventoy_freebsd_proc {
fi fi
done done
if [ -e (loop)/usr/freebsd-dist/cloninst.sh ]; then
set vtFreeBsdDistro=ClonOS
fi
vt_unix_replace_ko $vt_unix_mod_path (vtunix)/ventoy_unix/$vtFreeBsdDistro/geom_ventoy_ko/$vt_freebsd_ver/$vt_freebsd_bit/geom_ventoy.ko.xz vt_unix_replace_ko $vt_unix_mod_path (vtunix)/ventoy_unix/$vtFreeBsdDistro/geom_ventoy_ko/$vt_freebsd_ver/$vt_freebsd_bit/geom_ventoy.ko.xz
vt_unix_replace_conf FreeBSD "${1}${chosen_path}" vt_unix_replace_conf FreeBSD "${1}${chosen_path}"
} }
@@ -522,6 +533,10 @@ function uefi_windows_menu_func {
vt_windows_chain_data "${1}${chosen_path}" vt_windows_chain_data "${1}${chosen_path}"
ventoy_debug_pause ventoy_debug_pause
if vt_check_mode 4; then
vtoy_windows_wimboot_func
fi
if [ -n "$vtoy_chain_mem_addr" ]; then if [ -n "$vtoy_chain_mem_addr" ]; then
ventoy_acpi_param ${vtoy_chain_mem_addr} 2048 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
ventoy_cli_console ventoy_cli_console
@@ -533,6 +548,22 @@ function uefi_windows_menu_func {
fi fi
} }
function uefi_find_replace_initrd {
if vt_get_efi_vdisk_offset "${1}${2}" vt_efivdisk_offset; then
loopback -s $vt_efivdisk_offset vtefivdisk "${1}${2}"
unset vt_rp_initrd
vt_search_replace_initrd (vtefivdisk) vt_rp_initrd
if [ -n "$vt_rp_initrd" ]; then
vt_add_replace_file $3 "$vt_rp_initrd"
fi
loopback -d vtefivdisk
ventoy_debug_pause
fi
}
function uefi_linux_menu_func { function uefi_linux_menu_func {
if [ "$ventoy_compatible" = "NO" ]; then if [ "$ventoy_compatible" = "NO" ]; then
@@ -614,6 +645,11 @@ function uefi_linux_menu_func {
elif [ -f (loop)/loader/entries/pisi-efi-x86_64.conf ]; then elif [ -f (loop)/loader/entries/pisi-efi-x86_64.conf ]; then
vt_add_replace_file $vtindex "EFI\\pisi\\initrd.img" vt_add_replace_file $vtindex "EFI\\pisi\\initrd.img"
fi fi
vt_get_replace_file_cnt vt_replace_cnt
if [ $vt_replace_cnt -eq 0 ]; then
uefi_find_replace_initrd "$1" "$2" $vtindex
fi
elif [ -d (loop)/EFI/boot/entries ]; then elif [ -d (loop)/EFI/boot/entries ]; then
if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img" vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img"
@@ -621,6 +657,8 @@ function uefi_linux_menu_func {
vt_add_replace_file 0 "EFI\\hyperiso\\hyperiso.img" vt_add_replace_file 0 "EFI\\hyperiso\\hyperiso.img"
fi fi
elif [ -d (loop)/EFI/BOOT/entries ]; then elif [ -d (loop)/EFI/BOOT/entries ]; then
vt_linux_get_main_initrd_index vtindex
if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img" vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img"
elif [ -f (loop)/parabola/boot/x86_64/initramfs-linux-libre.img ]; then elif [ -f (loop)/parabola/boot/x86_64/initramfs-linux-libre.img ]; then
@@ -646,10 +684,14 @@ function uefi_linux_menu_func {
if [ -n "$vtoy_chain_mem_addr" ]; then if [ -n "$vtoy_chain_mem_addr" ]; then
ventoy_acpi_param ${vtoy_chain_mem_addr} 2048 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
ventoy_cli_console ventoy_cli_console
if [ "$VTOY_EFI_ARCH" != "mips" ]; then if vt_check_mode 3; then
chainloader ${vtoy_path}/ventoy_${VTOY_EFI_ARCH}.efi fallback env_param=${env_param} isoefi=${LoadIsoEfiDriver} FirstTry=${FirstTryBootFile} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} ventoy_debug_pause
boot else
if [ "$VTOY_EFI_ARCH" != "mips" ]; then
chainloader ${vtoy_path}/ventoy_${VTOY_EFI_ARCH}.efi fallback env_param=${env_param} isoefi=${LoadIsoEfiDriver} FirstTry=${FirstTryBootFile} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
boot
fi
fi fi
# fallback # fallback
@@ -788,6 +830,86 @@ function uefi_iso_memdisk {
} }
function vtoy_windows_wimboot_func {
if [ -f (loop)/x86/sources/boot.wim -a -f (loop)/x64/sources/boot.wim ]; then
vt_sel_wimboot vtoy_wimboot_bit
if [ "$vtoy_wimboot_bit" = "32" ]; then
set vtoy_wimboot_prefix=(loop)/x86
else
set vtoy_wimboot_prefix=(loop)/x64
fi
else
set vtoy_wimboot_prefix=(loop)
if vt_is_pe64 $vtoy_wimboot_prefix/setup.exe; then
set vtoy_wimboot_bit=64
else
set vtoy_wimboot_bit=32
fi
fi
if [ -n "${vtdebug_flag}" ]; then
echo vtoy_wimboot_prefix=$vtoy_wimboot_prefix vtoy_wimboot_bit=$vtoy_wimboot_bit
fi
for wmfile in sources/boot.wim boot/bcd boot/boot.sdi; do
if [ ! -f $vtoy_wimboot_prefix/$wmfile ]; then
return
fi
done
if [ -f $vtoy_wimboot_prefix/sources/install.wim -o -f $vtoy_wimboot_prefix/sources/install.esd ]; then
vt_windows_wimboot_data
else
return
fi
if [ "$grub_platform" = "pc" ]; then
set vt_wimkernel=wimboot.x86_64.xz
linux16 "$vtoy_path/$vt_wimkernel" quiet
ventoy_debug_pause
vt_set_wim_load_prompt 1 "Loading files......"
initrd16 newc:vtoyjump.exe:$vtoy_path/vtoyjump${vtoy_wimboot_bit}.exe \
newc:wimboot.data:mem:${vtoy_wimboot_mem_addr}:size:${vtoy_wimboot_mem_size} \
newc:winpeshl.ini:mem:${vtoy_winpeshl_ini_addr}:size:${vtoy_winpeshl_ini_size} \
newc:bcd:$vtoy_wimboot_prefix/boot/bcd \
newc:boot.sdi:$vtoy_wimboot_prefix/boot/boot.sdi \
newc:boot.wim:$vtoy_wimboot_prefix/sources/boot.wim
vt_set_wim_load_prompt 0
boot
else
if [ "$grub_cpu" = "i386" ]; then
set vt_wimkernel=wimboot.i386.efi.xz
else
set vt_wimkernel=wimboot.x86_64.xz
fi
vt_set_wim_load_prompt 1 "Loading files......"
vt_load_file_to_mem "nodecompress" $vtoy_wimboot_prefix/sources/boot.wim vtoy_wimfile_mem
vt_set_wim_load_prompt 0
if [ $? -eq 0 ]; then
set vtoy_wimfile_path=mem:${vtoy_wimfile_mem_addr}:size:${vtoy_wimfile_mem_size}
else
set vtoy_wimfile_path=$vtoy_wimboot_prefix/sources/boot.wim
fi
ventoy_cli_console
chainloader "$vtoy_path/$vt_wimkernel" quiet \
"vf=wimboot.data:mem:${vtoy_wimboot_mem_addr}:size:${vtoy_wimboot_mem_size}" \
"vf=winpeshl.ini:mem:${vtoy_winpeshl_ini_addr}:size:${vtoy_winpeshl_ini_size}" \
"vf=vtoyjump.exe:$vtoy_path/vtoyjump${vtoy_wimboot_bit}.exe" \
"vf=bcd:$vtoy_wimboot_prefix/boot/bcd" \
"vf=boot.sdi:$vtoy_wimboot_prefix/boot/boot.sdi" \
"vf=boot.wim:$vtoy_wimfile_path" \
pfsize=$vtoy_chain_file_size \
pfread=$vtoy_chain_file_read
boot
ventoy_gui_console
fi
}
function legacy_windows_menu_func { function legacy_windows_menu_func {
vt_windows_reset vt_windows_reset
@@ -799,7 +921,7 @@ function legacy_windows_menu_func {
loopback loop "$1$2" loopback loop "$1$2"
fi fi
for file in "boot/bcd" "/efi/microsoft/boot/bcd" "SSTR/BCD"; do for file in "boot/bcd" "/efi/microsoft/boot/bcd" "SSTR/BCD" "boot/bce"; do
vt_windows_collect_wim_patch bcd (loop)/$file vt_windows_collect_wim_patch bcd (loop)/$file
done done
@@ -816,7 +938,11 @@ function legacy_windows_menu_func {
vt_windows_chain_data "${1}${chosen_path}" vt_windows_chain_data "${1}${chosen_path}"
ventoy_debug_pause ventoy_debug_pause
if vt_check_mode 4; then
vtoy_windows_wimboot_func
fi
if [ -n "$vtoy_chain_mem_addr" ]; then if [ -n "$vtoy_chain_mem_addr" ]; then
ventoy_acpi_param ${vtoy_chain_mem_addr} 2048 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} ibft mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} ibft mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
@@ -885,9 +1011,39 @@ function legacy_linux_menu_func {
ventoy_debug_pause ventoy_debug_pause
if [ -n "$vtoy_chain_mem_addr" ]; then if [ -n "$vtoy_chain_mem_addr" ]; then
ventoy_acpi_param ${vtoy_chain_mem_addr} 2048 if vt_check_mode 3; then
linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
boot ventoy_cli_console
# fallback
set vtback_root=$root
vt_push_last_entry
set vtback_theme=$theme
unset theme
vt_trailer_cpio "$vtoy_iso_part" "$vt_chosen_path" noinit
vt_set_boot_opt rdinit=/vtoy/vtoy
set root=(loop)
set vtback_cfg_find=0
for cfg in "/boot/grub/grub.cfg" "/EFI/BOOT/grub.cfg" "/EFI/debian/grub.cfg" "EFI/boot/grub.cfg" "efi/boot/grub.cfg" "/grub/grub.cfg" "EFI/BOOT/BOOTX64.conf"; do
if [ -e "$cfg" ]; then
set vtback_cfg_find=1
configfile "$cfg"
break
fi
done
vt_unset_boot_opt
set root=$vtback_root
set theme=$vtback_theme
vt_pop_last_entry
ventoy_gui_console
else
ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
boot
fi
else else
echo "chain empty failed" echo "chain empty failed"
ventoy_pause ventoy_pause
@@ -1030,7 +1186,7 @@ function iso_common_menuentry {
vt_parse_iso_volume "${vtoy_iso_part}${vt_chosen_path}" vt_system_id vt_volume_id vt_volume_space vt_parse_iso_volume "${vtoy_iso_part}${vt_chosen_path}" vt_system_id vt_volume_id vt_volume_space
if [ $vt_volume_space -ne $vt_chosen_size ]; then if [ $vt_volume_space -ne $vt_chosen_size ]; then
vt_mod $vt_chosen_size 2048 vt_chosen_size_mod vt_mod $vt_chosen_size 2048 vt_chosen_size_mod
if [ $vt_volume_space -gt $vt_chosen_size -o $vt_chosen_size_mod -ne 0 ]; then if [ $vt_chosen_size_mod -ne 0 ]; then
echo -e "\n $vt_volume_space $vt_chosen_size $vt_chosen_size_mod\n" echo -e "\n $vt_volume_space $vt_chosen_size $vt_chosen_size_mod\n"
echo -e "\n The size of the iso file \"$vt_chosen_size\" is invalid. File corrupted ?\n" echo -e "\n The size of the iso file \"$vt_chosen_size\" is invalid. File corrupted ?\n"
echo -e " 此ISO文件的大小 \"$vt_chosen_size\" 有问题,请确认文件是否损坏。\n" echo -e " 此ISO文件的大小 \"$vt_chosen_size\" 有问题,请确认文件是否损坏。\n"
@@ -1183,6 +1339,30 @@ function efi_unsupport_menuentry {
common_unsupport_menuentry common_unsupport_menuentry
} }
function vhdboot_common_func {
vt_patch_vhdboot "$1"
ventoy_debug_pause
if [ -n "$vtoy_vhd_buf_addr" ]; then
if [ "$grub_platform" = "pc" ]; then
ventoy_cli_console
linux16 $vtoy_path/memdisk iso raw
initrd16 mem:${vtoy_vhd_buf_addr}:size:${vtoy_vhd_buf_size}
boot
ventoy_gui_console
else
ventoy_cli_console
chainloader ${vtoy_path}/ventoy_${VTOY_EFI_ARCH}.efi memdisk env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_vhd_buf_addr}:size:${vtoy_vhd_buf_size}
boot
ventoy_gui_console
fi
else
echo "Please put the right ventoy_vhdboot.img file to the 1st partition"
ventoy_pause
fi
}
function vhd_common_menuentry { function vhd_common_menuentry {
if [ "$VTOY_VHD_NO_WARNING" != "1" ]; then if [ "$VTOY_VHD_NO_WARNING" != "1" ]; then
@@ -1205,25 +1385,7 @@ function vhd_common_menuentry {
return return
fi fi
vt_patch_vhdboot "$vt_chosen_path" vhdboot_common_func "${vt_chosen_path}"
ventoy_debug_pause
if [ -n "$vtoy_vhd_buf_addr" ]; then
if [ "$grub_platform" = "pc" ]; then
linux16 $vtoy_path/memdisk iso raw
initrd16 mem:${vtoy_vhd_buf_addr}:size:${vtoy_vhd_buf_size}
boot
else
ventoy_cli_console
chainloader ${vtoy_path}/ventoy_${VTOY_EFI_ARCH}.efi memdisk env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_vhd_buf_addr}:size:${vtoy_vhd_buf_size}
boot
ventoy_gui_console
fi
else
echo "Please put the right ventoy_vhdboot.img file to the 1st partition"
ventoy_pause
fi
} }
function vhd_unsupport_menuentry { function vhd_unsupport_menuentry {
@@ -1258,7 +1420,7 @@ function vtoyboot_common_func {
ventoy_pause ventoy_pause
fi fi
fi fi
vt_img_sector "${1}" vt_img_sector "${1}"
vt_raw_chain_data "${1}" vt_raw_chain_data "${1}"
@@ -1480,6 +1642,64 @@ function ventoy_img_batocera {
vt_unset_boot_opt vt_unset_boot_opt
} }
function ventoy_img_openwrt {
if [ -e (vtimghd,2)/lib64 ]; then
set ventoy_busybox_ver=64
fi
vt_fs_enum_1st_dir (vtimghd,2) /lib/modules/ vt_dir_name
if [ -f (vtimghd,2)/lib/modules/$vt_dir_name/dm-mod.ko ]; then
set openwrt_plugin_need=0
vt_img_extra_initrd_append (vtimghd,2)/lib/modules/$vt_dir_name/dm-mod.ko
if [ -f (vtimghd,2)/lib/modules/$vt_dir_name/dax.ko ]; then
vt_img_extra_initrd_append (vtimghd,2)/lib/modules/$vt_dir_name/dax.ko
fi
else
set openwrt_plugin_need=1
if [ ! -f ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz ]; then
ventoy_gui_console
echo -e "\n ventoy_openwrt.xz not found. Please refer https://www.ventoy.net/en/doc_openwrt.html.\n"
echo -e " 未找到 ventoy_openwrt.xz 文件。请参考 https://www.ventoy.net/cn/doc_openwrt.html\n"
echo -e "\n press ENTER to exit (请按 回车 键返回) ..."
read vtInputKey
ventoy_cli_console
return
fi
fi
if vt_img_check_range "${vtoy_iso_part}${vt_chosen_path}"; then
ventoy_debug_pause
else
ventoy_gui_console
echo -e "\n IMG file need processed. Please refer https://www.ventoy.net/en/doc_openwrt.html.\n"
echo -e " 此 IMG 文件必须处理之后才能支持。请参考 https://www.ventoy.net/cn/doc_openwrt.html\n"
echo -e "\n press ENTER to exit (请按 回车 键返回) ..."
read vtInputKey
ventoy_cli_console
return
fi
vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
if [ $openwrt_plugin_need -eq 1 ]; then
if [ -f ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz ]; then
vt_img_extra_initrd_append ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz
fi
fi
#boot image file
vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=openwrt
vt_img_hook_root
set root=(vtimghd,1)
configfile (vtimghd,1)/boot/grub/grub.cfg
vt_img_unhook_root
vt_unset_boot_opt
}
function ventoy_img_tails { function ventoy_img_tails {
vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver" vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
@@ -1509,6 +1729,15 @@ function img_unsupport_tip {
read vtInputKey read vtInputKey
} }
function legacy_img_memdisk {
linux16 $vtoy_path/memdisk
echo "Loading img file to memory ..."
initrd16 "${1}${2}"
ventoy_cli_console
boot
}
function img_common_menuentry { function img_common_menuentry {
set ventoy_compatible=YES set ventoy_compatible=YES
set ventoy_busybox_ver=32 set ventoy_busybox_ver=32
@@ -1523,8 +1752,11 @@ function img_common_menuentry {
return return
fi fi
if [ -d (vtimghd)/ ]; then if [ "$grub_platform" = "pc" ]; then
loopback -d vtimghd if vt_check_mode 0; then
legacy_img_memdisk $vtoy_iso_part "$vt_chosen_path"
return
fi
fi fi
loopback vtimghd "${vtoy_iso_part}${vt_chosen_path}" loopback vtimghd "${vtoy_iso_part}${vt_chosen_path}"
@@ -1540,8 +1772,9 @@ function img_common_menuentry {
vt_img_extra_initrd_reset vt_img_extra_initrd_reset
vt_get_fs_label (vtimghd,1) vtImgHd1Label vt_get_fs_label (vtimghd,1) vtImgHd1Label
if [ -d (vtimghd,2)/lib ]; then if [ -d (vtimghd,2)/lib ]; then
vt_get_fs_label (vtimghd,2) vtImgHd2Label vt_get_fs_label (vtimghd,2) vtImgHd2Label
fi fi
@@ -1549,6 +1782,7 @@ function img_common_menuentry {
vt_1st_line (vtimghd,1)/etc/hostname vtImgHostname vt_1st_line (vtimghd,1)/etc/hostname vtImgHostname
fi fi
if [ -e (vtimghd,1)/easy.sfs ]; then if [ -e (vtimghd,1)/easy.sfs ]; then
ventoy_img_easyos ventoy_img_easyos
elif [ -e (vtimghd,1)/volumio.initrd ]; then elif [ -e (vtimghd,1)/volumio.initrd ]; then
@@ -1569,6 +1803,8 @@ function img_common_menuentry {
ventoy_img_recalbox ventoy_img_recalbox
elif [ -f (vtimghd,2)/loader/entries/ubos.conf ]; then elif [ -f (vtimghd,2)/loader/entries/ubos.conf ]; then
ventoy_img_ubos ventoy_img_ubos
elif [ -f (vtimghd,2)/etc/openwrt_version ]; then
ventoy_img_openwrt
elif [ -f (vtimghd,1)/efi/boot/mt86.png ]; then elif [ -f (vtimghd,1)/efi/boot/mt86.png ]; then
if [ "$grub_platform" = "pc" ]; then if [ "$grub_platform" = "pc" ]; then
img_unsupport_tip img_unsupport_tip
@@ -1587,6 +1823,8 @@ function img_common_menuentry {
fi fi
fi fi
loopback -d vtimghd
set root=$vtback_root set root=$vtback_root
vt_pop_last_entry vt_pop_last_entry
set theme=$vtback_theme set theme=$vtback_theme
@@ -1606,7 +1844,7 @@ function img_unsupport_menuentry {
############################################################# #############################################################
############################################################# #############################################################
set VENTOY_VERSION="1.0.38" set VENTOY_VERSION="1.0.49"
#ACPI not compatible with Window7/8, so disable by default #ACPI not compatible with Window7/8, so disable by default
set VTOY_PARAM_NO_ACPI=1 set VTOY_PARAM_NO_ACPI=1
@@ -1618,6 +1856,8 @@ set VTOY_DEFAULT_MENU_MODE=0
set VTOY_MEM_DISK_STR="[Memdisk]" set VTOY_MEM_DISK_STR="[Memdisk]"
set VTOY_ISO_RAW_STR="Compatible Mode" set VTOY_ISO_RAW_STR="Compatible Mode"
set VTOY_GRUB2_MODE_STR="GRUB2 Mode"
set VTOY_WIMBOOT_MODE_STR="WIMBOOT Mode"
set VTOY_ISO_UEFI_DRV_STR="UEFI FS" set VTOY_ISO_UEFI_DRV_STR="UEFI FS"
set VTOY_F2_CMD="ventoy_power" set VTOY_F2_CMD="ventoy_power"
@@ -1740,13 +1980,16 @@ elif [ "$vtoy_display_mode" = "serial_console" ]; then
terminal_output serial console terminal_output serial console
else else
if [ -n "$vtoy_theme" ]; then if [ -n "$vtoy_theme" ]; then
set theme=$vtoy_theme vt_set_theme
else else
set theme=$prefix/themes/ventoy/theme.txt set theme=$prefix/themes/ventoy/theme.txt
fi fi
terminal_output gfxterm terminal_output gfxterm
fi fi
if [ -n "$VTOY_DEFAULT_KBD_LAYOUT" ]; then
set_keyboard_layout "$VTOY_DEFAULT_KBD_LAYOUT"
fi
if [ -n "$VTOY_PLUGIN_SYNTAX_ERROR" ]; then if [ -n "$VTOY_PLUGIN_SYNTAX_ERROR" ]; then
clear clear
@@ -1766,6 +2009,8 @@ for vtTFile in ventoy.json ventoy_grub.cfg; do
fi fi
done done
#clear all input key before show main menu
vt_clear_key
#export necessary variable #export necessary variable
export theme export theme
@@ -1774,11 +2019,18 @@ export gfxpayload
export vtoydev export vtoydev
export vtoy_path export vtoy_path
export vtdebug_flag export vtdebug_flag
export vtoy_iso_fs
export vtoy_iso_part export vtoy_iso_part
export vtoy_efi_part export vtoy_efi_part
export VENTOY_VERSION export VENTOY_VERSION
export VTOY_CUR_VIDEO_MODE export VTOY_CUR_VIDEO_MODE
export VTOY_EFI_ARCH export VTOY_EFI_ARCH
export VTOY_MEM_DISK_STR
export VTOY_ISO_RAW_STR
export VTOY_GRUB2_MODE_STR
export VTOY_WIMBOOT_MODE_STR
export VTOY_ISO_UEFI_DRV_STR
#special VTOY_DEFAULT_IMAGE process #special VTOY_DEFAULT_IMAGE process
if [ -n "$VTOY_DEFAULT_IMAGE" ]; then if [ -n "$VTOY_DEFAULT_IMAGE" ]; then

View File

@@ -43,6 +43,7 @@
*save_env: loadenv *save_env: loadenv
*search: search *search: search
*serial: serial *serial: serial
*set_keyboard_layout: setkey
*setkey: setkey *setkey: setkey
*setpci: setpci *setpci: setpci
*sha1sum: hashsum *sha1sum: hashsum

Binary file not shown.

View File

@@ -1,7 +1,7 @@
videotest: font video gfxmenu videotest: font video gfxmenu
setkey: extcmd
odc: archelp odc: archelp
loopback: extcmd loopback: extcmd
setkey: extcmd
macho: macho:
gcry_des: crypto gcry_des: crypto
memrw: extcmd memrw: extcmd
@@ -26,7 +26,7 @@ sfs: fshelp
reiserfs: fshelp reiserfs: fshelp
part_sunpc: part_sunpc:
zstd: zstd:
gfxmenu: video_colors trig bitmap_scale gfxterm font normal bitmap video gfxmenu: trig video_colors bitmap_scale gfxterm font normal bitmap video
backtrace: backtrace:
jfs: jfs:
help: extcmd normal help: extcmd normal
@@ -82,7 +82,7 @@ gfxterm_background: video_colors bitmap_scale gfxterm extcmd video bitmap
search_fs_uuid: search_fs_uuid:
gcry_dsa: pgp mpi gcry_dsa: pgp mpi
keystatus: extcmd keystatus: extcmd
linux: verifiers video boot relocator mmap linux: ventoy verifiers video boot relocator mmap
geli: cryptodisk crypto gcry_sha512 pbkdf2 gcry_sha256 geli: cryptodisk crypto gcry_sha512 pbkdf2 gcry_sha256
cmdline_cat_test: font functional_test normal procfs video_fb cmdline_cat_test: font functional_test normal procfs video_fb
rdmsr: extcmd rdmsr: extcmd
@@ -120,7 +120,7 @@ ehci: cs5536 usb boot
crypto: crypto:
part_bsd: part_msdos part_bsd: part_msdos
cs5536: cs5536:
ventoy: ext2 fshelp btrfs font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660 ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd datetime div normal video gcry_sha1 iso9660
gcry_sha512: crypto gcry_sha512: crypto
password: crypto normal password: crypto normal
fshelp: fshelp:

View File

@@ -47,6 +47,7 @@
*search: search *search: search
*sendkey: sendkey *sendkey: sendkey
*serial: serial *serial: serial
*set_keyboard_layout: setkey
*setkey: setkey *setkey: setkey
*setpci: setpci *setpci: setpci
*sha1sum: hashsum *sha1sum: hashsum

View File

@@ -1,7 +1,7 @@
videotest: font video gfxmenu videotest: font video gfxmenu
setkey: extcmd
odc: archelp odc: archelp
loopback: extcmd loopback: extcmd
setkey: extcmd
macho: macho:
gcry_des: crypto gcry_des: crypto
memrw: extcmd memrw: extcmd
@@ -26,7 +26,7 @@ sfs: fshelp
reiserfs: fshelp reiserfs: fshelp
part_sunpc: part_sunpc:
zstd: zstd:
gfxmenu: video_colors trig bitmap_scale gfxterm font normal bitmap video gfxmenu: trig video_colors bitmap_scale gfxterm font normal bitmap video
backtrace: backtrace:
jfs: jfs:
help: extcmd normal help: extcmd normal
@@ -82,7 +82,7 @@ gfxterm_background: video_colors bitmap_scale gfxterm extcmd video bitmap
search_fs_uuid: search_fs_uuid:
gcry_dsa: pgp mpi gcry_dsa: pgp mpi
keystatus: extcmd keystatus: extcmd
linux: verifiers normal vbe video boot relocator mmap linux: ventoy verifiers normal vbe video boot relocator mmap
geli: cryptodisk crypto gcry_sha512 pbkdf2 gcry_sha256 geli: cryptodisk crypto gcry_sha512 pbkdf2 gcry_sha256
cmdline_cat_test: font functional_test normal procfs video_fb cmdline_cat_test: font functional_test normal procfs video_fb
rdmsr: extcmd rdmsr: extcmd
@@ -123,7 +123,7 @@ crypto:
part_bsd: part_msdos part_bsd: part_msdos
cs5536: pci cs5536: pci
biosdisk: biosdisk:
ventoy: ext2 fshelp btrfs font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660 acpi ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf datetime div extcmd normal video gcry_sha1 iso9660 acpi
lsapm: lsapm:
gcry_sha512: crypto gcry_sha512: crypto
password: crypto normal password: crypto normal

62
INSTALL/grub/keyboard.cfg Normal file
View File

@@ -0,0 +1,62 @@
submenu "Keyboard Layouts" --class=debug_krdlayout --class=F5tool {
menuentry QWERTY_USA --class=debug_kbd --class=debug_krdlayout --class=F5tool {
set_keyboard_layout QWERTY_USA
}
menuentry AZERTY --class=debug_kbd --class=debug_krdlayout --class=F5tool {
set_keyboard_layout AZERTY
}
menuentry CZECH_QWERTY --class=debug_kbd --class=debug_krdlayout --class=F5tool {
set_keyboard_layout CZECH_QWERTY
}
menuentry CZECH_QWERTZ --class=debug_kbd --class=debug_krdlayout --class=F5tool {
set_keyboard_layout CZECH_QWERTZ
}
menuentry DANISH --class=debug_kbd --class=debug_krdlayout --class=F5tool {
set_keyboard_layout DANISH
}
menuentry DVORAK_USA --class=debug_kbd --class=debug_krdlayout --class=F5tool {
set_keyboard_layout DVORAK_USA
}
menuentry FRENCH --class=debug_kbd --class=debug_krdlayout --class=F5tool {
set_keyboard_layout FRENCH
}
menuentry GERMAN --class=debug_kbd --class=debug_krdlayout --class=F5tool {
set_keyboard_layout GERMAN
}
menuentry ITALIANO --class=debug_kbd --class=debug_krdlayout --class=F5tool {
set_keyboard_layout ITALIANO
}
menuentry JAPAN_106 --class=debug_kbd --class=debug_krdlayout --class=F5tool {
set_keyboard_layout JAPAN_106
}
menuentry LATIN_USA --class=debug_kbd --class=debug_krdlayout --class=F5tool {
set_keyboard_layout LATIN_USA
}
menuentry PORTU_BRAZIL --class=debug_kbd --class=debug_krdlayout --class=F5tool {
set_keyboard_layout PORTU_BRAZIL
}
menuentry QWERTY_UK --class=debug_kbd --class=debug_krdlayout --class=F5tool {
set_keyboard_layout QWERTY_UK
}
menuentry QWERTZ --class=debug_kbd --class=debug_krdlayout --class=F5tool {
set_keyboard_layout QWERTZ
}
menuentry QWERTZ_HUN --class=debug_kbd --class=debug_krdlayout --class=F5tool {
set_keyboard_layout QWERTZ_HUN
}
menuentry QWERTZ_SLOV_CROAT --class=debug_kbd --class=debug_krdlayout --class=F5tool {
set_keyboard_layout QWERTZ_SLOV_CROAT
}
menuentry SPANISH --class=debug_kbd --class=debug_krdlayout --class=F5tool {
set_keyboard_layout SPANISH
}
menuentry SWEDISH --class=debug_kbd --class=debug_krdlayout --class=F5tool {
set_keyboard_layout SWEDISH
}
menuentry TURKISH_Q --class=debug_kbd --class=debug_krdlayout --class=F5tool {
set_keyboard_layout TURKISH_Q
}
menuentry VIETNAMESE --class=debug_kbd --class=debug_krdlayout --class=F5tool {
set_keyboard_layout VIETNAMESE
}
}

Binary file not shown.

View File

@@ -1,6 +1,6 @@
if [ "$grub_platform" = "pc" ]; then if [ "$grub_platform" = "pc" ]; then
menuentry 'Search and boot Windows' --class=boot_windows { menuentry 'Search and boot Windows' --class=boot_windows --class=F4boot {
set partid=3 set partid=3
while [ $partid -le 128 ]; do while [ $partid -le 128 ]; do
@@ -38,7 +38,7 @@ if [ "$grub_platform" = "pc" ]; then
fi fi
} }
menuentry 'Search and boot Grub4dos' --class=boot_g4d { menuentry 'Search and boot Grub4dos' --class=boot_g4d --class=F4boot {
if search -n -s -f /grldr; then if search -n -s -f /grldr; then
ntldr /grldr ntldr /grldr
else else
@@ -46,19 +46,19 @@ if [ "$grub_platform" = "pc" ]; then
fi fi
} }
menuentry 'Boot the 1st local disk' --class=boot_disk { menuentry 'Boot the 1st local disk' --class=boot_disk --class=F4boot {
set root=(hd0,1) set root=(hd0,1)
chainloader +1 chainloader +1
boot boot
} }
menuentry 'Boot the 2nd local disk' --class=boot_disk { menuentry 'Boot the 2nd local disk' --class=boot_disk --class=F4boot {
set root=(hd1,1) set root=(hd1,1)
chainloader +1 chainloader +1
boot boot
} }
menuentry 'Boot the 3rd local disk' --class=boot_disk { menuentry 'Boot the 3rd local disk' --class=boot_disk --class=F4boot {
set root=(hd2,1) set root=(hd2,1)
chainloader +1 chainloader +1
boot boot
@@ -66,7 +66,7 @@ if [ "$grub_platform" = "pc" ]; then
else else
menuentry 'Search and boot Windows' --class=boot_windows { menuentry 'Search and boot Windows' --class=boot_windows --class=F4boot {
set partid=3 set partid=3
while [ $partid -le 128 ]; do while [ $partid -le 128 ]; do
@@ -93,7 +93,7 @@ else
} }
if [ "$grub_cpu" = "i386" ]; then if [ "$grub_cpu" = "i386" ]; then
menuentry 'Search and boot BOOTIA32.EFI' --class=boot_uefi { menuentry 'Search and boot BOOTIA32.EFI' --class=boot_uefi --class=F4boot {
set VTOY_SEARCH_NO_VTOYEFI=1 set VTOY_SEARCH_NO_VTOYEFI=1
if search -n -s -f /efi/boot/bootia32.efi; then if search -n -s -f /efi/boot/bootia32.efi; then
unset VTOY_SEARCH_NO_VTOYEFI unset VTOY_SEARCH_NO_VTOYEFI
@@ -106,7 +106,7 @@ else
fi fi
} }
elif [ "$grub_cpu" = "arm64" ]; then elif [ "$grub_cpu" = "arm64" ]; then
menuentry 'Search and boot BOOTAA64.EFI' --class=boot_uefi { menuentry 'Search and boot BOOTAA64.EFI' --class=boot_uefi --class=F4boot {
set VTOY_SEARCH_NO_VTOYEFI=1 set VTOY_SEARCH_NO_VTOYEFI=1
if search -n -s -f /efi/boot/bootaa64.efi; then if search -n -s -f /efi/boot/bootaa64.efi; then
unset VTOY_SEARCH_NO_VTOYEFI unset VTOY_SEARCH_NO_VTOYEFI
@@ -119,7 +119,7 @@ else
fi fi
} }
else else
menuentry 'Search and boot BOOTX64.EFI' --class=boot_uefi { menuentry 'Search and boot BOOTX64.EFI' --class=boot_uefi --class=F4boot {
set VTOY_SEARCH_NO_VTOYEFI=1 set VTOY_SEARCH_NO_VTOYEFI=1
if search -n -s -f /efi/boot/bootx64.efi; then if search -n -s -f /efi/boot/bootx64.efi; then
unset VTOY_SEARCH_NO_VTOYEFI unset VTOY_SEARCH_NO_VTOYEFI

Binary file not shown.

Binary file not shown.

View File

@@ -70,6 +70,22 @@ terminal-box: "terminal_box_*.png"
} }
+ hbox{
left = 30%+200
top = 95%-50
width = 10%
height = 25
+ label {text = "@VTOY_GRUB2_MODE@" color = "red" align = "left"}
}
+ hbox{
left = 30%+200
top = 95%-25
width = 10%
height = 25
+ label {text = "@VTOY_WIMBOOT_MODE@" color = "red" align = "left"}
}
+ hbox{ + hbox{
left = 90% left = 90%
top = 55 top = 55

View File

@@ -43,6 +43,7 @@
*save_env: loadenv *save_env: loadenv
*search: search *search: search
*serial: serial *serial: serial
*set_keyboard_layout: setkey
*setkey: setkey *setkey: setkey
*setpci: setpci *setpci: setpci
*sha1sum: hashsum *sha1sum: hashsum

Binary file not shown.

View File

@@ -1,7 +1,7 @@
videotest: font video gfxmenu videotest: font video gfxmenu
setkey: extcmd
odc: archelp odc: archelp
loopback: extcmd loopback: extcmd
setkey: extcmd
macho: macho:
gcry_des: crypto gcry_des: crypto
memrw: extcmd memrw: extcmd
@@ -26,7 +26,7 @@ sfs: fshelp
reiserfs: fshelp reiserfs: fshelp
part_sunpc: part_sunpc:
zstd: zstd:
gfxmenu: video_colors trig bitmap_scale gfxterm font normal bitmap video gfxmenu: trig video_colors bitmap_scale gfxterm font normal bitmap video
backtrace: backtrace:
jfs: jfs:
help: extcmd normal help: extcmd normal
@@ -81,7 +81,7 @@ gfxterm_background: video_colors bitmap_scale gfxterm extcmd video bitmap
search_fs_uuid: search_fs_uuid:
gcry_dsa: pgp mpi gcry_dsa: pgp mpi
keystatus: extcmd keystatus: extcmd
linux: verifiers video boot relocator mmap linux: ventoy verifiers video boot relocator mmap
geli: cryptodisk crypto gcry_sha512 pbkdf2 gcry_sha256 geli: cryptodisk crypto gcry_sha512 pbkdf2 gcry_sha256
cmdline_cat_test: font functional_test normal procfs video_fb cmdline_cat_test: font functional_test normal procfs video_fb
rdmsr: extcmd rdmsr: extcmd
@@ -120,7 +120,7 @@ ehci: cs5536 usb boot
crypto: crypto:
part_bsd: part_msdos part_bsd: part_msdos
cs5536: cs5536:
ventoy: ext2 fshelp btrfs font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660 ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd datetime div normal video gcry_sha1 iso9660
gcry_sha512: crypto gcry_sha512: crypto
password: crypto normal password: crypto normal
fshelp: fshelp:

View File

@@ -70,6 +70,22 @@ terminal-box: "terminal_box_*.png"
} }
+ hbox{
left = 30%+200
top = 95%-50
width = 10%
height = 25
+ label {text = "@VTOY_GRUB2_MODE@" color = "red" align = "left"}
}
+ hbox{
left = 30%+200
top = 95%-25
width = 10%
height = 25
+ label {text = "@VTOY_WIMBOOT_MODE@" color = "red" align = "left"}
}
+ hbox{ + hbox{
left = 90% left = 90%
top = 55 top = 55

View File

@@ -365,11 +365,15 @@ else
oldver=$(get_disk_ventoy_version $DISK) oldver=$(get_disk_ventoy_version $DISK)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
vtwarn "$DISK does not contain Ventoy or data corrupted" if is_disk_contains_ventoy $DISK; then
echo "" oldver="Unknown"
vtwarn "Please use -i option if you want to install ventoy to $DISK" else
echo "" vtwarn "$DISK does not contain Ventoy or data corrupted"
exit 1 echo ""
vtwarn "Please use -i option if you want to install ventoy to $DISK"
echo ""
exit 1
fi
fi fi
#reserve secure boot option #reserve secure boot option

View File

@@ -1,95 +0,0 @@
#!/bin/sh
LOGFILE=log.txt
VUSER=$(get_user)
if [ -e $LOGFILE ]; then
chown $VUSER $LOGFILE
else
su $VUSER -c "touch $LOGFILE"
fi
#delete the log.txt if it's more than 8MB
if [ -f $LOGFILE ]; then
logsize=$(stat -c '%s' $LOGFILE)
if [ $logsize -gt 8388608 ]; then
rm -f $LOGFILE
fi
fi
if [ -f ./tool/$TOOLDIR/V2DServer.xz ]; then
xz -d ./tool/$TOOLDIR/V2DServer.xz
chmod +x ./tool/$TOOLDIR/V2DServer
fi
rm -rf ./*_VTMPDIR
vtWebTmpDir=$(mktemp -d -p ./ --suffix=_VTMPDIR)
chown $VUSER $vtWebTmpDir
V2DServer "$HOST" "$PORT" &
V2DPid=$!
sleep 1
su $VUSER -c "browser --window-size=550,400 --app=\"http://${HOST}:${PORT}/index.html?chrome-app\" --user-data-dir=$vtWebTmpDir >> $LOGFILE 2>&1" &
WebPid=$!
vtoy_trap_exit() {
[ -d /proc/$V2DPid ] && kill -2 $V2DPid
[ -d /proc/$WebPid ] && kill -9 $WebPid
while [ -n "1" ]; do
curPid=$(ps -ef | grep -m1 "$vtWebTmpDir" | egrep -v '\sgrep\s' | awk '{print $2}')
if [ -z "$curPid" ]; then
break
fi
if [ -d /proc/$curPid ]; then
kill -9 $curPid
fi
done
[ -d $vtWebTmpDir ] && rm -rf $vtWebTmpDir
if [ -n "$OLDDIR" ]; then
CURDIR=$(pwd)
if [ "$CURDIR" != "$OLDDIR" ]; then
cd "$OLDDIR"
fi
fi
exit 1
}
trap vtoy_trap_exit HUP INT QUIT TSTP
sleep 1
vtVer=$(cat ventoy/version)
echo ""
echo "=================================================="
if [ "$LANG" = "zh_CN.UTF-8" ]; then
echo " Ventoy Server $vtVer 已经启动 ..."
else
echo " Ventoy Server $vtVer is running ..."
fi
echo "=================================================="
echo ""
echo "########### Press Ctrl + C to exit ###############"
echo ""
wait $WebPid
[ -d /proc/$V2DPid ] && kill -2 $V2DPid
[ -d $vtWebTmpDir ] && rm -rf $vtWebTmpDir
if [ -n "$OLDDIR" ]; then
CURDIR=$(pwd)
if [ "$CURDIR" != "$OLDDIR" ]; then
cd "$OLDDIR"
fi
fi

View File

@@ -1,68 +0,0 @@
#!/bin/sh
LOGFILE=log.txt
#delete the log.txt if it's more than 8MB
if [ -f $LOGFILE ]; then
logsize=$(stat -c '%s' $LOGFILE)
if [ $logsize -gt 8388608 ]; then
rm -f $LOGFILE
fi
fi
if [ -f ./tool/$TOOLDIR/V2DServer.xz ]; then
xz -d ./tool/$TOOLDIR/V2DServer.xz
chmod +x ./tool/$TOOLDIR/V2DServer
fi
V2DServer "$HOST" "$PORT" &
V2DPid=$!
sleep 1
vtoy_trap_exit() {
[ -d /proc/$V2DPid ] && kill -2 $V2DPid
if [ -n "$OLDDIR" ]; then
CURDIR=$(pwd)
if [ "$CURDIR" != "$OLDDIR" ]; then
cd "$OLDDIR"
fi
fi
exit 1
}
trap vtoy_trap_exit HUP INT QUIT TSTP
sleep 1
vtVer=$(cat ventoy/version)
echo ""
echo "=================================================="
if [ "$LANG" = "zh_CN.UTF-8" ]; then
echo " Ventoy Server $vtVer 已经启动 ..."
else
echo " Ventoy Server $vtVer is running ..."
fi
echo "=================================================="
echo ""
echo "########### Press Ctrl + C to exit ###############"
echo ""
if [ "$VERBOSE" = "1" ]; then
uos-browser --window-size=550,400 --app="http://${HOST}:${PORT}/index.html?chrome-app"
else
uos-browser --window-size=550,400 --app="http://${HOST}:${PORT}/index.html?chrome-app" > /dev/null 2>&1
fi
[ -d /proc/$V2DPid ] && kill -2 $V2DPid
if [ -n "$OLDDIR" ]; then
CURDIR=$(pwd)
if [ "$CURDIR" != "$OLDDIR" ]; then
cd "$OLDDIR"
fi
fi

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

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