mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-09-16 09:01:15 +00:00
Compare commits
250 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
b5a649f96f | ||
|
443a1344f2 | ||
|
d3de1a91f8 | ||
|
580ad598f6 | ||
|
0891e34d47 | ||
|
4d777090cb | ||
|
b0568922d2 | ||
|
69b6bb8fca | ||
|
3d686c27d7 | ||
|
90ba217ec7 | ||
|
fab070ef64 | ||
|
b3869b6894 | ||
|
563214ed40 | ||
|
b67f738b00 | ||
|
a9c539572b | ||
|
32602a79ab | ||
|
863eafd2cc | ||
|
0f135b6646 | ||
|
675c24ffa3 | ||
|
cd309eb663 | ||
|
5cdd6540a4 | ||
|
fde2e4430c | ||
|
9a471f4956 | ||
|
1f3b3afa35 | ||
|
6947f2a047 | ||
|
0a15e4e427 | ||
|
e763d7590f | ||
|
f842d46f90 | ||
|
cc1cc6c301 | ||
|
9f3d209798 | ||
|
fc742244ab | ||
|
3e66227dae | ||
|
f32d342f66 | ||
|
09d7ae68e7 | ||
|
68fefbc1fc | ||
|
8d893d4c94 | ||
|
84798a4f7a | ||
|
87f88eeb2b | ||
|
7b2615744c | ||
|
d7faff4438 | ||
|
f15dfd7409 | ||
|
09162e8d97 | ||
|
eb8fcc8f30 | ||
|
5fcb3971bc | ||
|
e47e4484ce | ||
|
7e26decb31 | ||
|
e713946fd0 | ||
|
a93b0f6656 | ||
|
836e1aa11e | ||
|
154bbc6e5f | ||
|
d151e74336 | ||
|
df87cafdfb | ||
|
09494a5b23 | ||
|
e15a1c5ece | ||
|
f5843f576b | ||
|
be5bc6f3b7 | ||
|
f3b65452f4 | ||
|
ec4b6c2a2c | ||
|
be8b6e8976 | ||
|
82b1faa132 | ||
|
52ae65f54d | ||
|
ee104bfa97 | ||
|
9cfd05811b | ||
|
0c66908935 | ||
|
f53de3bdb0 | ||
|
8516786b31 | ||
|
f7c78879c7 | ||
|
f3e267a09e | ||
|
7c1370dcb0 | ||
|
1b5aa9c61d | ||
|
d6eba15d71 | ||
|
734c7b8ac4 | ||
|
0fa25c4526 | ||
|
1473be0e4c | ||
|
cd9aa16b20 | ||
|
a9be2fd4d9 | ||
|
f354d2b733 | ||
|
aa033e1fb6 | ||
|
9351fe4f97 | ||
|
67b8a34e8c | ||
|
c18399e8b4 | ||
|
5a591c1ae7 | ||
|
e208199cca | ||
|
4c9065a60d | ||
|
4fd4977c3a | ||
|
93614c3251 | ||
|
1db0827463 | ||
|
72d0fd0dd4 | ||
|
47797f0285 | ||
|
849eb7bf2c | ||
|
32c5b5deea | ||
|
d72bb15956 | ||
|
89a34bac18 | ||
|
8cecdae8f9 | ||
|
471432fc50 | ||
|
a78e19608b | ||
|
5e97d56033 | ||
|
a5041ad43c | ||
|
3149a67599 | ||
|
d0b7927b51 | ||
|
8775684367 | ||
|
d148139227 | ||
|
dd2411d7d4 | ||
|
7db83dc0f1 | ||
|
787d950f28 | ||
|
892a819da4 | ||
|
bfc5eaebb9 | ||
|
e7d05df9fa | ||
|
ca07b52cb2 | ||
|
1a2a35f5bc | ||
|
d71514f23e | ||
|
c5af17e04e | ||
|
05e208ea2a | ||
|
112c557428 | ||
|
92db873b5c | ||
|
3c01eec4af | ||
|
5c6d18fcd4 | ||
|
84ec4b0de4 | ||
|
9615e7eaa0 | ||
|
6a244ff260 | ||
|
b5503a7375 | ||
|
0b7fa630a4 | ||
|
7babe823d6 | ||
|
6db513a067 | ||
|
bafac7479d | ||
|
d3138479d7 | ||
|
56a1543f7d | ||
|
659ac1cfe3 | ||
|
c83daa86b6 | ||
|
dfcfaa9967 | ||
|
188f9e707c | ||
|
8b975b5e80 | ||
|
2ab717cc66 | ||
|
88793d548a | ||
|
5fea6eab7e | ||
|
5d55dc68ae | ||
|
2c320aad60 | ||
|
b63034b2c7 | ||
|
6c113880e5 | ||
|
e2656c287b | ||
|
d8433985e7 | ||
|
b003105925 | ||
|
2ca2c83b6b | ||
|
dff7e495ca | ||
|
cf0f395c56 | ||
|
69bc90da42 | ||
|
ffc40234ca | ||
|
e57daa5065 | ||
|
5c733a20f8 | ||
|
069342ab9a | ||
|
32a964eded | ||
|
51b92f398a | ||
|
5d0ebf4510 | ||
|
cf94487ad5 | ||
|
af83f46a3d | ||
|
4910e9f380 | ||
|
fb38b321c2 | ||
|
7b78fe555e | ||
|
094ba61848 | ||
|
faa0e46d3a | ||
|
537f0eaa7e | ||
|
c8cf9b7ce2 | ||
|
4c71d7c190 | ||
|
47f9f2c42c | ||
|
fc3a5fae36 | ||
|
b3982d4930 | ||
|
c280baae27 | ||
|
425d640480 | ||
|
07d4140cf4 | ||
|
90ae07d227 | ||
|
e3e21eb6e6 | ||
|
c8ce2ae85a | ||
|
c02a6955c3 | ||
|
6b78603dd3 | ||
|
07a386c963 | ||
|
eb048c0075 | ||
|
37ac3f312f | ||
|
092cff8429 | ||
|
b347c1b5da | ||
|
da746c608f | ||
|
81aa56955a | ||
|
d1679871a6 | ||
|
f383052013 | ||
|
667f5bcc1b | ||
|
af69cb7f44 | ||
|
7bb13fc18a | ||
|
7fce7e0aba | ||
|
2a435084c2 | ||
|
c0c454a436 | ||
|
63924fa8bd | ||
|
3e47f5e8de | ||
|
b5eb347244 | ||
|
9225c940a6 | ||
|
a8edb99d28 | ||
|
ac3ab97686 | ||
|
c42a8c6d93 | ||
|
4b1dd4d3af | ||
|
f342be1d6c | ||
|
f4774ee0e4 | ||
|
d3cfa73631 | ||
|
331080fb95 | ||
|
99fbd14f08 | ||
|
1c5aeb35dc | ||
|
f7b3bd1729 | ||
|
672632a0c2 | ||
|
d07aa6ce07 | ||
|
93996cf7e2 | ||
|
ca62128f9b | ||
|
265b70f1c7 | ||
|
491f0bea8a | ||
|
47e77e003c | ||
|
d05eab2be1 | ||
|
849dfb463d | ||
|
7715bd705c | ||
|
042ca4b5e3 | ||
|
e1099e1e5b | ||
|
c6be35f2c0 | ||
|
b15a96b747 | ||
|
6bd0463d34 | ||
|
1ce568d971 | ||
|
f82475d950 | ||
|
aad154616c | ||
|
83c3a932d3 | ||
|
0aff8f5109 | ||
|
2750f0c5a7 | ||
|
f71a1fcce9 | ||
|
e252fab9a4 | ||
|
37212a8ea4 | ||
|
e71221cdba | ||
|
65a2cb1685 | ||
|
e23e76f54e | ||
|
8ded032c92 | ||
|
fc5cd0a00a | ||
|
6cc400b8d4 | ||
|
ffc915ca53 | ||
|
8ebe972f6e | ||
|
39975dd1c3 | ||
|
1a648d8689 | ||
|
8234961228 | ||
|
e1ffbad431 | ||
|
4a66104c6e | ||
|
32bcd8f87b | ||
|
26c1756e8d | ||
|
f4bbec65ba | ||
|
58d387f732 | ||
|
2e10aabe94 | ||
|
a63a41f79d | ||
|
64748308a3 | ||
|
33cc1e271a | ||
|
291e0a3a38 |
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: ['https://www.ventoy.net/en/donation.html'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
custom: ['https://www.paypal.me/ventoy', 'https://www.ventoy.net/en/donation.html'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
|
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
blank_issues_enabled: false
|
100
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
Normal file
100
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
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.61
|
||||
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: input
|
||||
id: vendor
|
||||
attributes:
|
||||
label: Disk Manufacturer
|
||||
description: What is the manufacturer of the disk installed with Ventoy? (e.g. SanDisk/Kingston...)
|
||||
validations:
|
||||
required: false
|
||||
- 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
|
||||
|
101
.github/ISSUE_TEMPLATE/success_image_report.yml
vendored
Normal file
101
.github/ISSUE_TEMPLATE/success_image_report.yml
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
name: Success Image Report
|
||||
description: To report an image file that boot successfully in Ventoy and is not yet listed in https://www.ventoy.net/en/isolist.html
|
||||
title: "[Success Image Report]: "
|
||||
assignees:
|
||||
- octocat
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
I list all the successfully tested image files in the official website: https://www.ventoy.net/en/isolist.html
|
||||
If you successfully test an image file which is not listed in the above page, you can tell me and I will be very glad to add it to the tested list.
|
||||
- type: checkboxes
|
||||
id: faq
|
||||
attributes:
|
||||
label: Official Website List
|
||||
description: Have you checked the list at [https://www.ventoy.net/en/isolist.html](https://www.ventoy.net/en/isolist.html) and the image file is not listed?
|
||||
options:
|
||||
- label: I have checked the list in official website and the image file is not listed there.
|
||||
required: true
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: Ventoy Version
|
||||
description: What version of ventoy did you test with the image file.
|
||||
placeholder: 1.0.57
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: bios
|
||||
attributes:
|
||||
label: BIOS Mode
|
||||
description: In which BIOS mode did you successfully test the image file? (It's recommended to test in both mode)
|
||||
options:
|
||||
- Legacy BIOS Mode
|
||||
- UEFI Mode
|
||||
- Both
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: partstyle
|
||||
attributes:
|
||||
label: Partition Style
|
||||
description: Which partition style did you use with Ventoy?
|
||||
options:
|
||||
- MBR
|
||||
- GPT
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: filename
|
||||
attributes:
|
||||
label: Image file name
|
||||
description: The successfully tested image file name.
|
||||
placeholder: xxxx.iso
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: checksum
|
||||
attributes:
|
||||
label: Image file checksum type
|
||||
description:
|
||||
options:
|
||||
- MD5
|
||||
- SHA1
|
||||
- SHA256
|
||||
- SHA512
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: checkvalue
|
||||
attributes:
|
||||
label: Image file checksum value
|
||||
description: What is the image file checksum value corresponding to the above checksum type?
|
||||
placeholder: xxxx
|
||||
validations:
|
||||
required: true
|
||||
- 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: input
|
||||
id: testenv
|
||||
attributes:
|
||||
label: Test envrionment
|
||||
description: The manufacturer/model and other details about your computer (or VM).
|
||||
placeholder: Lenovo Thinkpad T420 laptop
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: details
|
||||
attributes:
|
||||
label: More Details?
|
||||
description: You can give more details here.
|
||||
value: "This image file booted successfully in Ventoy."
|
||||
validations:
|
||||
required: false
|
||||
|
1
.github/workflows/sync2gitee.yml
vendored
1
.github/workflows/sync2gitee.yml
vendored
@@ -11,6 +11,7 @@ on:
|
||||
jobs:
|
||||
run:
|
||||
name: Sync-GitHub-to-Gitee
|
||||
if: ${{ github.repository_owner == 'ventoy' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Mirror the Github repos to Gitee.
|
||||
|
@@ -5,6 +5,6 @@ RUN yum -y -q install \
|
||||
mpfr.i686 mpfr-devel.i686 rsync autogen autoconf automake libtool gettext* bison binutils \
|
||||
flex device-mapper-devel SDL libpciaccess libusb freetype freetype-devel gnu-free-* qemu-* virt-* \
|
||||
libvirt* vte* NetworkManager-bluetooth brlapi fuse-devel dejavu* gnu-efi* pesign shim \
|
||||
iscsi-initiator-utils grub2-tools zip nasm acpica-tools glibc-static zlib-static xorriso
|
||||
iscsi-initiator-utils grub2-tools zip nasm acpica-tools glibc-static zlib-static xorriso lz4 squashfs-tools
|
||||
|
||||
CMD cd /ventoy/INSTALL && ls -la && sh docker_ci_build.sh
|
||||
|
@@ -34,6 +34,7 @@
|
||||
#include <Protocol/BlockIo.h>
|
||||
#include <Protocol/RamDisk.h>
|
||||
#include <Protocol/SimpleFileSystem.h>
|
||||
#include <Protocol/DriverBinding.h>
|
||||
#include <Ventoy.h>
|
||||
|
||||
BOOLEAN gDebugPrint = FALSE;
|
||||
@@ -58,6 +59,9 @@ static grub_env_set_pf grub_env_set = NULL;
|
||||
ventoy_grub_param_file_replace *g_file_replace_list = NULL;
|
||||
ventoy_efi_file_replace g_efi_file_replace;
|
||||
|
||||
ventoy_grub_param_file_replace *g_img_replace_list = NULL;
|
||||
ventoy_efi_file_replace g_img_file_replace;
|
||||
|
||||
CONST CHAR16 gIso9660EfiDriverPath[] = ISO9660_EFI_DRIVER_PATH;
|
||||
CONST CHAR16 gUdfEfiDriverPath[] = UDF_EFI_DRIVER_PATH;
|
||||
|
||||
@@ -362,10 +366,22 @@ EFI_HANDLE EFIAPI ventoy_get_parent_handle(IN EFI_DEVICE_PATH_PROTOCOL *pDevPath
|
||||
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)
|
||||
{
|
||||
UINTN DataSize;
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
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,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
@@ -379,21 +395,38 @@ EFI_STATUS EFIAPI ventoy_delete_ramdisk_param(VOID)
|
||||
{
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
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,
|
||||
0, NULL);
|
||||
debug("delete efi variable %r", Status);
|
||||
debug("delete ramdisk variable %r", Status);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS EFIAPI ventoy_save_variable(VOID)
|
||||
{
|
||||
UINTN DataSize;
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
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,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
sizeof(g_chain->os_param), &(g_chain->os_param));
|
||||
@@ -406,11 +439,21 @@ EFI_STATUS EFIAPI ventoy_delete_variable(VOID)
|
||||
{
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
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,
|
||||
0, NULL);
|
||||
debug("delete efi variable %r", Status);
|
||||
debug("delete efi variable %r", Status);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
@@ -667,6 +710,35 @@ STATIC EFI_STATUS EFIAPI ventoy_load_isoefi_driver(IN EFI_HANDLE ImageHandle)
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
STATIC EFI_STATUS ventoy_proc_img_replace_name(ventoy_grub_param_file_replace *replace)
|
||||
{
|
||||
UINT32 i;
|
||||
char tmp[256];
|
||||
|
||||
if (replace->magic != GRUB_IMG_REPLACE_MAGIC)
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (replace->old_file_name[0][0] == 0)
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
AsciiStrCpyS(tmp, sizeof(tmp), replace->old_file_name[0]);
|
||||
|
||||
for (i = 0; i < 256 && tmp[i]; i++)
|
||||
{
|
||||
if (tmp[i] == '/')
|
||||
{
|
||||
tmp[i] = '\\';
|
||||
}
|
||||
}
|
||||
|
||||
AsciiStrCpyS(replace->old_file_name[0], 256, tmp);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
|
||||
{
|
||||
UINT32 i = 0;
|
||||
@@ -777,6 +849,19 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
|
||||
old_cnt > 3 ? g_file_replace_list->old_file_name[3] : ""
|
||||
);
|
||||
|
||||
g_img_replace_list = &pGrubParam->img_replace;
|
||||
ventoy_proc_img_replace_name(g_img_replace_list);
|
||||
old_cnt = g_img_replace_list->old_file_cnt;
|
||||
debug("img replace: magic:0x%x virtid:%u name count:%u <%a> <%a> <%a> <%a>",
|
||||
g_img_replace_list->magic,
|
||||
g_img_replace_list->new_file_virtual_id,
|
||||
old_cnt,
|
||||
old_cnt > 0 ? g_img_replace_list->old_file_name[0] : "",
|
||||
old_cnt > 1 ? g_img_replace_list->old_file_name[1] : "",
|
||||
old_cnt > 2 ? g_img_replace_list->old_file_name[2] : "",
|
||||
old_cnt > 3 ? g_img_replace_list->old_file_name[3] : ""
|
||||
);
|
||||
|
||||
pPos = StrStr(pCmdLine, L"mem:");
|
||||
chain = (ventoy_chain_head *)StrHexToUintn(pPos + 4);
|
||||
|
||||
@@ -1010,7 +1095,8 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
|
||||
gST->ConIn->Reset(gST->ConIn, FALSE);
|
||||
}
|
||||
|
||||
if (g_file_replace_list && g_file_replace_list->magic == GRUB_FILE_REPLACE_MAGIC)
|
||||
if ((g_file_replace_list && g_file_replace_list->magic == GRUB_FILE_REPLACE_MAGIC) ||
|
||||
(g_img_replace_list && g_img_replace_list->magic == GRUB_IMG_REPLACE_MAGIC))
|
||||
{
|
||||
ventoy_wrapper_push_openvolume(pFile->OpenVolume);
|
||||
pFile->OpenVolume = ventoy_wrapper_open_volume;
|
||||
@@ -1085,6 +1171,8 @@ EFI_STATUS EFIAPI VentoyEfiMain
|
||||
return Status;
|
||||
}
|
||||
|
||||
ventoy_disable_ex_filesystem();
|
||||
|
||||
if (gMemdiskMode)
|
||||
{
|
||||
g_ramdisk_param.PhyAddr = (UINT64)(UINTN)g_iso_data_buf;
|
||||
@@ -1159,6 +1247,8 @@ EFI_STATUS EFIAPI VentoyEfiMain
|
||||
grub_env_set("vtoy_dotefi_retry", "YES");
|
||||
}
|
||||
|
||||
ventoy_enable_ex_filesystem();
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@@ -169,7 +169,6 @@ typedef struct ventoy_virt_chunk
|
||||
{ 0x37b87ac6, 0xc180, 0x4583, { 0xa7, 0x05, 0x41, 0x4d, 0xa8, 0xf7, 0x7e, 0xd2 }}
|
||||
|
||||
|
||||
#define VTOY_BLOCK_DEVICE_PATH_NAME L"ventoy"
|
||||
|
||||
#if defined (MDE_CPU_IA32)
|
||||
#define VENTOY_UEFI_DESC L"IA32 UEFI"
|
||||
@@ -244,6 +243,7 @@ typedef int (*grub_env_printf_pf)(const char *fmt, ...);
|
||||
#pragma pack(1)
|
||||
|
||||
#define GRUB_FILE_REPLACE_MAGIC 0x1258BEEF
|
||||
#define GRUB_IMG_REPLACE_MAGIC 0x1259BEEF
|
||||
|
||||
typedef struct ventoy_efi_file_replace
|
||||
{
|
||||
@@ -268,6 +268,7 @@ typedef struct ventoy_grub_param
|
||||
grub_env_get_pf grub_env_get;
|
||||
grub_env_set_pf grub_env_set;
|
||||
ventoy_grub_param_file_replace file_replace;
|
||||
ventoy_grub_param_file_replace img_replace;
|
||||
grub_env_printf_pf grub_env_printf;
|
||||
}ventoy_grub_param;
|
||||
|
||||
@@ -344,6 +345,14 @@ typedef struct ventoy_system_wrapper
|
||||
EFI_LOCATE_DEVICE_PATH OriLocateDevicePath;
|
||||
} 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) \
|
||||
{\
|
||||
wrapper.Ori##func = bs->func;\
|
||||
@@ -351,6 +360,22 @@ typedef struct ventoy_system_wrapper
|
||||
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;
|
||||
VOID EFIAPI VtoyDebug(IN CONST CHAR8 *Format, ...);
|
||||
EFI_STATUS EFIAPI ventoy_wrapper_system(VOID);
|
||||
@@ -373,6 +398,7 @@ extern ventoy_virt_chunk *g_virt_chunk;
|
||||
extern UINT32 g_virt_chunk_num;
|
||||
extern vtoy_block_data gBlockData;
|
||||
extern ventoy_efi_file_replace g_efi_file_replace;
|
||||
extern ventoy_efi_file_replace g_img_file_replace;
|
||||
extern ventoy_sector_flag *g_sector_flag;
|
||||
extern UINT32 g_sector_flag_num;
|
||||
extern BOOLEAN gMemdiskMode;
|
||||
@@ -380,6 +406,7 @@ extern BOOLEAN gSector512Mode;
|
||||
extern UINTN g_iso_buf_size;
|
||||
extern UINT8 *g_iso_data_buf;
|
||||
extern ventoy_grub_param_file_replace *g_file_replace_list;
|
||||
extern ventoy_grub_param_file_replace *g_img_replace_list;
|
||||
extern BOOLEAN g_fixup_iso9660_secover_enable;
|
||||
extern EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *g_con_simple_input_ex;
|
||||
extern BOOLEAN g_fix_windows_1st_cdrom_issue;
|
||||
@@ -396,6 +423,8 @@ EFI_STATUS ventoy_hook_keyboard_stop(VOID);
|
||||
BOOLEAN ventoy_is_cdrom_dp_exist(VOID);
|
||||
EFI_STATUS ventoy_hook_1st_cdrom_start(VOID);
|
||||
EFI_STATUS ventoy_hook_1st_cdrom_stop(VOID);
|
||||
EFI_STATUS ventoy_disable_ex_filesystem(VOID);
|
||||
EFI_STATUS ventoy_enable_ex_filesystem(VOID);
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -34,6 +34,7 @@
|
||||
#include <Protocol/BlockIo.h>
|
||||
#include <Protocol/RamDisk.h>
|
||||
#include <Protocol/SimpleFileSystem.h>
|
||||
#include <Protocol/DriverBinding.h>
|
||||
#include <Ventoy.h>
|
||||
|
||||
#define PROCOTOL_SLEEP_MSECONDS 0
|
||||
|
@@ -34,8 +34,12 @@
|
||||
#include <Protocol/BlockIo.h>
|
||||
#include <Protocol/RamDisk.h>
|
||||
#include <Protocol/SimpleFileSystem.h>
|
||||
#include <Protocol/DriverBinding.h>
|
||||
#include <Ventoy.h>
|
||||
|
||||
#define ASSIGN_REPLACE(This, replace) \
|
||||
replace = (This->FlushEx == ventoy_wrapper_file_flush_ex) ? &g_efi_file_replace : &g_img_file_replace
|
||||
|
||||
UINT8 *g_iso_data_buf = NULL;
|
||||
UINTN g_iso_buf_size = 0;
|
||||
BOOLEAN gMemdiskMode = FALSE;
|
||||
@@ -73,6 +77,9 @@ STATIC UINT8 g_sector_buf[2048];
|
||||
STATIC EFI_BLOCK_READ g_sector_2048_read = 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)
|
||||
{
|
||||
UINTN i = 0;
|
||||
@@ -148,7 +155,7 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
|
||||
ventoy_override_chunk *pOverride = g_override_chunk;
|
||||
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;
|
||||
ReadEnd = (Sector + Count) * 2048;
|
||||
@@ -173,7 +180,6 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
|
||||
{
|
||||
MapLba = ((Sector - pchunk->img_start_sector) >> 1) + pchunk->disk_start_sector;
|
||||
}
|
||||
|
||||
|
||||
secLeft = pchunk->img_end_sector + 1 - Sector;
|
||||
secRead = (Count < secLeft) ? Count : secLeft;
|
||||
@@ -182,7 +188,7 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
|
||||
MapLba, secRead * 2048, pCurBuf);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -425,7 +431,7 @@ end:
|
||||
return Lba;
|
||||
}
|
||||
|
||||
EFI_STATUS EFIAPI ventoy_block_io_read
|
||||
EFI_STATUS EFIAPI ventoy_block_io_read_real
|
||||
(
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
@@ -438,6 +444,8 @@ EFI_STATUS EFIAPI ventoy_block_io_read
|
||||
UINT32 j = 0;
|
||||
UINT32 lbacount = 0;
|
||||
UINT32 secNum = 0;
|
||||
UINT32 TmpNum = 0;
|
||||
UINT64 VirtSec = 0;
|
||||
UINT64 offset = 0;
|
||||
EFI_LBA curlba = 0;
|
||||
EFI_LBA lastlba = 0;
|
||||
@@ -445,7 +453,7 @@ EFI_STATUS EFIAPI ventoy_block_io_read
|
||||
ventoy_sector_flag *cur_flag;
|
||||
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;
|
||||
|
||||
@@ -461,6 +469,28 @@ EFI_STATUS EFIAPI ventoy_block_io_read
|
||||
{
|
||||
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)
|
||||
{
|
||||
@@ -529,6 +559,42 @@ EFI_STATUS EFIAPI ventoy_block_io_read
|
||||
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
|
||||
(
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
@@ -561,26 +627,74 @@ EFI_STATUS EFIAPI ventoy_block_io_flush(IN EFI_BLOCK_IO_PROTOCOL *This)
|
||||
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)
|
||||
{
|
||||
UINTN CurVtoyDpId = 0;
|
||||
UINTN NameLen = 0;
|
||||
UINT8 TmpBuf[128] = {0};
|
||||
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;
|
||||
NameLen = StrSize(VTOY_BLOCK_DEVICE_PATH_NAME);
|
||||
NameLen = StrSize(VtoyDpName);
|
||||
venPath->Header.Type = HARDWARE_DEVICE_PATH;
|
||||
venPath->Header.SubType = HW_VENDOR_DP;
|
||||
venPath->Header.Length[0] = sizeof(VENDOR_DEVICE_PATH) + NameLen;
|
||||
venPath->Header.Length[1] = 0;
|
||||
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.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;
|
||||
}
|
||||
@@ -613,11 +727,7 @@ EFI_STATUS EFIAPI ventoy_connect_driver(IN EFI_HANDLE ControllerHandle, IN CONST
|
||||
continue;
|
||||
}
|
||||
|
||||
Status = Name2Protocol->GetDriverName(Name2Protocol, "en", &DriverName);
|
||||
if (EFI_ERROR(Status) || NULL == DriverName)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
VENTOY_GET_COMPONENT_NAME(Name2Protocol, DriverName);
|
||||
|
||||
if (StrStr(DriverName, DrvName))
|
||||
{
|
||||
@@ -655,11 +765,7 @@ EFI_STATUS EFIAPI ventoy_connect_driver(IN EFI_HANDLE ControllerHandle, IN CONST
|
||||
continue;
|
||||
}
|
||||
|
||||
Status = NameProtocol->GetDriverName(NameProtocol, "en", &DriverName);
|
||||
if (EFI_ERROR(Status))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
VENTOY_GET_COMPONENT_NAME(NameProtocol, DriverName);
|
||||
|
||||
if (StrStr(DriverName, DrvName))
|
||||
{
|
||||
@@ -684,6 +790,223 @@ end:
|
||||
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"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))
|
||||
{
|
||||
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
|
||||
(
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
@@ -698,7 +1021,7 @@ EFI_STATUS EFIAPI ventoy_block_io_read_512
|
||||
UINT8 *CurBuf = NULL;
|
||||
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;
|
||||
|
||||
@@ -818,14 +1141,15 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im
|
||||
{
|
||||
gBlockData.Media.BlockSize = 512;
|
||||
gBlockData.Media.LastBlock = ImgSize / 512 - 1;
|
||||
gBlockData.Media.ReadOnly = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gBlockData.Media.BlockSize = 2048;
|
||||
gBlockData.Media.LastBlock = ImgSize / 2048 - 1;
|
||||
gBlockData.Media.ReadOnly = TRUE;
|
||||
}
|
||||
|
||||
gBlockData.Media.ReadOnly = TRUE;
|
||||
gBlockData.Media.MediaPresent = 1;
|
||||
gBlockData.Media.LogicalBlocksPerPhysicalBlock = 1;
|
||||
|
||||
@@ -924,6 +1248,15 @@ ventoy_wrapper_file_flush_ex(EFI_FILE_HANDLE This, EFI_FILE_IO_TOKEN *Token)
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/* Ex version */
|
||||
STATIC EFI_STATUS EFIAPI
|
||||
ventoy_wrapper_file_flush_ex_img(EFI_FILE_HANDLE This, EFI_FILE_IO_TOKEN *Token)
|
||||
{
|
||||
(VOID)This;
|
||||
(VOID)Token;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
STATIC EFI_STATUS EFIAPI
|
||||
ventoy_wrapper_file_write(EFI_FILE_HANDLE This, UINTN *Len, VOID *Data)
|
||||
@@ -949,19 +1282,20 @@ ventoy_wrapper_file_close(EFI_FILE_HANDLE This)
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
STATIC EFI_STATUS EFIAPI
|
||||
ventoy_wrapper_file_set_pos(EFI_FILE_HANDLE This, UINT64 Position)
|
||||
{
|
||||
(VOID)This;
|
||||
|
||||
if (Position <= g_efi_file_replace.FileSizeBytes)
|
||||
ventoy_efi_file_replace *replace = NULL;
|
||||
|
||||
ASSIGN_REPLACE(This, replace);
|
||||
|
||||
if (Position <= replace->FileSizeBytes)
|
||||
{
|
||||
g_efi_file_replace.CurPos = Position;
|
||||
replace->CurPos = Position;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_efi_file_replace.CurPos = g_efi_file_replace.FileSizeBytes;
|
||||
replace->CurPos = replace->FileSizeBytes;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@@ -970,9 +1304,11 @@ ventoy_wrapper_file_set_pos(EFI_FILE_HANDLE This, UINT64 Position)
|
||||
STATIC EFI_STATUS EFIAPI
|
||||
ventoy_wrapper_file_get_pos(EFI_FILE_HANDLE This, UINT64 *Position)
|
||||
{
|
||||
(VOID)This;
|
||||
ventoy_efi_file_replace *replace = NULL;
|
||||
|
||||
*Position = g_efi_file_replace.CurPos;
|
||||
ASSIGN_REPLACE(This, replace);
|
||||
|
||||
*Position = replace->CurPos;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -982,6 +1318,9 @@ STATIC EFI_STATUS EFIAPI
|
||||
ventoy_wrapper_file_get_info(EFI_FILE_HANDLE This, EFI_GUID *Type, UINTN *Len, VOID *Data)
|
||||
{
|
||||
EFI_FILE_INFO *Info = (EFI_FILE_INFO *) Data;
|
||||
ventoy_efi_file_replace *replace = NULL;
|
||||
|
||||
ASSIGN_REPLACE(This, replace);
|
||||
|
||||
debug("ventoy_wrapper_file_get_info ... %u", *Len);
|
||||
|
||||
@@ -999,8 +1338,8 @@ ventoy_wrapper_file_get_info(EFI_FILE_HANDLE This, EFI_GUID *Type, UINTN *Len, V
|
||||
ZeroMem(Data, sizeof(EFI_FILE_INFO));
|
||||
|
||||
Info->Size = sizeof(EFI_FILE_INFO);
|
||||
Info->FileSize = g_efi_file_replace.FileSizeBytes;
|
||||
Info->PhysicalSize = g_efi_file_replace.FileSizeBytes;
|
||||
Info->FileSize = replace->FileSizeBytes;
|
||||
Info->PhysicalSize = replace->FileSizeBytes;
|
||||
Info->Attribute = EFI_FILE_READ_ONLY;
|
||||
//Info->FileName = EFI_FILE_READ_ONLY;
|
||||
|
||||
@@ -1014,23 +1353,24 @@ ventoy_wrapper_file_read(EFI_FILE_HANDLE This, UINTN *Len, VOID *Data)
|
||||
{
|
||||
EFI_LBA Lba;
|
||||
UINTN ReadLen = *Len;
|
||||
|
||||
(VOID)This;
|
||||
ventoy_efi_file_replace *replace = NULL;
|
||||
|
||||
ASSIGN_REPLACE(This, replace);
|
||||
|
||||
debug("ventoy_wrapper_file_read ... %u", *Len);
|
||||
|
||||
if (g_efi_file_replace.CurPos + ReadLen > g_efi_file_replace.FileSizeBytes)
|
||||
if (replace->CurPos + ReadLen > replace->FileSizeBytes)
|
||||
{
|
||||
ReadLen = g_efi_file_replace.FileSizeBytes - g_efi_file_replace.CurPos;
|
||||
ReadLen = replace->FileSizeBytes - replace->CurPos;
|
||||
}
|
||||
|
||||
Lba = g_efi_file_replace.CurPos / 2048 + g_efi_file_replace.BlockIoSectorStart;
|
||||
Lba = replace->CurPos / 2048 + replace->BlockIoSectorStart;
|
||||
|
||||
ventoy_block_io_read(NULL, 0, Lba, ReadLen, Data);
|
||||
|
||||
*Len = ReadLen;
|
||||
|
||||
g_efi_file_replace.CurPos += ReadLen;
|
||||
replace->CurPos += ReadLen;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -1041,7 +1381,7 @@ ventoy_wrapper_file_read_ex(IN EFI_FILE_PROTOCOL *This, IN OUT EFI_FILE_IO_TOKEN
|
||||
return ventoy_wrapper_file_read(This, &(Token->BufferSize), Token->Buffer);
|
||||
}
|
||||
|
||||
STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_procotol(EFI_FILE_PROTOCOL *File)
|
||||
STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_procotol(EFI_FILE_PROTOCOL *File, BOOLEAN Img)
|
||||
{
|
||||
File->Revision = EFI_FILE_PROTOCOL_REVISION2;
|
||||
File->Open = ventoy_wrapper_fs_open;
|
||||
@@ -1057,7 +1397,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_procotol(EFI_FILE_PROTOCOL *File)
|
||||
File->OpenEx = ventoy_wrapper_file_open_ex;
|
||||
File->ReadEx = ventoy_wrapper_file_read_ex;
|
||||
File->WriteEx = ventoy_wrapper_file_write_ex;
|
||||
File->FlushEx = ventoy_wrapper_file_flush_ex;
|
||||
File->FlushEx = Img ? ventoy_wrapper_file_flush_ex_img : ventoy_wrapper_file_flush_ex;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -1076,16 +1416,28 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
|
||||
UINT64 Sectors = 0;
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
CHAR8 TmpName[256];
|
||||
CHAR8 OldName[256];
|
||||
ventoy_virt_chunk *virt = NULL;
|
||||
|
||||
debug("## ventoy_wrapper_file_open <%s> ", Name);
|
||||
|
||||
if ((Mode & EFI_FILE_MODE_WRITE) > 0 && StrCmp(Name, L"\\loader\\random-seed") == 0)
|
||||
{
|
||||
if (gDebugPrint)
|
||||
{
|
||||
debug("## ventoy_wrapper_file_open return NOT_FOUND for random-seed %lx", Mode);
|
||||
sleep(3);
|
||||
}
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
Status = g_original_fopen(This, New, Name, Mode, Attributes);
|
||||
if (EFI_ERROR(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
if (g_file_replace_list && g_file_replace_list->magic == GRUB_FILE_REPLACE_MAGIC &&
|
||||
g_file_replace_list->new_file_virtual_id < g_virt_chunk_num)
|
||||
{
|
||||
@@ -1096,7 +1448,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
|
||||
{
|
||||
g_original_fclose(*New);
|
||||
*New = &g_efi_file_replace.WrapperHandle;
|
||||
ventoy_wrapper_file_procotol(*New);
|
||||
ventoy_wrapper_file_procotol(*New, FALSE);
|
||||
|
||||
virt = g_virt_chunk + g_file_replace_list->new_file_virtual_id;
|
||||
|
||||
@@ -1122,6 +1474,49 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (g_img_replace_list && g_img_replace_list->magic == GRUB_IMG_REPLACE_MAGIC &&
|
||||
g_img_replace_list->new_file_virtual_id < g_virt_chunk_num)
|
||||
{
|
||||
AsciiSPrint(TmpName, sizeof(TmpName), "%s", Name);
|
||||
for (j = 0; j < g_img_replace_list->old_file_cnt; j++)
|
||||
{
|
||||
AsciiStrCpyS(OldName, sizeof(OldName), g_img_replace_list[i].old_file_name[j]);
|
||||
if ((0 == AsciiStrCmp(OldName, TmpName)) ||
|
||||
(AsciiStrnCmp(OldName, "\\loader\\entries\\", 16) == 0 &&
|
||||
AsciiStrCmp(OldName + 16, TmpName) == 0
|
||||
)
|
||||
)
|
||||
{
|
||||
g_original_fclose(*New);
|
||||
*New = &g_img_file_replace.WrapperHandle;
|
||||
ventoy_wrapper_file_procotol(*New, TRUE);
|
||||
|
||||
virt = g_virt_chunk + g_img_replace_list->new_file_virtual_id;
|
||||
|
||||
Sectors = (virt->mem_sector_end - virt->mem_sector_start) + (virt->remap_sector_end - virt->remap_sector_start);
|
||||
|
||||
g_img_file_replace.BlockIoSectorStart = virt->mem_sector_start;
|
||||
g_img_file_replace.FileSizeBytes = Sectors * 2048;
|
||||
|
||||
if (gDebugPrint)
|
||||
{
|
||||
debug("## ventoy_wrapper_file_open2 <%s> BlockStart:%lu Sectors:%lu Bytes:%lu", Name,
|
||||
g_img_file_replace.BlockIoSectorStart, Sectors, Sectors * 2048);
|
||||
sleep(3);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
if (StrCmp(Name, L"\\loader\\entries") == 0)
|
||||
{
|
||||
(*New)->Open = ventoy_wrapper_file_open;
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,140 @@
|
||||
/******************************************************************************
|
||||
* VtoyDrv.c
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Uefi.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/UefiApplicationEntryPoint.h>
|
||||
#include <Protocol/LoadedImage.h>
|
||||
#include <Guid/FileInfo.h>
|
||||
#include <Guid/FileSystemInfo.h>
|
||||
#include <Protocol/BlockIo.h>
|
||||
#include <Protocol/RamDisk.h>
|
||||
#include <Protocol/SimpleFileSystem.h>
|
||||
#include <VtoyUtil.h>
|
||||
|
||||
STATIC UINTN g_EfiDriverNameCnt = 0;
|
||||
STATIC CHAR16 *g_EfiDriverNameList[1024] = { NULL };
|
||||
|
||||
STATIC EFI_STATUS AddEfiDriverName(IN CHAR16 *DriverName)
|
||||
{
|
||||
UINTN i = 0;
|
||||
|
||||
if (g_EfiDriverNameCnt >= 1024)
|
||||
{
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
for (i = 0; i < g_EfiDriverNameCnt; i++)
|
||||
{
|
||||
if (g_EfiDriverNameList[i] && StrCmp(g_EfiDriverNameList[i], DriverName) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= g_EfiDriverNameCnt)
|
||||
{
|
||||
g_EfiDriverNameList[g_EfiDriverNameCnt] = DriverName;
|
||||
g_EfiDriverNameCnt++;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS ShowEfiDrivers(IN EFI_HANDLE ImageHandle, IN CONST CHAR16 *CmdLine)
|
||||
{
|
||||
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;
|
||||
|
||||
(VOID)ImageHandle;
|
||||
(VOID)CmdLine;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
DriverName = NULL;
|
||||
Status = VtoyGetComponentName(2, Name2Protocol, &DriverName);
|
||||
if ((!EFI_ERROR(Status)) && (DriverName))
|
||||
{
|
||||
AddEfiDriverName(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))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
DriverName = NULL;
|
||||
Status = VtoyGetComponentName(1, Name2Protocol, &DriverName);
|
||||
if ((!EFI_ERROR(Status)) && (DriverName))
|
||||
{
|
||||
AddEfiDriverName(DriverName);
|
||||
}
|
||||
}
|
||||
|
||||
FreePool(Handles);
|
||||
|
||||
for (i = 0; i < g_EfiDriverNameCnt; i++)
|
||||
{
|
||||
Printf("%2d %s\n", i, g_EfiDriverNameList[i]);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
@@ -44,8 +44,39 @@ STATIC grub_env_printf_pf g_env_printf = NULL;
|
||||
STATIC VtoyUtilFeature gFeatureList[] =
|
||||
{
|
||||
{ L"fix_windows_mmap", FixWindowsMemhole },
|
||||
{ L"show_efi_drivers", ShowEfiDrivers },
|
||||
};
|
||||
|
||||
EFI_STATUS VtoyGetComponentName(IN UINTN Ver, IN VOID *Protocol, OUT CHAR16 **DriverName)
|
||||
{
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
CHAR16 *DrvName = NULL;
|
||||
EFI_COMPONENT_NAME_PROTOCOL *NameProtocol = NULL;
|
||||
EFI_COMPONENT_NAME2_PROTOCOL *Name2Protocol = NULL;
|
||||
|
||||
if (1 == Ver)
|
||||
{
|
||||
NameProtocol = (EFI_COMPONENT_NAME_PROTOCOL *)Protocol;
|
||||
Status = NameProtocol->GetDriverName(Protocol, "en", &DrvName);
|
||||
if (EFI_ERROR(Status) || NULL == DrvName)
|
||||
{
|
||||
Status = NameProtocol->GetDriverName(Protocol, "eng", &DrvName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Name2Protocol = (EFI_COMPONENT_NAME2_PROTOCOL *)Protocol;
|
||||
Status = Name2Protocol->GetDriverName(Protocol, "en", &DrvName);
|
||||
if (EFI_ERROR(Status) || NULL == DrvName)
|
||||
{
|
||||
Status = Name2Protocol->GetDriverName(Protocol, "eng", &DrvName);
|
||||
}
|
||||
}
|
||||
|
||||
*DriverName = DrvName;
|
||||
return Status;
|
||||
}
|
||||
|
||||
VOID EFIAPI VtoyUtilDebug(IN CONST CHAR8 *Format, ...)
|
||||
{
|
||||
VA_LIST Marker;
|
||||
|
@@ -41,6 +41,7 @@ typedef struct ventoy_grub_param
|
||||
grub_env_get_pf grub_env_get;
|
||||
grub_env_set_pf grub_env_set;
|
||||
ventoy_grub_param_file_replace file_replace;
|
||||
ventoy_grub_param_file_replace img_replace;
|
||||
grub_env_printf_pf grub_env_printf;
|
||||
}ventoy_grub_param;
|
||||
#pragma pack()
|
||||
@@ -57,7 +58,9 @@ VOID EFIAPI VtoyUtilDebug(IN CONST CHAR8 *Format, ...);
|
||||
#define debug(expr, ...) if (gVtoyDebugPrint) VtoyUtilDebug("[VTOY] "expr"\n", ##__VA_ARGS__)
|
||||
#define Printf VtoyUtilDebug
|
||||
|
||||
EFI_STATUS VtoyGetComponentName(IN UINTN Ver, IN VOID *Protocol, OUT CHAR16 **DriverName);
|
||||
EFI_STATUS FixWindowsMemhole(IN EFI_HANDLE ImageHandle, IN CONST CHAR16 *CmdLine);
|
||||
EFI_STATUS ShowEfiDrivers(IN EFI_HANDLE ImageHandle, IN CONST CHAR16 *CmdLine);
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -28,6 +28,7 @@
|
||||
[Sources]
|
||||
VtoyUtil.h
|
||||
VtoyUtil.c
|
||||
VtoyDrv.c
|
||||
Memhole.c
|
||||
|
||||
[Packages]
|
||||
|
@@ -1603,6 +1603,7 @@ module = {
|
||||
module = {
|
||||
name = ventoy;
|
||||
common = ventoy/ventoy.c;
|
||||
common = ventoy/ventoy_cmd.c;
|
||||
common = ventoy/ventoy_linux.c;
|
||||
common = ventoy/ventoy_unix.c;
|
||||
common = ventoy/ventoy_windows.c;
|
||||
|
349
GRUB2/MOD_SRC/grub-2.04/grub-core/commands/hashsum.c
Normal file
349
GRUB2/MOD_SRC/grub-2.04/grub-core/commands/hashsum.c
Normal file
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* 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 %s %d%% ", hash->name, (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 %s 100%% \n\r\n", hash->name);
|
||||
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;
|
||||
int len = 0;
|
||||
char hashsum[256];
|
||||
|
||||
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]);
|
||||
len += grub_snprintf(hashsum + len, sizeof(hashsum) - len, "%02x", ((grub_uint8_t *) result)[j]);
|
||||
}
|
||||
grub_printf (" %s\n", args[i]);
|
||||
grub_env_set("VT_LAST_CHECK_SUM", hashsum);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
257
GRUB2/MOD_SRC/grub-2.04/grub-core/disk/loopback.c
Normal file
257
GRUB2/MOD_SRC/grub-2.04/grub-core/disk/loopback.c
Normal 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);
|
||||
}
|
1603
GRUB2/MOD_SRC/grub-2.04/grub-core/font/font.c
Normal file
1603
GRUB2/MOD_SRC/grub-2.04/grub-core/font/font.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -33,6 +33,7 @@
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
static int g_ventoy_no_joliet = 0;
|
||||
static int g_ventoy_cur_joliet = 0;
|
||||
static grub_uint64_t g_ventoy_last_read_pos = 0;
|
||||
static grub_uint64_t g_ventoy_last_read_offset = 0;
|
||||
static grub_uint64_t g_ventoy_last_read_dirent_pos = 0;
|
||||
@@ -451,6 +452,7 @@ grub_iso9660_mount (grub_disk_t disk)
|
||||
|
||||
data->disk = disk;
|
||||
|
||||
g_ventoy_cur_joliet = 0;
|
||||
block = 16;
|
||||
do
|
||||
{
|
||||
@@ -484,6 +486,7 @@ grub_iso9660_mount (grub_disk_t disk)
|
||||
if (0 == g_ventoy_no_joliet) {
|
||||
copy_voldesc = 1;
|
||||
data->joliet = 1;
|
||||
g_ventoy_cur_joliet = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1118,6 +1121,11 @@ void grub_iso9660_set_nojoliet(int nojoliet)
|
||||
g_ventoy_no_joliet = nojoliet;
|
||||
}
|
||||
|
||||
int grub_iso9660_is_joliet(void)
|
||||
{
|
||||
return g_ventoy_cur_joliet;
|
||||
}
|
||||
|
||||
grub_uint64_t grub_iso9660_get_last_read_pos(grub_file_t file)
|
||||
{
|
||||
(void)file;
|
||||
|
@@ -28,6 +28,8 @@
|
||||
|
||||
extern int g_ventoy_memdisk_mode;
|
||||
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;
|
||||
|
||||
static const char *align_options[] =
|
||||
@@ -57,11 +59,15 @@ struct grub_gui_label
|
||||
grub_font_t font;
|
||||
grub_video_rgba_color_t color;
|
||||
int value;
|
||||
int vtoytip;
|
||||
enum align_mode align;
|
||||
};
|
||||
|
||||
typedef struct grub_gui_label *grub_gui_label_t;
|
||||
|
||||
extern const char * g_ventoy_tip_msg1;
|
||||
extern const char * g_ventoy_tip_msg2;
|
||||
|
||||
static void
|
||||
label_destroy (void *vself)
|
||||
{
|
||||
@@ -88,6 +94,7 @@ label_is_instance (void *vself __attribute__((unused)), const char *type)
|
||||
static void
|
||||
label_paint (void *vself, const grub_video_rect_t *region)
|
||||
{
|
||||
const char *text;
|
||||
grub_gui_label_t self = vself;
|
||||
|
||||
if (! self->visible)
|
||||
@@ -96,16 +103,24 @@ label_paint (void *vself, const grub_video_rect_t *region)
|
||||
if (!grub_video_have_common_points (region, &self->bounds))
|
||||
return;
|
||||
|
||||
if (self->vtoytip == 1) {
|
||||
text = g_ventoy_tip_msg1 ? g_ventoy_tip_msg1 : "";
|
||||
} else if (self->vtoytip == 2) {
|
||||
text = g_ventoy_tip_msg2 ? g_ventoy_tip_msg2 : "";
|
||||
} else {
|
||||
text = self->text;
|
||||
}
|
||||
|
||||
/* Calculate the starting x coordinate. */
|
||||
int left_x;
|
||||
if (self->align == align_left)
|
||||
left_x = 0;
|
||||
else if (self->align == align_center)
|
||||
left_x = (self->bounds.width
|
||||
- grub_font_get_string_width (self->font, self->text)) / 2;
|
||||
- grub_font_get_string_width (self->font, text)) / 2;
|
||||
else if (self->align == align_right)
|
||||
left_x = (self->bounds.width
|
||||
- grub_font_get_string_width (self->font, self->text));
|
||||
- grub_font_get_string_width (self->font, text));
|
||||
else
|
||||
return; /* Invalid alignment. */
|
||||
|
||||
@@ -114,7 +129,7 @@ label_paint (void *vself, const grub_video_rect_t *region)
|
||||
|
||||
grub_video_rect_t vpsave;
|
||||
grub_gui_set_viewport (&self->bounds, &vpsave);
|
||||
grub_font_draw_string (self->text,
|
||||
grub_font_draw_string (text,
|
||||
self->font,
|
||||
grub_video_map_rgba_color (self->color),
|
||||
left_x,
|
||||
@@ -154,8 +169,8 @@ static void
|
||||
label_get_minimal_size (void *vself, unsigned *width, unsigned *height)
|
||||
{
|
||||
grub_gui_label_t self = vself;
|
||||
*width = grub_font_get_string_width (self->font, self->text);
|
||||
*height = (grub_font_get_ascent (self->font)
|
||||
*width = grub_font_get_string_width (self->font, self->text);
|
||||
*height = (grub_font_get_ascent (self->font)
|
||||
+ grub_font_get_descent (self->font));
|
||||
}
|
||||
|
||||
@@ -205,6 +220,12 @@ label_set_property (void *vself, const char *name, const char *value)
|
||||
else if (grub_strcmp (value, "@VTOY_ISO_RAW@") == 0) {
|
||||
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) {
|
||||
value = g_ventoy_iso_uefi_drv ? grub_env_get("VTOY_ISO_UEFI_DRV_STR") : " ";
|
||||
}
|
||||
@@ -247,8 +268,14 @@ label_set_property (void *vself, const char *name, const char *value)
|
||||
{
|
||||
grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
|
||||
grub_free (self->id);
|
||||
if (value)
|
||||
if (value) {
|
||||
self->id = grub_strdup (value);
|
||||
if (grub_strcmp(value, "VTOY_MENU_TIP_1") == 0) {
|
||||
self->vtoytip = 1;
|
||||
} else if (grub_strcmp(value, "VTOY_MENU_TIP_2") == 0) {
|
||||
self->vtoytip = 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
self->id = 0;
|
||||
if (self->id && grub_strcmp (self->id, GRUB_GFXMENU_TIMEOUT_COMPONENT_ID)
|
||||
|
@@ -733,6 +733,8 @@ done:
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
extern int g_menu_update_mode;
|
||||
|
||||
/* Set properties on the view based on settings from the specified
|
||||
theme file. */
|
||||
grub_err_t
|
||||
@@ -752,7 +754,7 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
|
||||
}
|
||||
|
||||
p.len = grub_file_size (file);
|
||||
p.buf = grub_malloc (p.len + 4096);
|
||||
p.buf = grub_malloc (p.len + 8192);
|
||||
p.pos = 0;
|
||||
p.line_num = 1;
|
||||
p.col_num = 1;
|
||||
@@ -781,6 +783,33 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const char *tip = grub_env_get("VTOY_MENU_TIP_ENABLE");
|
||||
if (tip && tip[0] == '1')
|
||||
{
|
||||
char tmpmsg[512];
|
||||
|
||||
grub_memset(tmpmsg, 'w', 500);
|
||||
tmpmsg[500] = 0;
|
||||
|
||||
g_menu_update_mode = 1;
|
||||
p.len += grub_snprintf(p.buf + p.len, 4096,
|
||||
"\n+ vbox{\n left = %s\n top = %s\n"
|
||||
"+ label { id=\"VTOY_MENU_TIP_1\" text = \"%s\" color = \"%s\" align = \"%s\"}\n"
|
||||
"+ label { id=\"VTOY_MENU_TIP_2\" text = \"%s\" color = \"%s\" align = \"%s\"}\n"
|
||||
"}\n",
|
||||
grub_env_get("VTOY_TIP_LEFT"),
|
||||
grub_env_get("VTOY_TIP_TOP"),
|
||||
tmpmsg,
|
||||
grub_env_get("VTOY_TIP_COLOR"),
|
||||
grub_env_get("VTOY_TIP_ALIGN"),
|
||||
tmpmsg,
|
||||
grub_env_get("VTOY_TIP_COLOR"),
|
||||
grub_env_get("VTOY_TIP_ALIGN")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (view->canvas)
|
||||
view->canvas->component.ops->destroy (view->canvas);
|
||||
|
||||
|
@@ -386,21 +386,37 @@ redraw_menu_visit (grub_gui_component_t component,
|
||||
}
|
||||
}
|
||||
|
||||
extern int g_menu_update_mode;
|
||||
|
||||
static void grub_gfxmenu_update_all(grub_gfxmenu_view_t view)
|
||||
{
|
||||
grub_video_set_area_status(GRUB_VIDEO_AREA_DISABLED);
|
||||
grub_gfxmenu_view_redraw(view, &view->screen);
|
||||
}
|
||||
|
||||
void
|
||||
grub_gfxmenu_redraw_menu (grub_gfxmenu_view_t view)
|
||||
{
|
||||
update_menu_components (view);
|
||||
|
||||
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
|
||||
redraw_menu_visit, view);
|
||||
if (g_menu_update_mode)
|
||||
grub_gfxmenu_update_all(view);
|
||||
else
|
||||
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
|
||||
redraw_menu_visit, view);
|
||||
|
||||
grub_video_swap_buffers ();
|
||||
if (view->double_repaint)
|
||||
{
|
||||
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
|
||||
redraw_menu_visit, view);
|
||||
if (g_menu_update_mode)
|
||||
grub_gfxmenu_update_all(view);
|
||||
else
|
||||
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
|
||||
redraw_menu_visit, view);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
grub_gfxmenu_set_chosen_entry (int entry, void *data)
|
||||
{
|
||||
@@ -408,6 +424,8 @@ grub_gfxmenu_set_chosen_entry (int entry, void *data)
|
||||
|
||||
view->selected = entry;
|
||||
grub_gfxmenu_redraw_menu (view);
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -964,3 +964,20 @@ void * grub_efi_allocate_iso_buf(grub_uint64_t size)
|
||||
|
||||
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;
|
||||
}
|
||||
|
@@ -279,6 +279,13 @@ static int ventoy_boot_opt_filter(char *opt)
|
||||
opt[1] = 't';
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (grub_strncmp(opt, "dm=", 3) == 0)
|
||||
{
|
||||
opt[0] = 'D';
|
||||
opt[1] = 'M';
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ventoy_debug)
|
||||
{
|
||||
|
@@ -506,6 +506,13 @@ static int ventoy_boot_opt_filter(char *opt)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (grub_strncmp(opt, "dm=", 3) == 0)
|
||||
{
|
||||
opt[0] = 'D';
|
||||
opt[1] = 'M';
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ventoy_debug)
|
||||
{
|
||||
if (grub_strcmp(opt, "quiet") == 0)
|
||||
|
316
GRUB2/MOD_SRC/grub-2.04/grub-core/loader/linux.c
Normal file
316
GRUB2/MOD_SRC/grub-2.04/grub-core/loader/linux.c
Normal 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;
|
||||
}
|
@@ -228,6 +228,13 @@ static int ventoy_boot_opt_filter(char *opt)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (grub_strncmp(opt, "dm=", 3) == 0)
|
||||
{
|
||||
opt[0] = 'D';
|
||||
opt[1] = 'M';
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ventoy_debug)
|
||||
{
|
||||
if (grub_strcmp(opt, "quiet") == 0)
|
||||
|
@@ -33,15 +33,35 @@
|
||||
#include <grub/gfxterm.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/extcmd.h>
|
||||
#include <grub/ventoy.h>
|
||||
#include "ventoy/ventoy_def.h"
|
||||
|
||||
int g_ventoy_menu_refresh = 0;
|
||||
int g_ventoy_memdisk_mode = 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_last_entry = -1;
|
||||
int g_ventoy_suppress_esc = 0;
|
||||
int g_ventoy_suppress_esc_default = 1;
|
||||
int g_ventoy_menu_esc = 0;
|
||||
int g_ventoy_fn_mutex = 0;
|
||||
int g_ventoy_terminal_output = 0;
|
||||
|
||||
#define VTOY_COMM_HOTKEY(cmdkey) \
|
||||
if (0 == g_ventoy_fn_mutex) { \
|
||||
cmdstr = grub_env_get(cmdkey); \
|
||||
if (cmdstr) \
|
||||
{ \
|
||||
menu_fini (); \
|
||||
g_ventoy_fn_mutex = 1; \
|
||||
grub_script_execute_sourcecode(cmdstr); \
|
||||
g_ventoy_fn_mutex = 0; \
|
||||
goto refresh; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Time to delay after displaying an error message about a default/fallback
|
||||
entry failing to boot. */
|
||||
@@ -378,10 +398,57 @@ grub_menu_execute_with_fallback (grub_menu_t menu,
|
||||
|
||||
static struct grub_menu_viewer *viewers;
|
||||
|
||||
int g_menu_update_mode = 0;
|
||||
int g_ventoy_tip_label_enable = 0;
|
||||
const char * g_ventoy_tip_msg1 = NULL;
|
||||
const char * g_ventoy_tip_msg2 = NULL;
|
||||
static const char *g_ventoy_cur_img_path = NULL;
|
||||
static void menu_set_chosen_tip(grub_menu_t menu, int entry)
|
||||
{
|
||||
int i;
|
||||
img_info *img;
|
||||
menu_tip *tip;
|
||||
grub_menu_entry_t e = grub_menu_get_entry (menu, entry);
|
||||
|
||||
g_ventoy_tip_msg1 = g_ventoy_tip_msg2 = NULL;
|
||||
if (e && e->id && grub_strncmp(e->id, "VID_", 4) == 0)
|
||||
{
|
||||
img = (img_info *)(void *)grub_strtoul(e->id + 4, NULL, 16);
|
||||
if (img)
|
||||
{
|
||||
g_ventoy_tip_msg1 = img->tip1;
|
||||
g_ventoy_tip_msg2 = img->tip2;
|
||||
g_ventoy_cur_img_path = img->path;
|
||||
}
|
||||
}
|
||||
else if (e && e->id && grub_strncmp(e->id, "DIR_", 4) == 0)
|
||||
{
|
||||
for (i = 0; i < e->argc; i++)
|
||||
{
|
||||
if (e->args[i] && grub_strncmp(e->args[i], "_VTIP_", 6) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i < e->argc)
|
||||
{
|
||||
tip = (menu_tip *)(void *)grub_strtoul(e->args[i] + 6, NULL, 16);
|
||||
if (tip)
|
||||
{
|
||||
g_ventoy_tip_msg1 = tip->tip1;
|
||||
g_ventoy_tip_msg2 = tip->tip2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
menu_set_chosen_entry (int entry)
|
||||
menu_set_chosen_entry (grub_menu_t menu, int entry)
|
||||
{
|
||||
struct grub_menu_viewer *cur;
|
||||
|
||||
menu_set_chosen_tip(menu, entry);
|
||||
for (cur = viewers; cur; cur = cur->next)
|
||||
cur->set_chosen_entry (entry, cur->data);
|
||||
}
|
||||
@@ -595,7 +662,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
default_entry = get_entry_number (menu, "default");
|
||||
|
||||
if (g_ventoy_suppress_esc)
|
||||
default_entry = 1;
|
||||
default_entry = g_ventoy_suppress_esc_default;
|
||||
else if (g_ventoy_last_entry >= 0 && g_ventoy_last_entry < menu->size) {
|
||||
default_entry = g_ventoy_last_entry;
|
||||
}
|
||||
@@ -677,6 +744,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
current_entry = default_entry;
|
||||
|
||||
refresh:
|
||||
menu_set_chosen_tip(menu, current_entry);
|
||||
menu_init (current_entry, menu, nested);
|
||||
|
||||
/* Initialize the time. */
|
||||
@@ -729,13 +797,13 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
case GRUB_TERM_KEY_HOME:
|
||||
case GRUB_TERM_CTRL | 'a':
|
||||
current_entry = 0;
|
||||
menu_set_chosen_entry (current_entry);
|
||||
menu_set_chosen_entry (menu, current_entry);
|
||||
break;
|
||||
|
||||
case GRUB_TERM_KEY_END:
|
||||
case GRUB_TERM_CTRL | 'e':
|
||||
current_entry = menu->size - 1;
|
||||
menu_set_chosen_entry (current_entry);
|
||||
menu_set_chosen_entry (menu, current_entry);
|
||||
break;
|
||||
|
||||
case GRUB_TERM_KEY_UP:
|
||||
@@ -743,7 +811,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
case '^':
|
||||
if (current_entry > 0)
|
||||
current_entry--;
|
||||
menu_set_chosen_entry (current_entry);
|
||||
menu_set_chosen_entry (menu, current_entry);
|
||||
break;
|
||||
|
||||
case GRUB_TERM_CTRL | 'n':
|
||||
@@ -751,7 +819,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
case 'v':
|
||||
if (current_entry < menu->size - 1)
|
||||
current_entry++;
|
||||
menu_set_chosen_entry (current_entry);
|
||||
menu_set_chosen_entry (menu, current_entry);
|
||||
break;
|
||||
|
||||
case GRUB_TERM_CTRL | 'g':
|
||||
@@ -760,7 +828,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
current_entry = 0;
|
||||
else
|
||||
current_entry -= GRUB_MENU_PAGE_SIZE;
|
||||
menu_set_chosen_entry (current_entry);
|
||||
menu_set_chosen_entry (menu, current_entry);
|
||||
break;
|
||||
|
||||
case GRUB_TERM_CTRL | 'c':
|
||||
@@ -769,7 +837,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
current_entry += GRUB_MENU_PAGE_SIZE;
|
||||
else
|
||||
current_entry = menu->size - 1;
|
||||
menu_set_chosen_entry (current_entry);
|
||||
menu_set_chosen_entry (menu, current_entry);
|
||||
break;
|
||||
|
||||
case '\n':
|
||||
@@ -804,82 +872,37 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
|
||||
case GRUB_TERM_KEY_F2:
|
||||
case '2':
|
||||
if (0 == g_ventoy_fn_mutex) {
|
||||
cmdstr = grub_env_get("VTOY_F2_CMD");
|
||||
if (cmdstr)
|
||||
{
|
||||
menu_fini ();
|
||||
g_ventoy_fn_mutex = 1;
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
g_ventoy_fn_mutex = 0;
|
||||
goto refresh;
|
||||
}
|
||||
}
|
||||
VTOY_COMM_HOTKEY("VTOY_F2_CMD");
|
||||
break;
|
||||
case GRUB_TERM_KEY_F3:
|
||||
case '3':
|
||||
if (0 == g_ventoy_fn_mutex) {
|
||||
cmdstr = grub_env_get("VTOY_F3_CMD");
|
||||
if (cmdstr)
|
||||
{
|
||||
menu_fini ();
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
goto refresh;
|
||||
}
|
||||
}
|
||||
VTOY_COMM_HOTKEY("VTOY_F3_CMD");
|
||||
break;
|
||||
case GRUB_TERM_KEY_F4:
|
||||
case '4':
|
||||
if (0 == g_ventoy_fn_mutex) {
|
||||
cmdstr = grub_env_get("VTOY_F4_CMD");
|
||||
if (cmdstr)
|
||||
{
|
||||
menu_fini ();
|
||||
g_ventoy_fn_mutex = 1;
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
g_ventoy_fn_mutex = 0;
|
||||
goto refresh;
|
||||
}
|
||||
}
|
||||
VTOY_COMM_HOTKEY("VTOY_F4_CMD");
|
||||
break;
|
||||
case GRUB_TERM_KEY_F5:
|
||||
case '5':
|
||||
if (0 == g_ventoy_fn_mutex) {
|
||||
cmdstr = grub_env_get("VTOY_F5_CMD");
|
||||
if (cmdstr)
|
||||
{
|
||||
menu_fini ();
|
||||
g_ventoy_fn_mutex = 1;
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
g_ventoy_fn_mutex = 0;
|
||||
goto refresh;
|
||||
}
|
||||
}
|
||||
VTOY_COMM_HOTKEY("VTOY_F5_CMD");
|
||||
break;
|
||||
case GRUB_TERM_KEY_F6:
|
||||
case '6':
|
||||
if (0 == g_ventoy_fn_mutex) {
|
||||
cmdstr = grub_env_get("VTOY_F6_CMD");
|
||||
if (cmdstr)
|
||||
{
|
||||
menu_fini ();
|
||||
g_ventoy_fn_mutex = 1;
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
g_ventoy_fn_mutex = 0;
|
||||
goto refresh;
|
||||
}
|
||||
}
|
||||
VTOY_COMM_HOTKEY("VTOY_F6_CMD");
|
||||
break;
|
||||
case GRUB_TERM_KEY_F7:
|
||||
case '7':
|
||||
cmdstr = grub_env_get("VTOY_F7_CMD");
|
||||
if (cmdstr)
|
||||
menu_fini ();
|
||||
if (g_ventoy_terminal_output == 0)
|
||||
{
|
||||
menu_fini ();
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
goto refresh;
|
||||
grub_script_execute_sourcecode("terminal_output console");
|
||||
g_ventoy_terminal_output = 1;
|
||||
}
|
||||
break;
|
||||
else
|
||||
{
|
||||
grub_script_execute_sourcecode("terminal_output gfxterm");
|
||||
g_ventoy_terminal_output = 0;
|
||||
}
|
||||
goto refresh;
|
||||
case GRUB_TERM_KEY_F1:
|
||||
case '1':
|
||||
menu_fini ();
|
||||
@@ -893,12 +916,58 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
g_ventoy_menu_refresh = 1;
|
||||
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'):
|
||||
menu_fini ();
|
||||
g_ventoy_iso_uefi_drv = 1 - g_ventoy_iso_uefi_drv;
|
||||
g_ventoy_menu_refresh = 1;
|
||||
goto refresh;
|
||||
|
||||
case (GRUB_TERM_CTRL | 'h'):
|
||||
case 'h':
|
||||
{
|
||||
cmdstr = grub_env_get("VTOY_HELP_CMD");
|
||||
if (cmdstr)
|
||||
{
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
while (grub_getkey() != GRUB_TERM_ESC)
|
||||
;
|
||||
menu_fini ();
|
||||
goto refresh;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (GRUB_TERM_CTRL | 'm'):
|
||||
case 'm':
|
||||
{
|
||||
if (g_ventoy_cur_img_path)
|
||||
{
|
||||
grub_env_set("VTOY_CHKSUM_FILE_PATH", g_ventoy_cur_img_path);
|
||||
cmdstr = grub_env_get("VTOY_CHKSUM_CMD");
|
||||
if (cmdstr)
|
||||
{
|
||||
menu_fini();
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
goto refresh;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_env_set("VTOY_CHKSUM_FILE_PATH", "X");
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
int entry;
|
||||
@@ -992,6 +1061,11 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
|
||||
break;
|
||||
}
|
||||
|
||||
if (autobooted == 0 && g_ventoy_menu_esc && auto_boot) {
|
||||
g_ventoy_last_entry = boot_entry;
|
||||
break;
|
||||
}
|
||||
|
||||
e = grub_menu_get_entry (menu, boot_entry);
|
||||
if (! e)
|
||||
continue; /* Menu is empty. */
|
||||
|
232
GRUB2/MOD_SRC/grub-2.04/grub-core/partmap/gpt.c
Normal file
232
GRUB2/MOD_SRC/grub-2.04/grub-core/partmap/gpt.c
Normal file
@@ -0,0 +1,232 @@
|
||||
/* gpt.c - Read GUID Partition Tables (GPT). */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2005,2006,2007,2008 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/disk.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/partition.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/msdos_partition.h>
|
||||
#include <grub/gpt_partition.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
static grub_uint8_t grub_gpt_magic[8] =
|
||||
{
|
||||
0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54
|
||||
};
|
||||
|
||||
static const grub_gpt_part_guid_t grub_gpt_partition_type_empty = GRUB_GPT_PARTITION_TYPE_EMPTY;
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
static const grub_gpt_part_guid_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT;
|
||||
#endif
|
||||
|
||||
/* 512 << 7 = 65536 byte sectors. */
|
||||
#define MAX_SECTOR_LOG 7
|
||||
|
||||
static struct grub_partition_map grub_gpt_partition_map;
|
||||
|
||||
|
||||
|
||||
grub_err_t
|
||||
grub_gpt_partition_map_iterate (grub_disk_t disk,
|
||||
grub_partition_iterate_hook_t hook,
|
||||
void *hook_data)
|
||||
{
|
||||
struct grub_partition part;
|
||||
struct grub_gpt_header gpt;
|
||||
struct grub_gpt_partentry entry;
|
||||
struct grub_msdos_partition_mbr mbr;
|
||||
grub_uint64_t entries;
|
||||
unsigned int i;
|
||||
int last_offset = 0;
|
||||
int sector_log = 0;
|
||||
|
||||
/* Read the protective MBR. */
|
||||
if (grub_disk_read (disk, 0, 0, sizeof (mbr), &mbr))
|
||||
return grub_errno;
|
||||
|
||||
/* Check if it is valid. */
|
||||
if (mbr.signature != grub_cpu_to_le16_compile_time (GRUB_PC_PARTITION_SIGNATURE))
|
||||
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature");
|
||||
|
||||
/* Make sure the MBR is a protective MBR and not a normal MBR. */
|
||||
for (i = 0; i < 4; i++)
|
||||
if (mbr.entries[i].type == GRUB_PC_PARTITION_TYPE_GPT_DISK)
|
||||
break;
|
||||
if (i == 4)
|
||||
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no GPT partition map found");
|
||||
|
||||
/* Read the GPT header. */
|
||||
for (sector_log = 0; sector_log < MAX_SECTOR_LOG; sector_log++)
|
||||
{
|
||||
if (grub_disk_read (disk, 1 << sector_log, 0, sizeof (gpt), &gpt))
|
||||
return grub_errno;
|
||||
|
||||
if (grub_memcmp (gpt.magic, grub_gpt_magic, sizeof (grub_gpt_magic)) == 0)
|
||||
break;
|
||||
}
|
||||
if (sector_log == MAX_SECTOR_LOG)
|
||||
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no valid GPT header");
|
||||
|
||||
grub_dprintf ("gpt", "Read a valid GPT header\n");
|
||||
|
||||
entries = grub_le_to_cpu64 (gpt.partitions) << sector_log;
|
||||
for (i = 0; i < grub_le_to_cpu32 (gpt.maxpart); i++)
|
||||
{
|
||||
if (grub_disk_read (disk, entries, last_offset,
|
||||
sizeof (entry), &entry))
|
||||
return grub_errno;
|
||||
|
||||
if (grub_memcmp (&grub_gpt_partition_type_empty, &entry.type,
|
||||
sizeof (grub_gpt_partition_type_empty)))
|
||||
{
|
||||
/* Calculate the first block and the size of the partition. */
|
||||
part.start = grub_le_to_cpu64 (entry.start) << sector_log;
|
||||
part.len = (grub_le_to_cpu64 (entry.end)
|
||||
- grub_le_to_cpu64 (entry.start) + 1) << sector_log;
|
||||
part.offset = entries;
|
||||
part.number = i;
|
||||
part.index = last_offset;
|
||||
part.partmap = &grub_gpt_partition_map;
|
||||
part.parent = disk->partition;
|
||||
part.gpt_attrib = entry.attrib;
|
||||
|
||||
grub_dprintf ("gpt", "GPT entry %d: start=%lld, length=%lld\n", i,
|
||||
(unsigned long long) part.start,
|
||||
(unsigned long long) part.len);
|
||||
|
||||
if (hook (disk, &part, hook_data))
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
last_offset += grub_le_to_cpu32 (gpt.partentry_size);
|
||||
if (last_offset == GRUB_DISK_SECTOR_SIZE)
|
||||
{
|
||||
last_offset = 0;
|
||||
entries++;
|
||||
}
|
||||
}
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
/* Context for gpt_partition_map_embed. */
|
||||
struct gpt_partition_map_embed_ctx
|
||||
{
|
||||
grub_disk_addr_t start, len;
|
||||
};
|
||||
|
||||
/* Helper for gpt_partition_map_embed. */
|
||||
static int
|
||||
find_usable_region (grub_disk_t disk __attribute__ ((unused)),
|
||||
const grub_partition_t p, void *data)
|
||||
{
|
||||
struct gpt_partition_map_embed_ctx *ctx = data;
|
||||
struct grub_gpt_partentry gptdata;
|
||||
grub_partition_t p2;
|
||||
|
||||
p2 = disk->partition;
|
||||
disk->partition = p->parent;
|
||||
if (grub_disk_read (disk, p->offset, p->index,
|
||||
sizeof (gptdata), &gptdata))
|
||||
{
|
||||
disk->partition = p2;
|
||||
return 0;
|
||||
}
|
||||
disk->partition = p2;
|
||||
|
||||
/* If there's an embed region, it is in a dedicated partition. */
|
||||
if (! grub_memcmp (&gptdata.type, &grub_gpt_partition_type_bios_boot, 16))
|
||||
{
|
||||
ctx->start = p->start;
|
||||
ctx->len = p->len;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
gpt_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors,
|
||||
unsigned int max_nsectors,
|
||||
grub_embed_type_t embed_type,
|
||||
grub_disk_addr_t **sectors)
|
||||
{
|
||||
struct gpt_partition_map_embed_ctx ctx = {
|
||||
.start = 0,
|
||||
.len = 0
|
||||
};
|
||||
unsigned i;
|
||||
grub_err_t err;
|
||||
|
||||
if (embed_type != GRUB_EMBED_PCBIOS)
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"GPT currently supports only PC-BIOS embedding");
|
||||
|
||||
err = grub_gpt_partition_map_iterate (disk, find_usable_region, &ctx);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (ctx.len == 0)
|
||||
return grub_error (GRUB_ERR_FILE_NOT_FOUND,
|
||||
N_("this GPT partition label contains no BIOS Boot Partition;"
|
||||
" embedding won't be possible"));
|
||||
|
||||
if (ctx.len < *nsectors)
|
||||
return grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||
N_("your BIOS Boot Partition is too small;"
|
||||
" embedding won't be possible"));
|
||||
|
||||
*nsectors = ctx.len;
|
||||
if (*nsectors > max_nsectors)
|
||||
*nsectors = max_nsectors;
|
||||
*sectors = grub_malloc (*nsectors * sizeof (**sectors));
|
||||
if (!*sectors)
|
||||
return grub_errno;
|
||||
for (i = 0; i < *nsectors; i++)
|
||||
(*sectors)[i] = ctx.start + i;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Partition map type. */
|
||||
static struct grub_partition_map grub_gpt_partition_map =
|
||||
{
|
||||
.name = "gpt",
|
||||
.iterate = grub_gpt_partition_map_iterate,
|
||||
#ifdef GRUB_UTIL
|
||||
.embed = gpt_partition_map_embed
|
||||
#endif
|
||||
};
|
||||
|
||||
GRUB_MOD_INIT(part_gpt)
|
||||
{
|
||||
grub_partition_map_register (&grub_gpt_partition_map);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(part_gpt)
|
||||
{
|
||||
grub_partition_map_unregister (&grub_gpt_partition_map);
|
||||
}
|
113
GRUB2/MOD_SRC/grub-2.04/grub-core/script/function.c
Normal file
113
GRUB2/MOD_SRC/grub-2.04/grub-core/script/function.c
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2005,2007,2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/misc.h>
|
||||
#include <grub/script_sh.h>
|
||||
#include <grub/parser.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/charset.h>
|
||||
|
||||
grub_script_function_t grub_script_function_list;
|
||||
|
||||
grub_script_function_t
|
||||
grub_script_function_create (struct grub_script_arg *functionname_arg,
|
||||
struct grub_script *cmd)
|
||||
{
|
||||
grub_script_function_t func;
|
||||
grub_script_function_t *p;
|
||||
|
||||
func = (grub_script_function_t) grub_malloc (sizeof (*func));
|
||||
if (! func)
|
||||
return 0;
|
||||
|
||||
func->name = grub_strdup (functionname_arg->str);
|
||||
if (! func->name)
|
||||
{
|
||||
grub_free (func);
|
||||
return 0;
|
||||
}
|
||||
|
||||
func->func = cmd;
|
||||
|
||||
/* Keep the list sorted for simplicity. */
|
||||
p = &grub_script_function_list;
|
||||
while (*p)
|
||||
{
|
||||
if (grub_strcmp ((*p)->name, func->name) >= 0)
|
||||
break;
|
||||
|
||||
p = &((*p)->next);
|
||||
}
|
||||
|
||||
/* If the function already exists, overwrite the old function. */
|
||||
if (*p && grub_strcmp ((*p)->name, func->name) == 0)
|
||||
{
|
||||
grub_script_function_t q;
|
||||
|
||||
q = *p;
|
||||
grub_script_free (q->func);
|
||||
q->func = cmd;
|
||||
grub_free (func);
|
||||
func = q;
|
||||
}
|
||||
else
|
||||
{
|
||||
func->next = *p;
|
||||
*p = func;
|
||||
}
|
||||
|
||||
return func;
|
||||
}
|
||||
|
||||
void
|
||||
grub_script_function_remove (const char *name)
|
||||
{
|
||||
grub_script_function_t *p, q;
|
||||
|
||||
for (p = &grub_script_function_list, q = *p; q; p = &(q->next), q = q->next)
|
||||
if (grub_strcmp (name, q->name) == 0)
|
||||
{
|
||||
*p = q->next;
|
||||
grub_free (q->name);
|
||||
grub_script_free (q->func);
|
||||
grub_free (q);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
grub_script_function_t
|
||||
grub_script_function_find (char *functionname)
|
||||
{
|
||||
grub_script_function_t func;
|
||||
|
||||
for (func = grub_script_function_list; func; func = func->next)
|
||||
if (grub_strcmp (functionname, func->name) == 0)
|
||||
break;
|
||||
|
||||
if (! func)
|
||||
{
|
||||
char tmp[64];
|
||||
grub_strncpy (tmp, functionname, 63);
|
||||
tmp[63] = 0;
|
||||
/* Avoid truncating inside UTF-8 character. */
|
||||
tmp[grub_getend (tmp, tmp + grub_strlen (tmp))] = 0;
|
||||
grub_error (GRUB_ERR_UNKNOWN_COMMAND, N_("can't find command `%s'"), tmp);
|
||||
}
|
||||
|
||||
return func;
|
||||
}
|
795
GRUB2/MOD_SRC/grub-2.04/grub-core/term/keyboard_layout.c
Normal file
795
GRUB2/MOD_SRC/grub-2.04/grub-core/term/keyboard_layout.c
Normal 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);
|
||||
}
|
@@ -348,12 +348,38 @@ out:
|
||||
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)
|
||||
{
|
||||
cmd = grub_register_extcmd ("setkey", grub_cmd_setkey, 0, N_("NEW_KEY USA_KEY"),
|
||||
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)
|
||||
|
@@ -462,6 +462,8 @@ static int lzx_uncompressed ( struct lzx *lzx ) {
|
||||
if ( len % 2 )
|
||||
lzx->input.offset++;
|
||||
|
||||
lzx->output.offset += len;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -614,7 +616,7 @@ ssize_t lzx_decompress ( const void *data, size_t len, void *buf ) {
|
||||
/* Sanity check */
|
||||
if ( len % 2 ) {
|
||||
DBG ( "LZX cannot handle odd-length input data\n" );
|
||||
return -1;
|
||||
//return -1;
|
||||
}
|
||||
|
||||
/* Initialise global state, if required */
|
||||
|
File diff suppressed because it is too large
Load Diff
5308
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
Normal file
5308
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -21,6 +21,8 @@
|
||||
#ifndef __VENTOY_DEF_H__
|
||||
#define __VENTOY_DEF_H__
|
||||
|
||||
#define VTOY_MAX_DIR_DEPTH 32
|
||||
|
||||
#define VTOY_MAX_SCRIPT_BUF (4 * 1024 * 1024)
|
||||
|
||||
#define VTOY_PART_BUF_LEN (128 * 1024)
|
||||
@@ -29,6 +31,8 @@
|
||||
|
||||
#define VTOY_SIZE_1GB 1073741824
|
||||
#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_1KB 1024
|
||||
|
||||
@@ -67,6 +71,9 @@
|
||||
#define VTOY_ARCH_CPIO "ventoy_x86.cpio"
|
||||
#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) \
|
||||
{\
|
||||
grub_printf("\n\n Password corrupted, will reboot after 5 seconds.\n\n"); \
|
||||
@@ -140,6 +147,7 @@ typedef struct cpio_newc_header
|
||||
typedef int (*grub_char_check_func)(int c);
|
||||
#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)
|
||||
typedef struct ventoy_patch_vhd
|
||||
@@ -191,14 +199,28 @@ typedef struct ventoy_iso9660_vd
|
||||
grub_uint32_t space;
|
||||
}ventoy_iso9660_vd;
|
||||
|
||||
/* https://wiki.osdev.org/El-Torito */
|
||||
typedef struct boot_info_table
|
||||
{
|
||||
grub_uint32_t bi_data0;
|
||||
grub_uint32_t bi_data1;
|
||||
grub_uint32_t bi_PrimaryVolumeDescriptor;
|
||||
grub_uint32_t bi_BootFileLocation;
|
||||
grub_uint32_t bi_BootFileLength;
|
||||
grub_uint32_t bi_Checksum;
|
||||
grub_uint8_t bi_Reserved[40];
|
||||
}boot_info_table;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#define img_type_iso 0
|
||||
#define img_type_wim 1
|
||||
#define img_type_efi 2
|
||||
#define img_type_img 3
|
||||
#define img_type_vhd 4
|
||||
#define img_type_vtoy 5
|
||||
#define img_type_start 0
|
||||
#define img_type_iso 0
|
||||
#define img_type_wim 1
|
||||
#define img_type_efi 2
|
||||
#define img_type_img 3
|
||||
#define img_type_vhd 4
|
||||
#define img_type_vtoy 5
|
||||
#define img_type_max 6
|
||||
|
||||
typedef struct img_info
|
||||
{
|
||||
@@ -207,6 +229,8 @@ typedef struct img_info
|
||||
char name[256];
|
||||
|
||||
const char *alias;
|
||||
const char *tip1;
|
||||
const char *tip2;
|
||||
const char *class;
|
||||
const char *menu_prefix;
|
||||
|
||||
@@ -281,10 +305,11 @@ extern ventoy_img_chunk_list g_img_chunk_list;
|
||||
extern ventoy_img_chunk_list g_wimiso_chunk_list;
|
||||
extern char *g_wimiso_path;
|
||||
extern char g_arch_mode_suffix[64];
|
||||
extern const char *g_menu_prefix[img_type_max];
|
||||
|
||||
extern int g_ventoy_debug;
|
||||
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, ...) \
|
||||
pos += grub_snprintf(buf + pos, VTOY_MAX_SCRIPT_BUF - pos, fmt, __VA_ARGS__)
|
||||
@@ -390,6 +415,15 @@ typedef struct wim_security_header
|
||||
grub_uint32_t count; /* Number of entries */
|
||||
}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 */
|
||||
typedef struct wim_directory_entry
|
||||
{
|
||||
@@ -414,6 +448,18 @@ typedef struct wim_directory_entry
|
||||
/** No security information exists for this file */
|
||||
#define WIM_NO_SECURITY 0xffffffffUL
|
||||
|
||||
typedef struct reg_vk
|
||||
{
|
||||
grub_uint32_t res1;
|
||||
grub_uint16_t sig;
|
||||
grub_uint16_t namesize;
|
||||
grub_uint32_t datasize;
|
||||
grub_uint32_t dataoffset;
|
||||
grub_uint32_t datatype;
|
||||
grub_uint16_t flag;
|
||||
grub_uint16_t res2;
|
||||
}reg_vk;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
|
||||
@@ -516,9 +562,28 @@ typedef struct plugin_entry
|
||||
const char *key;
|
||||
ventoy_plugin_entry_pf entryfunc;
|
||||
ventoy_plugin_check_pf checkfunc;
|
||||
int flag;
|
||||
}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;
|
||||
|
||||
typedef struct chk_case_fs_dir
|
||||
{
|
||||
grub_device_t dev;
|
||||
grub_fs_t fs;
|
||||
}chk_case_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);
|
||||
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);
|
||||
@@ -532,6 +597,7 @@ grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc,
|
||||
grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_valid_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_append_ext_sector(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_skip_svd(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_cpio_busybox_64(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_trailer_cpio(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
@@ -543,10 +609,16 @@ int ventoy_is_dir_exist(const char *fmt, ...);
|
||||
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_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_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_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_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
|
||||
(
|
||||
@@ -756,11 +828,21 @@ typedef struct file_fullpath
|
||||
char path[256];
|
||||
}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
|
||||
{
|
||||
int type;
|
||||
int pathlen;
|
||||
char isopath[256];
|
||||
|
||||
int timeout;
|
||||
int autosel;
|
||||
int cursel;
|
||||
int templatenum;
|
||||
@@ -792,6 +874,7 @@ typedef struct persistence_config
|
||||
int pathlen;
|
||||
char isopath[256];
|
||||
|
||||
int timeout;
|
||||
int autosel;
|
||||
int cursel;
|
||||
int backendnum;
|
||||
@@ -813,6 +896,20 @@ typedef struct menu_alias
|
||||
struct menu_alias *next;
|
||||
}menu_alias;
|
||||
|
||||
#define vtoy_tip_image_file 0
|
||||
#define vtoy_tip_directory 1
|
||||
typedef struct menu_tip
|
||||
{
|
||||
int type;
|
||||
int pathlen;
|
||||
char isopath[256];
|
||||
char tip1[1024];
|
||||
char tip2[1024];
|
||||
|
||||
struct menu_tip *next;
|
||||
}menu_tip;
|
||||
|
||||
|
||||
#define vtoy_class_image_file 0
|
||||
#define vtoy_class_directory 1
|
||||
|
||||
@@ -820,6 +917,7 @@ typedef struct menu_class
|
||||
{
|
||||
int type;
|
||||
int patlen;
|
||||
int parent;
|
||||
char pattern[256];
|
||||
char class[64];
|
||||
|
||||
@@ -843,6 +941,7 @@ typedef struct custom_boot
|
||||
typedef struct conf_replace
|
||||
{
|
||||
int pathlen;
|
||||
int img;
|
||||
char isopath[256];
|
||||
char orgconf[256];
|
||||
char newconf[256];
|
||||
@@ -850,8 +949,11 @@ typedef struct conf_replace
|
||||
struct conf_replace *next;
|
||||
}conf_replace;
|
||||
|
||||
#define injection_type_file 0
|
||||
#define injection_type_parent 1
|
||||
typedef struct injection_config
|
||||
{
|
||||
int type;
|
||||
int pathlen;
|
||||
char isopath[256];
|
||||
char archive[256];
|
||||
@@ -888,8 +990,12 @@ typedef struct vtoy_password
|
||||
grub_uint8_t md5[16];
|
||||
}vtoy_password;
|
||||
|
||||
#define vtoy_menu_pwd_file 0
|
||||
#define vtoy_menu_pwd_parent 1
|
||||
|
||||
typedef struct menu_password
|
||||
{
|
||||
int type;
|
||||
int pathlen;
|
||||
char isopath[256];
|
||||
|
||||
@@ -900,9 +1006,12 @@ typedef struct menu_password
|
||||
|
||||
extern int g_ventoy_menu_esc;
|
||||
extern int g_ventoy_suppress_esc;
|
||||
extern int g_ventoy_suppress_esc_default;
|
||||
extern int g_ventoy_last_entry;
|
||||
extern int g_ventoy_memdisk_mode;
|
||||
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_case_insensitive;
|
||||
extern grub_uint8_t g_ventoy_chain_type;
|
||||
@@ -920,6 +1029,8 @@ extern grub_uint8_t *g_conf_replace_new_buf;
|
||||
extern int g_conf_replace_new_len;
|
||||
extern int g_conf_replace_new_len_align;
|
||||
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) \
|
||||
{ \
|
||||
@@ -937,19 +1048,26 @@ extern grub_uint64_t g_ventoy_disk_size;
|
||||
chain->virt_img_size_in_bytes += data_secs * 2048; \
|
||||
}
|
||||
|
||||
#define ventoy_syscall0(name) grub_##name()
|
||||
#define ventoy_syscall1(name, a) grub_##name(a)
|
||||
|
||||
void ventoy_str_tolower(char *str);
|
||||
void ventoy_str_toupper(char *str);
|
||||
char * ventoy_get_line(char *start);
|
||||
int ventoy_cmp_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);
|
||||
install_template * ventoy_plugin_find_install_template(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_auto_install(void);
|
||||
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);
|
||||
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_class(int type, const char *name);
|
||||
const menu_tip * ventoy_plugin_get_menu_tip(int type, const char *isopath);
|
||||
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_get_image_list_index(int type, const char *name);
|
||||
conf_replace * ventoy_plugin_find_conf_replace(const char *iso);
|
||||
@@ -958,6 +1076,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_check_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
|
||||
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_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);
|
||||
@@ -973,6 +1092,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_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_unix_freebsd_ver_elf(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
int ventoy_check_device_result(int ret);
|
||||
int ventoy_check_device(grub_device_t dev);
|
||||
void ventoy_debug_dump_guid(const char *prefix, grub_uint8_t *guid);
|
||||
@@ -981,11 +1101,32 @@ 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_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
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);
|
||||
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);
|
||||
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);\
|
||||
}
|
||||
|
||||
#define ret_goto_end(a) ret = a; goto end;
|
||||
|
||||
extern ventoy_grub_param *g_grub_param;
|
||||
|
||||
#endif /* __VENTOY_DEF_H__ */
|
||||
|
||||
|
@@ -152,6 +152,23 @@ static int vtoy_json_parse_string
|
||||
return JSON_FAILED;
|
||||
}
|
||||
|
||||
if (*(pcPos - 1) == '\\')
|
||||
{
|
||||
for (pcPos++; *pcPos; pcPos++)
|
||||
{
|
||||
if (*pcPos == '"' && *(pcPos - 1) != '\\')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (*pcPos == 0 || pcPos < pcTmp)
|
||||
{
|
||||
json_debug("Invalid quotes string %s.", pcData);
|
||||
return JSON_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
*ppcEnd = pcPos + 1;
|
||||
uiLen = (grub_uint32_t)(unsigned long)(pcPos - pcTmp);
|
||||
|
||||
|
@@ -38,6 +38,9 @@
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
#define VTOY_APPEND_EXT_SIZE 4096
|
||||
static int g_append_ext_sector = 0;
|
||||
|
||||
char * ventoy_get_line(char *start)
|
||||
{
|
||||
if (start == NULL)
|
||||
@@ -333,7 +336,9 @@ end:
|
||||
static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName)
|
||||
{
|
||||
int i = 0;
|
||||
int len = 0;
|
||||
int dollar = 0;
|
||||
int quotation = 0;
|
||||
grub_file_t file = NULL;
|
||||
char *buf = NULL;
|
||||
char *start = NULL;
|
||||
@@ -382,6 +387,12 @@ static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName)
|
||||
start++;
|
||||
}
|
||||
|
||||
if (*start == '"')
|
||||
{
|
||||
quotation = 1;
|
||||
start++;
|
||||
}
|
||||
|
||||
while (*start)
|
||||
{
|
||||
img = grub_zalloc(sizeof(initrd_info));
|
||||
@@ -400,6 +411,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))
|
||||
{
|
||||
grub_free(img);
|
||||
@@ -640,6 +661,11 @@ static grub_uint32_t ventoy_linux_get_virt_chunk_count(void)
|
||||
count++;
|
||||
}
|
||||
|
||||
if (g_append_ext_sector > 0)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -653,6 +679,11 @@ static grub_uint32_t ventoy_linux_get_virt_chunk_size(void)
|
||||
{
|
||||
size += sizeof(ventoy_virt_chunk) + g_conf_replace_new_len_align;
|
||||
}
|
||||
|
||||
if (g_append_ext_sector > 0)
|
||||
{
|
||||
size += sizeof(ventoy_virt_chunk) + VTOY_APPEND_EXT_SIZE;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
@@ -660,6 +691,7 @@ static grub_uint32_t ventoy_linux_get_virt_chunk_size(void)
|
||||
static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_head *chain)
|
||||
{
|
||||
int id = 0;
|
||||
int virtid = 0;
|
||||
initrd_info *node;
|
||||
grub_uint64_t sector;
|
||||
grub_uint32_t offset;
|
||||
@@ -707,6 +739,29 @@ static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_
|
||||
offset += g_ventoy_cpio_size;
|
||||
sector += cpio_secs + initrd_secs;
|
||||
cur++;
|
||||
virtid++;
|
||||
}
|
||||
|
||||
/* Lenovo EasyStartup need an addional sector for boundary check */
|
||||
if (g_append_ext_sector > 0)
|
||||
{
|
||||
cpio_secs = VTOY_APPEND_EXT_SIZE / 2048;
|
||||
|
||||
cur->mem_sector_start = sector;
|
||||
cur->mem_sector_end = cur->mem_sector_start + cpio_secs;
|
||||
cur->mem_sector_offset = offset;
|
||||
cur->remap_sector_start = 0;
|
||||
cur->remap_sector_end = 0;
|
||||
cur->org_sector_start = 0;
|
||||
|
||||
grub_memset(override + offset, 0, VTOY_APPEND_EXT_SIZE);
|
||||
|
||||
chain->virt_img_size_in_bytes += VTOY_APPEND_EXT_SIZE;
|
||||
|
||||
offset += VTOY_APPEND_EXT_SIZE;
|
||||
sector += cpio_secs;
|
||||
cur++;
|
||||
virtid++;
|
||||
}
|
||||
|
||||
if (g_conf_replace_offset > 0)
|
||||
@@ -724,9 +779,15 @@ static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_
|
||||
|
||||
chain->virt_img_size_in_bytes += g_conf_replace_new_len_align;
|
||||
|
||||
if (g_grub_param->img_replace.magic == GRUB_IMG_REPLACE_MAGIC)
|
||||
{
|
||||
g_grub_param->img_replace.new_file_virtual_id = virtid;
|
||||
}
|
||||
|
||||
offset += g_conf_replace_new_len_align;
|
||||
sector += cpio_secs;
|
||||
cur++;
|
||||
virtid++;
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -926,6 +987,12 @@ static grub_err_t ventoy_linux_locate_initrd(int filt, int *filtcnt)
|
||||
}
|
||||
}
|
||||
|
||||
/* skip hdt.img */
|
||||
if (file->size <= VTOY_SIZE_1MB && grub_strcmp(node->name, "/boot/hdt.img") == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (grub_strcmp(file->fs->name, "iso9660") == 0)
|
||||
{
|
||||
node->iso_type = 0;
|
||||
@@ -1101,6 +1168,24 @@ grub_err_t ventoy_cmd_skip_svd(grub_extcmd_context_t ctxt, int argc, char **args
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_append_ext_sector(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
if (args[0][0] == '1')
|
||||
{
|
||||
g_append_ext_sector = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_append_ext_sector = 0;
|
||||
}
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int i;
|
||||
@@ -1441,9 +1526,9 @@ grub_err_t ventoy_cmd_trailer_cpio(grub_extcmd_context_t ctxt, int argc, char **
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
|
||||
grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int len = 0;
|
||||
int ventoy_compatible = 0;
|
||||
grub_uint32_t size = 0;
|
||||
grub_uint64_t isosize = 0;
|
||||
@@ -1483,23 +1568,31 @@ grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, cha
|
||||
|
||||
isosize = file->size;
|
||||
|
||||
boot_catlog = ventoy_get_iso_boot_catlog(file);
|
||||
if (boot_catlog)
|
||||
len = (int)grub_strlen(args[0]);
|
||||
if (len >= 4 && 0 == grub_strcasecmp(args[0] + len - 4, ".img"))
|
||||
{
|
||||
if (ventoy_is_efi_os() && (!ventoy_has_efi_eltorito(file, boot_catlog)))
|
||||
{
|
||||
grub_env_set("LoadIsoEfiDriver", "on");
|
||||
}
|
||||
debug("boot catlog %u for img file\n", boot_catlog);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ventoy_is_efi_os())
|
||||
boot_catlog = ventoy_get_iso_boot_catlog(file);
|
||||
if (boot_catlog)
|
||||
{
|
||||
grub_env_set("LoadIsoEfiDriver", "on");
|
||||
if (ventoy_is_efi_os() && (!ventoy_has_efi_eltorito(file, boot_catlog)))
|
||||
{
|
||||
grub_env_set("LoadIsoEfiDriver", "on");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return grub_error(GRUB_ERR_BAD_ARGUMENT, "File %s is not bootable", args[0]);
|
||||
if (ventoy_is_efi_os())
|
||||
{
|
||||
grub_env_set("LoadIsoEfiDriver", "on");
|
||||
}
|
||||
else
|
||||
{
|
||||
return grub_error(GRUB_ERR_BAD_ARGUMENT, "File %s is not bootable", args[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -33,6 +33,8 @@
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/net.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/elf.h>
|
||||
#include <grub/elfload.h>
|
||||
#include <grub/ventoy.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);
|
||||
}
|
||||
|
||||
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_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->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_signature, g_ventoy_part_info->MBR.BootCode + 0x1B8, 4);
|
||||
|
||||
|
@@ -44,14 +44,12 @@
|
||||
|
||||
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 char *g_vhdboot_totbuf = NULL;
|
||||
static char *g_vhdboot_isobuf = NULL;
|
||||
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_file_t file;
|
||||
@@ -61,10 +59,9 @@ static int ventoy_vhd_find_bcd(int *bcdoffset, int *bcdlen)
|
||||
|
||||
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)
|
||||
{
|
||||
grub_printf("Failed to open bcd file in the image file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -83,13 +80,15 @@ static int ventoy_vhd_find_bcd(int *bcdoffset, int *bcdlen)
|
||||
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 cnt = 0;
|
||||
char *pos;
|
||||
grub_size_t pathlen;
|
||||
const char *plat;
|
||||
char *newpath = NULL;
|
||||
grub_uint16_t *unicode_path;
|
||||
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
|
||||
};
|
||||
|
||||
while ((*vhdpath) != '/')
|
||||
{
|
||||
vhdpath++;
|
||||
}
|
||||
|
||||
pathlen = sizeof(grub_uint16_t) * (grub_strlen(vhdpath) + 1);
|
||||
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 */
|
||||
{
|
||||
pos = g_vhdboot_isobuf + g_vhdboot_bcd_offset;
|
||||
pos = g_vhdboot_isobuf + bcdoffset;
|
||||
|
||||
/* 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 &&
|
||||
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);
|
||||
}
|
||||
|
||||
for (pos = vhdpath; *pos; pos++)
|
||||
newpath = grub_strdup(vhdpath);
|
||||
for (pos = newpath; *pos; 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(patch2->vhd_file_path, unicode_path, pathlen);
|
||||
|
||||
grub_free(newpath);
|
||||
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};
|
||||
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)
|
||||
{
|
||||
ventoy_debug_dump_guid("GPT disk GUID: ", g_ventoy_part_info->Head.DiskGuid);
|
||||
ventoy_debug_dump_guid("GPT part GUID: ", g_ventoy_part_info->PartTbl[0].PartGuid);
|
||||
ventoy_debug_dump_guid("GPT disk GUID: ", gpt->Head.DiskGuid);
|
||||
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->part_offset_or_guid, g_ventoy_part_info->PartTbl[0].PartGuid, 16);
|
||||
grub_memcpy(patch2->disk_signature_or_guid, g_ventoy_part_info->Head.DiskGuid, 16);
|
||||
grub_memcpy(patch2->part_offset_or_guid, g_ventoy_part_info->PartTbl[0].PartGuid, 16);
|
||||
grub_memcpy(patch1->disk_signature_or_guid, gpt->Head.DiskGuid, 16);
|
||||
grub_memcpy(patch1->part_offset_or_guid, gpt->PartTbl[partIndex].PartGuid, 16);
|
||||
grub_memcpy(patch2->disk_signature_or_guid, gpt->Head.DiskGuid, 16);
|
||||
grub_memcpy(patch2->part_offset_or_guid, gpt->PartTbl[partIndex].PartGuid, 16);
|
||||
|
||||
patch1->part_type = patch2->part_type = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("MBR disk signature: %02x%02x%02x%02x\n",
|
||||
g_ventoy_part_info->MBR.BootCode[0x1b8 + 0], g_ventoy_part_info->MBR.BootCode[0x1b8 + 1],
|
||||
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);
|
||||
grub_memcpy(patch2->disk_signature_or_guid, g_ventoy_part_info->MBR.BootCode + 0x1b8, 4);
|
||||
offset = gpt->MBR.PartTbl[partIndex].StartSectorId;
|
||||
offset *= 512;
|
||||
|
||||
debug("MBR disk signature: %02x%02x%02x%02x Part(%d) offset:%llu\n",
|
||||
gpt->MBR.BootCode[0x1b8 + 0], gpt->MBR.BootCode[0x1b8 + 1],
|
||||
gpt->MBR.BootCode[0x1b8 + 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;
|
||||
@@ -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)
|
||||
{
|
||||
int rc;
|
||||
int bcdoffset, bcdlen;
|
||||
int patchoffset[2];
|
||||
ventoy_patch_vhd *patch1;
|
||||
ventoy_patch_vhd *patch2;
|
||||
char envbuf[64];
|
||||
@@ -194,18 +320,39 @@ grub_err_t ventoy_cmd_patch_vhdboot(grub_extcmd_context_t ctxt, int argc, char *
|
||||
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)
|
||||
{
|
||||
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);
|
||||
patch2 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + g_vhdboot_bcd_offset + 0x50aa);
|
||||
|
||||
ventoy_vhd_patch_disk(patch1, patch2);
|
||||
ventoy_vhd_patch_path(args[0], patch1, patch2);
|
||||
rc = ventoy_vhd_find_bcd(&bcdoffset, &bcdlen, "/boot/BCD");
|
||||
if (rc)
|
||||
{
|
||||
debug("No file /boot/BCD \n");
|
||||
}
|
||||
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 */
|
||||
#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);
|
||||
#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)
|
||||
@@ -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);
|
||||
debug("<%s> vtoy type: <%s> ", args[0], type);
|
||||
debug("<%s> vtoy type: <%s> offset:%d\n", args[0], type, offset);
|
||||
|
||||
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;
|
||||
grub_env_set(args[3], "1");
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("offset data=0x%x\n", data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("BootCode: 0x%x\n", gpt->MBR.BootCode[92]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -314,6 +314,91 @@ static int ventoy_is_pe64(grub_uint8_t *buffer)
|
||||
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;
|
||||
g_ventoy_suppress_esc_default = 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)
|
||||
{
|
||||
wim_patch *next = NULL;
|
||||
@@ -464,6 +549,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;
|
||||
cur_offset = (chunk_num - 1) * 4;
|
||||
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;
|
||||
|
||||
@@ -516,9 +603,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cur_dst += 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)
|
||||
{
|
||||
@@ -570,30 +659,6 @@ static wim_directory_entry * search_full_wim_dirent
|
||||
return search;
|
||||
}
|
||||
|
||||
static wim_directory_entry * search_replace_wim_dirent(void *meta_data, wim_directory_entry *dir)
|
||||
{
|
||||
wim_directory_entry *wim_dirent = 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, winpeshl_path);
|
||||
debug("search winpeshl.exe %p\n", wim_dirent);
|
||||
if (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;
|
||||
}
|
||||
|
||||
|
||||
static wim_lookup_entry * ventoy_find_look_entry(wim_header *header, wim_lookup_entry *lookup, wim_hash *hash)
|
||||
@@ -611,6 +676,245 @@ static wim_lookup_entry * ventoy_find_look_entry(wim_header *header, wim_lookup_
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int parse_registry_setup_cmdline
|
||||
(
|
||||
grub_file_t file,
|
||||
wim_header *head,
|
||||
wim_lookup_entry *lookup,
|
||||
void *meta_data,
|
||||
wim_directory_entry *dir,
|
||||
char *buf,
|
||||
grub_uint32_t buflen
|
||||
)
|
||||
{
|
||||
char c;
|
||||
int ret = 0;
|
||||
grub_uint32_t i = 0;
|
||||
grub_uint32_t reglen = 0;
|
||||
wim_hash zerohash;
|
||||
reg_vk *regvk = NULL;
|
||||
wim_lookup_entry *look = NULL;
|
||||
wim_directory_entry *wim_dirent = NULL;
|
||||
char *decompress_data = NULL;
|
||||
const char *reg_path[] = { "Windows", "System32", "config", "SYSTEM", NULL };
|
||||
|
||||
wim_dirent = search_full_wim_dirent(meta_data, dir, reg_path);
|
||||
debug("search reg SYSTEM %p\n", wim_dirent);
|
||||
if (!wim_dirent)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
grub_memset(&zerohash, 0, sizeof(zerohash));
|
||||
if (grub_memcmp(&zerohash, wim_dirent->hash.sha1, sizeof(wim_hash)) == 0)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
look = ventoy_find_look_entry(head, lookup, &wim_dirent->hash);
|
||||
if (!look)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
reglen = (grub_uint32_t)look->resource.raw_size;
|
||||
debug("find system lookup entry_id:%ld raw_size:%u\n",
|
||||
((long)look - (long)lookup) / sizeof(wim_lookup_entry), reglen);
|
||||
|
||||
if (0 != ventoy_read_resource(file, head, &(look->resource), (void **)&(decompress_data)))
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
if (grub_strncmp(decompress_data + 0x1000, "hbin", 4))
|
||||
{
|
||||
ret_goto_end(5);
|
||||
}
|
||||
|
||||
for (i = 0x1000; i + sizeof(reg_vk) < reglen; i += 8)
|
||||
{
|
||||
regvk = (reg_vk *)(decompress_data + i);
|
||||
if (regvk->sig == 0x6B76 && regvk->namesize == 7 &&
|
||||
regvk->datatype == 1 && regvk->flag == 1)
|
||||
{
|
||||
if (grub_strncasecmp((char *)(regvk + 1), "cmdline", 7) == 0)
|
||||
{
|
||||
debug("find registry cmdline i:%u offset:(0x%x)%u size:(0x%x)%u\n",
|
||||
i, regvk->dataoffset, regvk->dataoffset, regvk->datasize, regvk->datasize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i + sizeof(reg_vk) >= reglen || regvk == NULL)
|
||||
{
|
||||
ret_goto_end(6);
|
||||
}
|
||||
|
||||
if (regvk->datasize == 0 || (regvk->datasize & 0x80000000) > 0 ||
|
||||
regvk->dataoffset == 0 || regvk->dataoffset == 0xFFFFFFFF)
|
||||
{
|
||||
ret_goto_end(7);
|
||||
}
|
||||
|
||||
if (regvk->datasize / 2 >= buflen)
|
||||
{
|
||||
ret_goto_end(8);
|
||||
}
|
||||
|
||||
debug("start offset is 0x%x(%u)\n", 0x1000 + regvk->dataoffset + 4, 0x1000 + regvk->dataoffset + 4);
|
||||
|
||||
for (i = 0; i < regvk->datasize; i+=2)
|
||||
{
|
||||
c = (char)(*(grub_uint16_t *)(decompress_data + 0x1000 + regvk->dataoffset + 4 + i));
|
||||
*buf++ = c;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
end:
|
||||
grub_check_free(decompress_data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int parse_custom_setup_path(char *cmdline, const char **path, char *exefile)
|
||||
{
|
||||
int i = 0;
|
||||
int len = 0;
|
||||
char *pos1 = NULL;
|
||||
char *pos2 = NULL;
|
||||
|
||||
if ((cmdline[0] == 'x' || cmdline[0] == 'X') && cmdline[1] == ':')
|
||||
{
|
||||
pos1 = pos2 = cmdline + 3;
|
||||
|
||||
while (i < VTOY_MAX_DIR_DEPTH && *pos2)
|
||||
{
|
||||
while (*pos2 && *pos2 != '\\' && *pos2 != '/')
|
||||
{
|
||||
pos2++;
|
||||
}
|
||||
|
||||
path[i++] = pos1;
|
||||
|
||||
if (*pos2 == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
*pos2 = 0;
|
||||
pos1 = pos2 + 1;
|
||||
pos2 = pos1;
|
||||
}
|
||||
|
||||
if (i == 0 || i >= VTOY_MAX_DIR_DEPTH)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
path[i++] = "Windows";
|
||||
path[i++] = "System32";
|
||||
path[i++] = cmdline;
|
||||
}
|
||||
|
||||
pos1 = (char *)path[i - 1];
|
||||
while (*pos1 != ' ' && *pos1 != '\t' && *pos1)
|
||||
{
|
||||
pos1++;
|
||||
}
|
||||
*pos1 = 0;
|
||||
|
||||
len = (int)grub_strlen(path[i - 1]);
|
||||
if (len < 4 || grub_strcasecmp(path[i - 1] + len - 4, ".exe") != 0)
|
||||
{
|
||||
grub_snprintf(exefile, 256, "%s.exe", path[i - 1]);
|
||||
path[i - 1] = exefile;
|
||||
}
|
||||
|
||||
|
||||
debug("custom setup: %d <%s>\n", i, path[i - 1]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static wim_directory_entry * search_replace_wim_dirent
|
||||
(
|
||||
grub_file_t file,
|
||||
wim_header *head,
|
||||
wim_lookup_entry *lookup,
|
||||
void *meta_data,
|
||||
wim_directory_entry *dir
|
||||
)
|
||||
{
|
||||
int ret;
|
||||
char exefile[256] = {0};
|
||||
char cmdline[256] = {0};
|
||||
wim_directory_entry *wim_dirent = NULL;
|
||||
wim_directory_entry *pecmd_dirent = NULL;
|
||||
const char *peset_path[] = { "Windows", "System32", "peset.exe", NULL };
|
||||
const char *pecmd_path[] = { "Windows", "System32", "pecmd.exe", NULL };
|
||||
const char *winpeshl_path[] = { "Windows", "System32", "winpeshl.exe", NULL };
|
||||
const char *custom_path[VTOY_MAX_DIR_DEPTH + 1] = { NULL };
|
||||
|
||||
pecmd_dirent = search_full_wim_dirent(meta_data, dir, pecmd_path);
|
||||
debug("search pecmd.exe %p\n", pecmd_dirent);
|
||||
|
||||
if (pecmd_dirent)
|
||||
{
|
||||
ret = parse_registry_setup_cmdline(file, head, lookup, meta_data, dir, cmdline, sizeof(cmdline) - 1);
|
||||
if (0 == ret)
|
||||
{
|
||||
debug("registry setup cmdline:<%s>\n", cmdline);
|
||||
|
||||
if (grub_strncasecmp(cmdline, "PECMD", 5) == 0)
|
||||
{
|
||||
wim_dirent = pecmd_dirent;
|
||||
}
|
||||
else if (grub_strncasecmp(cmdline, "PESET", 5) == 0)
|
||||
{
|
||||
wim_dirent = search_full_wim_dirent(meta_data, dir, peset_path);
|
||||
debug("search peset.exe %p\n", wim_dirent);
|
||||
}
|
||||
else if (grub_strncasecmp(cmdline, "WINPESHL", 8) == 0)
|
||||
{
|
||||
wim_dirent = search_full_wim_dirent(meta_data, dir, winpeshl_path);
|
||||
debug("search winpeshl.exe %p\n", wim_dirent);
|
||||
}
|
||||
else if (0 == parse_custom_setup_path(cmdline, custom_path, exefile))
|
||||
{
|
||||
wim_dirent = search_full_wim_dirent(meta_data, dir, custom_path);
|
||||
debug("search custom path %p\n", wim_dirent);
|
||||
}
|
||||
|
||||
if (wim_dirent)
|
||||
{
|
||||
return wim_dirent;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("registry setup cmdline failed : %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
wim_dirent = pecmd_dirent;
|
||||
if (wim_dirent)
|
||||
{
|
||||
return wim_dirent;
|
||||
}
|
||||
|
||||
wim_dirent = search_full_wim_dirent(meta_data, dir, winpeshl_path);
|
||||
debug("search winpeshl.exe %p\n", wim_dirent);
|
||||
if (wim_dirent)
|
||||
{
|
||||
return wim_dirent;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static wim_lookup_entry * ventoy_find_meta_entry(wim_header *header, wim_lookup_entry *lookup)
|
||||
{
|
||||
grub_uint32_t i = 0;
|
||||
@@ -636,6 +940,42 @@ static wim_lookup_entry * ventoy_find_meta_entry(wim_header *header, wim_lookup_
|
||||
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)
|
||||
{
|
||||
if ((meta_data == NULL) || (dir == NULL))
|
||||
@@ -660,8 +1000,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));
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
return 0;
|
||||
@@ -702,6 +1050,7 @@ int ventoy_fill_windows_rtdata(void *buf, char *isopath)
|
||||
{
|
||||
char *pos = NULL;
|
||||
char *script = NULL;
|
||||
const char *env = NULL;
|
||||
ventoy_windows_data *data = (ventoy_windows_data *)buf;
|
||||
|
||||
grub_memset(data, 0, sizeof(ventoy_windows_data));
|
||||
@@ -740,7 +1089,13 @@ int ventoy_fill_windows_rtdata(void *buf, char *isopath)
|
||||
{
|
||||
debug("injection archive not configed %s\n", pos);
|
||||
}
|
||||
|
||||
|
||||
env = grub_env_get("VTOY_WIN11_BYPASS_CHECK");
|
||||
if (env && env[0] == '1' && env[1] == 0)
|
||||
{
|
||||
data->windows11_bypass_check = 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -776,7 +1131,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);
|
||||
|
||||
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 */
|
||||
ventoy_update_all_hash(node, wim_data->new_meta_data, rootdir);
|
||||
@@ -809,6 +1171,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)
|
||||
{
|
||||
int rc;
|
||||
grub_uint16_t i;
|
||||
grub_file_t file;
|
||||
grub_uint32_t exe_len;
|
||||
grub_uint8_t *exe_data = NULL;
|
||||
@@ -817,6 +1180,7 @@ static int ventoy_wimdows_locate_wim(const char *disk, wim_patch *patch)
|
||||
wim_security_header *security = NULL;
|
||||
wim_directory_entry *rootdir = NULL;
|
||||
wim_directory_entry *search = NULL;
|
||||
wim_stream_entry *stream = NULL;
|
||||
wim_header *head = &(patch->wim_data.wim_header);
|
||||
wim_tail *wim_data = &patch->wim_data;
|
||||
|
||||
@@ -860,10 +1224,25 @@ static int ventoy_wimdows_locate_wim(const char *disk, wim_patch *patch)
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
debug("read lookup offset:%llu size:%llu\n", (ulonglong)head->lookup.offset, (ulonglong)head->lookup.raw_size);
|
||||
lookup = grub_malloc(head->lookup.raw_size);
|
||||
grub_file_seek(file, head->lookup.offset);
|
||||
grub_file_read(file, lookup, head->lookup.raw_size);
|
||||
|
||||
|
||||
|
||||
/* search winpeshl.exe dirent entry */
|
||||
search = search_replace_wim_dirent(decompress_data, rootdir);
|
||||
search = search_replace_wim_dirent(file, head, lookup, decompress_data, rootdir);
|
||||
if (!search)
|
||||
{
|
||||
debug("Failed to find replace file %p\n", search);
|
||||
@@ -872,14 +1251,30 @@ static int ventoy_wimdows_locate_wim(const char *disk, wim_patch *patch)
|
||||
}
|
||||
|
||||
debug("find replace file at %p\n", search);
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
lookup = grub_malloc(head->lookup.raw_size);
|
||||
grub_file_seek(file, head->lookup.offset);
|
||||
grub_file_read(file, lookup, head->lookup.raw_size);
|
||||
|
||||
/* find and extact winpeshl.exe */
|
||||
patch->replace_look = ventoy_find_look_entry(head, lookup, &patch->old_hash);
|
||||
if (patch->replace_look)
|
||||
@@ -900,8 +1295,8 @@ static int ventoy_wimdows_locate_wim(const char *disk, wim_patch *patch)
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("failed to find lookup entry for replace file 0x%02x 0x%02x\n",
|
||||
patch->old_hash.sha1[0], patch->old_hash.sha1[1]);
|
||||
debug("failed to find lookup entry for replace file %02x %02x %02x %02x\n",
|
||||
ventoy_varg_4(patch->old_hash.sha1));
|
||||
}
|
||||
|
||||
wim_data->wim_raw_size = (grub_uint32_t)file->size;
|
||||
@@ -1054,7 +1449,48 @@ static void ventoy_windows_fill_override_data_iso9660( grub_uint64_t isosize,
|
||||
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_uint64_t data64;
|
||||
@@ -1065,9 +1501,8 @@ static void ventoy_windows_fill_override_data_udf( grub_uint64_t isosize, voi
|
||||
ventoy_override_chunk *cur;
|
||||
wim_patch *node = 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;
|
||||
|
||||
@@ -1077,7 +1512,7 @@ static void ventoy_windows_fill_override_data_udf( grub_uint64_t isosize, voi
|
||||
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)
|
||||
{
|
||||
@@ -1118,13 +1553,11 @@ static void ventoy_windows_fill_override_data_udf( grub_uint64_t isosize, voi
|
||||
data64 = new_wim_size;
|
||||
grub_memcpy(cur->override_data, &(data64), 8);
|
||||
|
||||
udf = (ventoy_udf_override *)wim_data->override_data;
|
||||
udf->length = new_wim_size;
|
||||
udf->position = (grub_uint32_t)sector - udf_start_block;
|
||||
/* override 3: position and length in extend data */
|
||||
ventoy_windows_fill_udf_short_ad(isofile, (grub_uint32_t)sector - udf_start_block, wim_data, new_wim_size);
|
||||
|
||||
sector += (new_wim_size / 2048);
|
||||
|
||||
/* override 3: position and length in extend data */
|
||||
|
||||
cur++;
|
||||
cur->img_offset = wim_data->override_offset;
|
||||
cur->override_size = wim_data->override_len;
|
||||
@@ -1301,6 +1734,54 @@ end:
|
||||
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)
|
||||
{
|
||||
int unknown_image = 0;
|
||||
@@ -1470,7 +1951,7 @@ grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, c
|
||||
}
|
||||
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 */
|
||||
@@ -1733,3 +2214,29 @@ grub_err_t ventoy_cmd_wim_chain_data(grub_extcmd_context_t ctxt, int argc, char
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
||||
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,
|
||||
|
141
GRUB2/MOD_SRC/grub-2.04/include/grub/partition.h
Normal file
141
GRUB2/MOD_SRC/grub-2.04/include/grub/partition.h
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2004,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/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_PART_HEADER
|
||||
#define GRUB_PART_HEADER 1
|
||||
|
||||
#include <grub/dl.h>
|
||||
#include <grub/list.h>
|
||||
|
||||
struct grub_disk;
|
||||
|
||||
typedef struct grub_partition *grub_partition_t;
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
typedef enum
|
||||
{
|
||||
GRUB_EMBED_PCBIOS
|
||||
} grub_embed_type_t;
|
||||
#endif
|
||||
|
||||
typedef int (*grub_partition_iterate_hook_t) (struct grub_disk *disk,
|
||||
const grub_partition_t partition,
|
||||
void *data);
|
||||
|
||||
/* Partition map type. */
|
||||
struct grub_partition_map
|
||||
{
|
||||
/* The next partition map type. */
|
||||
struct grub_partition_map *next;
|
||||
struct grub_partition_map **prev;
|
||||
|
||||
/* The name of the partition map type. */
|
||||
const char *name;
|
||||
|
||||
/* Call HOOK with each partition, until HOOK returns non-zero. */
|
||||
grub_err_t (*iterate) (struct grub_disk *disk,
|
||||
grub_partition_iterate_hook_t hook, void *hook_data);
|
||||
#ifdef GRUB_UTIL
|
||||
/* Determine sectors available for embedding. */
|
||||
grub_err_t (*embed) (struct grub_disk *disk, unsigned int *nsectors,
|
||||
unsigned int max_nsectors,
|
||||
grub_embed_type_t embed_type,
|
||||
grub_disk_addr_t **sectors);
|
||||
#endif
|
||||
};
|
||||
typedef struct grub_partition_map *grub_partition_map_t;
|
||||
|
||||
/* Partition description. */
|
||||
struct grub_partition
|
||||
{
|
||||
/* The partition number. */
|
||||
int number;
|
||||
|
||||
/* The start sector (relative to parent). */
|
||||
grub_disk_addr_t start;
|
||||
|
||||
/* The length in sector units. */
|
||||
grub_uint64_t len;
|
||||
|
||||
/* The offset of the partition table. */
|
||||
grub_disk_addr_t offset;
|
||||
|
||||
/* The index of this partition in the partition table. */
|
||||
int index;
|
||||
|
||||
/* Parent partition (physically contains this partition). */
|
||||
struct grub_partition *parent;
|
||||
|
||||
/* The type partition map. */
|
||||
grub_partition_map_t partmap;
|
||||
|
||||
/* The type of partition whne it's on MSDOS.
|
||||
Used for embedding detection. */
|
||||
grub_uint8_t msdostype;
|
||||
|
||||
/* The attrib field for GPT. Needed for priority detection. */
|
||||
grub_uint64_t gpt_attrib;
|
||||
};
|
||||
|
||||
grub_partition_t EXPORT_FUNC(grub_partition_probe) (struct grub_disk *disk,
|
||||
const char *str);
|
||||
int EXPORT_FUNC(grub_partition_iterate) (struct grub_disk *disk,
|
||||
grub_partition_iterate_hook_t hook,
|
||||
void *hook_data);
|
||||
char *EXPORT_FUNC(grub_partition_get_name) (const grub_partition_t partition);
|
||||
|
||||
|
||||
extern grub_partition_map_t EXPORT_VAR(grub_partition_map_list);
|
||||
|
||||
#ifndef GRUB_LST_GENERATOR
|
||||
static inline void
|
||||
grub_partition_map_register (grub_partition_map_t partmap)
|
||||
{
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_partition_map_list),
|
||||
GRUB_AS_LIST (partmap));
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void
|
||||
grub_partition_map_unregister (grub_partition_map_t partmap)
|
||||
{
|
||||
grub_list_remove (GRUB_AS_LIST (partmap));
|
||||
}
|
||||
|
||||
#define FOR_PARTITION_MAPS(var) FOR_LIST_ELEMENTS((var), (grub_partition_map_list))
|
||||
|
||||
|
||||
static inline grub_disk_addr_t
|
||||
grub_partition_get_start (const grub_partition_t p)
|
||||
{
|
||||
grub_partition_t part;
|
||||
grub_uint64_t part_start = 0;
|
||||
|
||||
for (part = p; part; part = part->parent)
|
||||
part_start += part->start;
|
||||
|
||||
return part_start;
|
||||
}
|
||||
|
||||
static inline grub_uint64_t
|
||||
grub_partition_get_len (const grub_partition_t p)
|
||||
{
|
||||
return p->len;
|
||||
}
|
||||
|
||||
#endif /* ! GRUB_PART_HEADER */
|
@@ -135,7 +135,8 @@ typedef struct ventoy_windows_data
|
||||
{
|
||||
char auto_install_script[384];
|
||||
char injection_archive[384];
|
||||
grub_uint8_t reserved[256];
|
||||
grub_uint8_t windows11_bypass_check;
|
||||
grub_uint8_t reserved[255];
|
||||
}ventoy_windows_data;
|
||||
|
||||
|
||||
@@ -241,6 +242,7 @@ typedef struct ventoy_img_chunk_list
|
||||
#pragma pack(1)
|
||||
|
||||
#define GRUB_FILE_REPLACE_MAGIC 0x1258BEEF
|
||||
#define GRUB_IMG_REPLACE_MAGIC 0x1259BEEF
|
||||
|
||||
typedef const char * (*grub_env_get_pf)(const char *name);
|
||||
typedef int (*grub_env_set_pf)(const char *name, const char *val);
|
||||
@@ -259,6 +261,7 @@ typedef struct ventoy_grub_param
|
||||
grub_env_get_pf grub_env_get;
|
||||
grub_env_set_pf grub_env_set;
|
||||
ventoy_grub_param_file_replace file_replace;
|
||||
ventoy_grub_param_file_replace img_replace;
|
||||
grub_env_printf_pf grub_env_printf;
|
||||
}ventoy_grub_param;
|
||||
|
||||
@@ -267,6 +270,7 @@ typedef struct ventoy_grub_param
|
||||
int grub_ext_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_img_chunk_list *chunk_list);
|
||||
int grub_fat_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_img_chunk_list *chunk_list);
|
||||
void grub_iso9660_set_nojoliet(int nojoliet);
|
||||
int grub_iso9660_is_joliet(void);
|
||||
grub_uint64_t grub_iso9660_get_last_read_pos(grub_file_t file);
|
||||
grub_uint64_t grub_iso9660_get_last_file_dirent_pos(grub_file_t file);
|
||||
grub_uint64_t grub_udf_get_file_offset(grub_file_t file);
|
||||
|
@@ -12,14 +12,14 @@ make install
|
||||
PATH=$PATH:$VT_DIR/GRUB2/INSTALL/bin/:$VT_DIR/GRUB2/INSTALL/sbin/
|
||||
|
||||
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"
|
||||
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
|
||||
@@ -97,6 +97,8 @@ elif [ "$1" = "arm64" ]; then
|
||||
if ! echo $all_modules | grep -q " ${line%.mod} "; then
|
||||
echo "Copy $line ..."
|
||||
cp -a $VT_DIR/GRUB2/INSTALL/lib/grub/arm64-efi/$line $VT_DIR/INSTALL/grub/arm64-efi/
|
||||
xz $VT_DIR/INSTALL/grub/arm64-efi/$line
|
||||
mv $VT_DIR/INSTALL/grub/arm64-efi/${line}.xz $VT_DIR/INSTALL/grub/arm64-efi/${line}
|
||||
fi
|
||||
done
|
||||
elif [ "$1" = "mips64el" ]; then
|
||||
|
878
GRUB2/MOD_SRC/grub-2.04/util/setup.c
Normal file
878
GRUB2/MOD_SRC/grub-2.04/util/setup.c
Normal 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, §ors);
|
||||
else if (ctx.dest_partmap)
|
||||
err = ctx.dest_partmap->embed (dest_dev->disk, &nsec, maxsec,
|
||||
GRUB_EMBED_PCBIOS, §ors);
|
||||
else
|
||||
err = fs->fs_embed (dest_dev, &nsec, maxsec,
|
||||
GRUB_EMBED_PCBIOS, §ors);
|
||||
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);
|
||||
}
|
||||
|
@@ -121,6 +121,11 @@ elif [ "$VTOY_ARCH" = "i386" ]; then
|
||||
ln -s $VTOY_PATH/tool/dmsetup32 $VTOY_PATH/tool/dmsetup
|
||||
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
|
||||
echo "Use MIPS64 busybox toolkit ..." >>$VTLOG
|
||||
ln -s $BUSYBOX_PATH/xzminidecm64e $BUSYBOX_PATH/xzminidec
|
||||
|
@@ -61,3 +61,7 @@ else
|
||||
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k"
|
||||
fi
|
||||
|
||||
if [ -f $VTOY_PATH/ventoy_persistent_map ]; then
|
||||
$SED "1 aexport cow_label=vtoycow" -i /init
|
||||
fi
|
||||
|
@@ -36,6 +36,10 @@ done
|
||||
$BUSYBOX_PATH/umount /vtmnt && $BUSYBOX_PATH/rm -rf /vtmnt
|
||||
$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
|
||||
|
||||
ventoy_set_rule_dir_prefix /ventoy_rdroot
|
||||
|
@@ -31,10 +31,11 @@ done
|
||||
|
||||
ventoy_extract_vtloopex ${vtdiskname}2 crux
|
||||
|
||||
|
||||
vtKver=$(uname -r)
|
||||
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
|
||||
$BUSYBOX_PATH/insmod $vtLoopExDir/dm-mod/$(uname -r)/64/dax.ko
|
||||
$BUSYBOX_PATH/insmod $vtLoopExDir/dm-mod/$(uname -r)/64/dm-mod.ko
|
||||
|
||||
ventoy_check_install_module_xz $vtLoopExDir/dm-mod/$vtKver/64/dax.ko
|
||||
ventoy_check_install_module_xz $vtLoopExDir/dm-mod/$vtKver/64/dm-mod.ko
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
|
||||
|
79
IMG/cpio/ventoy/hook/debian/kerio-disk.sh
Normal file
79
IMG/cpio/ventoy/hook/debian/kerio-disk.sh
Normal 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
|
20
IMG/cpio/ventoy/hook/debian/kerio-hook.sh
Normal file
20
IMG/cpio/ventoy/hook/debian/kerio-hook.sh
Normal 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
|
47
IMG/cpio/ventoy/hook/debian/mocaccino-disk.sh
Normal file
47
IMG/cpio/ventoy/hook/debian/mocaccino-disk.sh
Normal 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
|
20
IMG/cpio/ventoy/hook/debian/mocaccino-hook.sh
Normal file
20
IMG/cpio/ventoy/hook/debian/mocaccino-hook.sh
Normal 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
|
@@ -22,19 +22,46 @@ porteus_hook() {
|
||||
$SED "/searching *for *\$CFG *file/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/porteus-disk.sh" -i $1
|
||||
}
|
||||
|
||||
if $GREP -q exfat /proc/filesystems; then
|
||||
vtPath=$($VTOY_PATH/tool/vtoydump -p $VTOY_PATH/ventoy_os_param)
|
||||
|
||||
vtPath=$($VTOY_PATH/tool/vtoydump -p $VTOY_PATH/ventoy_os_param)
|
||||
echo $vtPath | $GREP -q " "
|
||||
_vtRet1=$?
|
||||
|
||||
$GREP -q exfat /proc/filesystems
|
||||
_vtRet2=$?
|
||||
|
||||
echo "_vtRet1=$_vtRet1 _vtRet2=$_vtRet2 ..." >> $VTLOG
|
||||
|
||||
if [ $_vtRet1 -ne 0 -a $_vtRet2 -eq 0 ]; then
|
||||
vtFindFlag=0
|
||||
$GREP '`value from`' /usr/* -r | $AWK -F: '{print $1}' | while read vtline; do
|
||||
echo "hooking $vtline ..." >> $VTLOG
|
||||
$SED "s#\`value from\`#$vtPath#g" -i $vtline
|
||||
vtFindFlag=1
|
||||
done
|
||||
|
||||
if [ $vtFindFlag -eq 0 ]; then
|
||||
if $GREP -q '`value from`' /linuxrc; then
|
||||
if $GREP -q "searching *for *\$CFG *file" /linuxrc; then
|
||||
echo "hooking linuxrc CFG..." >> $VTLOG
|
||||
$SED "/searching *for *\$CFG *file/i$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/porteus-path.sh" -i /linuxrc
|
||||
$SED "/searching *for *\$CFG *file/iFROM=\$(cat /porteus-from)" -i /linuxrc
|
||||
$SED "/searching *for *\$CFG *file/iISO=\$(cat /porteus-from)" -i /linuxrc
|
||||
vtFindFlag=1
|
||||
else
|
||||
echo "hooking linuxrc SGN..." >> $VTLOG
|
||||
$SED "/searching *for *\$SGN *file/i$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/porteus-path.sh" -i /linuxrc
|
||||
$SED "/searching *for *\$SGN *file/iFROM=\$(cat /porteus-from)" -i /linuxrc
|
||||
$SED "/searching *for *\$SGN *file/iISO=\$(cat /porteus-from)" -i /linuxrc
|
||||
vtFindFlag=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
else
|
||||
for vtfile in '/init' '/linuxrc' ; do
|
||||
for vtfile in '/linuxrc' '/init'; do
|
||||
if [ -e $vtfile ]; then
|
||||
if ! $GREP -q ventoy $vtfile; then
|
||||
echo "hooking $vtfile ..." >> $VTLOG
|
||||
echo "hooking disk $vtfile ..." >> $VTLOG
|
||||
porteus_hook $vtfile
|
||||
fi
|
||||
fi
|
||||
|
38
IMG/cpio/ventoy/hook/debian/porteus-path.sh
Normal file
38
IMG/cpio/ventoy/hook/debian/porteus-path.sh
Normal 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
|
||||
|
||||
vtlog "####### $0 $* ########"
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
|
||||
vtPath=$(vtoydump -p $VTOY_PATH/ventoy_os_param)
|
||||
|
||||
if echo $vtdiskname | egrep -q "nvme|mmc|nbd"; then
|
||||
echo ${vtdiskname}p1${vtPath} > /porteus-from
|
||||
else
|
||||
echo ${vtdiskname}1${vtPath} > /porteus-from
|
||||
fi
|
||||
|
||||
PATH=$VTPATH_OLD
|
@@ -27,6 +27,33 @@ vtlog "####### $0 $* ########"
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
ventoy_os_install_dmsetup_by_fuse() {
|
||||
vtlog "ventoy_os_install_dmsetup_by_fuse $*"
|
||||
|
||||
mkdir -p $VTOY_PATH/mnt/fuse $VTOY_PATH/mnt/iso $VTOY_PATH/mnt/squashfs
|
||||
|
||||
vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_dm_table
|
||||
vtoy_fuse_iso -f $VTOY_PATH/ventoy_dm_table -m $VTOY_PATH/mnt/fuse
|
||||
|
||||
mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso $VTOY_PATH/mnt/iso
|
||||
|
||||
sfsfile=$(ls $VTOY_PATH/mnt/iso/*.sfs)
|
||||
|
||||
mount -t squashfs $sfsfile $VTOY_PATH/mnt/squashfs
|
||||
|
||||
kVer=$(uname -r)
|
||||
KoName=$(ls $VTOY_PATH/mnt/squashfs/lib/modules/$kVer/kernel/drivers/md/dm-mod.ko*)
|
||||
vtlog "insmod $KoName"
|
||||
insmod $KoName
|
||||
|
||||
umount $VTOY_PATH/mnt/squashfs
|
||||
umount $VTOY_PATH/mnt/iso
|
||||
umount $VTOY_PATH/mnt/fuse
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
@@ -36,6 +63,12 @@ if [ "$vtdiskname" = "unknown" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if grep -q 'device-mapper' /proc/devices; then
|
||||
vtlog "device-mapper module exist"
|
||||
else
|
||||
ventoy_os_install_dmsetup_by_fuse $vtdiskname
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
if ! [ -e $VTOY_DM_PATH ]; then
|
||||
|
@@ -18,8 +18,15 @@
|
||||
#************************************************************************************
|
||||
|
||||
$SED '1 apmedia=usbhd' -i /init
|
||||
$SED "/^ *HAVE_PARTS=/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/puppy-disk.sh" -i /init
|
||||
$SED "/^ *HAVE_PARTS=/a\ HAVE_PARTS='ventoy|iso9660'" -i /init
|
||||
|
||||
if $GREP -q 'HAVE_PARTS=' /init; then
|
||||
$SED "/^ *HAVE_PARTS=/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/puppy-disk.sh" -i /init
|
||||
$SED "/^ *HAVE_PARTS=/a\ HAVE_PARTS='ventoy|iso9660'" -i /init
|
||||
elif $GREP -q 'LESSPARTS=' /init; then
|
||||
$SED "/^ *LESSPARTS=/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/puppy-disk.sh" -i /init
|
||||
$SED "/^ *LESSPARTS=/a\ LESSPARTS='ventoy|iso9660'" -i /init
|
||||
fi
|
||||
|
||||
|
||||
if [ -f /DISTRO_SPECS ]; then
|
||||
if ! [ -d /dev ]; then
|
||||
|
91
IMG/cpio/ventoy/hook/debian/pyabr-disk.sh
Normal file
91
IMG/cpio/ventoy/hook/debian/pyabr-disk.sh
Normal file
@@ -0,0 +1,91 @@
|
||||
#!/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_fuse() {
|
||||
vtlog "ventoy_os_install_dmsetup_by_fuse $*"
|
||||
|
||||
mkdir -p $VTOY_PATH/mnt/fuse $VTOY_PATH/mnt/iso $VTOY_PATH/mnt/squashfs
|
||||
|
||||
vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_dm_table
|
||||
vtoy_fuse_iso -f $VTOY_PATH/ventoy_dm_table -m $VTOY_PATH/mnt/fuse
|
||||
|
||||
mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso $VTOY_PATH/mnt/iso
|
||||
mount -t squashfs $VTOY_PATH/mnt/iso/pyabr/01-core.sb $VTOY_PATH/mnt/squashfs
|
||||
|
||||
KoName=$(ls $VTOY_PATH/mnt/squashfs/lib/modules/$2/kernel/drivers/md/dm-mod.ko*)
|
||||
vtlog "insmod $KoName"
|
||||
insmod $KoName
|
||||
|
||||
umount $VTOY_PATH/mnt/squashfs
|
||||
umount $VTOY_PATH/mnt/iso
|
||||
umount $VTOY_PATH/mnt/fuse
|
||||
}
|
||||
|
||||
while [ -n "Y" ]; do
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
if [ -r /proc/sys/kernel/hotplug ]; then
|
||||
echo /sbin/mdev > /proc/sys/kernel/hotplug
|
||||
fi
|
||||
mdev -s
|
||||
sleep 1
|
||||
else
|
||||
if check_usb_disk_ready "$vtdiskname"; then
|
||||
vtlog "check_usb_disk_ready $vtdiskname ok"
|
||||
break
|
||||
else
|
||||
vtlog "check_usb_disk_ready $vtdiskname error"
|
||||
if [ -r /proc/sys/kernel/hotplug ]; then
|
||||
echo /sbin/mdev > /proc/sys/kernel/hotplug
|
||||
fi
|
||||
mdev -s
|
||||
sleep 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
PATH=$VTPATH_OLD
|
||||
exit 0
|
||||
fi
|
||||
|
||||
modprobe fuse
|
||||
modprobe cuse
|
||||
|
||||
vtKver=$(uname -r)
|
||||
ventoy_os_install_dmsetup_by_fuse $vtdiskname $vtKver
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
||||
set_ventoy_hook_finish
|
20
IMG/cpio/ventoy/hook/debian/pyabr-hook.sh
Normal file
20
IMG/cpio/ventoy/hook/debian/pyabr-hook.sh
Normal 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 "/find_data/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/pyabr-disk.sh" -i /init
|
@@ -23,6 +23,11 @@ $SED "s#.*livefs_root=.*find_livefs.*#$BUSYBOX_PATH/mount -t iso9660 /dev/mapper
|
||||
if [ -e /init ] && $GREP -q '^mountroot$' /init; then
|
||||
echo "Here before mountroot ..." >> $VTLOG
|
||||
$SED "/^mountroot$/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/disk_mount_hook.sh" -i /init
|
||||
|
||||
if [ -f /scripts/init-premount/ORDER ]; then
|
||||
$SED "/\/scripts\/init-premount\/partitioning/,+1d" -i /scripts/init-premount/ORDER
|
||||
fi
|
||||
|
||||
else
|
||||
echo "Use default hook ..." >> $VTLOG
|
||||
ventoy_systemd_udevd_work_around
|
||||
|
@@ -41,18 +41,18 @@ ventoy_os_install_dmsetup() {
|
||||
fi
|
||||
|
||||
# install md-modules
|
||||
LINE=$($GREP ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list)
|
||||
LINE=$($GREP -i ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list)
|
||||
if [ $? -eq 0 ]; then
|
||||
LINTCNT=$($GREP -c ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list)
|
||||
LINTCNT=$($GREP -i -c ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list)
|
||||
if [ $LINTCNT -gt 1 ]; then
|
||||
vtlog "more than one pkgs, need to filter..."
|
||||
VER=$($BUSYBOX_PATH/uname -r)
|
||||
|
||||
LINE=$($GREP ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list | $GREP $VER)
|
||||
LINTCNT=$($GREP ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list | $GREP -c $VER)
|
||||
LINE=$($GREP -i ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list | $GREP -i $VER)
|
||||
LINTCNT=$($GREP -i ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list | $GREP -i -c $VER)
|
||||
if [ $LINTCNT -gt 1 ]; then
|
||||
vtlog "Still more than one pkgs, use the first one..."
|
||||
LINE=$($GREP ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list | $GREP -m1 $VER)
|
||||
LINE=$($GREP -i ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list | $GREP -i -m1 $VER)
|
||||
fi
|
||||
fi
|
||||
install_udeb_from_line "$LINE" ${vt_usb_disk}
|
||||
|
@@ -37,9 +37,17 @@ ventoy_os_install_dmsetup_by_fuse() {
|
||||
|
||||
mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso $VTOY_PATH/mnt/iso
|
||||
|
||||
sfsfile=$(ls $VTOY_PATH/mnt/iso/adrv_veket*.sfs)
|
||||
|
||||
mount -t squashfs $sfsfile $VTOY_PATH/mnt/squashfs
|
||||
for sfsfile in $(ls $VTOY_PATH/mnt/iso/*drv_veket*.sfs); do
|
||||
mount -t squashfs $sfsfile $VTOY_PATH/mnt/squashfs
|
||||
if [ -d $VTOY_PATH/mnt/squashfs/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*)
|
||||
vtlog "insmod $KoName"
|
||||
|
@@ -35,7 +35,7 @@ ventoy_get_debian_distro() {
|
||||
fi
|
||||
|
||||
if [ -e /init ]; then
|
||||
if $GREP -q PUPPYSFS /init; then
|
||||
if $EGREP -q 'PUPPYSFS|PUPPYFILE' /init; then
|
||||
if $GREP -q VEKETSFS /init; then
|
||||
echo 'veket'; return
|
||||
else
|
||||
@@ -86,7 +86,17 @@ ventoy_get_debian_distro() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -e /opt/kerio ]; then
|
||||
echo 'kerio'; return
|
||||
fi
|
||||
|
||||
if $GREP -q 'mocaccino' /proc/version; then
|
||||
echo 'mocaccino'; return
|
||||
fi
|
||||
|
||||
if $GREP -q '/pyabr/' /proc/cmdline; then
|
||||
echo 'pyabr'; return
|
||||
fi
|
||||
|
||||
echo 'default'
|
||||
}
|
||||
|
7
IMG/cpio/ventoy/hook/default/export.list
Normal file
7
IMG/cpio/ventoy/hook/default/export.list
Normal file
@@ -0,0 +1,7 @@
|
||||
preseed/file
|
||||
debian-installer/locale
|
||||
console-keymaps-at/keymap
|
||||
keyboard-configuration/xkb-keymap
|
||||
keyboard-configuration/layout
|
||||
simple-cdd/profiles
|
||||
vga
|
83
IMG/cpio/ventoy/hook/easystartup/disk_hook.sh
Normal file
83
IMG/cpio/ventoy/hook/easystartup/disk_hook.sh
Normal file
@@ -0,0 +1,83 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2021, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
get_rhel_ver() {
|
||||
if uname -m | grep -q '64'; then
|
||||
machine='_X64'
|
||||
fi
|
||||
|
||||
if grep -q '6[.]1' /etc/redhat-release; then
|
||||
echo "RHAS6U1$machine"; return
|
||||
fi
|
||||
|
||||
echo "RHAS6U1$machine"
|
||||
}
|
||||
|
||||
install_dm_mod_ko() {
|
||||
# dump iso file location
|
||||
vtoydm -i -f $VTOY_PATH/ventoy_image_map -d ${vtdiskname} > $VTOY_PATH/iso_file_list
|
||||
|
||||
sysver=$(get_rhel_ver)
|
||||
vtlog "sysver=$sysver"
|
||||
|
||||
LINE=$(grep "$sysver" -n -m1 $VTOY_PATH/iso_file_list | awk -F: '{print $1}')
|
||||
vtlog "LINE=$LINE"
|
||||
|
||||
LINE=$(sed -n "$LINE,\$p" $VTOY_PATH/iso_file_list | grep -m1 'initrd.img')
|
||||
vtlog "LINE=$LINE"
|
||||
|
||||
sector=$(echo $LINE | $AWK '{print $(NF-1)}')
|
||||
length=$(echo $LINE | $AWK '{print $NF}')
|
||||
vtlog "sector=$sector length=$length"
|
||||
|
||||
mkdir xxx
|
||||
vtoydm -e -f $VTOY_PATH/ventoy_image_map -d ${vtdiskname} -s $sector -l $length -o ./xxx.img
|
||||
|
||||
cd xxx/
|
||||
zcat ../xxx.img | cpio -idmu
|
||||
ko=$(find -name dm-mod.ko*)
|
||||
vtlog "ko=$ko ..."
|
||||
insmod $ko
|
||||
|
||||
cd ../
|
||||
rm -f xxx.img
|
||||
rm -rf xxx
|
||||
}
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
vtlog "vtdiskname=$vtdiskname ..."
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if grep -q 'device-mapper' /proc/devices; then
|
||||
vtlog "device-mapper module check ko"
|
||||
else
|
||||
install_dm_mod_ko
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
ln -s /dev/dm-0 /dev/root
|
||||
|
||||
PATH=$VTPATH_OLD
|
23
IMG/cpio/ventoy/hook/easystartup/ventoy-hook.sh
Normal file
23
IMG/cpio/ventoy/hook/easystartup/ventoy-hook.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2021, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "s#^CDROM=.*#CDROM=/dev/dm-0#" -i /init
|
||||
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/easystartup/ventoy-initqueue.sh /initqueue/ventoy.sh
|
20
IMG/cpio/ventoy/hook/easystartup/ventoy-initqueue.sh
Normal file
20
IMG/cpio/ventoy/hook/easystartup/ventoy-initqueue.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2021, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
/ventoy/busybox/sh /ventoy/hook/easystartup/disk_hook.sh $*
|
@@ -49,7 +49,12 @@ done
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
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
|
||||
vtLABEL=$($BUSYBOX_PATH/blkid /dev/$vtDM | $SED 's/.*LABEL="\([^"]*\)".*/\1/')
|
||||
vtlog "vtLABEL is $vtLABEL"
|
||||
|
@@ -19,9 +19,6 @@
|
||||
|
||||
. $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
|
||||
VTKS="inst.ks=file:$VTOY_PATH/autoinstall"
|
||||
else
|
||||
@@ -40,7 +37,25 @@ else
|
||||
done
|
||||
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
|
||||
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
|
||||
echo "vtInstDD=$vtInstDD" >> $VTLOG
|
||||
|
||||
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
|
||||
else
|
||||
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/dm-0 $VTKS $vtInstDD#" -i /lib/dracut-lib.sh
|
||||
fi
|
||||
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/dm-0 $VTKS $vtInstDD#" -i /lib/dracut-lib.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-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
|
||||
$SED "1 a $BUSYBOX_PATH/sh $VTOY_PATH/hook/openEuler/ventoy-make-link.sh" -i /sbin/dmsquash-live-root
|
||||
fi
|
||||
|
||||
# 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
|
||||
fi
|
||||
|
||||
|
@@ -29,20 +29,11 @@ if is_inotify_ventoy_part $3; then
|
||||
|
||||
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 ..."
|
||||
|
||||
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/')
|
||||
vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||
|
21
IMG/cpio/ventoy/hook/openEuler/ventoy-overlay.sh
Normal file
21
IMG/cpio/ventoy/hook/openEuler/ventoy-overlay.sh
Normal 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
|
29
IMG/cpio/ventoy/hook/openEuler/ventoy-repo.sh
Normal file
29
IMG/cpio/ventoy/hook/openEuler/ventoy-repo.sh
Normal 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
|
@@ -26,3 +26,13 @@ ventoy_add_udev_rule "$VTOY_PATH/hook/rhel6/udev_disk_hook.sh %k"
|
||||
|
||||
#loop7 was used by loader
|
||||
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
|
||||
|
@@ -40,7 +40,26 @@ else
|
||||
done
|
||||
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
|
||||
for vtDud in $(ls $VTOY_PATH/ventoy_dud*); do
|
||||
@@ -50,9 +69,9 @@ fi
|
||||
echo "vtInstDD=$vtInstDD" >> $VTLOG
|
||||
|
||||
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
|
||||
$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
|
||||
|
||||
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-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
|
||||
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
|
||||
|
@@ -41,12 +41,8 @@ if is_inotify_ventoy_part $3; then
|
||||
vtlog "find ventoy partition ..."
|
||||
|
||||
vtReplaceOpt=noreplace
|
||||
|
||||
if $GREP -q el8 /proc/version && [ -f /etc/system-release ]; then
|
||||
vtRhel8Ver=$($SED "s#.*8\.\([0-9]*\).*#\1#" /etc/system-release)
|
||||
if [ $vtRhel8Ver -ge 3 ]; then
|
||||
vtReplaceOpt=""
|
||||
fi
|
||||
if [ -f /lib/dracut/hooks/pre-pivot/99-ventoy-repo.sh ]; then
|
||||
vtReplaceOpt=""
|
||||
fi
|
||||
|
||||
$BUSYBOX_PATH/sh $VTOY_PATH/hook/default/udev_disk_hook.sh $3 $vtReplaceOpt
|
||||
|
21
IMG/cpio/ventoy/hook/rhel7/ventoy-overlay.sh
Normal file
21
IMG/cpio/ventoy/hook/rhel7/ventoy-overlay.sh
Normal 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
|
29
IMG/cpio/ventoy/hook/rhel7/ventoy-repo.sh
Normal file
29
IMG/cpio/ventoy/hook/rhel7/ventoy-repo.sh
Normal 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
|
42
IMG/cpio/ventoy/hook/suse/udev_setup_hook.sh
Normal file
42
IMG/cpio/ventoy/hook/suse/udev_setup_hook.sh
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /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/}"
|
||||
|
||||
if $GREP -q 'mediacheck=1' /proc/cmdline; then
|
||||
ventoy_copy_device_mapper "${vtdiskname}"
|
||||
fi
|
@@ -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
|
||||
$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
|
||||
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
|
||||
echo "SUSE" >> $VTLOG
|
||||
ventoy_systemd_udevd_work_around
|
||||
|
@@ -57,14 +57,14 @@ vterr() {
|
||||
|
||||
|
||||
is_ventoy_hook_finished() {
|
||||
[ -e $VTOY_PATH/hook_finish ]
|
||||
[ -e $VTOY_PATH/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)
|
||||
if [ $? -eq 0 ]; then
|
||||
echo ${line%%#*}
|
||||
@@ -74,7 +74,7 @@ get_ventoy_disk_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
|
||||
echo ${line##*#}
|
||||
else
|
||||
@@ -83,8 +83,9 @@ get_ventoy_iso_name() {
|
||||
}
|
||||
|
||||
wait_for_usb_disk_ready() {
|
||||
while [ -n "Y" ]; do
|
||||
usb_disk=$(get_ventoy_disk_name)
|
||||
vtloop=0
|
||||
while [ -n "Y" ]; do
|
||||
usb_disk=$(get_ventoy_disk_name)
|
||||
vtlog "wait_for_usb_disk_ready $usb_disk ..."
|
||||
|
||||
if echo $usb_disk | $EGREP -q "nvme|mmc|nbd"; then
|
||||
@@ -95,13 +96,20 @@ wait_for_usb_disk_ready() {
|
||||
|
||||
if [ -e "${vtpart2}" ]; then
|
||||
vtlog "wait_for_usb_disk_ready $usb_disk finish"
|
||||
break
|
||||
else
|
||||
$SLEEP 0.3
|
||||
fi
|
||||
done
|
||||
break
|
||||
else
|
||||
let vtloop=vtloop+1
|
||||
if [ $vtloop -gt 2 ]; then
|
||||
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() {
|
||||
if echo $1 | $EGREP -q "nvme|mmc|nbd"; then
|
||||
vtpart2=${1}p2
|
||||
@@ -554,6 +562,31 @@ ventoy_create_dev_ventoy_part() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
ventoy_create_chromeos_ventoy_part() {
|
||||
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | $GREP ventoy | $SED 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
|
||||
$BUSYBOX_PATH/mknod -m 0666 /dev/ventoy b $blkdev_num
|
||||
|
||||
if [ -e /vtoy_dm_table ]; then
|
||||
vtPartid=1
|
||||
|
||||
$CAT /vtoy_dm_table | while read vtline; do
|
||||
echo $vtline > /ventoy/dm_table_part${vtPartid}
|
||||
|
||||
if [ $vtPartid -eq $1 ]; then
|
||||
$VTOY_PATH/tool/dmsetup create ventoy${vtPartid} /ventoy/dm_table_part${vtPartid} --readonly
|
||||
else
|
||||
$VTOY_PATH/tool/dmsetup create ventoy${vtPartid} /ventoy/dm_table_part${vtPartid}
|
||||
fi
|
||||
|
||||
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | $GREP ventoy${vtPartid} | $SED 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
|
||||
$BUSYBOX_PATH/mknod -m 0666 /dev/ventoy${vtPartid} b $blkdev_num
|
||||
|
||||
vtPartid=$(expr $vtPartid + 1)
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
is_inotify_ventoy_part() {
|
||||
if echo $1 | $GREP -q "2$"; then
|
||||
if ! [ -e /sys/block/$1 ]; then
|
||||
@@ -610,3 +643,10 @@ ventoy_extract_vtloopex() {
|
||||
|
||||
cd $vtCurPwd
|
||||
}
|
||||
|
||||
ventoy_check_install_module_xz() {
|
||||
if [ -f "${1}.xz" ]; then
|
||||
$BUSYBOX_PATH/xz -d "${1}.xz"
|
||||
$BUSYBOX_PATH/insmod "$1"
|
||||
fi
|
||||
}
|
||||
|
@@ -185,7 +185,7 @@ ventoy_unpack_injection() {
|
||||
|
||||
if [ -e $VTOY_PATH/ventoy_injection ]; then
|
||||
echo "### decompress injection ... ###" >>$VTLOG
|
||||
ventoy_unpack_injection > $VTOY_PATH/injection.log 2>&1
|
||||
ventoy_unpack_injection > $VTOY_PATH/injection.log 2>&1
|
||||
fi
|
||||
|
||||
|
||||
|
201
IMG/cpio/ventoy/loop/cloudready/ventoy-hook.sh
Normal file
201
IMG/cpio/ventoy/loop/cloudready/ventoy-hook.sh
Normal file
@@ -0,0 +1,201 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2021, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
vtlog "####### $0 $* ########"
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
mkdir /sys
|
||||
mount -t sysfs sys /sys
|
||||
mdev -s
|
||||
sleep 2
|
||||
|
||||
while [ -n "Y" ]; do
|
||||
usb_disk=$(get_ventoy_disk_name)
|
||||
|
||||
if echo $usb_disk | egrep -q "nvme|mmc|nbd"; then
|
||||
vtpart2=${usb_disk}p2
|
||||
else
|
||||
vtpart2=${usb_disk}2
|
||||
fi
|
||||
|
||||
if [ -e "${vtpart2}" ]; then
|
||||
break
|
||||
else
|
||||
sleep 2
|
||||
mdev -s
|
||||
fi
|
||||
done
|
||||
|
||||
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})
|
||||
echo -n $vtDM > /ventoy/vtDM
|
||||
|
||||
ventoy_create_chromeos_ventoy_part 3
|
||||
mdev -s
|
||||
|
||||
vtlog "copy out the e2fsck program ..."
|
||||
|
||||
copy_lib() {
|
||||
cp -a /ventoy_rdroot/usr/lib64/$1 /usr/lib64/
|
||||
cp -a /ventoy_rdroot/lib64/$1 /lib64/
|
||||
}
|
||||
|
||||
mkdir /ventoy_rdroot
|
||||
mkdir -p /lib /lib64 /usr/lib64 /sbin
|
||||
|
||||
mount -o ro /dev/ventoy3 /ventoy_rdroot >>$VTLOG 2>&1
|
||||
cp -a /ventoy_rdroot/sbin/e2fsck /sbin/
|
||||
cp -a /ventoy_rdroot/sbin/dmsetup /sbin/
|
||||
|
||||
copy_lib libext2fs*
|
||||
copy_lib libcom_err*
|
||||
copy_lib libe2p*
|
||||
copy_lib libblk*
|
||||
copy_lib libuuid*
|
||||
copy_lib libdl.*
|
||||
copy_lib libdl-*
|
||||
copy_lib libc.*
|
||||
copy_lib libc-*
|
||||
copy_lib libpthread*
|
||||
copy_lib ld-*
|
||||
copy_lib libdevmapper*
|
||||
copy_lib libudev*
|
||||
copy_lib libm.*
|
||||
copy_lib libm-*
|
||||
copy_lib librt*
|
||||
copy_lib libpopt*
|
||||
copy_lib libgpg-error*
|
||||
copy_lib libselinux*
|
||||
copy_lib libsepol*
|
||||
copy_lib libpcre*
|
||||
copy_lib libcap*
|
||||
copy_lib libdw*
|
||||
copy_lib libgcc_s*
|
||||
copy_lib libattr*
|
||||
copy_lib libelf*
|
||||
copy_lib libz.*
|
||||
copy_lib libbz2*
|
||||
copy_lib libgcrypt*
|
||||
copy_lib liblvm*
|
||||
|
||||
ln -s /lib64/libdevmapper.so.1.02 /lib64/libdevmapper.so.1.02.1
|
||||
|
||||
umount /ventoy_rdroot
|
||||
|
||||
vtlog "========================================="
|
||||
vtlog "===== e2fsck -y -v /dev/ventoy1 ====="
|
||||
e2fsck -y -v /dev/ventoy1 >>$VTLOG 2>&1
|
||||
#vtlog "===== e2fsck -y -v /dev/ventoy3 ====="
|
||||
#e2fsck -y -v /dev/ventoy3 >>$VTLOG 2>&1
|
||||
vtlog "===== e2fsck -y -v /dev/ventoy8 ====="
|
||||
e2fsck -y -v /dev/ventoy8 >>$VTLOG 2>&1
|
||||
vtlog "========================================="
|
||||
|
||||
/sbin/dmsetup --version >>$VTLOG 2>&1
|
||||
veritysetup --version >>$VTLOG 2>&1
|
||||
|
||||
vtlog "proc devtmpfs ..."
|
||||
mkdir /newdev
|
||||
mount -t devtmpfs dev /newdev
|
||||
|
||||
cp -a /dev/mapper/ventoy* /newdev/mapper/
|
||||
cp -a /dev/ventoy* /newdev/
|
||||
|
||||
|
||||
vtshortname="${vtdiskname#/dev/}"
|
||||
mv /newdev/${vtshortname} /newdev/backup_${vtshortname}
|
||||
cp -a /dev/ventoy /newdev/${vtshortname}
|
||||
|
||||
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
|
||||
if [ -e /dev/ventoy${i} ]; then
|
||||
if echo $vtdiskname | egrep -q "nvme|mmc|nbd"; then
|
||||
vtpart=p$i
|
||||
else
|
||||
vtpart=$i
|
||||
fi
|
||||
|
||||
if [ -e /newdev/${vtshortname}${vtpart} ]; then
|
||||
mv /newdev/${vtshortname}${vtpart} /newdev/backup_${vtshortname}${vtpart}
|
||||
fi
|
||||
|
||||
cp -a /dev/ventoy${i} /newdev/${vtshortname}${vtpart}
|
||||
|
||||
if [ $i -eq 3 ]; then
|
||||
[ -e /dev/${vtshortname}${vtpart} ] && rm -f /dev/${vtshortname}${vtpart}
|
||||
cp -a /dev/ventoy${i} /dev/${vtshortname}${vtpart}
|
||||
vt_root_dev="/dev/${vtshortname}${vtpart}"
|
||||
vtlog "vt_root_dev=$vt_root_dev"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# if grep -q 'DM=' /proc/cmdline; then
|
||||
# vtlog "Boot verified image ..."
|
||||
|
||||
# dmP1=$(sed "s/.*\(0 [0-9]* verity\).*/\1/" /proc/cmdline)
|
||||
# alg=$(sed "s/.*alg=\([^ ]*\).*/\1/" /proc/cmdline)
|
||||
# hexdigest=$(sed "s/.*root_hexdigest=\([0-9a-fA-F][0-9a-fA-F]*\).*/\1/" /proc/cmdline)
|
||||
# salt=$(sed "s/.*salt=\([0-9a-fA-F][0-9a-fA-F]*\).*/\1/" /proc/cmdline)
|
||||
# hashstart=$(sed "s/.*hashstart=\([0-9][0-9]*\).*/\1/" /proc/cmdline)
|
||||
|
||||
#512 to 4096
|
||||
# blocknum=$(expr $hashstart / 8)
|
||||
# hashoffset=$(expr $hashstart \* 512)
|
||||
|
||||
# vtlog "veritysetup create vroot $vt_root_dev $vt_root_dev $hexdigest --data-block-size=4096 --hash-block-size=4096 --data-blocks=$blocknum --hash-offset=$hashoffset --salt=$salt --hash=$alg --no-superblock --format=0"
|
||||
# veritysetup create vroot $vt_root_dev $vt_root_dev $hexdigest --data-block-size=4096 --hash-block-size=4096 --data-blocks=$blocknum --hash-offset=$hashoffset --salt=$salt --hash=$alg --no-superblock --format=0
|
||||
# sleep 1
|
||||
# mdev -s
|
||||
|
||||
# blkdev_num=$(dmsetup ls | grep vroot | sed 's/.*(\([0-9][0-9]*\),[^0-9]*\([0-9][0-9]*\).*/\1:\2/')
|
||||
# vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||
# vtlog "blkdev_num=$blkdev_num vtDM=$vtDM"
|
||||
|
||||
# if [ -b /dev/$vtDM ]; then
|
||||
# veritysetup status vroot >> $VTLOG 2>&1
|
||||
# mount -o ro /dev/$vtDM /ventoy_rdroot
|
||||
# else
|
||||
# mount -o ro $vt_root_dev /ventoy_rdroot
|
||||
# fi
|
||||
# else
|
||||
# vtlog "Boot normal image ..."
|
||||
# mount -o ro $vt_root_dev /ventoy_rdroot
|
||||
# fi
|
||||
|
||||
vtlog "Boot normal image ..."
|
||||
mount -o ro $vt_root_dev /ventoy_rdroot
|
||||
|
||||
cp -a $VTLOG /newdev/ventoy.log
|
||||
umount /newdev
|
||||
mount -t devtmpfs dev /ventoy_rdroot/dev
|
||||
|
||||
PATH=$VTPATH_OLD
|
47
IMG/cpio/ventoy/loop/esysrescue/ventoy-disk.sh
Normal file
47
IMG/cpio/ventoy/loop/esysrescue/ventoy-disk.sh
Normal 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"
|
||||
|
||||
ventoy_create_dev_ventoy_part
|
||||
|
||||
ln -s "../../ventoy1" /dev/disk/by-label/ESYSRESCUE
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
||||
set_ventoy_hook_finish
|
26
IMG/cpio/ventoy/loop/esysrescue/ventoy-hook.sh
Normal file
26
IMG/cpio/ventoy/loop/esysrescue/ventoy-hook.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "/maybe_break premount/i\ $BUSYBOX_PATH/sh $VTOY_PATH/loop/esysrescue/ventoy-disk.sh" -i /init
|
||||
|
||||
if [ -f /scripts/casper-bottom/09format_esr_data_partition ]; then
|
||||
$SED '/mkfs.vfat.*edev.3/icp -a /dev/dm-3 /dev/ventoy3' -i /scripts/casper-bottom/09format_esr_data_partition
|
||||
fi
|
201
IMG/cpio/ventoy/loop/fydeos/ventoy-hook.sh
Normal file
201
IMG/cpio/ventoy/loop/fydeos/ventoy-hook.sh
Normal file
@@ -0,0 +1,201 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2021, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
vtlog "####### $0 $* ########"
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
mkdir /sys
|
||||
mount -t sysfs sys /sys
|
||||
mdev -s
|
||||
sleep 2
|
||||
|
||||
while [ -n "Y" ]; do
|
||||
usb_disk=$(get_ventoy_disk_name)
|
||||
|
||||
if echo $usb_disk | egrep -q "nvme|mmc|nbd"; then
|
||||
vtpart2=${usb_disk}p2
|
||||
else
|
||||
vtpart2=${usb_disk}2
|
||||
fi
|
||||
|
||||
if [ -e "${vtpart2}" ]; then
|
||||
break
|
||||
else
|
||||
sleep 2
|
||||
mdev -s
|
||||
fi
|
||||
done
|
||||
|
||||
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})
|
||||
echo -n $vtDM > /ventoy/vtDM
|
||||
|
||||
ventoy_create_chromeos_ventoy_part 3
|
||||
mdev -s
|
||||
|
||||
vtlog "copy out the e2fsck program ..."
|
||||
|
||||
copy_lib() {
|
||||
cp -a /ventoy_rdroot/usr/lib64/$1 /usr/lib64/
|
||||
cp -a /ventoy_rdroot/lib64/$1 /lib64/
|
||||
}
|
||||
|
||||
mkdir /ventoy_rdroot
|
||||
mkdir -p /lib /lib64 /usr/lib64 /sbin
|
||||
|
||||
mount -o ro /dev/ventoy3 /ventoy_rdroot >>$VTLOG 2>&1
|
||||
cp -a /ventoy_rdroot/sbin/e2fsck /sbin/
|
||||
cp -a /ventoy_rdroot/sbin/dmsetup /sbin/
|
||||
|
||||
copy_lib libext2fs*
|
||||
copy_lib libcom_err*
|
||||
copy_lib libe2p*
|
||||
copy_lib libblk*
|
||||
copy_lib libuuid*
|
||||
copy_lib libdl.*
|
||||
copy_lib libdl-*
|
||||
copy_lib libc.*
|
||||
copy_lib libc-*
|
||||
copy_lib libpthread*
|
||||
copy_lib ld-*
|
||||
copy_lib libdevmapper*
|
||||
copy_lib libudev*
|
||||
copy_lib libm.*
|
||||
copy_lib libm-*
|
||||
copy_lib librt*
|
||||
copy_lib libpopt*
|
||||
copy_lib libgpg-error*
|
||||
copy_lib libselinux*
|
||||
copy_lib libsepol*
|
||||
copy_lib libpcre*
|
||||
copy_lib libcap*
|
||||
copy_lib libdw*
|
||||
copy_lib libgcc_s*
|
||||
copy_lib libattr*
|
||||
copy_lib libelf*
|
||||
copy_lib libz.*
|
||||
copy_lib libbz2*
|
||||
copy_lib libgcrypt*
|
||||
copy_lib liblvm*
|
||||
|
||||
ln -s /lib64/libdevmapper.so.1.02 /lib64/libdevmapper.so.1.02.1
|
||||
|
||||
umount /ventoy_rdroot
|
||||
|
||||
vtlog "========================================="
|
||||
vtlog "===== e2fsck -y -v /dev/ventoy1 ====="
|
||||
e2fsck -y -v /dev/ventoy1 >>$VTLOG 2>&1
|
||||
#vtlog "===== e2fsck -y -v /dev/ventoy3 ====="
|
||||
#e2fsck -y -v /dev/ventoy3 >>$VTLOG 2>&1
|
||||
vtlog "===== e2fsck -y -v /dev/ventoy8 ====="
|
||||
e2fsck -y -v /dev/ventoy8 >>$VTLOG 2>&1
|
||||
vtlog "========================================="
|
||||
|
||||
/sbin/dmsetup --version >>$VTLOG 2>&1
|
||||
veritysetup --version >>$VTLOG 2>&1
|
||||
|
||||
vtlog "proc devtmpfs ..."
|
||||
mkdir /newdev
|
||||
mount -t devtmpfs dev /newdev
|
||||
|
||||
cp -a /dev/mapper/ventoy* /newdev/mapper/
|
||||
cp -a /dev/ventoy* /newdev/
|
||||
|
||||
|
||||
vtshortname="${vtdiskname#/dev/}"
|
||||
mv /newdev/${vtshortname} /newdev/backup_${vtshortname}
|
||||
cp -a /dev/ventoy /newdev/${vtshortname}
|
||||
|
||||
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
|
||||
if [ -e /dev/ventoy${i} ]; then
|
||||
if echo $vtdiskname | egrep -q "nvme|mmc|nbd"; then
|
||||
vtpart=p$i
|
||||
else
|
||||
vtpart=$i
|
||||
fi
|
||||
|
||||
if [ -e /newdev/${vtshortname}${vtpart} ]; then
|
||||
mv /newdev/${vtshortname}${vtpart} /newdev/backup_${vtshortname}${vtpart}
|
||||
fi
|
||||
|
||||
cp -a /dev/ventoy${i} /newdev/${vtshortname}${vtpart}
|
||||
|
||||
if [ $i -eq 3 ]; then
|
||||
[ -e /dev/${vtshortname}${vtpart} ] && rm -f /dev/${vtshortname}${vtpart}
|
||||
cp -a /dev/ventoy${i} /dev/${vtshortname}${vtpart}
|
||||
vt_root_dev="/dev/${vtshortname}${vtpart}"
|
||||
vtlog "vt_root_dev=$vt_root_dev"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# if grep -q 'DM=' /proc/cmdline; then
|
||||
# vtlog "Boot verified image ..."
|
||||
|
||||
# dmP1=$(sed "s/.*\(0 [0-9]* verity\).*/\1/" /proc/cmdline)
|
||||
# alg=$(sed "s/.*alg=\([^ ]*\).*/\1/" /proc/cmdline)
|
||||
# hexdigest=$(sed "s/.*root_hexdigest=\([0-9a-fA-F][0-9a-fA-F]*\).*/\1/" /proc/cmdline)
|
||||
# salt=$(sed "s/.*salt=\([0-9a-fA-F][0-9a-fA-F]*\).*/\1/" /proc/cmdline)
|
||||
# hashstart=$(sed "s/.*hashstart=\([0-9][0-9]*\).*/\1/" /proc/cmdline)
|
||||
|
||||
#512 to 4096
|
||||
# blocknum=$(expr $hashstart / 8)
|
||||
# hashoffset=$(expr $hashstart \* 512)
|
||||
|
||||
# vtlog "veritysetup create vroot $vt_root_dev $vt_root_dev $hexdigest --data-block-size=4096 --hash-block-size=4096 --data-blocks=$blocknum --hash-offset=$hashoffset --salt=$salt --hash=$alg --no-superblock --format=0"
|
||||
# veritysetup create vroot $vt_root_dev $vt_root_dev $hexdigest --data-block-size=4096 --hash-block-size=4096 --data-blocks=$blocknum --hash-offset=$hashoffset --salt=$salt --hash=$alg --no-superblock --format=0
|
||||
# sleep 1
|
||||
# mdev -s
|
||||
|
||||
# blkdev_num=$(dmsetup ls | grep vroot | sed 's/.*(\([0-9][0-9]*\),[^0-9]*\([0-9][0-9]*\).*/\1:\2/')
|
||||
# vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||
# vtlog "blkdev_num=$blkdev_num vtDM=$vtDM"
|
||||
|
||||
# if [ -b /dev/$vtDM ]; then
|
||||
# veritysetup status vroot >> $VTLOG 2>&1
|
||||
# mount -o ro /dev/$vtDM /ventoy_rdroot
|
||||
# else
|
||||
# mount -o ro $vt_root_dev /ventoy_rdroot
|
||||
# fi
|
||||
# else
|
||||
# vtlog "Boot normal image ..."
|
||||
# mount -o ro $vt_root_dev /ventoy_rdroot
|
||||
# fi
|
||||
|
||||
vtlog "Boot normal image ..."
|
||||
mount -o ro $vt_root_dev /ventoy_rdroot
|
||||
|
||||
cp -a $VTLOG /newdev/ventoy.log
|
||||
umount /newdev
|
||||
mount -t devtmpfs dev /ventoy_rdroot/dev
|
||||
|
||||
PATH=$VTPATH_OLD
|
@@ -34,9 +34,19 @@ else
|
||||
vtBit=32
|
||||
fi
|
||||
|
||||
xz -d $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko.xz
|
||||
insmod $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko
|
||||
if grep -q "device-mapper" /proc/devices; then
|
||||
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
|
||||
|
||||
|
@@ -27,7 +27,83 @@ vtlog "####### $0 $* ########"
|
||||
|
||||
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)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
@@ -44,6 +120,11 @@ echo -n $vtDM > /ventoy/vtDM
|
||||
|
||||
ventoy_create_dev_ventoy_part
|
||||
mdev -s
|
||||
check_mkdev_node
|
||||
|
||||
|
||||
mkdir /ventoy_rdroot
|
||||
mount /dev/ventoy2 /ventoy_rdroot
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
||||
|
@@ -19,12 +19,10 @@
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$BUSYBOX_PATH/mkdir /sys
|
||||
$BUSYBOX_PATH/mount -t proc proc /proc
|
||||
$BUSYBOX_PATH/mount -t sysfs sys /sys
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
$BUSYBOX_PATH/mdev -s
|
||||
mkdir /sys
|
||||
mount -t sysfs sys /sys
|
||||
mdev -s
|
||||
|
||||
#$BUSYBOX_PATH/sh $VTOY_PATH/loop/openwrt/ventoy-disk.sh
|
||||
|
||||
exec $BUSYBOX_PATH/sh
|
||||
sh $VTOY_PATH/loop/openwrt/ventoy-disk.sh
|
||||
|
@@ -52,12 +52,30 @@ ventoy_get_os_type() {
|
||||
fi
|
||||
fi
|
||||
|
||||
# Debian :
|
||||
if $GREP -q '[Dd]ebian' /proc/version; then
|
||||
echo 'debian'; return
|
||||
|
||||
# Ubuntu : do the same process with debian
|
||||
elif $GREP -q '[Uu]buntu' /proc/version; then
|
||||
echo 'debian'; return
|
||||
|
||||
# Deepin : do the same process with debian
|
||||
elif $GREP -q '[Dd]eepin' /proc/version; then
|
||||
echo 'debian'; return
|
||||
|
||||
# rhel5/CentOS5 and all other distributions based on them
|
||||
if $GREP -q 'el5' /proc/version; then
|
||||
elif $GREP -q 'el5' /proc/version; then
|
||||
echo 'rhel5'; return
|
||||
|
||||
# rhel6/CentOS6 and all other distributions based on them
|
||||
elif $GREP -q 'el6' /proc/version; then
|
||||
if [ -f /sbin/detectcd ]; then
|
||||
if $GREP -q -i 'LENOVO-EasyStartup' /sbin/detectcd; then
|
||||
echo 'easystartup'; return
|
||||
fi
|
||||
fi
|
||||
|
||||
echo 'rhel6'; return
|
||||
|
||||
# rhel7/CentOS7/rhel8/CentOS8 and all other distributions based on them
|
||||
@@ -72,18 +90,6 @@ ventoy_get_os_type() {
|
||||
elif $GREP -q '\.fc[0-9][0-9]\.' /proc/version; then
|
||||
echo 'rhel7'; return
|
||||
|
||||
# Debian :
|
||||
elif $GREP -q '[Dd]ebian' /proc/version; then
|
||||
echo 'debian'; return
|
||||
|
||||
# Ubuntu : do the same process with debian
|
||||
elif $GREP -q '[Uu]buntu' /proc/version; then
|
||||
echo 'debian'; return
|
||||
|
||||
# Deepin : do the same process with debian
|
||||
elif $GREP -q '[Dd]eepin' /proc/version; then
|
||||
echo 'debian'; return
|
||||
|
||||
# SUSE
|
||||
elif $GREP -q 'SUSE' /proc/version; then
|
||||
echo 'suse'; return
|
||||
@@ -153,6 +159,12 @@ ventoy_get_os_type() {
|
||||
echo 'rhel7'; return
|
||||
elif $GREP -q 'openEuler' /etc/os-release; then
|
||||
echo 'openEuler'; return
|
||||
elif $GREP -q 'fuyu' /etc/os-release; then
|
||||
echo 'openEuler'; return
|
||||
elif $GREP -q 'deepin' /etc/os-release; then
|
||||
echo 'debian'; return
|
||||
elif $GREP -q 'chinauos' /etc/os-release; then
|
||||
echo 'debian'; return
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -336,9 +348,36 @@ if [ -e "$VTOY_PATH/hook/$VTOS/ventoy-hook.sh" ]; then
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if $GREP -q -i Untangle /proc/version; then
|
||||
for vtPara in $($CAT /proc/cmdline); do
|
||||
vtItemkey=$(echo $vtPara | $AWK -F= '{print $1}')
|
||||
vtItemVal=$(echo $vtPara | $AWK -F= '{print $2}')
|
||||
if $GREP -q -m1 "^$vtItemkey\$" $VTOY_PATH/hook/default/export.list; then
|
||||
vtEnvExport="$vtEnvExport $vtItemkey=$vtItemVal"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "================ env export ================" >> $VTLOG
|
||||
echo $vtEnvExport >> $VTLOG
|
||||
echo "============================================" >> $VTLOG
|
||||
fi
|
||||
|
||||
|
||||
|
||||
####################################################################
|
||||
# #
|
||||
# Step 3 : Check for debug break #
|
||||
# Step 3 : Run LiveInjection Hook #
|
||||
# #
|
||||
####################################################################
|
||||
if [ -f "/live_injection_7ed136ec_7a61_4b54_adc3_ae494d5106ea/hook.sh" ]; then
|
||||
$BUSYBOX_PATH/sh "/live_injection_7ed136ec_7a61_4b54_adc3_ae494d5106ea/hook.sh" $VTOS
|
||||
fi
|
||||
|
||||
|
||||
####################################################################
|
||||
# #
|
||||
# Step 4 : Check for debug break #
|
||||
# #
|
||||
####################################################################
|
||||
if [ "$VTOY_BREAK_LEVEL" = "03" ] || [ "$VTOY_BREAK_LEVEL" = "13" ]; then
|
||||
@@ -355,7 +394,7 @@ fi
|
||||
|
||||
####################################################################
|
||||
# #
|
||||
# Step 4 : Hand over to real init #
|
||||
# Step 5 : Hand over to real init #
|
||||
# #
|
||||
####################################################################
|
||||
$BUSYBOX_PATH/umount /proc
|
||||
@@ -384,7 +423,12 @@ for vtinit in $user_rdinit /init /sbin/init /linuxrc; do
|
||||
if [ -f "$VTOY_PATH/hook/$VTOS/ventoy-before-init.sh" ]; then
|
||||
$BUSYBOX_PATH/sh "$VTOY_PATH/hook/$VTOS/ventoy-before-init.sh"
|
||||
fi
|
||||
exec "$vtinit"
|
||||
|
||||
if [ -z "$vtEnvExport" ]; then
|
||||
exec "$vtinit"
|
||||
else
|
||||
exec env $vtEnvExport "$vtinit"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
@@ -127,8 +127,8 @@ ventoy_get_os_type() {
|
||||
|
||||
# Deepin : do the same process with debian
|
||||
elif $GREP -q '[Dd]eepin' /proc/version; then
|
||||
echo 'debian'; return
|
||||
|
||||
echo 'debian'; return
|
||||
|
||||
# SUSE
|
||||
elif $GREP -q 'SUSE' /proc/version; then
|
||||
echo 'suse'; return
|
||||
@@ -198,6 +198,12 @@ ventoy_get_os_type() {
|
||||
echo 'rhel7'; return
|
||||
elif $GREP -q 'openEuler' /etc/os-release; then
|
||||
echo 'openEuler'; return
|
||||
elif $GREP -q 'fuyu' /etc/os-release; then
|
||||
echo 'openEuler'; return
|
||||
elif $GREP -q 'deepin' /etc/os-release; then
|
||||
echo 'debian'; return
|
||||
elif $GREP -q 'chinauos' /etc/os-release; then
|
||||
echo 'debian'; return
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@@ -81,6 +81,18 @@ else
|
||||
echo "use unsquashfs_32" >>$VTLOG
|
||||
$BUSYBOX_PATH/cp -a $VTOY_PATH/tool/unsquashfs_32 $VTOY_PATH/tool/vtoy_unsquashfs
|
||||
fi
|
||||
|
||||
|
||||
if $GREP -q 64 $VTOY_PATH/ventoy_arch; then
|
||||
echo "use veritysetup64" >>$VTLOG
|
||||
if [ -f $VTOY_PATH/tool/veritysetup64 ]; then
|
||||
$BUSYBOX_PATH/cp -a $VTOY_PATH/tool/veritysetup64 $VTOY_PATH/tool/veritysetup
|
||||
fi
|
||||
else
|
||||
echo "use veritysetup32" >>$VTLOG
|
||||
|
||||
if [ -f $VTOY_PATH/tool/veritysetup32 ]; then
|
||||
$BUSYBOX_PATH/cp -a $VTOY_PATH/tool/veritysetup32 $VTOY_PATH/tool/veritysetup
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@@ -21,19 +21,19 @@ ln -s sbin/init linuxrc
|
||||
|
||||
cd ventoy
|
||||
|
||||
find ./loop | cpio -o -H newc>loop.cpio
|
||||
find ./loop | cpio -o -H newc --owner=root:root >loop.cpio
|
||||
xz loop.cpio
|
||||
rm -rf loop
|
||||
|
||||
xz ventoy_chain.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
|
||||
rm -rf hook
|
||||
cd ..
|
||||
|
||||
find .| cpio -o -H newc>../ventoy.cpio
|
||||
find .| cpio -o -H newc --owner=root:root >../ventoy.cpio
|
||||
|
||||
cd ..
|
||||
rm -rf cpio_tmp
|
||||
@@ -62,14 +62,17 @@ cp -a $VENTOY_PATH/VBLADE/vblade-master/vblade_64 tool/
|
||||
cp -a $VENTOY_PATH/LZIP/lunzip32 tool/
|
||||
cp -a $VENTOY_PATH/LZIP/lunzip64 tool/
|
||||
|
||||
cp -a $VENTOY_PATH/cryptsetup/veritysetup32 tool/
|
||||
cp -a $VENTOY_PATH/cryptsetup/veritysetup64 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
|
||||
rm -rf tool
|
||||
|
||||
cd ..
|
||||
find .| cpio -o -H newc>../ventoy_x86.cpio
|
||||
find .| cpio -o -H newc --owner=root:root >../ventoy_x86.cpio
|
||||
|
||||
cd ..
|
||||
rm -rf cpio_tmp
|
||||
@@ -95,12 +98,12 @@ cp -a $VENTOY_PATH/LZIP/lunzipaa64 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
|
||||
rm -rf tool
|
||||
|
||||
cd ..
|
||||
find .| cpio -o -H newc>../ventoy_arm64.cpio
|
||||
find .| cpio -o -H newc --owner=root:root >../ventoy_arm64.cpio
|
||||
|
||||
cd ..
|
||||
rm -rf cpio_tmp
|
||||
@@ -127,12 +130,12 @@ rm -f tool/vtoytool/00/vtoytool_aa64
|
||||
|
||||
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
|
||||
rm -rf tool
|
||||
|
||||
cd ..
|
||||
find .| cpio -o -H newc>../ventoy_mips64.cpio
|
||||
find .| cpio -o -H newc --owner=root:root >../ventoy_mips64.cpio
|
||||
|
||||
cd ..
|
||||
rm -rf cpio_tmp
|
||||
|
@@ -14,7 +14,7 @@ for dir in $(ls); do
|
||||
cd ..
|
||||
done
|
||||
|
||||
find . | cpio -o -H newc>../vtloopex.cpio
|
||||
find . | cpio -o -H newc --owner=root:root >../vtloopex.cpio
|
||||
|
||||
cd ..
|
||||
|
||||
|
Binary file not shown.
BIN
IMG/vtloopex/lakka/vtloopex/dm-mod/5.10.35/64/dax.ko.xz
Normal file
BIN
IMG/vtloopex/lakka/vtloopex/dm-mod/5.10.35/64/dax.ko.xz
Normal file
Binary file not shown.
BIN
IMG/vtloopex/lakka/vtloopex/dm-mod/5.10.35/64/dm-mod.ko.xz
Normal file
BIN
IMG/vtloopex/lakka/vtloopex/dm-mod/5.10.35/64/dm-mod.ko.xz
Normal file
Binary file not shown.
@@ -4,6 +4,7 @@ size=1024
|
||||
fstype=ext4
|
||||
label=casper-rw
|
||||
config=''
|
||||
outputfile=persistence.dat
|
||||
|
||||
print_usage() {
|
||||
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 ' -l label, default is casper-rw'
|
||||
echo ' -c configfile name inside the persistence file. File content is "/ union"'
|
||||
echo ' -o outputfile name, default is persistence.dat'
|
||||
echo ''
|
||||
}
|
||||
|
||||
@@ -28,6 +30,9 @@ while [ -n "$1" ]; do
|
||||
elif [ "$1" = "-c" ]; then
|
||||
shift
|
||||
config=$1
|
||||
elif [ "$1" = "-o" ]; then
|
||||
shift
|
||||
outputfile=$1
|
||||
elif [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
||||
print_usage
|
||||
exit 0
|
||||
@@ -69,13 +74,17 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$outputdir" != "persistence.dat" ]; then
|
||||
mkdir -p "$(dirname "$outputfile")"
|
||||
fi
|
||||
|
||||
# 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
|
||||
|
||||
freeloop=$(losetup -f)
|
||||
|
||||
losetup $freeloop persistence.dat
|
||||
losetup $freeloop "$outputfile"
|
||||
|
||||
mkfs -t $fstype $fsopt -L $label $freeloop
|
||||
|
||||
|
127
INSTALL/ExtendPersistentImg.sh
Normal file
127
INSTALL/ExtendPersistentImg.sh
Normal file
@@ -0,0 +1,127 @@
|
||||
#!/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 "^-"; then
|
||||
mode="Shrink"
|
||||
size=${size:1}
|
||||
else
|
||||
mode="Extend"
|
||||
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)
|
||||
|
||||
if [ "$mode" = "Extend" ]; then
|
||||
total=$(expr $fsMB + $size)
|
||||
else
|
||||
if [ $fsMB -le $size ]; then
|
||||
echo "File size of $file is less than ${size}MB."
|
||||
exit 1
|
||||
fi
|
||||
total=$(expr $fsMB - $size)
|
||||
fi
|
||||
|
||||
|
||||
magic=$(hexdump -n3 -e '3/1 "%02X"' $file)
|
||||
if [ "$magic" = "584653" ]; then
|
||||
if [ "$mode" = "Shrink" ]; then
|
||||
echo "Shrink is not supported for XFS filesystem."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
if [ "$mode" = "Extend" ]; then
|
||||
echo "$mode dat file... (current is ${fsMB}MB, append ${size}MB, total ${total}MB)"
|
||||
dd if=/dev/zero bs=1M count=$size status=none >> "$file"
|
||||
sync
|
||||
else
|
||||
echo "$mode dat file... (current is ${fsMB}MB, reduce ${size}MB, finally ${total}MB)"
|
||||
fi
|
||||
|
||||
|
||||
freeloop=$(losetup -f)
|
||||
losetup $freeloop "$file"
|
||||
|
||||
if [ "$cmd" = "resize2fs" ]; then
|
||||
echo "$mode ext filesystem by resize2fs ..."
|
||||
echo "resize2fs $freeloop ${total}M"
|
||||
e2fsck -f $freeloop
|
||||
resize2fs $freeloop ${total}M
|
||||
ret=$?
|
||||
else
|
||||
echo "$mode xfs filesystem by xfs_growfs ..."
|
||||
tmpdir=$(mktemp -d)
|
||||
mount $freeloop $tmpdir
|
||||
xfs_growfs $freeloop
|
||||
ret=$?
|
||||
umount $tmpdir && rm -rf $tmpdir
|
||||
fi
|
||||
|
||||
losetup -d $freeloop
|
||||
|
||||
if [ $ret -eq 0 -a "$mode" = "Shrink" ]; then
|
||||
echo "truncate persistent file ..."
|
||||
truncate "$file" -s ${total}M
|
||||
ret=$?
|
||||
fi
|
||||
|
||||
echo ""
|
||||
if [ $ret -eq 0 ]; then
|
||||
echo "======= SUCCESS ========="
|
||||
else
|
||||
echo "======= FAILED ========="
|
||||
fi
|
||||
echo ""
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user