mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-03-13 21:12:58 -04:00
Merge branch 'ventoy:master' into master
This commit is contained in:
commit
ef6af2695f
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']
|
||||
|
17
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
17
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
@ -21,7 +21,7 @@ body:
|
||||
attributes:
|
||||
label: Ventoy Version
|
||||
description: What version of ventoy are you running?
|
||||
placeholder: 1.0.46
|
||||
placeholder: 1.0.62
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
@ -63,6 +63,13 @@ body:
|
||||
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:
|
||||
@ -73,6 +80,14 @@ body:
|
||||
- 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:
|
||||
|
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;
|
||||
@ -483,6 +490,8 @@ EFI_STATUS EFIAPI ventoy_block_io_read_real
|
||||
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)
|
||||
{
|
||||
cur_flag = AllocatePool(secNum * sizeof(ventoy_sector_flag));
|
||||
@ -618,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;
|
||||
}
|
||||
@ -670,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))
|
||||
{
|
||||
@ -712,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))
|
||||
{
|
||||
@ -741,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,
|
||||
@ -875,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;
|
||||
|
||||
@ -981,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)
|
||||
@ -1006,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;
|
||||
@ -1027,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;
|
||||
}
|
||||
@ -1039,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);
|
||||
|
||||
@ -1056,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;
|
||||
|
||||
@ -1071,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;
|
||||
}
|
||||
@ -1098,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;
|
||||
@ -1114,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;
|
||||
}
|
||||
@ -1133,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)
|
||||
{
|
||||
@ -1153,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;
|
||||
|
||||
@ -1179,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]
|
||||
|
@ -69,7 +69,7 @@ hash_file (grub_file_t file, const gcry_md_spec_t *hash, void *result)
|
||||
grub_uint64_t total = 0;
|
||||
void *context;
|
||||
grub_uint8_t *readbuf;
|
||||
#define BUF_SIZE 4096
|
||||
#define BUF_SIZE 1024 * 1024
|
||||
readbuf = grub_malloc (BUF_SIZE);
|
||||
if (!readbuf)
|
||||
return grub_errno;
|
||||
@ -94,7 +94,7 @@ hash_file (grub_file_t file, const gcry_md_spec_t *hash, void *result)
|
||||
{
|
||||
total += r;
|
||||
div = grub_divmod64(total * 100, (grub_uint64_t)file->size, &ro);
|
||||
grub_printf("\rCalculating %d%% ", (int)div);
|
||||
grub_printf("\rCalculating %s %d%% ", hash->name, (int)div);
|
||||
grub_refresh();
|
||||
}
|
||||
}
|
||||
@ -105,7 +105,7 @@ hash_file (grub_file_t file, const gcry_md_spec_t *hash, void *result)
|
||||
grub_free (context);
|
||||
if (progress)
|
||||
{
|
||||
grub_printf("\rCalculating 100%% \n\r\n");
|
||||
grub_printf("\rCalculating %s 100%% \n\r\n", hash->name);
|
||||
grub_refresh();
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
@ -224,6 +224,8 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
|
||||
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)
|
||||
@ -282,8 +284,12 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
|
||||
continue;
|
||||
}
|
||||
for (j = 0; j < hash->mdlen; j++)
|
||||
grub_printf ("%02x", ((grub_uint8_t *) result)[j]);
|
||||
{
|
||||
grub_printf ("%02x", ((grub_uint8_t *) result)[j]);
|
||||
len += grub_snprintf(hashsum + len, sizeof(hashsum) - len, "%02x", ((grub_uint8_t *) result)[j]);
|
||||
}
|
||||
grub_printf (" %s\n", args[i]);
|
||||
grub_env_set("VT_LAST_CHECK_SUM", hashsum);
|
||||
}
|
||||
|
||||
if (unread)
|
||||
|
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;
|
||||
|
@ -59,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)
|
||||
{
|
||||
@ -90,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)
|
||||
@ -98,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. */
|
||||
|
||||
@ -116,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,
|
||||
@ -156,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));
|
||||
}
|
||||
|
||||
@ -255,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
|
||||
|
@ -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)
|
||||
|
@ -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,6 +33,9 @@
|
||||
#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;
|
||||
@ -42,10 +45,24 @@ 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. */
|
||||
#define DEFAULT_ENTRY_ERROR_DELAY_MS 2500
|
||||
@ -381,10 +398,65 @@ 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;
|
||||
char g_ventoy_theme_path[256] = {0};
|
||||
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);
|
||||
|
||||
if (g_ventoy_theme_path[0])
|
||||
{
|
||||
grub_env_set("theme", g_ventoy_theme_path);
|
||||
}
|
||||
|
||||
g_ventoy_tip_msg1 = g_ventoy_tip_msg2 = NULL;
|
||||
if (e && e->id && grub_strncmp(e->id, "VID_", 4) == 0)
|
||||
{
|
||||
g_ventoy_theme_path[0] = 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)
|
||||
{
|
||||
g_ventoy_theme_path[0] = 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);
|
||||
}
|
||||
@ -598,7 +670,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;
|
||||
}
|
||||
@ -680,6 +752,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. */
|
||||
@ -732,13 +805,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:
|
||||
@ -746,7 +819,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':
|
||||
@ -754,7 +827,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':
|
||||
@ -763,7 +836,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':
|
||||
@ -772,7 +845,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':
|
||||
@ -807,71 +880,23 @@ 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:
|
||||
menu_fini ();
|
||||
@ -917,6 +942,40 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
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;
|
||||
@ -1010,6 +1069,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;
|
||||
}
|
@ -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 */
|
||||
|
@ -53,6 +53,26 @@ void ventoy_debug(const char *fmt, ...)
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
void ventoy_str_tolower(char *str)
|
||||
{
|
||||
while (*str)
|
||||
{
|
||||
*str = grub_tolower(*str);
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
void ventoy_str_toupper(char *str)
|
||||
{
|
||||
while (*str)
|
||||
{
|
||||
*str = grub_toupper(*str);
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ventoy_strcmp(const char *pattern, const char *str)
|
||||
{
|
||||
while (*pattern && *str)
|
||||
|
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)
|
||||
@ -69,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"); \
|
||||
@ -194,6 +199,18 @@ 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_start 0
|
||||
@ -212,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;
|
||||
|
||||
@ -429,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()
|
||||
|
||||
|
||||
@ -531,8 +562,26 @@ 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);
|
||||
@ -548,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);
|
||||
@ -792,6 +842,7 @@ typedef struct install_template
|
||||
int pathlen;
|
||||
char isopath[256];
|
||||
|
||||
int timeout;
|
||||
int autosel;
|
||||
int cursel;
|
||||
int templatenum;
|
||||
@ -823,6 +874,7 @@ typedef struct persistence_config
|
||||
int pathlen;
|
||||
char isopath[256];
|
||||
|
||||
int timeout;
|
||||
int autosel;
|
||||
int cursel;
|
||||
int backendnum;
|
||||
@ -844,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
|
||||
|
||||
@ -875,6 +941,7 @@ typedef struct custom_boot
|
||||
typedef struct conf_replace
|
||||
{
|
||||
int pathlen;
|
||||
int img;
|
||||
char isopath[256];
|
||||
char orgconf[256];
|
||||
char newconf[256];
|
||||
@ -939,6 +1006,7 @@ 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;
|
||||
@ -983,6 +1051,8 @@ extern grub_uint32_t g_ventoy_plat_data;
|
||||
#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);
|
||||
@ -996,6 +1066,7 @@ 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 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);
|
||||
@ -1006,6 +1077,8 @@ int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, gr
|
||||
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_set_theme_path(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_select_theme_cfg(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);
|
||||
@ -1017,6 +1090,7 @@ int ventoy_get_disk_guid(const char *filename, grub_uint8_t *guid, grub_uint8_t
|
||||
grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_unix_ko_fillmap(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_unix_fill_image_desc(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_unix_gzip_newko(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_unix_freebsd_ver(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
@ -1053,5 +1127,31 @@ int ventoy_chain_file_read(const char *path, int offset, int len, void *buf);
|
||||
grub_env_export(env);\
|
||||
}
|
||||
|
||||
#define ret_goto_end(a) ret = a; goto end;
|
||||
|
||||
extern ventoy_grub_param *g_grub_param;
|
||||
|
||||
#pragma pack(1)
|
||||
#define VENTOY_UNIX_SEG_MAGIC0 0x11223344
|
||||
#define VENTOY_UNIX_SEG_MAGIC1 0x55667788
|
||||
#define VENTOY_UNIX_SEG_MAGIC2 0x99aabbcc
|
||||
#define VENTOY_UNIX_SEG_MAGIC3 0xddeeff00
|
||||
#define VENTOY_UNIX_MAX_SEGNUM 40960
|
||||
struct g_ventoy_seg {
|
||||
grub_uint64_t seg_start_bytes;
|
||||
grub_uint64_t seg_end_bytes;
|
||||
};
|
||||
|
||||
struct g_ventoy_map{
|
||||
grub_uint32_t magic1[4];
|
||||
grub_uint32_t magic2[4];
|
||||
grub_uint64_t segnum;
|
||||
grub_uint64_t disksize;
|
||||
grub_uint8_t diskuuid[16];
|
||||
struct g_ventoy_seg seglist[VENTOY_UNIX_MAX_SEGNUM];
|
||||
grub_uint32_t magic3[4];
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
#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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,7 @@ static install_template *g_install_template_head = NULL;
|
||||
static dud *g_dud_head = NULL;
|
||||
static menu_password *g_pwd_head = NULL;
|
||||
static persistence_config *g_persistence_head = NULL;
|
||||
static menu_tip *g_menu_tip_head = NULL;
|
||||
static menu_alias *g_menu_alias_head = NULL;
|
||||
static menu_class *g_menu_class_head = NULL;
|
||||
static custom_boot *g_custom_boot_head = NULL;
|
||||
@ -56,6 +57,7 @@ static auto_memdisk *g_auto_memdisk_head = NULL;
|
||||
static image_list *g_image_list_head = NULL;
|
||||
static conf_replace *g_conf_replace_head = NULL;
|
||||
|
||||
static int g_theme_id = 0;
|
||||
static int g_theme_num = 0;
|
||||
static theme_list *g_theme_head = NULL;
|
||||
static int g_theme_random = vtoy_theme_random_boot_second;
|
||||
@ -280,6 +282,7 @@ static int ventoy_plugin_theme_check(VTOY_JSON *json, const char *isodisk)
|
||||
static int ventoy_plugin_theme_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
const char *value;
|
||||
char val[64];
|
||||
char filepath[256];
|
||||
VTOY_JSON *node = NULL;
|
||||
theme_list *tail = NULL;
|
||||
@ -365,6 +368,18 @@ static int ventoy_plugin_theme_entry(VTOY_JSON *json, const char *isodisk)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
grub_snprintf(val, sizeof(val), "%d", g_theme_num);
|
||||
grub_env_set("VTOY_THEME_COUNT", val);
|
||||
grub_env_export("VTOY_THEME_COUNT");
|
||||
if (g_theme_num > 0)
|
||||
{
|
||||
vtoy_json_get_int(json->pstChild, "default_file", &g_theme_id);
|
||||
if (g_theme_id > g_theme_num || g_theme_id < 0)
|
||||
{
|
||||
g_theme_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "gfxmode");
|
||||
if (value)
|
||||
@ -601,6 +616,7 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
|
||||
{
|
||||
int pathnum = 0;
|
||||
int autosel = 0;
|
||||
int timeout = 0;
|
||||
char *pos = NULL;
|
||||
const char *iso = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
@ -637,6 +653,18 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
|
||||
grub_printf("autosel: %d [FAIL]\n", autosel);
|
||||
}
|
||||
}
|
||||
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "timeout", &timeout))
|
||||
{
|
||||
if (timeout >= 0)
|
||||
{
|
||||
grub_printf("timeout: %d [OK]\n", timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("timeout: %d [FAIL]\n", timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -661,6 +689,18 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
|
||||
grub_printf("autosel: %d [FAIL]\n", autosel);
|
||||
}
|
||||
}
|
||||
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "timeout", &timeout))
|
||||
{
|
||||
if (timeout >= 0)
|
||||
{
|
||||
grub_printf("timeout: %d [OK]\n", timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("timeout: %d [FAIL]\n", timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -681,6 +721,7 @@ static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk
|
||||
int type = 0;
|
||||
int pathnum = 0;
|
||||
int autosel = 0;
|
||||
int timeout = 0;
|
||||
const char *iso = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
install_template *node = NULL;
|
||||
@ -728,6 +769,7 @@ static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk
|
||||
node->templatenum = pathnum;
|
||||
|
||||
node->autosel = -1;
|
||||
node->timeout = -1;
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "autosel", &autosel))
|
||||
{
|
||||
if (autosel >= 0 && autosel <= pathnum)
|
||||
@ -735,6 +777,14 @@ static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk
|
||||
node->autosel = autosel;
|
||||
}
|
||||
}
|
||||
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "timeout", &timeout))
|
||||
{
|
||||
if (timeout >= 0)
|
||||
{
|
||||
node->timeout = timeout;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_install_template_head)
|
||||
{
|
||||
@ -1174,6 +1224,7 @@ static int ventoy_plugin_pwd_check(VTOY_JSON *json, const char *isodisk)
|
||||
static int ventoy_plugin_persistence_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int autosel = 0;
|
||||
int timeout = 0;
|
||||
int pathnum = 0;
|
||||
char *pos = NULL;
|
||||
const char *iso = NULL;
|
||||
@ -1212,6 +1263,18 @@ static int ventoy_plugin_persistence_check(VTOY_JSON *json, const char *isodisk)
|
||||
grub_printf("autosel: %d [FAIL]\n", autosel);
|
||||
}
|
||||
}
|
||||
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "timeout", &timeout))
|
||||
{
|
||||
if (timeout >= 0)
|
||||
{
|
||||
grub_printf("timeout: %d [OK]\n", timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("timeout: %d [FAIL]\n", timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1230,6 +1293,7 @@ static int ventoy_plugin_persistence_check(VTOY_JSON *json, const char *isodisk)
|
||||
static int ventoy_plugin_persistence_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int autosel = 0;
|
||||
int timeout = 0;
|
||||
int pathnum = 0;
|
||||
const char *iso = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
@ -1272,6 +1336,7 @@ static int ventoy_plugin_persistence_entry(VTOY_JSON *json, const char *isodisk)
|
||||
node->backendnum = pathnum;
|
||||
|
||||
node->autosel = -1;
|
||||
node->timeout = -1;
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "autosel", &autosel))
|
||||
{
|
||||
if (autosel >= 0 && autosel <= pathnum)
|
||||
@ -1279,6 +1344,14 @@ static int ventoy_plugin_persistence_entry(VTOY_JSON *json, const char *isodisk)
|
||||
node->autosel = autosel;
|
||||
}
|
||||
}
|
||||
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "timeout", &timeout))
|
||||
{
|
||||
if (timeout >= 0)
|
||||
{
|
||||
node->timeout = timeout;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_persistence_head)
|
||||
{
|
||||
@ -1417,6 +1490,207 @@ static int ventoy_plugin_menualias_entry(VTOY_JSON *json, const char *isodisk)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_plugin_menutip_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int type;
|
||||
const char *path = NULL;
|
||||
const char *tip = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
|
||||
(void)isodisk;
|
||||
|
||||
if (json->enDataType != JSON_TYPE_OBJECT)
|
||||
{
|
||||
grub_printf("Not object %d\n", json->enDataType);
|
||||
return 1;
|
||||
}
|
||||
|
||||
tip = vtoy_json_get_string_ex(json->pstChild, "left");
|
||||
if (tip)
|
||||
{
|
||||
grub_printf("left: <%s>\n", tip);
|
||||
}
|
||||
|
||||
tip = vtoy_json_get_string_ex(json->pstChild, "top");
|
||||
if (tip)
|
||||
{
|
||||
grub_printf("top: <%s>\n", tip);
|
||||
}
|
||||
|
||||
tip = vtoy_json_get_string_ex(json->pstChild, "color");
|
||||
if (tip)
|
||||
{
|
||||
grub_printf("color: <%s>\n", tip);
|
||||
}
|
||||
|
||||
pNode = vtoy_json_find_item(json->pstChild, JSON_TYPE_ARRAY, "tips");
|
||||
for (pNode = pNode->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
type = vtoy_tip_image_file;
|
||||
path = vtoy_json_get_string_ex(pNode->pstChild, "image");
|
||||
if (!path)
|
||||
{
|
||||
path = vtoy_json_get_string_ex(pNode->pstChild, "dir");
|
||||
type = vtoy_tip_directory;
|
||||
}
|
||||
|
||||
if (path && path[0] == '/')
|
||||
{
|
||||
if (vtoy_tip_image_file == type)
|
||||
{
|
||||
if (grub_strchr(path, '*'))
|
||||
{
|
||||
grub_printf("image: <%s> [ * ]\n", path);
|
||||
}
|
||||
else if (ventoy_is_file_exist("%s%s", isodisk, path))
|
||||
{
|
||||
grub_printf("image: <%s> [ OK ]\n", path);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("image: <%s> [ NOT EXIST ]\n", path);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ventoy_is_dir_exist("%s%s", isodisk, path))
|
||||
{
|
||||
grub_printf("dir: <%s> [ OK ]\n", path);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("dir: <%s> [ NOT EXIST ]\n", path);
|
||||
}
|
||||
}
|
||||
|
||||
tip = vtoy_json_get_string_ex(pNode->pstChild, "tip");
|
||||
if (tip)
|
||||
{
|
||||
grub_printf("tip: <%s>\n", tip);
|
||||
}
|
||||
else
|
||||
{
|
||||
tip = vtoy_json_get_string_ex(pNode->pstChild, "tip1");
|
||||
if (tip)
|
||||
grub_printf("tip1: <%s>\n", tip);
|
||||
else
|
||||
grub_printf("tip1: <NULL>\n");
|
||||
|
||||
tip = vtoy_json_get_string_ex(pNode->pstChild, "tip2");
|
||||
if (tip)
|
||||
grub_printf("tip2: <%s>\n", tip);
|
||||
else
|
||||
grub_printf("tip2: <NULL>\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("image: <%s> [ INVALID ]\n", path);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_plugin_menutip_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int type;
|
||||
const char *path = NULL;
|
||||
const char *tip = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
menu_tip *node = NULL;
|
||||
menu_tip *next = NULL;
|
||||
|
||||
(void)isodisk;
|
||||
|
||||
if (json->enDataType != JSON_TYPE_OBJECT)
|
||||
{
|
||||
debug("Not object %d\n", json->enDataType);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pNode = vtoy_json_find_item(json->pstChild, JSON_TYPE_ARRAY, "tips");
|
||||
if (pNode == NULL)
|
||||
{
|
||||
debug("Not tips found\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (g_menu_tip_head)
|
||||
{
|
||||
for (node = g_menu_tip_head; node; node = next)
|
||||
{
|
||||
next = node->next;
|
||||
grub_free(node);
|
||||
}
|
||||
|
||||
g_menu_tip_head = NULL;
|
||||
}
|
||||
|
||||
tip = vtoy_json_get_string_ex(json->pstChild, "left");
|
||||
if (tip)
|
||||
{
|
||||
grub_env_set("VTOY_TIP_LEFT", tip);
|
||||
}
|
||||
|
||||
tip = vtoy_json_get_string_ex(json->pstChild, "top");
|
||||
if (tip)
|
||||
{
|
||||
grub_env_set("VTOY_TIP_TOP", tip);
|
||||
}
|
||||
|
||||
tip = vtoy_json_get_string_ex(json->pstChild, "color");
|
||||
if (tip)
|
||||
{
|
||||
grub_env_set("VTOY_TIP_COLOR", tip);
|
||||
}
|
||||
|
||||
for (pNode = pNode->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
type = vtoy_tip_image_file;
|
||||
path = vtoy_json_get_string_ex(pNode->pstChild, "image");
|
||||
if (!path)
|
||||
{
|
||||
path = vtoy_json_get_string_ex(pNode->pstChild, "dir");
|
||||
type = vtoy_tip_directory;
|
||||
}
|
||||
|
||||
if (path && path[0] == '/')
|
||||
{
|
||||
node = grub_zalloc(sizeof(menu_tip));
|
||||
if (node)
|
||||
{
|
||||
node->type = type;
|
||||
node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", path);
|
||||
|
||||
tip = vtoy_json_get_string_ex(pNode->pstChild, "tip");
|
||||
if (tip)
|
||||
{
|
||||
grub_snprintf(node->tip1, 1000, "%s", tip);
|
||||
}
|
||||
else
|
||||
{
|
||||
tip = vtoy_json_get_string_ex(pNode->pstChild, "tip1");
|
||||
if (tip)
|
||||
grub_snprintf(node->tip1, 1000, "%s", tip);
|
||||
|
||||
tip = vtoy_json_get_string_ex(pNode->pstChild, "tip2");
|
||||
if (tip)
|
||||
grub_snprintf(node->tip2, 1000, "%s", tip);
|
||||
}
|
||||
|
||||
if (g_menu_tip_head)
|
||||
{
|
||||
node->next = g_menu_tip_head;
|
||||
}
|
||||
|
||||
g_menu_tip_head = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_plugin_injection_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
@ -1776,6 +2050,7 @@ static int ventoy_plugin_custom_boot_check(VTOY_JSON *json, const char *isodisk)
|
||||
|
||||
static int ventoy_plugin_conf_replace_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int img = 0;
|
||||
const char *isof = NULL;
|
||||
const char *orgf = NULL;
|
||||
const char *newf = NULL;
|
||||
@ -1813,6 +2088,11 @@ static int ventoy_plugin_conf_replace_entry(VTOY_JSON *json, const char *isodisk
|
||||
node = grub_zalloc(sizeof(conf_replace));
|
||||
if (node)
|
||||
{
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "img", &img))
|
||||
{
|
||||
node->img = img;
|
||||
}
|
||||
|
||||
node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", isof);
|
||||
grub_snprintf(node->orgconf, sizeof(node->orgconf), "%s", orgf);
|
||||
grub_snprintf(node->newconf, sizeof(node->newconf), "%s", newf);
|
||||
@ -1835,6 +2115,7 @@ static int ventoy_plugin_conf_replace_entry(VTOY_JSON *json, const char *isodisk
|
||||
|
||||
static int ventoy_plugin_conf_replace_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int img = 0;
|
||||
const char *isof = NULL;
|
||||
const char *orgf = NULL;
|
||||
const char *newf = NULL;
|
||||
@ -1904,7 +2185,7 @@ static int ventoy_plugin_conf_replace_check(VTOY_JSON *json, const char *isodisk
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("new:<%s> [OK]\n", newf);
|
||||
grub_printf("new1:<%s> [OK]\n", newf);
|
||||
}
|
||||
grub_file_close(file);
|
||||
}
|
||||
@ -1912,6 +2193,12 @@ static int ventoy_plugin_conf_replace_check(VTOY_JSON *json, const char *isodisk
|
||||
{
|
||||
grub_printf("new:<%s> [NOT Exist]\n", newf);
|
||||
}
|
||||
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "img", &img))
|
||||
{
|
||||
grub_printf("img:<%d>\n", img);
|
||||
}
|
||||
|
||||
grub_printf("\n");
|
||||
}
|
||||
}
|
||||
@ -2096,44 +2383,59 @@ static int ventoy_plugin_image_list_check(VTOY_JSON *json, const char *isodisk)
|
||||
|
||||
static plugin_entry g_plugin_entries[] =
|
||||
{
|
||||
{ "control", ventoy_plugin_control_entry, ventoy_plugin_control_check },
|
||||
{ "theme", ventoy_plugin_theme_entry, ventoy_plugin_theme_check },
|
||||
{ "auto_install", ventoy_plugin_auto_install_entry, ventoy_plugin_auto_install_check },
|
||||
{ "persistence", ventoy_plugin_persistence_entry, ventoy_plugin_persistence_check },
|
||||
{ "menu_alias", ventoy_plugin_menualias_entry, ventoy_plugin_menualias_check },
|
||||
{ "menu_class", ventoy_plugin_menuclass_entry, ventoy_plugin_menuclass_check },
|
||||
{ "injection", ventoy_plugin_injection_entry, ventoy_plugin_injection_check },
|
||||
{ "auto_memdisk", ventoy_plugin_auto_memdisk_entry, ventoy_plugin_auto_memdisk_check },
|
||||
{ "image_list", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check },
|
||||
{ "image_blacklist", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check },
|
||||
{ "conf_replace", ventoy_plugin_conf_replace_entry, ventoy_plugin_conf_replace_check },
|
||||
{ "dud", ventoy_plugin_dud_entry, ventoy_plugin_dud_check },
|
||||
{ "password", ventoy_plugin_pwd_entry, ventoy_plugin_pwd_check },
|
||||
{ "custom_boot", ventoy_plugin_custom_boot_entry, ventoy_plugin_custom_boot_check },
|
||||
{ "control", ventoy_plugin_control_entry, ventoy_plugin_control_check, 0 },
|
||||
{ "theme", ventoy_plugin_theme_entry, ventoy_plugin_theme_check, 0 },
|
||||
{ "auto_install", ventoy_plugin_auto_install_entry, ventoy_plugin_auto_install_check, 0 },
|
||||
{ "persistence", ventoy_plugin_persistence_entry, ventoy_plugin_persistence_check, 0 },
|
||||
{ "menu_alias", ventoy_plugin_menualias_entry, ventoy_plugin_menualias_check, 0 },
|
||||
{ "menu_tip", ventoy_plugin_menutip_entry, ventoy_plugin_menutip_check, 0 },
|
||||
{ "menu_class", ventoy_plugin_menuclass_entry, ventoy_plugin_menuclass_check, 0 },
|
||||
{ "injection", ventoy_plugin_injection_entry, ventoy_plugin_injection_check, 0 },
|
||||
{ "auto_memdisk", ventoy_plugin_auto_memdisk_entry, ventoy_plugin_auto_memdisk_check, 0 },
|
||||
{ "image_list", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check, 0 },
|
||||
{ "image_blacklist", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check, 0 },
|
||||
{ "conf_replace", ventoy_plugin_conf_replace_entry, ventoy_plugin_conf_replace_check, 0 },
|
||||
{ "dud", ventoy_plugin_dud_entry, ventoy_plugin_dud_check, 0 },
|
||||
{ "password", ventoy_plugin_pwd_entry, ventoy_plugin_pwd_check, 0 },
|
||||
{ "custom_boot", ventoy_plugin_custom_boot_entry, ventoy_plugin_custom_boot_check, 0 },
|
||||
};
|
||||
|
||||
static int ventoy_parse_plugin_config(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int i;
|
||||
char key[128];
|
||||
VTOY_JSON *cur = json;
|
||||
VTOY_JSON *cur = NULL;
|
||||
|
||||
grub_snprintf(g_iso_disk_name, sizeof(g_iso_disk_name), "%s", isodisk);
|
||||
|
||||
while (cur)
|
||||
for (cur = json; cur; cur = cur->pstNext)
|
||||
{
|
||||
for (i = 0; i < (int)ARRAY_SIZE(g_plugin_entries); i++)
|
||||
{
|
||||
grub_snprintf(key, sizeof(key), "%s_%s", g_plugin_entries[i].key, g_arch_mode_suffix);
|
||||
if (grub_strcmp(g_plugin_entries[i].key, cur->pcName) == 0 || grub_strcmp(key, cur->pcName) == 0)
|
||||
if (g_plugin_entries[i].flag == 0 && grub_strcmp(key, cur->pcName) == 0)
|
||||
{
|
||||
debug("Plugin entry for %s\n", g_plugin_entries[i].key);
|
||||
g_plugin_entries[i].entryfunc(cur, isodisk);
|
||||
g_plugin_entries[i].flag = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cur = cur->pstNext;
|
||||
for (cur = json; cur; cur = cur->pstNext)
|
||||
{
|
||||
for (i = 0; i < (int)ARRAY_SIZE(g_plugin_entries); i++)
|
||||
{
|
||||
if (g_plugin_entries[i].flag == 0 && grub_strcmp(g_plugin_entries[i].key, cur->pcName) == 0)
|
||||
{
|
||||
debug("Plugin entry for %s\n", g_plugin_entries[i].key);
|
||||
g_plugin_entries[i].entryfunc(cur, isodisk);
|
||||
g_plugin_entries[i].flag = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -2142,13 +2444,20 @@ static int ventoy_parse_plugin_config(VTOY_JSON *json, const char *isodisk)
|
||||
grub_err_t ventoy_cmd_load_plugin(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int ret = 0;
|
||||
int offset = 0;
|
||||
char *buf = NULL;
|
||||
grub_uint8_t *code = NULL;
|
||||
grub_file_t file;
|
||||
VTOY_JSON *json = NULL;
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
|
||||
grub_env_set("VTOY_TIP_LEFT", "10%");
|
||||
grub_env_set("VTOY_TIP_TOP", "80%+5");
|
||||
grub_env_set("VTOY_TIP_COLOR", "blue");
|
||||
grub_env_set("VTOY_TIP_ALIGN", "left");
|
||||
|
||||
file = ventoy_grub_file_open(GRUB_FILE_TYPE_LINUX_INITRD, "%s/ventoy/ventoy.json", args[0]);
|
||||
if (!file)
|
||||
{
|
||||
@ -2174,9 +2483,25 @@ grub_err_t ventoy_cmd_load_plugin(grub_extcmd_context_t ctxt, int argc, char **a
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
code = (grub_uint8_t *)buf;
|
||||
if (code[0] == 0xef && code[1] == 0xbb && code[2] == 0xbf)
|
||||
{
|
||||
offset = 3; /* Skip UTF-8 BOM */
|
||||
}
|
||||
else if ((code[0] == 0xff && code[1] == 0xfe) || (code[0] == 0xfe && code[1] == 0xff))
|
||||
{
|
||||
grub_env_set("VTOY_PLUGIN_SYNTAX_ERROR", "1");
|
||||
grub_env_export("VTOY_PLUGIN_SYNTAX_ERROR");
|
||||
|
||||
ret = vtoy_json_parse(json, buf);
|
||||
grub_env_set("VTOY_PLUGIN_ENCODE_ERROR", "1");
|
||||
grub_env_export("VTOY_PLUGIN_ENCODE_ERROR");
|
||||
|
||||
debug("Failed to parse json string %d\n", ret);
|
||||
grub_free(buf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = vtoy_json_parse(json, buf + offset);
|
||||
if (ret)
|
||||
{
|
||||
grub_env_set("VTOY_PLUGIN_SYNTAX_ERROR", "1");
|
||||
@ -2205,6 +2530,15 @@ grub_err_t ventoy_cmd_load_plugin(grub_extcmd_context_t ctxt, int argc, char **a
|
||||
}
|
||||
}
|
||||
|
||||
if (g_menu_tip_head)
|
||||
{
|
||||
grub_env_set("VTOY_MENU_TIP_ENABLE", "1");
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_env_unset("VTOY_MENU_TIP_ENABLE");
|
||||
}
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
@ -2465,6 +2799,29 @@ const char * ventoy_plugin_get_menu_alias(int type, const char *isopath)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const menu_tip * ventoy_plugin_get_menu_tip(int type, const char *isopath)
|
||||
{
|
||||
int len;
|
||||
menu_tip *node = NULL;
|
||||
|
||||
if (!g_menu_tip_head)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = (int)grub_strlen(isopath);
|
||||
for (node = g_menu_tip_head; node; node = node->next)
|
||||
{
|
||||
if (node->type == type && node->pathlen &&
|
||||
node->pathlen == len && ventoy_strcmp(node->isopath, isopath) == 0)
|
||||
{
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char * ventoy_plugin_get_menu_class(int type, const char *name, const char *path)
|
||||
{
|
||||
int namelen;
|
||||
@ -2891,7 +3248,7 @@ grub_err_t ventoy_cmd_plugin_check_json(grub_extcmd_context_t ctxt, int argc, ch
|
||||
grub_snprintf(key, sizeof(key), "%s_%s", args[1], g_arch_mode_suffix);
|
||||
for (node = json->pstChild; node; node = node->pstNext)
|
||||
{
|
||||
if (grub_strcmp(node->pcName, args[1]) == 0 || grub_strcmp(node->pcName, key) == 0)
|
||||
if (grub_strcmp(node->pcName, key) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -2899,8 +3256,19 @@ grub_err_t ventoy_cmd_plugin_check_json(grub_extcmd_context_t ctxt, int argc, ch
|
||||
|
||||
if (!node)
|
||||
{
|
||||
grub_printf("%s is NOT found in ventoy.json\n", args[1]);
|
||||
goto end;
|
||||
for (node = json->pstChild; node; node = node->pstNext)
|
||||
{
|
||||
if (grub_strcmp(node->pcName, args[1]) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!node)
|
||||
{
|
||||
grub_printf("%s is NOT found in ventoy.json\n", args[1]);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < (int)ARRAY_SIZE(g_plugin_entries); i++)
|
||||
@ -2923,6 +3291,65 @@ end:
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_select_theme_cfg(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int pos = 0;
|
||||
int bufsize = 0;
|
||||
char *name = NULL;
|
||||
char *buf = NULL;
|
||||
theme_list *node = NULL;
|
||||
|
||||
(void)argc;
|
||||
(void)args;
|
||||
(void)ctxt;
|
||||
|
||||
if (g_theme_single_file[0])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (g_theme_num < 2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bufsize = (g_theme_num + 1) * 1024;
|
||||
buf = grub_malloc(bufsize);
|
||||
if (!buf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (node = g_theme_head; node; node = node->next)
|
||||
{
|
||||
name = grub_strstr(node->theme.path, ")/");
|
||||
if (name)
|
||||
{
|
||||
name++;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = node->theme.path;
|
||||
}
|
||||
|
||||
pos += grub_snprintf(buf + pos, bufsize - pos,
|
||||
"menuentry \"%s\" --class=debug_theme_item --class=debug_theme_select --class=F5tool {\n"
|
||||
"vt_set_theme_path \"%s\"\n"
|
||||
"}\n",
|
||||
name, node->theme.path);
|
||||
}
|
||||
|
||||
pos += grub_snprintf(buf + pos, bufsize - pos,
|
||||
"menuentry 'Return to previous menu [Esc]' --class=vtoyret VTOY_RET {\n"
|
||||
"echo 'Return ...'\n"
|
||||
"}\n");
|
||||
|
||||
grub_script_execute_sourcecode(buf);
|
||||
grub_free(buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_set_theme(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
grub_uint32_t i = 0;
|
||||
@ -2947,6 +3374,17 @@ grub_err_t ventoy_cmd_set_theme(grub_extcmd_context_t ctxt, int argc, char **arg
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (g_theme_id > 0 && g_theme_id <= g_theme_num)
|
||||
{
|
||||
for (i = 0; i < (grub_uint32_t)(g_theme_id - 1) && node; i++)
|
||||
{
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
grub_env_set("theme", node->theme.path);
|
||||
goto end;
|
||||
}
|
||||
|
||||
grub_memset(&datetime, 0, sizeof(datetime));
|
||||
grub_get_datetime(&datetime);
|
||||
@ -2978,7 +3416,25 @@ grub_err_t ventoy_cmd_set_theme(grub_extcmd_context_t ctxt, int argc, char **arg
|
||||
grub_env_set("theme", node->theme.path);
|
||||
|
||||
end:
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
extern char g_ventoy_theme_path[256];
|
||||
grub_err_t ventoy_cmd_set_theme_path(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
(void)argc;
|
||||
(void)ctxt;
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
g_ventoy_theme_path[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_snprintf(g_ventoy_theme_path, sizeof(g_ventoy_theme_path), "%s", args[0]);
|
||||
}
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,11 @@ char *g_conf_new_data = NULL;
|
||||
int g_mod_new_len = 0;
|
||||
char *g_mod_new_data = NULL;
|
||||
|
||||
int g_mod_search_magic = 0;
|
||||
|
||||
int g_ko_fillmap_len = 0;
|
||||
char *g_ko_fillmap_data = NULL;
|
||||
|
||||
grub_uint64_t g_mod_override_offset = 0;
|
||||
grub_uint64_t g_conf_override_offset = 0;
|
||||
|
||||
@ -82,6 +87,15 @@ static grub_uint32_t ventoy_unix_get_override_chunk_count(void)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
||||
if (g_ko_fillmap_len > 0)
|
||||
{
|
||||
count += (g_ko_fillmap_len / 512);
|
||||
if ((g_ko_fillmap_len % 512) > 0)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
@ -121,15 +135,50 @@ static grub_uint32_t ventoy_unix_get_virt_chunk_size(void)
|
||||
return size;
|
||||
}
|
||||
|
||||
static void ventoy_unix_fill_override_data( grub_uint64_t isosize, void *override)
|
||||
static void ventoy_unix_fill_map_data(ventoy_chain_head *chain, struct g_ventoy_map *map)
|
||||
{
|
||||
grub_uint32_t i;
|
||||
ventoy_img_chunk *chunk = NULL;
|
||||
|
||||
debug("Fill unix map data: <%llu> <%u> %p\n",
|
||||
(unsigned long long)chain->os_param.vtoy_disk_size, g_img_chunk_list.cur_chunk, map);
|
||||
|
||||
map->magic1[0] = map->magic2[0] = VENTOY_UNIX_SEG_MAGIC0;
|
||||
map->magic1[1] = map->magic2[1] = VENTOY_UNIX_SEG_MAGIC1;
|
||||
map->magic1[2] = map->magic2[2] = VENTOY_UNIX_SEG_MAGIC2;
|
||||
map->magic1[3] = map->magic2[3] = VENTOY_UNIX_SEG_MAGIC3;
|
||||
|
||||
map->disksize = chain->os_param.vtoy_disk_size;
|
||||
grub_memcpy(map->diskuuid, chain->os_param.vtoy_disk_guid, 16);
|
||||
|
||||
map->segnum = g_img_chunk_list.cur_chunk;
|
||||
if (g_img_chunk_list.cur_chunk > VENTOY_UNIX_MAX_SEGNUM)
|
||||
{
|
||||
debug("####[FAIL] Too many segments for the ISO file %u\n", g_img_chunk_list.cur_chunk);
|
||||
map->segnum = VENTOY_UNIX_MAX_SEGNUM;
|
||||
}
|
||||
|
||||
for (i = 0; i < (grub_uint32_t)(map->segnum); i++)
|
||||
{
|
||||
chunk = g_img_chunk_list.chunk + i;
|
||||
map->seglist[i].seg_start_bytes = chunk->disk_start_sector * 512ULL;
|
||||
map->seglist[i].seg_end_bytes = (chunk->disk_end_sector + 1) * 512ULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void ventoy_unix_fill_override_data( grub_uint64_t isosize, ventoy_chain_head *chain)
|
||||
{
|
||||
int i;
|
||||
int left;
|
||||
char *data = NULL;
|
||||
grub_uint64_t offset;
|
||||
grub_uint64_t sector;
|
||||
ventoy_override_chunk *cur;
|
||||
ventoy_iso9660_override *dirent;
|
||||
|
||||
sector = (isosize + 2047) / 2048;
|
||||
|
||||
cur = (ventoy_override_chunk *)override;
|
||||
cur = (ventoy_override_chunk *)((char *)chain + chain->override_chunk_offset);
|
||||
|
||||
if (g_conf_new_len > 0)
|
||||
{
|
||||
@ -142,12 +191,12 @@ static void ventoy_unix_fill_override_data( grub_uint64_t isosize, void *over
|
||||
dirent->first_sector_be = grub_swap_bytes32(dirent->first_sector);
|
||||
dirent->size_be = grub_swap_bytes32(dirent->size);
|
||||
sector += (dirent->size + 2047) / 2048;
|
||||
cur++;
|
||||
}
|
||||
|
||||
if (g_mod_new_len > 0)
|
||||
{
|
||||
/* mod.ko */
|
||||
cur++;
|
||||
cur->img_offset = g_mod_override_offset;
|
||||
cur->override_size = sizeof(ventoy_iso9660_override);
|
||||
dirent = (ventoy_iso9660_override *)cur->override_data;
|
||||
@ -156,6 +205,37 @@ static void ventoy_unix_fill_override_data( grub_uint64_t isosize, void *over
|
||||
dirent->first_sector_be = grub_swap_bytes32(dirent->first_sector);
|
||||
dirent->size_be = grub_swap_bytes32(dirent->size);
|
||||
sector += (dirent->size + 2047) / 2048;
|
||||
cur++;
|
||||
}
|
||||
|
||||
if (g_ko_fillmap_len > 0)
|
||||
{
|
||||
data = g_ko_fillmap_data;
|
||||
offset = g_mod_override_offset;
|
||||
|
||||
ventoy_unix_fill_map_data(chain, (struct g_ventoy_map *)data);
|
||||
|
||||
for (i = 0; i < g_ko_fillmap_len / 512; i++)
|
||||
{
|
||||
cur->img_offset = offset;
|
||||
cur->override_size = 512;
|
||||
grub_memcpy(cur->override_data, data, 512);
|
||||
|
||||
offset += 512;
|
||||
data += 512;
|
||||
cur++;
|
||||
}
|
||||
|
||||
left = (g_ko_fillmap_len % 512);
|
||||
if (left > 0)
|
||||
{
|
||||
cur->img_offset = offset;
|
||||
cur->override_size = left;
|
||||
grub_memcpy(cur->override_data, data, left);
|
||||
|
||||
offset += left;
|
||||
cur++;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
@ -182,6 +262,11 @@ static void ventoy_unix_fill_virt_data( grub_uint64_t isosize, ventoy_chain_h
|
||||
|
||||
if (g_mod_new_len > 0)
|
||||
{
|
||||
if (g_mod_search_magic > 0)
|
||||
{
|
||||
ventoy_unix_fill_map_data(chain, (struct g_ventoy_map *)(g_mod_new_data + g_mod_search_magic));
|
||||
}
|
||||
|
||||
ventoy_unix_fill_virt(g_mod_new_data, g_mod_new_len);
|
||||
}
|
||||
|
||||
@ -210,6 +295,12 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath)
|
||||
vtoy_ssprintf(buf, pos, "ventoy_load=\"%s\"\n", "YES");
|
||||
vtoy_ssprintf(buf, pos, "ventoy_name=\"%s\"\n", g_ko_mod_path);
|
||||
|
||||
if (g_mod_search_magic)
|
||||
{
|
||||
debug("hint.ventoy NO need\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
disk = isofile->device->disk;
|
||||
|
||||
ventoy_get_disk_guid(isofile->name, disk_guid, disk_sig);
|
||||
@ -232,8 +323,8 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath)
|
||||
(ulonglong)((chunk->disk_end_sector + 1) * 512));
|
||||
}
|
||||
|
||||
out:
|
||||
grub_file_close(isofile);
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
@ -258,13 +349,16 @@ grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **ar
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
g_mod_search_magic = 0;
|
||||
g_conf_new_len = 0;
|
||||
g_mod_new_len = 0;
|
||||
g_mod_override_offset = 0;
|
||||
g_conf_override_offset = 0;
|
||||
g_ko_fillmap_len = 0;
|
||||
|
||||
check_free(g_mod_new_data, grub_free);
|
||||
check_free(g_conf_new_data, grub_free);
|
||||
check_free(g_ko_fillmap_data, grub_free);
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
@ -624,6 +718,27 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
static int ventoy_unix_search_magic(char *data, int len)
|
||||
{
|
||||
int i;
|
||||
grub_uint32_t *magic = NULL;
|
||||
|
||||
for (i = 0; i < len; i += 65536)
|
||||
{
|
||||
magic = (grub_uint32_t *)(data + i);
|
||||
if (magic[0] == VENTOY_UNIX_SEG_MAGIC0 && magic[1] == VENTOY_UNIX_SEG_MAGIC1 &&
|
||||
magic[2] == VENTOY_UNIX_SEG_MAGIC2 && magic[3] == VENTOY_UNIX_SEG_MAGIC3)
|
||||
{
|
||||
debug("unix find search magic at 0x%x loop:%d\n", i, (i >> 16));
|
||||
g_mod_search_magic = i;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
debug("unix can not find search magic\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
char *data;
|
||||
@ -673,10 +788,73 @@ grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char
|
||||
|
||||
g_mod_new_data = data;
|
||||
g_mod_new_len = (int)file->size;
|
||||
|
||||
ventoy_unix_search_magic(g_mod_new_data, g_mod_new_len);
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_unix_ko_fillmap(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int i;
|
||||
grub_file_t file;
|
||||
grub_uint32_t magic[4];
|
||||
grub_uint32_t len;
|
||||
|
||||
(void)ctxt;
|
||||
|
||||
if (argc != 1)
|
||||
{
|
||||
debug("Fillmap ko invalid argc %d\n", argc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
debug("Fillmap ko %s\n", args[0]);
|
||||
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "(loop)%s", args[0]);
|
||||
if (file)
|
||||
{
|
||||
grub_file_read(file, magic, 4); /* read for trigger */
|
||||
g_mod_override_offset = grub_iso9660_get_last_read_pos(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("Can't find replace ko file from %s\n", args[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < (int)(file->size); i += 65536)
|
||||
{
|
||||
magic[0] = 0;
|
||||
grub_file_seek(file, i);
|
||||
grub_file_read(file, magic, sizeof(magic));
|
||||
|
||||
if (magic[0] == VENTOY_UNIX_SEG_MAGIC0 && magic[1] == VENTOY_UNIX_SEG_MAGIC1 &&
|
||||
magic[2] == VENTOY_UNIX_SEG_MAGIC2 && magic[3] == VENTOY_UNIX_SEG_MAGIC3)
|
||||
{
|
||||
debug("unix find search magic at 0x%x loop:%d\n", i, (i >> 16));
|
||||
g_mod_override_offset += i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
len = (grub_uint32_t)OFFSET_OF(struct g_ventoy_map, seglist) +
|
||||
(sizeof(struct g_ventoy_seg) * g_img_chunk_list.cur_chunk);
|
||||
|
||||
g_ko_fillmap_len = (int)len;
|
||||
g_ko_fillmap_data = grub_malloc(len);
|
||||
if (!g_ko_fillmap_data)
|
||||
{
|
||||
g_ko_fillmap_len = 0;
|
||||
debug("Failed to malloc fillmap data\n");
|
||||
}
|
||||
|
||||
debug("Fillmap ko segnum:%u, override len:%u data:%p\n", g_img_chunk_list.cur_chunk, len, g_ko_fillmap_data);
|
||||
|
||||
grub_file_close(file);
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_unix_fill_image_desc(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int i;
|
||||
@ -908,7 +1086,7 @@ grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char
|
||||
/* part 4: override chunk */
|
||||
chain->override_chunk_offset = chain->img_chunk_offset + img_chunk_size;
|
||||
chain->override_chunk_num = override_count;
|
||||
ventoy_unix_fill_override_data(isosize, (char *)chain + chain->override_chunk_offset);
|
||||
ventoy_unix_fill_override_data(isosize, chain);
|
||||
|
||||
/* part 5: virt chunk */
|
||||
chain->virt_chunk_offset = chain->override_chunk_offset + override_size;
|
||||
|
@ -375,6 +375,7 @@ grub_err_t ventoy_cmd_sel_wimboot(grub_extcmd_context_t ctxt, int argc, char **a
|
||||
|
||||
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);
|
||||
@ -548,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;
|
||||
|
||||
@ -600,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)
|
||||
{
|
||||
@ -654,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)
|
||||
@ -695,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;
|
||||
@ -735,6 +955,27 @@ static grub_uint64_t ventoy_get_stream_len(wim_directory_entry *dir)
|
||||
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))
|
||||
@ -762,6 +1003,7 @@ static int ventoy_update_all_hash(wim_patch *patch, void *meta_data, wim_directo
|
||||
|
||||
if (dir->streams)
|
||||
{
|
||||
ventoy_update_stream_hash(patch, dir);
|
||||
dir = (wim_directory_entry *)((char *)dir + dir->len + ventoy_get_stream_len(dir));
|
||||
}
|
||||
else
|
||||
@ -808,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));
|
||||
@ -846,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;
|
||||
}
|
||||
|
||||
@ -882,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);
|
||||
@ -915,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;
|
||||
@ -923,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;
|
||||
|
||||
@ -975,8 +1233,16 @@ static int ventoy_wimdows_locate_wim(const char *disk, wim_patch *patch)
|
||||
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);
|
||||
@ -985,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)
|
||||
@ -1013,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;
|
||||
@ -1167,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;
|
||||
@ -1178,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;
|
||||
|
||||
@ -1190,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)
|
||||
{
|
||||
@ -1231,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;
|
||||
@ -1631,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 */
|
||||
|
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);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -29,13 +29,21 @@ for i in 0 1 2 3 4 5 6 7 8 9; do
|
||||
fi
|
||||
done
|
||||
|
||||
ventoy_extract_vtloopex ${vtdiskname}2 crux
|
||||
# no need since 3.6.1
|
||||
$BUSYBOX_PATH/modprobe dax > /dev/null 2>&1
|
||||
$BUSYBOX_PATH/modprobe dm-mod > /dev/null 2>&1
|
||||
|
||||
if $GREP -q 'device-mapper' /proc/devices; then
|
||||
vtlog "dm-mod module check success ..."
|
||||
else
|
||||
vtlog "Need to load dm-mod module ..."
|
||||
ventoy_extract_vtloopex ${vtdiskname}2 crux
|
||||
|
||||
vtKver=$(uname -r)
|
||||
vtLoopExDir=$VTOY_PATH/vtloopex/crux/vtloopex
|
||||
vtKver=$(uname -r)
|
||||
vtLoopExDir=$VTOY_PATH/vtloopex/crux/vtloopex
|
||||
|
||||
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_check_install_module_xz $vtLoopExDir/dm-mod/$vtKver/64/dax.ko
|
||||
ventoy_check_install_module_xz $vtLoopExDir/dm-mod/$vtKver/64/dm-mod.ko
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
|
||||
|
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}
|
||||
|
@ -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
|
||||
@ -90,6 +90,13 @@ ventoy_get_debian_distro() {
|
||||
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 $*
|
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
|
||||
|
@ -562,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
|
||||
|
@ -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
|
@ -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
|
||||
@ -154,7 +160,11 @@ ventoy_get_os_type() {
|
||||
elif $GREP -q 'openEuler' /etc/os-release; then
|
||||
echo 'openEuler'; return
|
||||
elif $GREP -q 'fuyu' /etc/os-release; then
|
||||
echo 'openEuler'; return
|
||||
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
|
||||
|
||||
@ -338,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
|
||||
@ -357,7 +394,7 @@ fi
|
||||
|
||||
####################################################################
|
||||
# #
|
||||
# Step 4 : Hand over to real init #
|
||||
# Step 5 : Hand over to real init #
|
||||
# #
|
||||
####################################################################
|
||||
$BUSYBOX_PATH/umount /proc
|
||||
@ -386,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
|
||||
@ -200,6 +200,10 @@ ventoy_get_os_type() {
|
||||
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 ..
|
||||
|
||||
|
BIN
IMG/vtloopex/LibreELEC/vtloopex/dm-mod/5.10.76/64/dm-mod.ko.xz
Normal file
BIN
IMG/vtloopex/LibreELEC/vtloopex/dm-mod/5.10.76/64/dm-mod.ko.xz
Normal file
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
size=1024
|
||||
fstype=ext4
|
||||
@ -7,13 +7,14 @@ config=''
|
||||
outputfile=persistence.dat
|
||||
|
||||
print_usage() {
|
||||
echo 'Usage: CreatePersistentImg.sh [ -s size ] [ -t fstype ] [ -l LABEL ] [ -c CFG ]'
|
||||
echo 'Usage: sudo ./CreatePersistentImg.sh [ -s size ] [ -t fstype ] [ -l LABEL ] [ -c CFG ] [ -e ]'
|
||||
echo ' OPTION: (optional)'
|
||||
echo ' -s size in MB, default is 1024'
|
||||
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 ' -e enable encryption, disabled by default (only few distros support this)'
|
||||
echo ''
|
||||
}
|
||||
|
||||
@ -33,6 +34,9 @@ while [ -n "$1" ]; do
|
||||
elif [ "$1" = "-o" ]; then
|
||||
shift
|
||||
outputfile=$1
|
||||
elif [ "$1" = "-e" ]; then
|
||||
read -s -p "Encryption passphrase: " passphrase
|
||||
echo
|
||||
elif [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
||||
print_usage
|
||||
exit 0
|
||||
@ -86,6 +90,13 @@ freeloop=$(losetup -f)
|
||||
|
||||
losetup $freeloop "$outputfile"
|
||||
|
||||
if [ ! -z "$passphrase" ]; then
|
||||
printf "$passphrase" | cryptsetup -q --verbose luksFormat $freeloop -
|
||||
printf "$passphrase" | cryptsetup -q --verbose luksOpen $freeloop persist_decrypted -
|
||||
_freeloop=$freeloop
|
||||
freeloop="/dev/mapper/persist_decrypted"
|
||||
fi
|
||||
|
||||
mkfs -t $fstype $fsopt -L $label $freeloop
|
||||
|
||||
sync
|
||||
@ -104,4 +115,9 @@ if [ -n "$config" ]; then
|
||||
rm -rf ./persist_tmp_mnt
|
||||
fi
|
||||
|
||||
if [ ! -z "$passphrase" ]; then
|
||||
cryptsetup luksClose $freeloop
|
||||
freeloop=$_freeloop
|
||||
fi
|
||||
|
||||
losetup -d $freeloop
|
||||
|
@ -27,6 +27,13 @@ if [ ! -f "$file" ]; then
|
||||
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
|
||||
@ -42,10 +49,25 @@ fi
|
||||
|
||||
|
||||
fsMB=$(expr $fsize / 1024 / 1024)
|
||||
total=$(expr $fsMB + $size)
|
||||
|
||||
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
|
||||
@ -61,23 +83,26 @@ else
|
||||
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
|
||||
|
||||
echo "Extend dat file... (current is ${fsMB}MB, append ${size}MB, total ${total}MB)"
|
||||
dd if=/dev/zero bs=1M count=$size status=none >> "$file"
|
||||
sync
|
||||
|
||||
freeloop=$(losetup -f)
|
||||
losetup $freeloop "$file"
|
||||
|
||||
if [ "$cmd" = "resize2fs" ]; then
|
||||
echo "Extend ext filesystem by resize2fs ..."
|
||||
echo "$mode ext filesystem by resize2fs ..."
|
||||
echo "resize2fs $freeloop ${total}M"
|
||||
e2fsck -f $freeloop
|
||||
resize2fs $freeloop ${total}M
|
||||
ret=$?
|
||||
else
|
||||
echo "Extend xfs filesystem by xfs_growfs ..."
|
||||
|
||||
echo "$mode xfs filesystem by xfs_growfs ..."
|
||||
tmpdir=$(mktemp -d)
|
||||
mount $freeloop $tmpdir
|
||||
xfs_growfs $freeloop
|
||||
@ -87,6 +112,12 @@ 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 ========="
|
||||
@ -94,4 +125,3 @@ else
|
||||
echo "======= FAILED ========="
|
||||
fi
|
||||
echo ""
|
||||
|
||||
|
12
INSTALL/FOR_X64_ARM.txt
Normal file
12
INSTALL/FOR_X64_ARM.txt
Normal file
@ -0,0 +1,12 @@
|
||||
============ Ventoy2Disk.exe for x86_64/ARM/ARM64 =================
|
||||
Ventoy2Disk.exe is a x86_32 application and supports both 32-bit and 64-bit Windows PC with intel/amd processor.
|
||||
Since 1.0.58, Ventoy also provides Ventoy2Disk_X64.exe/Ventoy2Disk_ARM.exe/Ventoy2Disk_ARM64.exe you can use them if needed.
|
||||
These exe files are in altexe directory of the installation package.
|
||||
You must copy them to the upper directory to use them. (The same location with Ventoy2Disk.exe)
|
||||
|
||||
|
||||
============ x86_64/ARM/ARM64 版本 Ventoy2Disk.exe =================
|
||||
默认的 Ventoy2Disk.exe 是32位x86程序,同时支持最常见的32位和64位Windows系统,绝大部分情况下使用它就可以。
|
||||
从1.0.58版本开始,Ventoy还同时提供了 Ventoy2Disk_X64.exe/Ventoy2Disk_ARM.exe/Ventoy2Disk_ARM64.exe 可以根据需要使用。
|
||||
这些文件位于安装包内的altexe目录下,使用时需要将其拷贝到上一层目录(即和 Ventoy2Disk.exe 同一位置)。
|
||||
|
@ -21,8 +21,16 @@ Please refer https://www.ventoy.net/en/doc_start.html for details.
|
||||
1. sudo sh VentoyWeb.sh
|
||||
2. open your browser and visit http://127.0.0.1:24680
|
||||
|
||||
========== VentoyWebDeepin.sh ===============
|
||||
1. sudo sh VentoyWebDeepin.sh
|
||||
|
||||
========== VentoyPlugson.sh ===============
|
||||
1. sudo sh VentoyPlugson.sh
|
||||
2. open your browser and visit http://127.0.0.1:24681
|
||||
|
||||
|
||||
========= VentoyGUI ===================
|
||||
VentoyGUI is native GUI program for Linux (GTK/QT)
|
||||
1. Just double-click the file (e.g. VentoyGUI.x86_64)
|
||||
2. If it can not startup after double-click, you can open the terminal and just execute the file (e.g. ./VentoyGUI.x86_64)
|
||||
|
||||
|
||||
========== CreatePersistentImg.sh ===============
|
||||
|
Binary file not shown.
@ -21,7 +21,7 @@ elif uname -m | egrep -q 'mips64'; then
|
||||
else
|
||||
export TOOLDIR=i386
|
||||
fi
|
||||
export PATH=./tool/$TOOLDIR:$PATH
|
||||
export PATH="./tool/$TOOLDIR:$PATH"
|
||||
|
||||
|
||||
echo ''
|
||||
@ -46,23 +46,25 @@ echo "############# Ventoy2Disk $* [$TOOLDIR] ################" >> ./log.txt
|
||||
date >> ./log.txt
|
||||
|
||||
#decompress tool
|
||||
if [ -f ./tool/$TOOLDIR/ash ]; then
|
||||
echo "no need to decompress tools" >> ./log.txt
|
||||
else
|
||||
cd ./tool/$TOOLDIR
|
||||
|
||||
echo "decompress tools" >> ./log.txt
|
||||
cd ./tool/$TOOLDIR
|
||||
|
||||
ls *.xz > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
[ -f ./xzcat ] && chmod +x ./xzcat
|
||||
|
||||
|
||||
for file in $(ls *.xz); do
|
||||
echo "decompress $file" >> ./log.txt
|
||||
xzcat $file > ${file%.xz}
|
||||
[ -f ./${file%.xz} ] && chmod +x ./${file%.xz}
|
||||
[ -f ./$file ] && rm -f ./$file
|
||||
done
|
||||
cd ../../
|
||||
|
||||
chmod +x -R ./tool/$TOOLDIR
|
||||
fi
|
||||
|
||||
cd ../../
|
||||
chmod +x -R ./tool/$TOOLDIR
|
||||
|
||||
|
||||
if [ -f /bin/bash ]; then
|
||||
/bin/bash ./tool/VentoyWorker.sh $*
|
||||
else
|
||||
|
BIN
INSTALL/Ventoy2Disk_ARM.exe
Normal file
BIN
INSTALL/Ventoy2Disk_ARM.exe
Normal file
Binary file not shown.
BIN
INSTALL/Ventoy2Disk_ARM64.exe
Normal file
BIN
INSTALL/Ventoy2Disk_ARM64.exe
Normal file
Binary file not shown.
BIN
INSTALL/Ventoy2Disk_X64.exe
Normal file
BIN
INSTALL/Ventoy2Disk_X64.exe
Normal file
Binary file not shown.
BIN
INSTALL/VentoyGUI.aarch64
Normal file
BIN
INSTALL/VentoyGUI.aarch64
Normal file
Binary file not shown.
BIN
INSTALL/VentoyGUI.i386
Normal file
BIN
INSTALL/VentoyGUI.i386
Normal file
Binary file not shown.
BIN
INSTALL/VentoyGUI.mips64el
Normal file
BIN
INSTALL/VentoyGUI.mips64el
Normal file
Binary file not shown.
BIN
INSTALL/VentoyGUI.x86_64
Normal file
BIN
INSTALL/VentoyGUI.x86_64
Normal file
Binary file not shown.
218
INSTALL/VentoyPlugson.sh
Normal file
218
INSTALL/VentoyPlugson.sh
Normal file
@ -0,0 +1,218 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ./tool/ventoy_lib.sh
|
||||
|
||||
print_usage() {
|
||||
echo 'Usage: sudo sh VentoyPlugson.sh [OPTION] /dev/sdX'
|
||||
echo ' OPTION: (optional)'
|
||||
echo ' -H x.x.x.x http server IP address (default is 127.0.0.1)'
|
||||
echo ' -P PORT http server PORT (default is 24681)'
|
||||
echo ' -h print this help'
|
||||
echo ''
|
||||
}
|
||||
|
||||
uid=$(id -u)
|
||||
if [ $uid -ne 0 ]; then
|
||||
echo "Please use sudo or run the script as root."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
OLDDIR=$(pwd)
|
||||
|
||||
machine=$(uname -m)
|
||||
if echo $machine | egrep -q 'aarch64|arm64'; then
|
||||
TOOLDIR=aarch64
|
||||
elif echo $machine | egrep -q 'x86_64|amd64'; then
|
||||
TOOLDIR=x86_64
|
||||
elif echo $machine | egrep -q 'mips64'; then
|
||||
TOOLDIR=mips64el
|
||||
elif echo $machine | egrep -q 'i[3-6]86'; then
|
||||
TOOLDIR=i386
|
||||
else
|
||||
echo "Unsupported machine type $machine"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if ! [ -f "$OLDDIR/tool/plugson.tar.xz" ]; then
|
||||
echo "Please run under the correct directory!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "############# VentoyPlugson $* [$TOOLDIR] ################" >> ./VentoyPlugson.log
|
||||
date >> ./VentoyPlugson.log
|
||||
|
||||
echo "decompress tools" >> ./VentoyPlugson.log
|
||||
cd ./tool/$TOOLDIR
|
||||
|
||||
ls *.xz > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
[ -f ./xzcat ] && chmod +x ./xzcat
|
||||
|
||||
for file in $(ls *.xz); do
|
||||
echo "decompress $file" >> ./VentoyPlugson.log
|
||||
xzcat $file > ${file%.xz}
|
||||
[ -f ./${file%.xz} ] && chmod +x ./${file%.xz}
|
||||
[ -f ./$file ] && rm -f ./$file
|
||||
done
|
||||
fi
|
||||
|
||||
cd ../../
|
||||
chmod +x -R ./tool/$TOOLDIR
|
||||
|
||||
if ! [ -f "$OLDDIR/tool/$TOOLDIR/Plugson" ]; then
|
||||
echo "$OLDDIR/tool/$TOOLDIR/Plugson does not exist!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
PATH=./tool/$TOOLDIR:$PATH
|
||||
|
||||
HOST="127.0.0.1"
|
||||
PORT=24681
|
||||
|
||||
while [ -n "$1" ]; do
|
||||
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
||||
print_usage
|
||||
exit 0
|
||||
elif [ "$1" = "-H" ]; then
|
||||
shift
|
||||
if echo $1 | grep -q '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'; then
|
||||
HOST="$1"
|
||||
else
|
||||
echo "Invalid host $1"
|
||||
exit 1
|
||||
fi
|
||||
elif [ "$1" = "-P" ]; then
|
||||
shift
|
||||
if [ $1 -gt 0 -a $1 -le 65535 ]; then
|
||||
PORT="$1"
|
||||
else
|
||||
echo "Invalid port $1"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
DISK=$1
|
||||
fi
|
||||
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -z "$DISK" ]; then
|
||||
print_usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ps -ef | grep "tool/$TOOLDIR/Plugson.*$HOST.*$PORT" | grep -q -v grep; then
|
||||
echo "Another ventoy server is running now, please close it first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if echo $DISK | grep -q "[a-z]d[a-z][1-9]"; then
|
||||
DISK=${DISK:0:-1}
|
||||
fi
|
||||
|
||||
if echo $DISK | egrep -q "/dev/nvme|/dev/mmcblk/dev/nbd"; then
|
||||
if echo $DISK | grep -q "p[1-9]$"; then
|
||||
DISK=${DISK:0:-2}
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -b "$DISK" ]; then
|
||||
echo "$DISK does NOT exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
version=$(get_disk_ventoy_version $DISK)
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Ventoy version in Disk: $version"
|
||||
|
||||
vtPart1Type=$(dd if=$DISK bs=1 count=1 skip=450 status=none | hexdump -n1 -e '1/1 "%02X"')
|
||||
if [ "$vtPart1Type" = "EE" ]; then
|
||||
echo "Disk Partition Style : GPT"
|
||||
partstyle=1
|
||||
else
|
||||
echo "Disk Partition Style : MBR"
|
||||
partstyle=0
|
||||
fi
|
||||
|
||||
if check_disk_secure_boot $DISK; then
|
||||
echo "Secure Boot Support : YES"
|
||||
secureboot=1
|
||||
else
|
||||
echo "Secure Boot Support : NO"
|
||||
secureboot=0
|
||||
fi
|
||||
else
|
||||
echo "$DISK is NOT Ventoy disk."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PART1=$(get_disk_part_name $DISK 1)
|
||||
|
||||
if grep -q "^$PART1 " /proc/mounts; then
|
||||
mtpnt=$(grep "^$PART1 " /proc/mounts | awk '{print $2}')
|
||||
fstype=$(grep "^$PART1 " /proc/mounts | awk '{print $3}')
|
||||
|
||||
if echo $fstype | grep -q -i 'fuse'; then
|
||||
if hexdump -C -n 16 $PART1 | grep -q -i "EXFAT"; then
|
||||
fstype="exFAT"
|
||||
elif hexdump -C -n 16 $PART1 | grep -q -i "NTFS"; then
|
||||
fstype="NTFS"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$PART1 is mounted at $mtpnt $fstype"
|
||||
else
|
||||
echo "$PART1 is NOT mounted, please mount it first!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -d "$mtpnt/ventoy" ]; then
|
||||
echo "ventoy directory exist OK"
|
||||
else
|
||||
echo "create ventoy directory"
|
||||
mkdir -p "$mtpnt/ventoy"
|
||||
if [ -d "$mtpnt/ventoy" ]; then
|
||||
chmod -R 0755 "$mtpnt/ventoy"
|
||||
else
|
||||
echo "Failed to create directory $mtpnt/ventoy"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
#change current directory to Ventoy disk
|
||||
cd "$mtpnt"
|
||||
$OLDDIR/tool/$TOOLDIR/Plugson "$HOST" "$PORT" "$OLDDIR" "$DISK" $version "$fstype" $partstyle $secureboot &
|
||||
wID=$!
|
||||
sleep 1
|
||||
|
||||
if [ -f /proc/$wID/maps ]; then
|
||||
echo ""
|
||||
echo "==============================================================="
|
||||
if [ "$LANG" = "zh_CN.UTF-8" ]; then
|
||||
echo " Ventoy Plugson Server 已经启动 ..."
|
||||
echo " 请打开浏览器,访问 http://${HOST}:${PORT}"
|
||||
else
|
||||
echo " Ventoy Plugson Server is running ..."
|
||||
echo " Please open your browser and visit http://${HOST}:${PORT}"
|
||||
fi
|
||||
echo "==============================================================="
|
||||
echo ""
|
||||
echo "################## Press Ctrl + C to exit #####################"
|
||||
echo ""
|
||||
|
||||
wait $wID
|
||||
fi
|
||||
|
||||
|
||||
if [ -n "$OLDDIR" ]; then
|
||||
CURDIR=$(pwd)
|
||||
if [ "$CURDIR" != "$OLDDIR" ]; then
|
||||
cd "$OLDDIR"
|
||||
fi
|
||||
fi
|
@ -45,6 +45,7 @@ if [ ! -f ./boot/boot.img ]; then
|
||||
if [ -d ./grub ]; then
|
||||
echo "Don't run VentoyWeb.sh here, please download the released install package, and run the script in it."
|
||||
else
|
||||
echo "Current directory is $PWD"
|
||||
echo "Please run under the correct directory!"
|
||||
fi
|
||||
exit 1
|
||||
|
@ -1,109 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
if echo "$*" | grep -q '[-]v'; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
print_usage() {
|
||||
echo 'Usage: VentoyWebDeepin.sh [ OPTION ]'
|
||||
echo ' OPTION: (optional)'
|
||||
echo ' -H x.x.x.x http server IP address (default is 127.0.0.1)'
|
||||
echo ' -p PORT http server PORT (default is 24680)'
|
||||
echo ' -h print this help'
|
||||
echo ' -v print verbose info'
|
||||
echo ''
|
||||
}
|
||||
|
||||
print_err() {
|
||||
echo ""
|
||||
echo "$*"
|
||||
echo ""
|
||||
}
|
||||
|
||||
get_user() {
|
||||
name=$(logname)
|
||||
if [ -n "$name" -a "$name" != "root" ]; then
|
||||
echo $name; return
|
||||
fi
|
||||
|
||||
name=${HOME#/home/}
|
||||
if [ -n "$name" -a "$name" != "root" ]; then
|
||||
echo $name; return
|
||||
fi
|
||||
}
|
||||
|
||||
uid=$(id -u)
|
||||
if [ $uid -ne 0 ]; then
|
||||
exec sudo sh $0 $*
|
||||
fi
|
||||
|
||||
OLDDIR=$(pwd)
|
||||
|
||||
if uname -m | egrep -q 'aarch64|arm64'; then
|
||||
TOOLDIR=aarch64
|
||||
elif uname -m | egrep -q 'x86_64|amd64'; then
|
||||
TOOLDIR=x86_64
|
||||
elif uname -m | egrep -q 'mips64'; then
|
||||
TOOLDIR=mips64el
|
||||
else
|
||||
TOOLDIR=i386
|
||||
fi
|
||||
|
||||
if [ ! -f ./tool/$TOOLDIR/V2DServer ]; then
|
||||
if [ -f ${0%VentoyWebDeepin.sh}/tool/$TOOLDIR/V2DServer ]; then
|
||||
cd ${0%VentoyWebDeepin.sh}
|
||||
fi
|
||||
fi
|
||||
|
||||
PATH=./tool/$TOOLDIR:$PATH
|
||||
|
||||
if [ ! -f ./boot/boot.img ]; then
|
||||
if [ -d ./grub ]; then
|
||||
echo "Don't run VentoyWebDeepin.sh here, please download the released install package, and run the script in it."
|
||||
else
|
||||
echo "Please run under the correct directory!"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
HOST="127.0.0.1"
|
||||
PORT=24680
|
||||
|
||||
while [ -n "$1" ]; do
|
||||
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
||||
print_usage
|
||||
exit 0
|
||||
elif [ "$1" = "-v" ]; then
|
||||
VERBOSE=1
|
||||
elif [ "$1" = "-H" ]; then
|
||||
shift
|
||||
if echo $1 | grep -q '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'; then
|
||||
HOST="$1"
|
||||
else
|
||||
print_err "Invalid host $1"
|
||||
exit 1
|
||||
fi
|
||||
elif [ "$1" = "-p" ]; then
|
||||
shift
|
||||
if [ $1 -gt 0 -a $1 -le 65535 ]; then
|
||||
PORT="$1"
|
||||
else
|
||||
print_err "Invalid port $1"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
if ps -ef | grep "V2DServer.*$HOST.*$PORT" | grep -q -v grep; then
|
||||
print_err "Another ventoy server is running now, please close it first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if grep -q -i uos /etc/os-release; then
|
||||
. ./tool/WebUos.sh
|
||||
else
|
||||
. ./tool/WebDeepin.sh
|
||||
fi
|
@ -38,13 +38,10 @@ sh buildedk.sh >> $LOG 2>&1 || exit 1
|
||||
#cd $VTOY_PATH/VtoyTool
|
||||
#sh build.sh || exit 1
|
||||
|
||||
#cd $VTOY_PATH/vtoyfat/fat_io_lib
|
||||
#cd $VTOY_PATH/vtoycli/fat_io_lib
|
||||
#sh buildlib.sh
|
||||
|
||||
#cd $VTOY_PATH/vtoyfat
|
||||
#sh build.sh || exit 1
|
||||
|
||||
#cd $VTOY_PATH/vtoygpt
|
||||
#cd $VTOY_PATH/vtoycli
|
||||
#sh build.sh || exit 1
|
||||
|
||||
#cd $VTOY_PATH/FUSEISO
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user