mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-09-16 09:01:15 +00:00
Compare commits
101 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
8775684367 | ||
|
d148139227 | ||
|
dd2411d7d4 | ||
|
7db83dc0f1 | ||
|
787d950f28 | ||
|
892a819da4 | ||
|
bfc5eaebb9 | ||
|
e7d05df9fa | ||
|
ca07b52cb2 | ||
|
1a2a35f5bc | ||
|
d71514f23e | ||
|
c5af17e04e | ||
|
05e208ea2a | ||
|
112c557428 | ||
|
92db873b5c | ||
|
3c01eec4af | ||
|
5c6d18fcd4 | ||
|
84ec4b0de4 | ||
|
9615e7eaa0 | ||
|
6a244ff260 | ||
|
b5503a7375 | ||
|
0b7fa630a4 | ||
|
7babe823d6 | ||
|
6db513a067 | ||
|
bafac7479d | ||
|
d3138479d7 | ||
|
56a1543f7d | ||
|
659ac1cfe3 | ||
|
c83daa86b6 | ||
|
dfcfaa9967 | ||
|
188f9e707c | ||
|
8b975b5e80 | ||
|
2ab717cc66 | ||
|
88793d548a | ||
|
5fea6eab7e | ||
|
5d55dc68ae | ||
|
2c320aad60 | ||
|
b63034b2c7 | ||
|
6c113880e5 | ||
|
e2656c287b | ||
|
d8433985e7 | ||
|
b003105925 | ||
|
2ca2c83b6b | ||
|
dff7e495ca | ||
|
cf0f395c56 | ||
|
69bc90da42 | ||
|
ffc40234ca | ||
|
e57daa5065 | ||
|
5c733a20f8 | ||
|
069342ab9a | ||
|
32a964eded | ||
|
51b92f398a | ||
|
5d0ebf4510 | ||
|
cf94487ad5 | ||
|
af83f46a3d | ||
|
4910e9f380 | ||
|
fb38b321c2 | ||
|
7b78fe555e | ||
|
094ba61848 | ||
|
faa0e46d3a | ||
|
537f0eaa7e | ||
|
c8cf9b7ce2 | ||
|
4c71d7c190 | ||
|
47f9f2c42c | ||
|
fc3a5fae36 | ||
|
b3982d4930 | ||
|
c280baae27 | ||
|
425d640480 | ||
|
07d4140cf4 | ||
|
90ae07d227 | ||
|
e3e21eb6e6 | ||
|
c8ce2ae85a | ||
|
c02a6955c3 | ||
|
6b78603dd3 | ||
|
07a386c963 | ||
|
eb048c0075 | ||
|
37ac3f312f | ||
|
092cff8429 | ||
|
b347c1b5da | ||
|
da746c608f | ||
|
81aa56955a | ||
|
d1679871a6 | ||
|
f383052013 | ||
|
667f5bcc1b | ||
|
af69cb7f44 | ||
|
7bb13fc18a | ||
|
7fce7e0aba | ||
|
2a435084c2 | ||
|
c0c454a436 | ||
|
63924fa8bd | ||
|
3e47f5e8de | ||
|
b5eb347244 | ||
|
9225c940a6 | ||
|
a8edb99d28 | ||
|
ac3ab97686 | ||
|
c42a8c6d93 | ||
|
4b1dd4d3af | ||
|
f342be1d6c | ||
|
f4774ee0e4 | ||
|
d3cfa73631 | ||
|
331080fb95 |
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
blank_issues_enabled: false
|
100
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
Normal file
100
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
name: Issue Report
|
||||
description: File an issue report
|
||||
title: "[issue]: "
|
||||
assignees:
|
||||
- octocat
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this issue report!
|
||||
- type: checkboxes
|
||||
id: faq
|
||||
attributes:
|
||||
label: Official FAQ
|
||||
description: Have you checked the official FAQ at [https://www.ventoy.net/en/faq.html](https://www.ventoy.net/en/faq.html) ?
|
||||
options:
|
||||
- label: I have checked the official FAQ.
|
||||
required: true
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: Ventoy Version
|
||||
description: What version of ventoy are you running?
|
||||
placeholder: 1.0.51
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: latestrelease
|
||||
attributes:
|
||||
label: What about latest release
|
||||
description: Have you tried with the latest release of Ventoy?
|
||||
options:
|
||||
- Yes. I have tried the latest release, but the bug still exist.
|
||||
- No. I didn't try the latest release.
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: bios
|
||||
attributes:
|
||||
label: BIOS Mode
|
||||
description: In which BIOS mode did you find the bug?
|
||||
options:
|
||||
- Legacy BIOS Mode
|
||||
- UEFI Mode
|
||||
- Both
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: partstyle
|
||||
attributes:
|
||||
label: Partition Style
|
||||
description: Which partition style did you select when you install Ventoy?
|
||||
options:
|
||||
- MBR
|
||||
- GPT
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: capacity
|
||||
attributes:
|
||||
label: Disk Capacity
|
||||
description: What is the capacity of the disk installed with Ventoy?
|
||||
placeholder: 32GB
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: vendor
|
||||
attributes:
|
||||
label: Disk Manufacturer
|
||||
description: What is the manufacturer of the disk installed with Ventoy? (e.g. SanDisk/Kingston...)
|
||||
validations:
|
||||
required: false
|
||||
- type: dropdown
|
||||
id: checksum
|
||||
attributes:
|
||||
label: Image file checksum (if applicable)
|
||||
description: Have you checked the image file in Ventoy's menu as [https://www.ventoy.net/en/faq.html#faq_boot_checksum](https://www.ventoy.net/en/faq.html#faq_boot_checksum) ?
|
||||
options:
|
||||
- Yes.
|
||||
- No.
|
||||
validations:
|
||||
required: false
|
||||
- type: input
|
||||
id: link
|
||||
attributes:
|
||||
label: Image file download link (if applicable)
|
||||
description: What is the image file download link?
|
||||
placeholder: https://xxx
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: what-happened
|
||||
attributes:
|
||||
label: What happened?
|
||||
description: Tell me what happened. It's highly recommended to include some photo or video about the bug.
|
||||
placeholder: Tell us what you see!
|
||||
value: "A bug happened!"
|
||||
validations:
|
||||
required: true
|
||||
|
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.
|
||||
|
@@ -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;
|
||||
@@ -362,11 +363,23 @@ 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,
|
||||
sizeof(g_ramdisk_param), &(g_ramdisk_param));
|
||||
@@ -380,20 +393,37 @@ EFI_STATUS EFIAPI ventoy_delete_ramdisk_param(VOID)
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
EFI_GUID VarGuid = VENTOY_GUID;
|
||||
|
||||
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));
|
||||
@@ -407,10 +437,20 @@ EFI_STATUS EFIAPI ventoy_delete_variable(VOID)
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
EFI_GUID VarGuid = VENTOY_GUID;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
@@ -1085,6 +1125,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 +1201,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"
|
||||
@@ -344,6 +343,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 +358,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);
|
||||
@@ -396,6 +419,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,6 +34,7 @@
|
||||
#include <Protocol/BlockIo.h>
|
||||
#include <Protocol/RamDisk.h>
|
||||
#include <Protocol/SimpleFileSystem.h>
|
||||
#include <Protocol/DriverBinding.h>
|
||||
#include <Ventoy.h>
|
||||
|
||||
UINT8 *g_iso_data_buf = NULL;
|
||||
@@ -73,6 +74,9 @@ STATIC UINT8 g_sector_buf[2048];
|
||||
STATIC EFI_BLOCK_READ g_sector_2048_read = NULL;
|
||||
STATIC EFI_BLOCK_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 +487,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 +624,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 +724,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 +762,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 +787,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 +1138,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;
|
||||
|
||||
@@ -1137,6 +1401,16 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
|
||||
|
||||
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))
|
||||
{
|
||||
|
@@ -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;
|
||||
|
@@ -57,7 +57,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]
|
||||
|
343
GRUB2/MOD_SRC/grub-2.04/grub-core/commands/hashsum.c
Normal file
343
GRUB2/MOD_SRC/grub-2.04/grub-core/commands/hashsum.c
Normal file
@@ -0,0 +1,343 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/dl.h>
|
||||
#include <grub/extcmd.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/crypto.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
static const struct grub_arg_option options[] = {
|
||||
{"hash", 'h', 0, N_("Specify hash to use."), N_("HASH"), ARG_TYPE_STRING},
|
||||
{"check", 'c', 0, N_("Check hashes of files with hash list FILE."),
|
||||
N_("FILE"), ARG_TYPE_STRING},
|
||||
{"prefix", 'p', 0, N_("Base directory for hash list."), N_("DIR"),
|
||||
ARG_TYPE_STRING},
|
||||
{"keep-going", 'k', 0, N_("Don't stop after first error."), 0, 0},
|
||||
{"uncompress", 'u', 0, N_("Uncompress file before checksumming."), 0, 0},
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static struct { const char *name; const char *hashname; } aliases[] =
|
||||
{
|
||||
{"sha256sum", "sha256"},
|
||||
{"sha512sum", "sha512"},
|
||||
{"sha1sum", "sha1"},
|
||||
{"md5sum", "md5"},
|
||||
{"crc", "crc32"},
|
||||
};
|
||||
|
||||
static inline int
|
||||
hextoval (char c)
|
||||
{
|
||||
if (c >= '0' && c <= '9')
|
||||
return c - '0';
|
||||
if (c >= 'a' && c <= 'f')
|
||||
return c - 'a' + 10;
|
||||
if (c >= 'A' && c <= 'F')
|
||||
return c - 'A' + 10;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
hash_file (grub_file_t file, const gcry_md_spec_t *hash, void *result)
|
||||
{
|
||||
int progress = 0;
|
||||
grub_uint64_t ro = 0;
|
||||
grub_uint64_t div = 0;
|
||||
grub_uint64_t total = 0;
|
||||
void *context;
|
||||
grub_uint8_t *readbuf;
|
||||
#define BUF_SIZE 1024 * 1024
|
||||
readbuf = grub_malloc (BUF_SIZE);
|
||||
if (!readbuf)
|
||||
return grub_errno;
|
||||
context = grub_zalloc (hash->contextsize);
|
||||
if (!readbuf || !context)
|
||||
goto fail;
|
||||
|
||||
if (file->size > 16 * 1024 * 1024)
|
||||
progress = 1;
|
||||
|
||||
hash->init (context);
|
||||
while (1)
|
||||
{
|
||||
grub_ssize_t r;
|
||||
r = grub_file_read (file, readbuf, BUF_SIZE);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
if (r == 0)
|
||||
break;
|
||||
hash->write (context, readbuf, r);
|
||||
if (progress)
|
||||
{
|
||||
total += r;
|
||||
div = grub_divmod64(total * 100, (grub_uint64_t)file->size, &ro);
|
||||
grub_printf("\rCalculating %d%% ", (int)div);
|
||||
grub_refresh();
|
||||
}
|
||||
}
|
||||
hash->final (context);
|
||||
grub_memcpy (result, hash->read (context), hash->mdlen);
|
||||
|
||||
grub_free (readbuf);
|
||||
grub_free (context);
|
||||
if (progress)
|
||||
{
|
||||
grub_printf("\rCalculating 100%% \n\r\n");
|
||||
grub_refresh();
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
fail:
|
||||
grub_free (readbuf);
|
||||
grub_free (context);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
check_list (const gcry_md_spec_t *hash, const char *hashfilename,
|
||||
const char *prefix, int keep, int uncompress)
|
||||
{
|
||||
grub_file_t hashlist, file;
|
||||
char *buf = NULL;
|
||||
grub_uint8_t expected[GRUB_CRYPTO_MAX_MDLEN];
|
||||
grub_uint8_t actual[GRUB_CRYPTO_MAX_MDLEN];
|
||||
grub_err_t err;
|
||||
unsigned i;
|
||||
unsigned unread = 0, mismatch = 0;
|
||||
|
||||
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
|
||||
return grub_error (GRUB_ERR_BUG, "mdlen is too long");
|
||||
|
||||
hashlist = grub_file_open (hashfilename, GRUB_FILE_TYPE_HASHLIST);
|
||||
if (!hashlist)
|
||||
return grub_errno;
|
||||
|
||||
while (grub_free (buf), (buf = grub_file_getline (hashlist)))
|
||||
{
|
||||
const char *p = buf;
|
||||
while (grub_isspace (p[0]))
|
||||
p++;
|
||||
for (i = 0; i < hash->mdlen; i++)
|
||||
{
|
||||
int high, low;
|
||||
high = hextoval (*p++);
|
||||
low = hextoval (*p++);
|
||||
if (high < 0 || low < 0)
|
||||
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid hash list");
|
||||
expected[i] = (high << 4) | low;
|
||||
}
|
||||
if ((p[0] != ' ' && p[0] != '\t') || (p[1] != ' ' && p[1] != '\t'))
|
||||
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid hash list");
|
||||
p += 2;
|
||||
if (prefix)
|
||||
{
|
||||
char *filename;
|
||||
|
||||
filename = grub_xasprintf ("%s/%s", prefix, p);
|
||||
if (!filename)
|
||||
return grub_errno;
|
||||
file = grub_file_open (filename, GRUB_FILE_TYPE_TO_HASH
|
||||
| (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
|
||||
: GRUB_FILE_TYPE_NONE));
|
||||
grub_free (filename);
|
||||
}
|
||||
else
|
||||
file = grub_file_open (p, GRUB_FILE_TYPE_TO_HASH
|
||||
| (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
|
||||
: GRUB_FILE_TYPE_NONE));
|
||||
if (!file)
|
||||
{
|
||||
grub_file_close (hashlist);
|
||||
grub_free (buf);
|
||||
return grub_errno;
|
||||
}
|
||||
err = hash_file (file, hash, actual);
|
||||
grub_file_close (file);
|
||||
if (err)
|
||||
{
|
||||
grub_printf_ (N_("%s: READ ERROR\n"), p);
|
||||
if (!keep)
|
||||
{
|
||||
grub_file_close (hashlist);
|
||||
grub_free (buf);
|
||||
return err;
|
||||
}
|
||||
grub_print_error ();
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
unread++;
|
||||
continue;
|
||||
}
|
||||
if (grub_crypto_memcmp (expected, actual, hash->mdlen) != 0)
|
||||
{
|
||||
grub_printf_ (N_("%s: HASH MISMATCH\n"), p);
|
||||
if (!keep)
|
||||
{
|
||||
grub_file_close (hashlist);
|
||||
grub_free (buf);
|
||||
return grub_error (GRUB_ERR_TEST_FAILURE,
|
||||
"hash of '%s' mismatches", p);
|
||||
}
|
||||
mismatch++;
|
||||
continue;
|
||||
}
|
||||
grub_printf_ (N_("%s: OK\n"), p);
|
||||
}
|
||||
if (mismatch || unread)
|
||||
return grub_error (GRUB_ERR_TEST_FAILURE,
|
||||
"%d files couldn't be read and hash "
|
||||
"of %d files mismatches", unread, mismatch);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
|
||||
int argc, char **args)
|
||||
{
|
||||
struct grub_arg_list *state = ctxt->state;
|
||||
const char *hashname = NULL;
|
||||
const char *prefix = NULL;
|
||||
const gcry_md_spec_t *hash;
|
||||
unsigned i;
|
||||
int keep = state[3].set;
|
||||
int uncompress = state[4].set;
|
||||
unsigned unread = 0;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE (aliases); i++)
|
||||
if (grub_strcmp (ctxt->extcmd->cmd->name, aliases[i].name) == 0)
|
||||
hashname = aliases[i].hashname;
|
||||
if (state[0].set)
|
||||
hashname = state[0].arg;
|
||||
|
||||
if (!hashname)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no hash specified");
|
||||
|
||||
hash = grub_crypto_lookup_md_by_name (hashname);
|
||||
if (!hash)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown hash");
|
||||
|
||||
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
|
||||
return grub_error (GRUB_ERR_BUG, "mdlen is too long");
|
||||
|
||||
if (state[2].set)
|
||||
prefix = state[2].arg;
|
||||
|
||||
if (state[1].set)
|
||||
{
|
||||
if (argc != 0)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"--check is incompatible with file list");
|
||||
return check_list (hash, state[1].arg, prefix, keep, uncompress);
|
||||
}
|
||||
|
||||
for (i = 0; i < (unsigned) argc; i++)
|
||||
{
|
||||
GRUB_PROPERLY_ALIGNED_ARRAY (result, GRUB_CRYPTO_MAX_MDLEN);
|
||||
grub_file_t file;
|
||||
grub_err_t err;
|
||||
unsigned j;
|
||||
file = grub_file_open (args[i], GRUB_FILE_TYPE_TO_HASH
|
||||
| (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
|
||||
: GRUB_FILE_TYPE_NONE));
|
||||
if (!file)
|
||||
{
|
||||
if (!keep)
|
||||
return grub_errno;
|
||||
grub_print_error ();
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
unread++;
|
||||
continue;
|
||||
}
|
||||
err = hash_file (file, hash, result);
|
||||
grub_file_close (file);
|
||||
if (err)
|
||||
{
|
||||
if (!keep)
|
||||
return err;
|
||||
grub_print_error ();
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
unread++;
|
||||
continue;
|
||||
}
|
||||
for (j = 0; j < hash->mdlen; j++)
|
||||
grub_printf ("%02x", ((grub_uint8_t *) result)[j]);
|
||||
grub_printf (" %s\n", args[i]);
|
||||
}
|
||||
|
||||
if (unread)
|
||||
return grub_error (GRUB_ERR_TEST_FAILURE, "%d files couldn't be read",
|
||||
unread);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_extcmd_t cmd, cmd_md5, cmd_sha1, cmd_sha256, cmd_sha512, cmd_crc;
|
||||
|
||||
GRUB_MOD_INIT(hashsum)
|
||||
{
|
||||
cmd = grub_register_extcmd ("hashsum", grub_cmd_hashsum, 0,
|
||||
N_("-h HASH [-c FILE [-p PREFIX]] "
|
||||
"[FILE1 [FILE2 ...]]"),
|
||||
/* TRANSLATORS: "hash checksum" is just to
|
||||
be a bit more precise, you can treat it as
|
||||
just "hash". */
|
||||
N_("Compute or check hash checksum."),
|
||||
options);
|
||||
cmd_md5 = grub_register_extcmd ("md5sum", grub_cmd_hashsum, 0,
|
||||
N_("[-c FILE [-p PREFIX]] "
|
||||
"[FILE1 [FILE2 ...]]"),
|
||||
N_("Compute or check hash checksum."),
|
||||
options);
|
||||
cmd_sha1 = grub_register_extcmd ("sha1sum", grub_cmd_hashsum, 0,
|
||||
N_("[-c FILE [-p PREFIX]] "
|
||||
"[FILE1 [FILE2 ...]]"),
|
||||
N_("Compute or check hash checksum."),
|
||||
options);
|
||||
cmd_sha256 = grub_register_extcmd ("sha256sum", grub_cmd_hashsum, 0,
|
||||
N_("[-c FILE [-p PREFIX]] "
|
||||
"[FILE1 [FILE2 ...]]"),
|
||||
N_("Compute or check hash checksum."),
|
||||
options);
|
||||
cmd_sha512 = grub_register_extcmd ("sha512sum", grub_cmd_hashsum, 0,
|
||||
N_("[-c FILE [-p PREFIX]] "
|
||||
"[FILE1 [FILE2 ...]]"),
|
||||
N_("Compute or check hash checksum."),
|
||||
options);
|
||||
|
||||
cmd_crc = grub_register_extcmd ("crc", grub_cmd_hashsum, 0,
|
||||
N_("[-c FILE [-p PREFIX]] "
|
||||
"[FILE1 [FILE2 ...]]"),
|
||||
N_("Compute or check hash checksum."),
|
||||
options);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(hashsum)
|
||||
{
|
||||
grub_unregister_extcmd (cmd);
|
||||
grub_unregister_extcmd (cmd_md5);
|
||||
grub_unregister_extcmd (cmd_sha1);
|
||||
grub_unregister_extcmd (cmd_sha256);
|
||||
grub_unregister_extcmd (cmd_sha512);
|
||||
grub_unregister_extcmd (cmd_crc);
|
||||
}
|
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);
|
||||
}
|
@@ -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;
|
||||
|
@@ -280,6 +280,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)
|
||||
|
@@ -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)
|
||||
|
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);
|
||||
}
|
@@ -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 */
|
||||
|
@@ -127,6 +127,9 @@ static grub_uint64_t g_enumerate_start_time_ms;
|
||||
static grub_uint64_t g_enumerate_finish_time_ms;
|
||||
static int g_vtoy_file_flt[VTOY_FILE_FLT_BUTT] = {0};
|
||||
|
||||
static int g_pager_flag = 0;
|
||||
static char g_old_pager[32];
|
||||
|
||||
static const char *g_vtoy_winpeshl_ini = "[LaunchApps]\r\nvtoyjump.exe";
|
||||
|
||||
static const char *g_menu_class[] =
|
||||
@@ -142,6 +145,8 @@ const char *g_menu_prefix[img_type_max] =
|
||||
static int g_vtoy_load_prompt = 0;
|
||||
static char g_vtoy_prompt_msg[64];
|
||||
|
||||
static char g_json_case_mis_path[32];
|
||||
|
||||
static int ventoy_get_fs_type(const char *fs)
|
||||
{
|
||||
if (NULL == fs)
|
||||
@@ -1221,6 +1226,23 @@ static grub_err_t ventoy_cmd_load_img_memdisk(grub_extcmd_context_t ctxt, int ar
|
||||
return rc;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_iso9660_is_joliet(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
if (grub_iso9660_is_joliet())
|
||||
{
|
||||
debug("This time has joliet process\n");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_iso9660_nojoliet(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
(void)ctxt;
|
||||
@@ -3148,6 +3170,22 @@ static grub_err_t ventoy_cmd_add_replace_file(grub_extcmd_context_t ctxt, int ar
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_get_replace_file_cnt(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
char buf[32];
|
||||
ventoy_grub_param_file_replace *replace = &(g_grub_param->file_replace);
|
||||
|
||||
(void)ctxt;
|
||||
|
||||
if (argc >= 1)
|
||||
{
|
||||
grub_snprintf(buf, sizeof(buf), "%u", replace->old_name_cnt);
|
||||
grub_env_set(args[0], buf);
|
||||
}
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_dump_menu(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
(void)ctxt;
|
||||
@@ -3453,9 +3491,11 @@ end:
|
||||
|
||||
static int ventoy_img_partition_callback (struct grub_disk *disk, const grub_partition_t partition, void *data)
|
||||
{
|
||||
(void)disk;
|
||||
(void)data;
|
||||
int *pCnt = (int *)data;
|
||||
|
||||
(void)disk;
|
||||
|
||||
(*pCnt)++;
|
||||
g_part_list_pos += grub_snprintf(g_part_list_buf + g_part_list_pos, VTOY_MAX_SCRIPT_BUF - g_part_list_pos,
|
||||
"0 %llu linear /dev/ventoy %llu\n",
|
||||
(ulonglong)partition->len, (ulonglong)partition->start);
|
||||
@@ -3465,6 +3505,7 @@ static int ventoy_img_partition_callback (struct grub_disk *disk, const grub_par
|
||||
|
||||
static grub_err_t ventoy_cmd_img_part_info(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int cnt = 0;
|
||||
char *device_name = NULL;
|
||||
grub_device_t dev = NULL;
|
||||
char buf[64];
|
||||
@@ -3493,11 +3534,14 @@ static grub_err_t ventoy_cmd_img_part_info(grub_extcmd_context_t ctxt, int argc,
|
||||
goto end;
|
||||
}
|
||||
|
||||
grub_partition_iterate(dev->disk, ventoy_img_partition_callback, NULL);
|
||||
grub_partition_iterate(dev->disk, ventoy_img_partition_callback, &cnt);
|
||||
|
||||
grub_snprintf(buf, sizeof(buf), "newc:vtoy_dm_table:mem:0x%llx:size:%d", (ulonglong)(ulong)g_part_list_buf, g_part_list_pos);
|
||||
grub_env_set("vtoy_img_part_file", buf);
|
||||
|
||||
grub_snprintf(buf, sizeof(buf), "%d", cnt);
|
||||
grub_env_set("vtoy_img_part_cnt", buf);
|
||||
|
||||
end:
|
||||
|
||||
check_free(device_name, grub_free);
|
||||
@@ -4204,8 +4248,18 @@ static int ventoy_fs_enum_1st_file(const char *filename, const struct grub_dirho
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_fs_enum_1st_dir(const char *filename, const struct grub_dirhook_info *info, void *data)
|
||||
{
|
||||
if (info->dir && filename && filename[0] != '.')
|
||||
{
|
||||
grub_snprintf((char *)data, 256, "%s", filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_fs_enum_1st_file(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_fs_enum_1st_child(int argc, char **args, grub_fs_dir_hook_t hook)
|
||||
{
|
||||
int rc = 1;
|
||||
char *device_name = NULL;
|
||||
@@ -4213,11 +4267,9 @@ static grub_err_t ventoy_cmd_fs_enum_1st_file(grub_extcmd_context_t ctxt, int ar
|
||||
grub_fs_t fs = NULL;
|
||||
char name[256] ={0};
|
||||
|
||||
(void)ctxt;
|
||||
|
||||
if (argc != 3)
|
||||
{
|
||||
debug("ventoy_cmd_fs_enum_1st_file, invalid param num %d\n", argc);
|
||||
debug("ventoy_fs_enum_1st_child, invalid param num %d\n", argc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -4242,7 +4294,7 @@ static grub_err_t ventoy_cmd_fs_enum_1st_file(grub_extcmd_context_t ctxt, int ar
|
||||
goto end;
|
||||
}
|
||||
|
||||
fs->fs_dir(dev, args[1], ventoy_fs_enum_1st_file, name);
|
||||
fs->fs_dir(dev, args[1], hook, name);
|
||||
if (name[0])
|
||||
{
|
||||
ventoy_set_env(args[2], name);
|
||||
@@ -4258,6 +4310,18 @@ end:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_fs_enum_1st_file(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
(void)ctxt;
|
||||
return ventoy_fs_enum_1st_child(argc, args, ventoy_fs_enum_1st_file);
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_fs_enum_1st_dir(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
(void)ctxt;
|
||||
return ventoy_fs_enum_1st_child(argc, args, ventoy_fs_enum_1st_dir);
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_basename(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
char c;
|
||||
@@ -4405,6 +4469,388 @@ static grub_err_t ventoy_cmd_get_video_mode(grub_extcmd_context_t ctxt, int argc
|
||||
VENTOY_CMD_RETURN(0);
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_get_efivdisk_offset(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
grub_uint32_t i;
|
||||
grub_uint32_t loadsector = 0;
|
||||
grub_file_t file;
|
||||
char value[32];
|
||||
grub_uint32_t boot_catlog = 0;
|
||||
grub_uint8_t buf[512];
|
||||
|
||||
(void)ctxt;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
debug("ventoy_cmd_get_efivdisk_offset, invalid param num %d\n", argc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
file = grub_file_open(args[0], VENTOY_FILE_TYPE);
|
||||
if (!file)
|
||||
{
|
||||
debug("failed to open %s\n", args[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
boot_catlog = ventoy_get_iso_boot_catlog(file);
|
||||
if (boot_catlog == 0)
|
||||
{
|
||||
debug("No bootcatlog found\n");
|
||||
grub_file_close(file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
grub_memset(buf, 0, sizeof(buf));
|
||||
grub_file_seek(file, boot_catlog * 2048);
|
||||
grub_file_read(file, buf, sizeof(buf));
|
||||
grub_file_close(file);
|
||||
|
||||
for (i = 0; i < sizeof(buf); i += 32)
|
||||
{
|
||||
if ((buf[i] == 0 || buf[i] == 0x90 || buf[i] == 0x91) && buf[i + 1] == 0xEF)
|
||||
{
|
||||
if (buf[i + 32] == 0x88)
|
||||
{
|
||||
loadsector = *(grub_uint32_t *)(buf + i + 32 + 8);
|
||||
grub_snprintf(value, sizeof(value), "%u", loadsector * 4); //change to sector size 512
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (loadsector == 0)
|
||||
{
|
||||
debug("No EFI eltorito info found\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
debug("ventoy_cmd_get_efivdisk_offset <%s>\n", value);
|
||||
grub_env_set(args[1], value);
|
||||
VENTOY_CMD_RETURN(0);
|
||||
}
|
||||
|
||||
static int ventoy_collect_replace_initrd(const char *filename, const struct grub_dirhook_info *info, void *data)
|
||||
{
|
||||
int curpos;
|
||||
int printlen;
|
||||
grub_size_t len;
|
||||
replace_fs_dir *pfsdir = (replace_fs_dir *)data;
|
||||
|
||||
if (pfsdir->initrd[0])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
curpos = pfsdir->curpos;
|
||||
len = grub_strlen(filename);
|
||||
|
||||
if (info->dir)
|
||||
{
|
||||
if ((len == 1 && filename[0] == '.') ||
|
||||
(len == 2 && filename[0] == '.' && filename[1] == '.'))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//debug("#### [DIR] <%s> <%s>\n", pfsdir->fullpath, filename);
|
||||
pfsdir->dircnt++;
|
||||
|
||||
printlen = grub_snprintf(pfsdir->fullpath + curpos, 512 - curpos, "%s/", filename);
|
||||
pfsdir->curpos = curpos + printlen;
|
||||
pfsdir->fs->fs_dir(pfsdir->dev, pfsdir->fullpath, ventoy_collect_replace_initrd, pfsdir);
|
||||
pfsdir->curpos = curpos;
|
||||
pfsdir->fullpath[curpos] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//debug("#### [FILE] <%s> <%s>\n", pfsdir->fullpath, filename);
|
||||
pfsdir->filecnt++;
|
||||
|
||||
/* We consider the xxx.img file bigger than 32MB is the initramfs file */
|
||||
if (len > 4 && grub_strncmp(filename + len - 4, ".img", 4) == 0)
|
||||
{
|
||||
if (info->size > 32 * VTOY_SIZE_1MB)
|
||||
{
|
||||
grub_snprintf(pfsdir->initrd, sizeof(pfsdir->initrd), "%s%s", pfsdir->fullpath, filename);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_search_replace_initrd(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int i;
|
||||
char *pos = NULL;
|
||||
char *device_name = NULL;
|
||||
grub_device_t dev = NULL;
|
||||
grub_fs_t fs = NULL;
|
||||
replace_fs_dir *pfsdir = NULL;
|
||||
|
||||
(void)ctxt;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
debug("ventoy_cmd_search_replace_initrd, invalid param num %d\n", argc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
pfsdir = grub_zalloc(sizeof(replace_fs_dir));
|
||||
if (!pfsdir)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
device_name = grub_file_get_device_name(args[0]);
|
||||
if (!device_name)
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
|
||||
dev = grub_device_open(device_name);
|
||||
if (!dev)
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
|
||||
fs = grub_fs_probe(dev);
|
||||
if (!fs)
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pfsdir->dev = dev;
|
||||
pfsdir->fs = fs;
|
||||
pfsdir->curpos = 1;
|
||||
pfsdir->fullpath[0] = '/';
|
||||
fs->fs_dir(dev, "/", ventoy_collect_replace_initrd, pfsdir);
|
||||
|
||||
if (pfsdir->initrd[0])
|
||||
{
|
||||
debug("Replace initrd <%s> <%d %d>\n", pfsdir->initrd, pfsdir->dircnt, pfsdir->filecnt);
|
||||
|
||||
for (i = 0; i < (int)sizeof(pfsdir->initrd) && pfsdir->initrd[i]; i++)
|
||||
{
|
||||
if (pfsdir->initrd[i] == '/')
|
||||
{
|
||||
pfsdir->initrd[i] = '\\';
|
||||
}
|
||||
}
|
||||
|
||||
pos = (pfsdir->initrd[0] == '\\') ? pfsdir->initrd + 1 : pfsdir->initrd;
|
||||
grub_env_set(args[1], pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("Replace initrd NOT found <%s> <%d %d>\n", args[0], pfsdir->dircnt, pfsdir->filecnt);
|
||||
}
|
||||
|
||||
fail:
|
||||
|
||||
grub_check_free(pfsdir);
|
||||
grub_check_free(device_name);
|
||||
check_free(dev, grub_device_close);
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_push_pager(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
const char *pager = NULL;
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
pager = grub_env_get("pager");
|
||||
if (NULL == pager)
|
||||
{
|
||||
g_pager_flag = 1;
|
||||
grub_env_set("pager", "1");
|
||||
}
|
||||
else if (pager[0] == '1')
|
||||
{
|
||||
g_pager_flag = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_snprintf(g_old_pager, sizeof(g_old_pager), "%s", pager);
|
||||
g_pager_flag = 2;
|
||||
grub_env_set("pager", "1");
|
||||
}
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_pop_pager(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
if (g_pager_flag == 1)
|
||||
{
|
||||
grub_env_unset("pager");
|
||||
}
|
||||
else if (g_pager_flag == 2)
|
||||
{
|
||||
grub_env_set("pager", g_old_pager);
|
||||
}
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
static int ventoy_chk_case_file(const char *filename, const struct grub_dirhook_info *info, void *data)
|
||||
{
|
||||
if (g_json_case_mis_path[0])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 == info->dir && grub_strncasecmp(filename, "ventoy.json", 11) == 0)
|
||||
{
|
||||
grub_snprintf(g_json_case_mis_path, 32, "%s/%s", (char *)data, filename);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_chk_case_dir(const char *filename, const struct grub_dirhook_info *info, void *data)
|
||||
{
|
||||
char path[16];
|
||||
chk_case_fs_dir *fs_dir = (chk_case_fs_dir *)data;
|
||||
|
||||
if (g_json_case_mis_path[0])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (info->dir && (filename[0] == 'v' || filename[0] == 'V'))
|
||||
{
|
||||
if (grub_strncasecmp(filename, "ventoy", 6) == 0)
|
||||
{
|
||||
grub_snprintf(path, sizeof(path), "/%s", filename);
|
||||
fs_dir->fs->fs_dir(fs_dir->dev, path, ventoy_chk_case_file, path);
|
||||
if (g_json_case_mis_path[0])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_chk_json_pathcase(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int fstype = 0;
|
||||
char *device_name = NULL;
|
||||
grub_device_t dev = NULL;
|
||||
grub_fs_t fs = NULL;
|
||||
chk_case_fs_dir fs_dir;
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
device_name = grub_file_get_device_name(args[0]);
|
||||
if (!device_name)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
dev = grub_device_open(device_name);
|
||||
if (!dev)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
fs = grub_fs_probe(dev);
|
||||
if (!fs)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
fstype = ventoy_get_fs_type(fs->name);
|
||||
if (fstype == ventoy_fs_fat || fstype == ventoy_fs_exfat || fstype >= ventoy_fs_max)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
g_json_case_mis_path[0] = 0;
|
||||
fs_dir.dev = dev;
|
||||
fs_dir.fs = fs;
|
||||
fs->fs_dir(dev, "/", ventoy_chk_case_dir, &fs_dir);
|
||||
|
||||
if (g_json_case_mis_path[0])
|
||||
{
|
||||
grub_env_set("VTOY_PLUGIN_PATH_CASE_MISMATCH", g_json_case_mis_path);
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
grub_check_free(device_name);
|
||||
check_free(dev, grub_device_close);
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
static grub_err_t grub_cmd_gptpriority(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
grub_disk_t disk;
|
||||
grub_partition_t part;
|
||||
char priority_str[3]; /* Maximum value 15 */
|
||||
|
||||
(void)ctxt;
|
||||
|
||||
if (argc < 2 || argc > 3)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"gptpriority DISKNAME PARTITIONNUM [VARNAME]");
|
||||
|
||||
/* Open the disk if it exists */
|
||||
disk = grub_disk_open (args[0]);
|
||||
if (!disk)
|
||||
{
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"Not a disk");
|
||||
}
|
||||
|
||||
part = grub_partition_probe (disk, args[1]);
|
||||
if (!part)
|
||||
{
|
||||
grub_disk_close (disk);
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"No such partition");
|
||||
}
|
||||
|
||||
if (grub_strcmp (part->partmap->name, "gpt"))
|
||||
{
|
||||
grub_disk_close (disk);
|
||||
return grub_error (GRUB_ERR_BAD_PART_TABLE,
|
||||
"Not a GPT partition");
|
||||
}
|
||||
|
||||
grub_snprintf (priority_str, sizeof(priority_str), "%u",
|
||||
(grub_uint32_t)((part->gpt_attrib >> 48) & 0xfULL));
|
||||
|
||||
if (argc == 3)
|
||||
{
|
||||
grub_env_set (args[2], priority_str);
|
||||
grub_env_export (args[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf ("Priority is %s\n", priority_str);
|
||||
}
|
||||
|
||||
grub_disk_close (disk);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
||||
int ventoy_env_init(void)
|
||||
{
|
||||
char buf[64];
|
||||
@@ -4452,6 +4898,8 @@ int ventoy_env_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static cmd_para ventoy_cmds[] =
|
||||
{
|
||||
{ "vt_incr", ventoy_cmd_incr, 0, NULL, "{Var} {INT}", "Increase integer variable", NULL },
|
||||
@@ -4491,6 +4939,7 @@ static cmd_para ventoy_cmds[] =
|
||||
{ "vt_check_part_exist", ventoy_cmd_part_exist, 0, NULL, "", "", NULL },
|
||||
{ "vt_get_fs_label", ventoy_cmd_get_fs_label, 0, NULL, "", "", NULL },
|
||||
{ "vt_fs_enum_1st_file", ventoy_cmd_fs_enum_1st_file, 0, NULL, "", "", NULL },
|
||||
{ "vt_fs_enum_1st_dir", ventoy_cmd_fs_enum_1st_dir, 0, NULL, "", "", NULL },
|
||||
{ "vt_file_basename", ventoy_cmd_basename, 0, NULL, "", "", NULL },
|
||||
{ "vt_file_basefile", ventoy_cmd_basefile, 0, NULL, "", "", NULL },
|
||||
{ "vt_enum_video_mode", ventoy_cmd_enum_video_mode, 0, NULL, "", "", NULL },
|
||||
@@ -4511,6 +4960,7 @@ static cmd_para ventoy_cmds[] =
|
||||
{ "vt_select_conf_replace", ventoy_select_conf_replace, 0, NULL, "", "", NULL },
|
||||
|
||||
{ "vt_iso9660_nojoliet", ventoy_cmd_iso9660_nojoliet, 0, NULL, "", "", NULL },
|
||||
{ "vt_iso9660_isjoliet", ventoy_cmd_iso9660_is_joliet, 0, NULL, "", "", NULL },
|
||||
{ "vt_is_udf", ventoy_cmd_is_udf, 0, NULL, "", "", NULL },
|
||||
{ "vt_file_size", ventoy_cmd_file_size, 0, NULL, "", "", NULL },
|
||||
{ "vt_load_file_to_mem", ventoy_cmd_load_file_to_mem, 0, NULL, "", "", NULL },
|
||||
@@ -4539,6 +4989,7 @@ static cmd_para ventoy_cmds[] =
|
||||
{ "vt_wim_chain_data", ventoy_cmd_wim_chain_data, 0, NULL, "", "", NULL },
|
||||
|
||||
{ "vt_add_replace_file", ventoy_cmd_add_replace_file, 0, NULL, "", "", NULL },
|
||||
{ "vt_get_replace_file_cnt", ventoy_cmd_get_replace_file_cnt, 0, NULL, "", "", NULL },
|
||||
{ "vt_test_block_list", ventoy_cmd_test_block_list, 0, NULL, "", "", NULL },
|
||||
{ "vt_file_exist_nocase", ventoy_cmd_file_exist_nocase, 0, NULL, "", "", NULL },
|
||||
|
||||
@@ -4573,7 +5024,15 @@ static cmd_para ventoy_cmds[] =
|
||||
{ "vt_is_pe64", ventoy_cmd_is_pe64, 0, NULL, "", "", NULL },
|
||||
{ "vt_sel_wimboot", ventoy_cmd_sel_wimboot, 0, NULL, "", "", NULL },
|
||||
{ "vt_set_wim_load_prompt", ventoy_cmd_set_wim_prompt, 0, NULL, "", "", NULL },
|
||||
{ "vt_set_theme", ventoy_cmd_set_theme, 0, NULL, "", "", NULL },
|
||||
|
||||
{ "vt_get_efi_vdisk_offset", ventoy_cmd_get_efivdisk_offset, 0, NULL, "", "", NULL },
|
||||
{ "vt_search_replace_initrd", ventoy_cmd_search_replace_initrd, 0, NULL, "", "", NULL },
|
||||
{ "vt_push_pager", ventoy_cmd_push_pager, 0, NULL, "", "", NULL },
|
||||
{ "vt_pop_pager", ventoy_cmd_pop_pager, 0, NULL, "", "", NULL },
|
||||
{ "vt_check_json_path_case", ventoy_cmd_chk_json_pathcase, 0, NULL, "", "", NULL },
|
||||
{ "vt_append_extra_sector", ventoy_cmd_append_ext_sector, 0, NULL, "", "", NULL },
|
||||
{ "gptpriority", grub_cmd_gptpriority, 0, NULL, "", "", NULL },
|
||||
};
|
||||
|
||||
int ventoy_register_all_cmd(void)
|
||||
|
@@ -69,6 +69,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"); \
|
||||
@@ -533,6 +536,23 @@ typedef struct plugin_entry
|
||||
ventoy_plugin_check_pf checkfunc;
|
||||
}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 +568,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);
|
||||
@@ -778,8 +799,17 @@ typedef struct file_fullpath
|
||||
char path[256];
|
||||
}file_fullpath;
|
||||
|
||||
typedef struct theme_list
|
||||
{
|
||||
file_fullpath theme;
|
||||
struct theme_list *next;
|
||||
}theme_list;
|
||||
|
||||
#define auto_install_type_file 0
|
||||
#define auto_install_type_parent 1
|
||||
typedef struct install_template
|
||||
{
|
||||
int type;
|
||||
int pathlen;
|
||||
char isopath[256];
|
||||
|
||||
@@ -873,8 +903,11 @@ typedef struct conf_replace
|
||||
struct conf_replace *next;
|
||||
}conf_replace;
|
||||
|
||||
#define injection_type_file 0
|
||||
#define injection_type_parent 1
|
||||
typedef struct injection_config
|
||||
{
|
||||
int type;
|
||||
int pathlen;
|
||||
char isopath[256];
|
||||
char archive[256];
|
||||
@@ -993,6 +1026,7 @@ int ventoy_plugin_load_dud(dud *node, const char *isopart);
|
||||
int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
|
||||
int ventoy_check_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
|
||||
void ventoy_plugin_dump_persistence(void);
|
||||
grub_err_t ventoy_cmd_set_theme(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_plugin_check_json(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_check_password(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_linux_get_main_initrd_index(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
@@ -1030,5 +1064,15 @@ int ventoy_chain_file_read(const char *path, int offset, int len, void *buf);
|
||||
|
||||
#define VTOY_CMD_CHECK(a) if (33554432 != g_ventoy_disk_part_size[a]) ventoy_syscall0(exit)
|
||||
|
||||
#define vtoy_theme_random_boot_second 0
|
||||
#define vtoy_theme_random_boot_day 1
|
||||
#define vtoy_theme_random_boot_month 2
|
||||
|
||||
#define ventoy_env_export(env, name) \
|
||||
{\
|
||||
grub_env_set((env), (name));\
|
||||
grub_env_export(env);\
|
||||
}
|
||||
|
||||
#endif /* __VENTOY_DEF_H__ */
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
@@ -654,6 +680,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;
|
||||
}
|
||||
|
||||
@@ -709,6 +740,27 @@ static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_
|
||||
cur++;
|
||||
}
|
||||
|
||||
/* 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++;
|
||||
}
|
||||
|
||||
if (g_conf_replace_offset > 0)
|
||||
{
|
||||
cpio_secs = g_conf_replace_new_len_align / 2048;
|
||||
@@ -1101,6 +1153,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 +1511,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,6 +1553,13 @@ grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, cha
|
||||
|
||||
isosize = file->size;
|
||||
|
||||
len = (int)grub_strlen(args[0]);
|
||||
if (len >= 4 && 0 == grub_strcasecmp(args[0] + len - 4, ".img"))
|
||||
{
|
||||
debug("boot catlog %u for img file\n", boot_catlog);
|
||||
}
|
||||
else
|
||||
{
|
||||
boot_catlog = ventoy_get_iso_boot_catlog(file);
|
||||
if (boot_catlog)
|
||||
{
|
||||
@@ -1502,6 +1579,7 @@ grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, cha
|
||||
return grub_error(GRUB_ERR_BAD_ARGUMENT, "File %s is not bootable", args[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
img_chunk_size = g_img_chunk_list.cur_chunk * sizeof(ventoy_img_chunk);
|
||||
|
||||
|
@@ -56,6 +56,32 @@ 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_num = 0;
|
||||
static theme_list *g_theme_head = NULL;
|
||||
static int g_theme_random = vtoy_theme_random_boot_second;
|
||||
static char g_theme_single_file[256];
|
||||
|
||||
static int ventoy_plugin_is_parent(const char *pat, int patlen, const char *isopath)
|
||||
{
|
||||
if (patlen > 1)
|
||||
{
|
||||
if (isopath[patlen] == '/' && ventoy_strncmp(pat, isopath, patlen) == 0 &&
|
||||
grub_strchr(isopath + patlen + 1, '/') == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pat[0] == '/' && grub_strchr(isopath + 1, '/') == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_plugin_control_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int rc = 0;
|
||||
@@ -156,6 +182,38 @@ static int ventoy_plugin_theme_check(VTOY_JSON *json, const char *isodisk)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
node = vtoy_json_find_item(json->pstChild, JSON_TYPE_ARRAY, "file");
|
||||
if (node)
|
||||
{
|
||||
for (node = node->pstChild; node; node = node->pstNext)
|
||||
{
|
||||
value = node->unData.pcStrVal;
|
||||
grub_printf("file: %s\n", value);
|
||||
if (value[0] == '/')
|
||||
{
|
||||
exist = ventoy_is_file_exist("%s%s", isodisk, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
exist = ventoy_is_file_exist("%s/ventoy/%s", isodisk, value);
|
||||
}
|
||||
|
||||
if (exist == 0)
|
||||
{
|
||||
grub_printf("Theme file %s does NOT exist\n", value);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "random");
|
||||
if (value)
|
||||
{
|
||||
grub_printf("random: %s\n", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "gfxmode");
|
||||
if (value)
|
||||
@@ -223,7 +281,9 @@ static int ventoy_plugin_theme_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
const char *value;
|
||||
char filepath[256];
|
||||
VTOY_JSON *node;
|
||||
VTOY_JSON *node = NULL;
|
||||
theme_list *tail = NULL;
|
||||
theme_list *themenode = NULL;
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "file");
|
||||
if (value)
|
||||
@@ -237,53 +297,112 @@ static int ventoy_plugin_theme_entry(VTOY_JSON *json, const char *isodisk)
|
||||
grub_snprintf(filepath, sizeof(filepath), "%s/ventoy/%s", isodisk, value);
|
||||
}
|
||||
|
||||
if (ventoy_is_file_exist(filepath) == 0)
|
||||
if (ventoy_check_file_exist(filepath) == 0)
|
||||
{
|
||||
debug("Theme file %s does not exist\n", filepath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
debug("vtoy_theme %s\n", filepath);
|
||||
grub_env_set("vtoy_theme", filepath);
|
||||
ventoy_env_export("vtoy_theme", filepath);
|
||||
grub_snprintf(g_theme_single_file, sizeof(g_theme_single_file), "%s", filepath);
|
||||
}
|
||||
else
|
||||
{
|
||||
node = vtoy_json_find_item(json->pstChild, JSON_TYPE_ARRAY, "file");
|
||||
if (node)
|
||||
{
|
||||
for (node = node->pstChild; node; node = node->pstNext)
|
||||
{
|
||||
value = node->unData.pcStrVal;
|
||||
if (value[0] == '/')
|
||||
{
|
||||
grub_snprintf(filepath, sizeof(filepath), "%s%s", isodisk, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_snprintf(filepath, sizeof(filepath), "%s/ventoy/%s", isodisk, value);
|
||||
}
|
||||
|
||||
if (ventoy_check_file_exist(filepath) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
themenode = grub_zalloc(sizeof(theme_list));
|
||||
if (themenode)
|
||||
{
|
||||
grub_snprintf(themenode->theme.path, sizeof(themenode->theme.path), "%s", filepath);
|
||||
if (g_theme_head)
|
||||
{
|
||||
tail->next = themenode;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_theme_head = themenode;
|
||||
}
|
||||
tail = themenode;
|
||||
g_theme_num++;
|
||||
}
|
||||
}
|
||||
|
||||
ventoy_env_export("vtoy_theme", "random");
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "random");
|
||||
if (value)
|
||||
{
|
||||
if (grub_strcmp(value, "boot_second") == 0)
|
||||
{
|
||||
g_theme_random = vtoy_theme_random_boot_second;
|
||||
}
|
||||
else if (grub_strcmp(value, "boot_day") == 0)
|
||||
{
|
||||
g_theme_random = vtoy_theme_random_boot_day;
|
||||
}
|
||||
else if (grub_strcmp(value, "boot_month") == 0)
|
||||
{
|
||||
g_theme_random = vtoy_theme_random_boot_month;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "gfxmode");
|
||||
if (value)
|
||||
{
|
||||
debug("vtoy_gfxmode %s\n", value);
|
||||
grub_env_set("vtoy_gfxmode", value);
|
||||
ventoy_env_export("vtoy_gfxmode", value);
|
||||
}
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "display_mode");
|
||||
if (value)
|
||||
{
|
||||
debug("display_mode %s\n", value);
|
||||
grub_env_set("vtoy_display_mode", value);
|
||||
ventoy_env_export("vtoy_display_mode", value);
|
||||
}
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "serial_param");
|
||||
if (value)
|
||||
{
|
||||
debug("serial_param %s\n", value);
|
||||
grub_env_set("vtoy_serial_param", value);
|
||||
ventoy_env_export("vtoy_serial_param", value);
|
||||
}
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "ventoy_left");
|
||||
if (value)
|
||||
{
|
||||
grub_env_set("VTLE_LFT", value);
|
||||
ventoy_env_export("VTLE_LFT", value);
|
||||
}
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "ventoy_top");
|
||||
if (value)
|
||||
{
|
||||
grub_env_set("VTLE_TOP", value);
|
||||
ventoy_env_export("VTLE_TOP", value);
|
||||
}
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "ventoy_color");
|
||||
if (value)
|
||||
{
|
||||
grub_env_set("VTLE_CLR", value);
|
||||
ventoy_env_export("VTLE_CLR", value);
|
||||
}
|
||||
|
||||
node = vtoy_json_find_item(json->pstChild, JSON_TYPE_ARRAY, "fonts");
|
||||
@@ -499,8 +618,7 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
|
||||
grub_printf("NOT object type\n");
|
||||
}
|
||||
|
||||
iso = vtoy_json_get_string_ex(pNode->pstChild, "image");
|
||||
if (iso)
|
||||
if ((iso = vtoy_json_get_string_ex(pNode->pstChild, "image")) != NULL)
|
||||
{
|
||||
pos = grub_strchr(iso, '*');
|
||||
if (pos || 0 == ventoy_plugin_check_path(isodisk, iso))
|
||||
@@ -525,6 +643,30 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
|
||||
grub_printf("image: %s [FAIL]\n", iso);
|
||||
}
|
||||
}
|
||||
else if ((iso = vtoy_json_get_string_ex(pNode->pstChild, "parent")) != NULL)
|
||||
{
|
||||
if (ventoy_is_dir_exist("%s%s", isodisk, iso))
|
||||
{
|
||||
grub_printf("parent: %s [OK]\n", iso);
|
||||
ventoy_plugin_check_fullpath(pNode->pstChild, isodisk, "template", &pathnum);
|
||||
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "autosel", &autosel))
|
||||
{
|
||||
if (autosel >= 0 && autosel <= pathnum)
|
||||
{
|
||||
grub_printf("autosel: %d [OK]\n", autosel);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("autosel: %d [FAIL]\n", autosel);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("parent: %s [FAIL]\n", iso);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("image not found\n");
|
||||
@@ -536,6 +678,7 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
|
||||
|
||||
static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int type = 0;
|
||||
int pathnum = 0;
|
||||
int autosel = 0;
|
||||
const char *iso = NULL;
|
||||
@@ -564,7 +707,14 @@ static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk
|
||||
|
||||
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
type = auto_install_type_file;
|
||||
iso = vtoy_json_get_string_ex(pNode->pstChild, "image");
|
||||
if (!iso)
|
||||
{
|
||||
type = auto_install_type_parent;
|
||||
iso = vtoy_json_get_string_ex(pNode->pstChild, "parent");
|
||||
}
|
||||
|
||||
if (iso && iso[0] == '/')
|
||||
{
|
||||
if (0 == ventoy_plugin_parse_fullpath(pNode->pstChild, isodisk, "template", &templatepath, &pathnum))
|
||||
@@ -572,6 +722,7 @@ static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk
|
||||
node = grub_zalloc(sizeof(install_template));
|
||||
if (node)
|
||||
{
|
||||
node->type = type;
|
||||
node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", iso);
|
||||
node->templatepath = templatepath;
|
||||
node->templatenum = pathnum;
|
||||
@@ -1269,6 +1420,7 @@ static int ventoy_plugin_menualias_entry(VTOY_JSON *json, const char *isodisk)
|
||||
|
||||
static int ventoy_plugin_injection_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int type = 0;
|
||||
const char *path = NULL;
|
||||
const char *archive = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
@@ -1283,12 +1435,18 @@ static int ventoy_plugin_injection_check(VTOY_JSON *json, const char *isodisk)
|
||||
|
||||
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
type = injection_type_file;
|
||||
path = vtoy_json_get_string_ex(pNode->pstChild, "image");
|
||||
if (!path)
|
||||
{
|
||||
grub_printf("image not found\n");
|
||||
type = injection_type_parent;
|
||||
path = vtoy_json_get_string_ex(pNode->pstChild, "parent");
|
||||
if (!path)
|
||||
{
|
||||
grub_printf("image/parent not found\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
archive = vtoy_json_get_string_ex(pNode->pstChild, "archive");
|
||||
if (!archive)
|
||||
@@ -1297,6 +1455,8 @@ static int ventoy_plugin_injection_check(VTOY_JSON *json, const char *isodisk)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type == injection_type_file)
|
||||
{
|
||||
if (grub_strchr(path, '*'))
|
||||
{
|
||||
grub_printf("image: <%s> [*]\n", path);
|
||||
@@ -1305,6 +1465,12 @@ static int ventoy_plugin_injection_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
grub_printf("image: <%s> [%s]\n", path, ventoy_check_file_exist("%s%s", isodisk, path) ? "OK" : "NOT EXIST");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("parent: <%s> [%s]\n", path,
|
||||
ventoy_is_dir_exist("%s%s", isodisk, path) ? "OK" : "NOT EXIST");
|
||||
}
|
||||
|
||||
grub_printf("archive: <%s> [%s]\n\n", archive, ventoy_check_file_exist("%s%s", isodisk, archive) ? "OK" : "NOT EXIST");
|
||||
}
|
||||
@@ -1314,6 +1480,7 @@ static int ventoy_plugin_injection_check(VTOY_JSON *json, const char *isodisk)
|
||||
|
||||
static int ventoy_plugin_injection_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int type = 0;
|
||||
const char *path = NULL;
|
||||
const char *archive = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
@@ -1341,13 +1508,21 @@ static int ventoy_plugin_injection_entry(VTOY_JSON *json, const char *isodisk)
|
||||
|
||||
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
type = injection_type_file;
|
||||
path = vtoy_json_get_string_ex(pNode->pstChild, "image");
|
||||
if (!path)
|
||||
{
|
||||
type = injection_type_parent;
|
||||
path = vtoy_json_get_string_ex(pNode->pstChild, "parent");
|
||||
}
|
||||
|
||||
archive = vtoy_json_get_string_ex(pNode->pstChild, "archive");
|
||||
if (path && path[0] == '/' && archive && archive[0] == '/')
|
||||
{
|
||||
node = grub_zalloc(sizeof(injection_config));
|
||||
if (node)
|
||||
{
|
||||
node->type = type;
|
||||
node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", path);
|
||||
grub_snprintf(node->archive, sizeof(node->archive), "%s", archive);
|
||||
|
||||
@@ -2039,7 +2214,7 @@ void ventoy_plugin_dump_injection(void)
|
||||
|
||||
for (node = g_injection_head; node; node = node->next)
|
||||
{
|
||||
grub_printf("\nIMAGE:<%s>\n", node->isopath);
|
||||
grub_printf("\n%s:<%s>\n", (node->type == injection_type_file) ? "IMAGE" : "PARENT", node->isopath);
|
||||
grub_printf("ARCHIVE:<%s>\n", node->archive);
|
||||
}
|
||||
|
||||
@@ -2054,7 +2229,9 @@ void ventoy_plugin_dump_auto_install(void)
|
||||
|
||||
for (node = g_install_template_head; node; node = node->next)
|
||||
{
|
||||
grub_printf("\nIMAGE:<%s> <%d>\n", node->isopath, node->templatenum);
|
||||
grub_printf("\n%s:<%s> <%d>\n",
|
||||
(node->type == auto_install_type_file) ? "IMAGE" : "PARENT",
|
||||
node->isopath, node->templatenum);
|
||||
for (i = 0; i < node->templatenum; i++)
|
||||
{
|
||||
grub_printf("SCRIPT %d:<%s>\n", i, node->templatepath[i].path);
|
||||
@@ -2106,12 +2283,26 @@ install_template * ventoy_plugin_find_install_template(const char *isopath)
|
||||
|
||||
len = (int)grub_strlen(isopath);
|
||||
for (node = g_install_template_head; node; node = node->next)
|
||||
{
|
||||
if (node->type == auto_install_type_file)
|
||||
{
|
||||
if (node->pathlen == len && ventoy_strcmp(node->isopath, isopath) == 0)
|
||||
{
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (node = g_install_template_head; node; node = node->next)
|
||||
{
|
||||
if (node->type == auto_install_type_parent)
|
||||
{
|
||||
if (node->pathlen < len && ventoy_plugin_is_parent(node->isopath, node->pathlen, isopath))
|
||||
{
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -2227,12 +2418,26 @@ const char * ventoy_plugin_get_injection(const char *isopath)
|
||||
|
||||
len = (int)grub_strlen(isopath);
|
||||
for (node = g_injection_head; node; node = node->next)
|
||||
{
|
||||
if (node->type == injection_type_file)
|
||||
{
|
||||
if (node->pathlen == len && ventoy_strcmp(node->isopath, isopath) == 0)
|
||||
{
|
||||
return node->archive;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (node = g_injection_head; node; node = node->next)
|
||||
{
|
||||
if (node->type == injection_type_parent)
|
||||
{
|
||||
if (node->pathlen < len && ventoy_plugin_is_parent(node->isopath, node->pathlen, isopath))
|
||||
{
|
||||
return node->archive;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -2262,7 +2467,8 @@ const char * ventoy_plugin_get_menu_alias(int type, const char *isopath)
|
||||
|
||||
const char * ventoy_plugin_get_menu_class(int type, const char *name, const char *path)
|
||||
{
|
||||
int len;
|
||||
int namelen;
|
||||
int pathlen;
|
||||
menu_class *node = NULL;
|
||||
|
||||
if (!g_menu_class_head)
|
||||
@@ -2270,6 +2476,9 @@ const char * ventoy_plugin_get_menu_class(int type, const char *name, const char
|
||||
return NULL;
|
||||
}
|
||||
|
||||
namelen = (int)grub_strlen(name);
|
||||
pathlen = (int)grub_strlen(path);
|
||||
|
||||
if (vtoy_class_image_file == type)
|
||||
{
|
||||
for (node = g_menu_class_head; node; node = node->next)
|
||||
@@ -2279,31 +2488,36 @@ const char * ventoy_plugin_get_menu_class(int type, const char *name, const char
|
||||
continue;
|
||||
}
|
||||
|
||||
if (node->parent)
|
||||
if (node->parent == 0)
|
||||
{
|
||||
len = (int)grub_strlen(path);
|
||||
if ((node->patlen < len) && (path[node->patlen] == '/') &&
|
||||
(grub_strncmp(path, node->pattern, node->patlen) == 0))
|
||||
{
|
||||
return node->class;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
len = (int)grub_strlen(name);
|
||||
if ((node->patlen < len) && grub_strstr(name, node->pattern))
|
||||
if ((node->patlen < namelen) && grub_strstr(name, node->pattern))
|
||||
{
|
||||
return node->class;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
len = (int)grub_strlen(name);
|
||||
|
||||
for (node = g_menu_class_head; node; node = node->next)
|
||||
{
|
||||
if (node->type == type && node->patlen == len && grub_strncmp(name, node->pattern, len) == 0)
|
||||
if (node->type != type)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (node->parent)
|
||||
{
|
||||
if ((node->patlen < pathlen) && ventoy_plugin_is_parent(node->pattern, node->patlen, path))
|
||||
{
|
||||
return node->class;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (node = g_menu_class_head; node; node = node->next)
|
||||
{
|
||||
if (node->type == type && node->patlen == namelen && grub_strncmp(name, node->pattern, namelen) == 0)
|
||||
{
|
||||
return node->class;
|
||||
}
|
||||
@@ -2565,8 +2779,7 @@ static const vtoy_password * ventoy_plugin_get_password(const char *isopath)
|
||||
{
|
||||
if (node->type == vtoy_menu_pwd_parent)
|
||||
{
|
||||
if (node->pathlen < len && (isopath[node->pathlen] == '/') &&
|
||||
ventoy_strncmp(node->isopath, isopath, node->pathlen) == 0)
|
||||
if (node->pathlen < len && ventoy_plugin_is_parent(node->isopath, node->pathlen, isopath))
|
||||
{
|
||||
return &(node->password);
|
||||
}
|
||||
@@ -2710,3 +2923,62 @@ end:
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_set_theme(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
grub_uint32_t i = 0;
|
||||
grub_uint32_t mod = 0;
|
||||
theme_list *node = g_theme_head;
|
||||
struct grub_datetime datetime;
|
||||
|
||||
(void)argc;
|
||||
(void)args;
|
||||
(void)ctxt;
|
||||
|
||||
if (g_theme_single_file[0])
|
||||
{
|
||||
debug("single theme %s\n", g_theme_single_file);
|
||||
grub_env_set("theme", g_theme_single_file);
|
||||
goto end;
|
||||
}
|
||||
|
||||
debug("g_theme_num = %d\n", g_theme_num);
|
||||
|
||||
if (g_theme_num == 0)
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
|
||||
grub_memset(&datetime, 0, sizeof(datetime));
|
||||
grub_get_datetime(&datetime);
|
||||
|
||||
if (g_theme_random == vtoy_theme_random_boot_second)
|
||||
{
|
||||
grub_divmod32((grub_uint32_t)datetime.second, (grub_uint32_t)g_theme_num, &mod);
|
||||
}
|
||||
else if (g_theme_random == vtoy_theme_random_boot_day)
|
||||
{
|
||||
grub_divmod32((grub_uint32_t)datetime.day, (grub_uint32_t)g_theme_num, &mod);
|
||||
}
|
||||
else if (g_theme_random == vtoy_theme_random_boot_month)
|
||||
{
|
||||
grub_divmod32((grub_uint32_t)datetime.month, (grub_uint32_t)g_theme_num, &mod);
|
||||
}
|
||||
|
||||
debug("%04d/%02d/%02d %02d:%02d:%02d radom:%d mod:%d\n",
|
||||
datetime.year, datetime.month, datetime.day,
|
||||
datetime.hour, datetime.minute, datetime.second,
|
||||
g_theme_random, mod);
|
||||
|
||||
for (i = 0; i < mod && node; i++)
|
||||
{
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
debug("random theme %s\n", node->theme.path);
|
||||
grub_env_set("theme", node->theme.path);
|
||||
|
||||
end:
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -549,6 +549,8 @@ static int ventoy_read_resource(grub_file_t fp, wim_header *wimhdr, wim_resource
|
||||
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;
|
||||
|
||||
for (i = 0; i < chunk_num - 1; i++)
|
||||
@@ -604,6 +606,8 @@ static int ventoy_read_resource(grub_file_t fp, wim_header *wimhdr, wim_resource
|
||||
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)
|
||||
{
|
||||
debug("head->size_in_wim:%llu head->raw_size:%llu cur_dst:%p buffer_decompress:%p total_decompress:%d\n",
|
||||
@@ -657,8 +661,15 @@ static wim_directory_entry * search_full_wim_dirent
|
||||
static wim_directory_entry * search_replace_wim_dirent(void *meta_data, wim_directory_entry *dir)
|
||||
{
|
||||
wim_directory_entry *wim_dirent = NULL;
|
||||
const char *pecmd_path[] = { "Windows", "System32", "pecmd.exe", NULL };
|
||||
const char *winpeshl_path[] = { "Windows", "System32", "winpeshl.exe", NULL };
|
||||
//const char *native_path[] = { "Windows", "System32", "native.exe", NULL };
|
||||
|
||||
wim_dirent = search_full_wim_dirent(meta_data, dir, pecmd_path);
|
||||
debug("search pecmd.exe %p\n", wim_dirent);
|
||||
if (wim_dirent)
|
||||
{
|
||||
return wim_dirent;
|
||||
}
|
||||
|
||||
wim_dirent = search_full_wim_dirent(meta_data, dir, winpeshl_path);
|
||||
debug("search winpeshl.exe %p\n", wim_dirent);
|
||||
@@ -667,15 +678,6 @@ static wim_directory_entry * search_replace_wim_dirent(void *meta_data, wim_dire
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -735,6 +737,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 +785,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
|
||||
@@ -882,7 +906,14 @@ static int ventoy_update_before_chain(ventoy_os_param *param, char *isopath)
|
||||
grub_crypto_hash(GRUB_MD_SHA1, wim_data->bin_hash.sha1, wim_data->jump_bin_data, wim_data->bin_raw_len);
|
||||
|
||||
security = (wim_security_header *)wim_data->new_meta_data;
|
||||
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 +946,7 @@ static int ventoy_update_before_chain(ventoy_os_param *param, char *isopath)
|
||||
static int ventoy_wimdows_locate_wim(const char *disk, wim_patch *patch)
|
||||
{
|
||||
int rc;
|
||||
grub_uint16_t i;
|
||||
grub_file_t file;
|
||||
grub_uint32_t exe_len;
|
||||
grub_uint8_t *exe_data = NULL;
|
||||
@@ -923,6 +955,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;
|
||||
|
||||
@@ -986,7 +1019,27 @@ 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));
|
||||
}
|
||||
|
||||
debug("read lookup offset:%llu size:%llu\n", (ulonglong)head->lookup.offset, (ulonglong)head->lookup.raw_size);
|
||||
lookup = grub_malloc(head->lookup.raw_size);
|
||||
@@ -1013,8 +1066,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 +1220,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 +1272,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 +1283,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 +1324,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 +1722,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 */
|
@@ -267,6 +267,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
|
||||
|
878
GRUB2/MOD_SRC/grub-2.04/util/setup.c
Normal file
878
GRUB2/MOD_SRC/grub-2.04/util/setup.c
Normal file
@@ -0,0 +1,878 @@
|
||||
/* grub-setup.c - make GRUB usable */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/emu/misc.h>
|
||||
#include <grub/util/misc.h>
|
||||
#include <grub/device.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/fs.h>
|
||||
#include <grub/partition.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/emu/hostdisk.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
#include <grub/util/ofpath.h>
|
||||
#include <grub/sparc64/ieee1275/boot.h>
|
||||
#include <grub/sparc64/ieee1275/kernel.h>
|
||||
#else
|
||||
#include <grub/i386/pc/boot.h>
|
||||
#include <grub/i386/pc/kernel.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <assert.h>
|
||||
#include <grub/emu/getroot.h>
|
||||
#include "progname.h"
|
||||
#include <grub/reed_solomon.h>
|
||||
#include <grub/msdos_partition.h>
|
||||
#include <grub/crypto.h>
|
||||
#include <grub/util/install.h>
|
||||
#include <grub/emu/hostfile.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
/* On SPARC this program fills in various fields inside of the 'boot' and 'core'
|
||||
* image files.
|
||||
*
|
||||
* The 'boot' image needs to know the OBP path name of the root
|
||||
* device. It also needs to know the initial block number of
|
||||
* 'core' (which is 'diskboot' concatenated with 'kernel' and
|
||||
* all the modules, this is created by grub-mkimage). This resulting
|
||||
* 'boot' image is 512 bytes in size and is placed in the second block
|
||||
* of a partition.
|
||||
*
|
||||
* The initial 'diskboot' block acts as a loader for the actual GRUB
|
||||
* kernel. It contains the loading code and then a block list.
|
||||
*
|
||||
* The block list of 'core' starts at the end of the 'diskboot' image
|
||||
* and works it's way backwards towards the end of the code of 'diskboot'.
|
||||
*
|
||||
* We patch up the images with the necessary values and write out the
|
||||
* result.
|
||||
*/
|
||||
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
#define grub_target_to_host16(x) grub_be_to_cpu16(x)
|
||||
#define grub_target_to_host32(x) grub_be_to_cpu32(x)
|
||||
#define grub_target_to_host64(x) grub_be_to_cpu64(x)
|
||||
#define grub_host_to_target16(x) grub_cpu_to_be16(x)
|
||||
#define grub_host_to_target32(x) grub_cpu_to_be32(x)
|
||||
#define grub_host_to_target64(x) grub_cpu_to_be64(x)
|
||||
#elif defined (GRUB_SETUP_BIOS)
|
||||
#define grub_target_to_host16(x) grub_le_to_cpu16(x)
|
||||
#define grub_target_to_host32(x) grub_le_to_cpu32(x)
|
||||
#define grub_target_to_host64(x) grub_le_to_cpu64(x)
|
||||
#define grub_host_to_target16(x) grub_cpu_to_le16(x)
|
||||
#define grub_host_to_target32(x) grub_cpu_to_le32(x)
|
||||
#define grub_host_to_target64(x) grub_cpu_to_le64(x)
|
||||
#else
|
||||
#error Complete this
|
||||
#endif
|
||||
|
||||
static void
|
||||
write_rootdev (grub_device_t root_dev,
|
||||
char *boot_img, grub_uint64_t first_sector)
|
||||
{
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
{
|
||||
grub_uint8_t *boot_drive;
|
||||
void *kernel_sector;
|
||||
boot_drive = (grub_uint8_t *) (boot_img + GRUB_BOOT_MACHINE_BOOT_DRIVE);
|
||||
kernel_sector = (boot_img + GRUB_BOOT_MACHINE_KERNEL_SECTOR);
|
||||
|
||||
/* FIXME: can this be skipped? */
|
||||
*boot_drive = 0xFF;
|
||||
|
||||
grub_set_unaligned64 (kernel_sector, grub_cpu_to_le64 (first_sector));
|
||||
}
|
||||
#endif
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
{
|
||||
void *kernel_byte;
|
||||
kernel_byte = (boot_img + GRUB_BOOT_AOUT_HEADER_SIZE
|
||||
+ GRUB_BOOT_MACHINE_KERNEL_BYTE);
|
||||
grub_set_unaligned64 (kernel_byte,
|
||||
grub_cpu_to_be64 (first_sector << GRUB_DISK_SECTOR_BITS));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
#define BOOT_SECTOR 1
|
||||
#else
|
||||
#define BOOT_SECTOR 0
|
||||
#endif
|
||||
|
||||
/* Helper for setup. */
|
||||
|
||||
struct blocklists
|
||||
{
|
||||
struct grub_boot_blocklist *first_block, *block;
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
grub_uint16_t current_segment;
|
||||
#endif
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
grub_uint64_t gpt_offset;
|
||||
#endif
|
||||
grub_uint16_t last_length;
|
||||
grub_disk_addr_t first_sector;
|
||||
};
|
||||
|
||||
/* Helper for setup. */
|
||||
static void
|
||||
save_blocklists (grub_disk_addr_t sector, unsigned offset, unsigned length,
|
||||
void *data)
|
||||
{
|
||||
struct blocklists *bl = data;
|
||||
struct grub_boot_blocklist *prev = bl->block + 1;
|
||||
grub_uint64_t seclen;
|
||||
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
sector -= bl->gpt_offset;
|
||||
#endif
|
||||
|
||||
grub_util_info ("saving <%" GRUB_HOST_PRIuLONG_LONG ",%u,%u>",
|
||||
(unsigned long long) sector, offset, length);
|
||||
|
||||
if (bl->first_sector == (grub_disk_addr_t) -1)
|
||||
{
|
||||
if (offset != 0 || length < GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error ("%s", _("the first sector of the core file is not sector-aligned"));
|
||||
|
||||
bl->first_sector = sector;
|
||||
sector++;
|
||||
length -= GRUB_DISK_SECTOR_SIZE;
|
||||
if (!length)
|
||||
return;
|
||||
}
|
||||
|
||||
if (offset != 0 || bl->last_length != 0)
|
||||
grub_util_error ("%s", _("non-sector-aligned data is found in the core file"));
|
||||
|
||||
seclen = (length + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS;
|
||||
|
||||
if (bl->block != bl->first_block
|
||||
&& (grub_target_to_host64 (prev->start)
|
||||
+ grub_target_to_host16 (prev->len)) == sector)
|
||||
{
|
||||
grub_uint16_t t = grub_target_to_host16 (prev->len);
|
||||
t += seclen;
|
||||
prev->len = grub_host_to_target16 (t);
|
||||
}
|
||||
else
|
||||
{
|
||||
bl->block->start = grub_host_to_target64 (sector);
|
||||
bl->block->len = grub_host_to_target16 (seclen);
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
bl->block->segment = grub_host_to_target16 (bl->current_segment);
|
||||
#endif
|
||||
|
||||
bl->block--;
|
||||
if (bl->block->len)
|
||||
grub_util_error ("%s", _("the sectors of the core file are too fragmented"));
|
||||
}
|
||||
|
||||
bl->last_length = length & (GRUB_DISK_SECTOR_SIZE - 1);
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
bl->current_segment += seclen << (GRUB_DISK_SECTOR_BITS - 4);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Context for setup/identify_partmap. */
|
||||
struct identify_partmap_ctx
|
||||
{
|
||||
grub_partition_map_t dest_partmap;
|
||||
grub_partition_t container;
|
||||
int multiple_partmaps;
|
||||
};
|
||||
|
||||
/* Helper for setup.
|
||||
Unlike root_dev, with dest_dev we're interested in the partition map even
|
||||
if dest_dev itself is a whole disk. */
|
||||
static int
|
||||
identify_partmap (grub_disk_t disk __attribute__ ((unused)),
|
||||
const grub_partition_t p, void *data)
|
||||
{
|
||||
struct identify_partmap_ctx *ctx = data;
|
||||
|
||||
if (p->parent != ctx->container)
|
||||
return 0;
|
||||
/* NetBSD and OpenBSD subpartitions have metadata inside a partition,
|
||||
so they are safe to ignore.
|
||||
*/
|
||||
if (grub_strcmp (p->partmap->name, "netbsd") == 0
|
||||
|| grub_strcmp (p->partmap->name, "openbsd") == 0)
|
||||
return 0;
|
||||
if (ctx->dest_partmap == NULL)
|
||||
{
|
||||
ctx->dest_partmap = p->partmap;
|
||||
return 0;
|
||||
}
|
||||
if (ctx->dest_partmap == p->partmap)
|
||||
return 0;
|
||||
ctx->multiple_partmaps = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
#define SETUP grub_util_bios_setup
|
||||
#elif GRUB_SETUP_SPARC64
|
||||
#define SETUP grub_util_sparc_setup
|
||||
#else
|
||||
#error "Shouldn't happen"
|
||||
#endif
|
||||
|
||||
void
|
||||
SETUP (const char *dir,
|
||||
const char *boot_file, const char *core_file,
|
||||
const char *dest, int force,
|
||||
int fs_probe, int allow_floppy,
|
||||
int add_rs_codes __attribute__ ((unused))) /* unused on sparc64 */
|
||||
{
|
||||
char *core_path;
|
||||
char *boot_img, *core_img, *boot_path;
|
||||
char *root = 0;
|
||||
size_t boot_size, core_size;
|
||||
grub_uint16_t core_sectors;
|
||||
grub_device_t root_dev = 0, dest_dev, core_dev;
|
||||
grub_util_fd_t fp;
|
||||
struct blocklists bl;
|
||||
|
||||
bl.first_sector = (grub_disk_addr_t) -1;
|
||||
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
bl.current_segment =
|
||||
GRUB_BOOT_I386_PC_KERNEL_SEG + (GRUB_DISK_SECTOR_SIZE >> 4);
|
||||
#endif
|
||||
bl.last_length = 0;
|
||||
|
||||
/* Read the boot image by the OS service. */
|
||||
boot_path = grub_util_get_path (dir, boot_file);
|
||||
boot_size = grub_util_get_image_size (boot_path);
|
||||
if (boot_size != GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error (_("the size of `%s' is not %u"),
|
||||
boot_path, GRUB_DISK_SECTOR_SIZE);
|
||||
boot_img = grub_util_read_image (boot_path);
|
||||
free (boot_path);
|
||||
|
||||
core_path = grub_util_get_path (dir, core_file);
|
||||
core_size = grub_util_get_image_size (core_path);
|
||||
core_sectors = ((core_size + GRUB_DISK_SECTOR_SIZE - 1)
|
||||
>> GRUB_DISK_SECTOR_BITS);
|
||||
if (core_size < GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error (_("the size of `%s' is too small"), core_path);
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
if (core_size > 0xFFFF * GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error (_("the size of `%s' is too large"), core_path);
|
||||
#endif
|
||||
|
||||
core_img = grub_util_read_image (core_path);
|
||||
|
||||
/* Have FIRST_BLOCK to point to the first blocklist. */
|
||||
bl.first_block = (struct grub_boot_blocklist *) (core_img
|
||||
+ GRUB_DISK_SECTOR_SIZE
|
||||
- sizeof (*bl.block));
|
||||
|
||||
grub_util_info ("Opening dest `%s'", dest);
|
||||
dest_dev = grub_device_open (dest);
|
||||
if (! dest_dev)
|
||||
grub_util_error ("%s", grub_errmsg);
|
||||
|
||||
core_dev = dest_dev;
|
||||
|
||||
{
|
||||
char **root_devices = grub_guess_root_devices (dir);
|
||||
char **cur;
|
||||
int found = 0;
|
||||
|
||||
if (!root_devices)
|
||||
grub_util_error (_("cannot find a device for %s (is /dev mounted?)"), dir);
|
||||
|
||||
for (cur = root_devices; *cur; cur++)
|
||||
{
|
||||
char *drive;
|
||||
grub_device_t try_dev;
|
||||
|
||||
drive = grub_util_get_grub_dev (*cur);
|
||||
if (!drive)
|
||||
continue;
|
||||
try_dev = grub_device_open (drive);
|
||||
if (! try_dev)
|
||||
{
|
||||
free (drive);
|
||||
continue;
|
||||
}
|
||||
if (!found && try_dev->disk->id == dest_dev->disk->id
|
||||
&& try_dev->disk->dev->id == dest_dev->disk->dev->id)
|
||||
{
|
||||
if (root_dev)
|
||||
grub_device_close (root_dev);
|
||||
free (root);
|
||||
root_dev = try_dev;
|
||||
root = drive;
|
||||
found = 1;
|
||||
continue;
|
||||
}
|
||||
if (!root_dev)
|
||||
{
|
||||
root_dev = try_dev;
|
||||
root = drive;
|
||||
continue;
|
||||
}
|
||||
grub_device_close (try_dev);
|
||||
free (drive);
|
||||
}
|
||||
if (!root_dev)
|
||||
{
|
||||
root = grub_util_get_grub_dev ("/dev/sda");
|
||||
root_dev = grub_device_open (root);
|
||||
if (root_dev)
|
||||
grub_util_info ("guessing the root device failed, because of `%s'", grub_errmsg);
|
||||
else
|
||||
grub_util_error ("guessing the root device failed, because of `%s'", grub_errmsg);
|
||||
}
|
||||
grub_util_info ("guessed root_dev `%s' from "
|
||||
"dir `%s'", root_dev->disk->name, dir);
|
||||
|
||||
for (cur = root_devices; *cur; cur++)
|
||||
free (*cur);
|
||||
free (root_devices);
|
||||
}
|
||||
|
||||
grub_util_info ("setting the root device to `%s'", root);
|
||||
if (grub_env_set ("root", root) != GRUB_ERR_NONE)
|
||||
grub_util_error ("%s", grub_errmsg);
|
||||
|
||||
{
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
char *tmp_img;
|
||||
grub_uint8_t *boot_drive_check;
|
||||
|
||||
/* Read the original sector from the disk. */
|
||||
tmp_img = xmalloc (GRUB_DISK_SECTOR_SIZE);
|
||||
if (grub_disk_read (dest_dev->disk, 0, 0, GRUB_DISK_SECTOR_SIZE, tmp_img))
|
||||
grub_util_error ("%s", grub_errmsg);
|
||||
|
||||
boot_drive_check = (grub_uint8_t *) (boot_img
|
||||
+ GRUB_BOOT_MACHINE_DRIVE_CHECK);
|
||||
/* Copy the possible DOS BPB. */
|
||||
memcpy (boot_img + GRUB_BOOT_MACHINE_BPB_START,
|
||||
tmp_img + GRUB_BOOT_MACHINE_BPB_START,
|
||||
GRUB_BOOT_MACHINE_BPB_END - GRUB_BOOT_MACHINE_BPB_START);
|
||||
|
||||
/* If DEST_DRIVE is a hard disk, enable the workaround, which is
|
||||
for buggy BIOSes which don't pass boot drive correctly. Instead,
|
||||
they pass 0x00 or 0x01 even when booted from 0x80. */
|
||||
if (!allow_floppy && !grub_util_biosdisk_is_floppy (dest_dev->disk))
|
||||
{
|
||||
/* Replace the jmp (2 bytes) with double nop's. */
|
||||
boot_drive_check[0] = 0x90;
|
||||
boot_drive_check[1] = 0x90;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct identify_partmap_ctx ctx = {
|
||||
.dest_partmap = NULL,
|
||||
.container = dest_dev->disk->partition,
|
||||
.multiple_partmaps = 0
|
||||
};
|
||||
int is_ldm;
|
||||
grub_err_t err;
|
||||
grub_disk_addr_t *sectors;
|
||||
int i;
|
||||
grub_fs_t fs;
|
||||
unsigned int nsec, maxsec;
|
||||
|
||||
grub_partition_iterate (dest_dev->disk, identify_partmap, &ctx);
|
||||
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
/* Copy the partition table. */
|
||||
if (ctx.dest_partmap ||
|
||||
(!allow_floppy && !grub_util_biosdisk_is_floppy (dest_dev->disk)))
|
||||
memcpy (boot_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
|
||||
tmp_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
|
||||
GRUB_BOOT_MACHINE_PART_END - GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC);
|
||||
|
||||
free (tmp_img);
|
||||
#endif
|
||||
|
||||
if (ctx.container
|
||||
&& grub_strcmp (ctx.container->partmap->name, "msdos") == 0
|
||||
&& ctx.dest_partmap
|
||||
&& (ctx.container->msdostype == GRUB_PC_PARTITION_TYPE_NETBSD
|
||||
|| ctx.container->msdostype == GRUB_PC_PARTITION_TYPE_OPENBSD))
|
||||
{
|
||||
grub_util_warn ("%s", _("Attempting to install GRUB to a disk with multiple partition labels or both partition label and filesystem. This is not supported yet."));
|
||||
goto unable_to_embed;
|
||||
}
|
||||
|
||||
fs = grub_fs_probe (dest_dev);
|
||||
if (!fs)
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
is_ldm = grub_util_is_ldm (dest_dev->disk);
|
||||
|
||||
if (fs_probe)
|
||||
{
|
||||
if (!fs && !ctx.dest_partmap)
|
||||
grub_util_error (_("unable to identify a filesystem in %s; safety check can't be performed"),
|
||||
dest_dev->disk->name);
|
||||
if (fs && !fs->reserved_first_sector)
|
||||
/* TRANSLATORS: Filesystem may reserve the space just GRUB isn't sure about it. */
|
||||
grub_util_error (_("%s appears to contain a %s filesystem which isn't known to "
|
||||
"reserve space for DOS-style boot. Installing GRUB there could "
|
||||
"result in FILESYSTEM DESTRUCTION if valuable data is overwritten "
|
||||
"by grub-setup (--skip-fs-probe disables this "
|
||||
"check, use at your own risk)"), dest_dev->disk->name, fs->name);
|
||||
|
||||
if (ctx.dest_partmap && strcmp (ctx.dest_partmap->name, "msdos") != 0
|
||||
&& strcmp (ctx.dest_partmap->name, "gpt") != 0
|
||||
&& strcmp (ctx.dest_partmap->name, "bsd") != 0
|
||||
&& strcmp (ctx.dest_partmap->name, "netbsd") != 0
|
||||
&& strcmp (ctx.dest_partmap->name, "openbsd") != 0
|
||||
&& strcmp (ctx.dest_partmap->name, "sunpc") != 0)
|
||||
/* TRANSLATORS: Partition map may reserve the space just GRUB isn't sure about it. */
|
||||
grub_util_error (_("%s appears to contain a %s partition map which isn't known to "
|
||||
"reserve space for DOS-style boot. Installing GRUB there could "
|
||||
"result in FILESYSTEM DESTRUCTION if valuable data is overwritten "
|
||||
"by grub-setup (--skip-fs-probe disables this "
|
||||
"check, use at your own risk)"), dest_dev->disk->name, ctx.dest_partmap->name);
|
||||
if (is_ldm && ctx.dest_partmap && strcmp (ctx.dest_partmap->name, "msdos") != 0
|
||||
&& strcmp (ctx.dest_partmap->name, "gpt") != 0)
|
||||
grub_util_error (_("%s appears to contain a %s partition map and "
|
||||
"LDM which isn't known to be a safe combination."
|
||||
" Installing GRUB there could "
|
||||
"result in FILESYSTEM DESTRUCTION if valuable data"
|
||||
" is overwritten "
|
||||
"by grub-setup (--skip-fs-probe disables this "
|
||||
"check, use at your own risk)"),
|
||||
dest_dev->disk->name, ctx.dest_partmap->name);
|
||||
|
||||
}
|
||||
|
||||
if (! ctx.dest_partmap && ! fs && !is_ldm)
|
||||
{
|
||||
grub_util_warn ("%s", _("Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea."));
|
||||
goto unable_to_embed;
|
||||
}
|
||||
if (ctx.multiple_partmaps || (ctx.dest_partmap && fs) || (is_ldm && fs))
|
||||
{
|
||||
grub_util_warn ("%s", _("Attempting to install GRUB to a disk with multiple partition labels. This is not supported yet."));
|
||||
goto unable_to_embed;
|
||||
}
|
||||
|
||||
if (ctx.dest_partmap && !ctx.dest_partmap->embed)
|
||||
{
|
||||
grub_util_warn (_("Partition style `%s' doesn't support embedding"),
|
||||
ctx.dest_partmap->name);
|
||||
goto unable_to_embed;
|
||||
}
|
||||
|
||||
if (fs && !fs->fs_embed)
|
||||
{
|
||||
grub_util_warn (_("File system `%s' doesn't support embedding"),
|
||||
fs->name);
|
||||
goto unable_to_embed;
|
||||
}
|
||||
|
||||
nsec = core_sectors;
|
||||
|
||||
if (add_rs_codes)
|
||||
maxsec = 2 * core_sectors;
|
||||
else
|
||||
maxsec = core_sectors;
|
||||
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
if (maxsec > ((0x78000 - GRUB_KERNEL_I386_PC_LINK_ADDR)
|
||||
>> GRUB_DISK_SECTOR_BITS))
|
||||
maxsec = ((0x78000 - GRUB_KERNEL_I386_PC_LINK_ADDR)
|
||||
>> GRUB_DISK_SECTOR_BITS);
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
/*
|
||||
* On SPARC we need two extra. One is because we are combining the
|
||||
* core.img with the boot.img. The other is because the boot sector
|
||||
* starts at 1.
|
||||
*/
|
||||
nsec += 2;
|
||||
maxsec += 2;
|
||||
#endif
|
||||
|
||||
if (is_ldm)
|
||||
err = grub_util_ldm_embed (dest_dev->disk, &nsec, maxsec,
|
||||
GRUB_EMBED_PCBIOS, §ors);
|
||||
else if (ctx.dest_partmap)
|
||||
err = ctx.dest_partmap->embed (dest_dev->disk, &nsec, maxsec,
|
||||
GRUB_EMBED_PCBIOS, §ors);
|
||||
else
|
||||
err = fs->fs_embed (dest_dev, &nsec, maxsec,
|
||||
GRUB_EMBED_PCBIOS, §ors);
|
||||
if (!err && nsec < core_sectors)
|
||||
{
|
||||
err = grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||
N_("Your embedding area is unusually small. "
|
||||
"core.img won't fit in it."));
|
||||
}
|
||||
|
||||
if (err)
|
||||
{
|
||||
grub_util_warn ("%s", grub_errmsg);
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
goto unable_to_embed;
|
||||
}
|
||||
|
||||
assert (nsec <= maxsec);
|
||||
|
||||
/* Clean out the blocklists. */
|
||||
bl.block = bl.first_block;
|
||||
while (bl.block->len)
|
||||
{
|
||||
grub_memset (bl.block, 0, sizeof (*bl.block));
|
||||
|
||||
bl.block--;
|
||||
|
||||
if ((char *) bl.block <= core_img)
|
||||
grub_util_error ("%s", _("no terminator in the core image"));
|
||||
}
|
||||
|
||||
bl.block = bl.first_block;
|
||||
for (i = 0; i < nsec; i++)
|
||||
save_blocklists (sectors[i] + grub_partition_get_start (ctx.container),
|
||||
0, GRUB_DISK_SECTOR_SIZE, &bl);
|
||||
|
||||
/* Make sure that the last blocklist is a terminator. */
|
||||
if (bl.block == bl.first_block)
|
||||
bl.block--;
|
||||
bl.block->start = 0;
|
||||
bl.block->len = 0;
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
bl.block->segment = 0;
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
{
|
||||
/*
|
||||
* On SPARC, the block-list entries need to be based off the beginning
|
||||
* of the parition, not the beginning of the disk.
|
||||
*/
|
||||
struct grub_boot_blocklist *block;
|
||||
block = bl.first_block;
|
||||
|
||||
while (block->len)
|
||||
{
|
||||
block->start -= bl.first_sector;
|
||||
block--;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Reserve space for the boot block since it can not be in the
|
||||
* Parition table on SPARC.
|
||||
*/
|
||||
assert (bl.first_block->len > 2);
|
||||
bl.first_block->start += 2;
|
||||
bl.first_block->len -= 2;
|
||||
write_rootdev (root_dev, boot_img, sectors[BOOT_SECTOR + 1] - bl.first_sector);
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
write_rootdev (root_dev, boot_img, bl.first_sector);
|
||||
#endif
|
||||
|
||||
/* Round up to the nearest sector boundary, and zero the extra memory */
|
||||
core_img = xrealloc (core_img, nsec * GRUB_DISK_SECTOR_SIZE);
|
||||
assert (core_img && (nsec * GRUB_DISK_SECTOR_SIZE >= core_size));
|
||||
memset (core_img + core_size, 0, nsec * GRUB_DISK_SECTOR_SIZE - core_size);
|
||||
|
||||
bl.first_block = (struct grub_boot_blocklist *) (core_img
|
||||
+ GRUB_DISK_SECTOR_SIZE
|
||||
- sizeof (*bl.block));
|
||||
#if GRUB_SETUP_BIOS
|
||||
grub_size_t no_rs_length;
|
||||
no_rs_length = grub_target_to_host16
|
||||
(grub_get_unaligned16 (core_img
|
||||
+ GRUB_DISK_SECTOR_SIZE
|
||||
+ GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH));
|
||||
|
||||
if (no_rs_length == 0xffff)
|
||||
grub_util_error ("%s", _("core.img version mismatch"));
|
||||
|
||||
if (add_rs_codes)
|
||||
{
|
||||
grub_set_unaligned32 ((core_img + GRUB_DISK_SECTOR_SIZE
|
||||
+ GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY),
|
||||
grub_host_to_target32 (nsec * GRUB_DISK_SECTOR_SIZE - core_size));
|
||||
|
||||
void *tmp = xmalloc (core_size);
|
||||
grub_memcpy (tmp, core_img, core_size);
|
||||
grub_reed_solomon_add_redundancy (core_img + no_rs_length + GRUB_DISK_SECTOR_SIZE,
|
||||
core_size - no_rs_length - GRUB_DISK_SECTOR_SIZE,
|
||||
nsec * GRUB_DISK_SECTOR_SIZE
|
||||
- core_size);
|
||||
assert (grub_memcmp (tmp, core_img, core_size) == 0);
|
||||
free (tmp);
|
||||
}
|
||||
|
||||
/* Write the core image onto the disk. */
|
||||
for (i = 0; i < nsec; i++)
|
||||
grub_disk_write (dest_dev->disk, sectors[i], 0,
|
||||
GRUB_DISK_SECTOR_SIZE,
|
||||
core_img + i * GRUB_DISK_SECTOR_SIZE);
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
{
|
||||
int isec = BOOT_SECTOR;
|
||||
|
||||
/* Write the boot image onto the disk. */
|
||||
if (grub_disk_write (dest_dev->disk, sectors[isec++], 0,
|
||||
GRUB_DISK_SECTOR_SIZE, boot_img))
|
||||
grub_util_error ("%s", grub_errmsg);
|
||||
|
||||
/* Write the core image onto the disk. */
|
||||
for (i = 0 ; isec < nsec; i++, isec++)
|
||||
{
|
||||
if (grub_disk_write (dest_dev->disk, sectors[isec], 0,
|
||||
GRUB_DISK_SECTOR_SIZE,
|
||||
core_img + i * GRUB_DISK_SECTOR_SIZE))
|
||||
grub_util_error ("%s", grub_errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
grub_free (sectors);
|
||||
|
||||
goto finish;
|
||||
}
|
||||
|
||||
unable_to_embed:
|
||||
|
||||
if (dest_dev->disk->dev->id != root_dev->disk->dev->id)
|
||||
grub_util_error ("%s", _("embedding is not possible, but this is required for "
|
||||
"RAID and LVM install"));
|
||||
|
||||
{
|
||||
grub_fs_t fs;
|
||||
fs = grub_fs_probe (root_dev);
|
||||
if (!fs)
|
||||
grub_util_error (_("can't determine filesystem on %s"), root);
|
||||
|
||||
if (!fs->blocklist_install)
|
||||
grub_util_error (_("filesystem `%s' doesn't support blocklists"),
|
||||
fs->name);
|
||||
}
|
||||
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
if (dest_dev->disk->id != root_dev->disk->id
|
||||
|| dest_dev->disk->dev->id != root_dev->disk->dev->id)
|
||||
/* TRANSLATORS: cross-disk refers to /boot being on one disk
|
||||
but MBR on another. */
|
||||
grub_util_error ("%s", _("embedding is not possible, but this is required for "
|
||||
"cross-disk install"));
|
||||
#else
|
||||
core_dev = root_dev;
|
||||
#endif
|
||||
|
||||
grub_util_warn ("%s", _("Embedding is not possible. GRUB can only be installed in this "
|
||||
"setup by using blocklists. However, blocklists are UNRELIABLE and "
|
||||
"their use is discouraged."));
|
||||
if (! force)
|
||||
/* TRANSLATORS: Here GRUB refuses to continue with blocklist install. */
|
||||
grub_util_error ("%s", _("will not proceed with blocklists"));
|
||||
|
||||
/* The core image must be put on a filesystem unfortunately. */
|
||||
grub_util_info ("will leave the core image on the filesystem");
|
||||
|
||||
grub_util_biosdisk_flush (root_dev->disk);
|
||||
|
||||
/* Clean out the blocklists. */
|
||||
bl.block = bl.first_block;
|
||||
while (bl.block->len)
|
||||
{
|
||||
bl.block->start = 0;
|
||||
bl.block->len = 0;
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
bl.block->segment = 0;
|
||||
#endif
|
||||
|
||||
bl.block--;
|
||||
|
||||
if ((char *) bl.block <= core_img)
|
||||
grub_util_error ("%s", _("no terminator in the core image"));
|
||||
}
|
||||
|
||||
bl.block = bl.first_block;
|
||||
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
{
|
||||
grub_partition_t container = root_dev->disk->partition;
|
||||
bl.gpt_offset = 0;
|
||||
|
||||
if (grub_strstr (container->partmap->name, "gpt"))
|
||||
bl.gpt_offset = grub_partition_get_start (container);
|
||||
}
|
||||
#endif
|
||||
|
||||
grub_install_get_blocklist (root_dev, core_path, core_img, core_size,
|
||||
save_blocklists, &bl);
|
||||
|
||||
if (bl.first_sector == (grub_disk_addr_t)-1)
|
||||
grub_util_error ("%s", _("can't retrieve blocklists"));
|
||||
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
{
|
||||
char *boot_devpath;
|
||||
boot_devpath = (char *) (boot_img
|
||||
+ GRUB_BOOT_AOUT_HEADER_SIZE
|
||||
+ GRUB_BOOT_MACHINE_BOOT_DEVPATH);
|
||||
if (dest_dev->disk->id != root_dev->disk->id
|
||||
|| dest_dev->disk->dev->id != root_dev->disk->dev->id)
|
||||
{
|
||||
char *dest_ofpath;
|
||||
dest_ofpath
|
||||
= grub_util_devname_to_ofpath (grub_util_biosdisk_get_osdev (root_dev->disk));
|
||||
/* FIXME handle NULL result */
|
||||
grub_util_info ("dest_ofpath is `%s'", dest_ofpath);
|
||||
strncpy (boot_devpath, dest_ofpath,
|
||||
GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
|
||||
- GRUB_BOOT_MACHINE_BOOT_DEVPATH - 1);
|
||||
boot_devpath[GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
|
||||
- GRUB_BOOT_MACHINE_BOOT_DEVPATH - 1] = 0;
|
||||
free (dest_ofpath);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_util_info ("non cross-disk install");
|
||||
memset (boot_devpath, 0, GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
|
||||
- GRUB_BOOT_MACHINE_BOOT_DEVPATH);
|
||||
}
|
||||
grub_util_info ("boot device path %s", boot_devpath);
|
||||
}
|
||||
#endif
|
||||
|
||||
write_rootdev (root_dev, boot_img, bl.first_sector);
|
||||
|
||||
/* Write the first two sectors of the core image onto the disk. */
|
||||
grub_util_info ("opening the core image `%s'", core_path);
|
||||
fp = grub_util_fd_open (core_path, GRUB_UTIL_FD_O_WRONLY);
|
||||
if (! GRUB_UTIL_FD_IS_VALID (fp))
|
||||
grub_util_error (_("cannot open `%s': %s"), core_path,
|
||||
grub_util_fd_strerror ());
|
||||
|
||||
if (grub_util_fd_write (fp, core_img, GRUB_DISK_SECTOR_SIZE * 2)
|
||||
!= GRUB_DISK_SECTOR_SIZE * 2)
|
||||
grub_util_error (_("cannot write to `%s': %s"),
|
||||
core_path, strerror (errno));
|
||||
if (grub_util_fd_sync (fp) < 0)
|
||||
grub_util_error (_("cannot sync `%s': %s"), core_path, strerror (errno));
|
||||
if (grub_util_fd_close (fp) < 0)
|
||||
grub_util_error (_("cannot close `%s': %s"), core_path, strerror (errno));
|
||||
grub_util_biosdisk_flush (root_dev->disk);
|
||||
|
||||
grub_disk_cache_invalidate_all ();
|
||||
|
||||
{
|
||||
char *buf, *ptr = core_img;
|
||||
size_t len = core_size;
|
||||
grub_uint64_t blk, offset = 0;
|
||||
grub_partition_t container = core_dev->disk->partition;
|
||||
grub_err_t err;
|
||||
|
||||
core_dev->disk->partition = 0;
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
offset = bl.gpt_offset;
|
||||
#endif
|
||||
|
||||
buf = xmalloc (core_size);
|
||||
blk = bl.first_sector;
|
||||
err = grub_disk_read (core_dev->disk, blk + offset, 0, GRUB_DISK_SECTOR_SIZE, buf);
|
||||
if (err)
|
||||
grub_util_error (_("cannot read `%s': %s"), core_dev->disk->name,
|
||||
grub_errmsg);
|
||||
if (grub_memcmp (buf, ptr, GRUB_DISK_SECTOR_SIZE) != 0)
|
||||
grub_util_error ("%s", _("blocklists are invalid"));
|
||||
|
||||
ptr += GRUB_DISK_SECTOR_SIZE;
|
||||
len -= GRUB_DISK_SECTOR_SIZE;
|
||||
|
||||
bl.block = bl.first_block;
|
||||
while (bl.block->len)
|
||||
{
|
||||
size_t cur = grub_target_to_host16 (bl.block->len) << GRUB_DISK_SECTOR_BITS;
|
||||
blk = grub_target_to_host64 (bl.block->start);
|
||||
|
||||
if (cur > len)
|
||||
cur = len;
|
||||
|
||||
err = grub_disk_read (core_dev->disk, blk + offset, 0, cur, buf);
|
||||
if (err)
|
||||
grub_util_error (_("cannot read `%s': %s"), core_dev->disk->name,
|
||||
grub_errmsg);
|
||||
|
||||
if (grub_memcmp (buf, ptr, cur) != 0)
|
||||
grub_util_error ("%s", _("blocklists are invalid"));
|
||||
|
||||
ptr += cur;
|
||||
len -= cur;
|
||||
bl.block--;
|
||||
|
||||
if ((char *) bl.block <= core_img)
|
||||
grub_util_error ("%s", _("no terminator in the core image"));
|
||||
}
|
||||
if (len)
|
||||
grub_util_error ("%s", _("blocklists are incomplete"));
|
||||
core_dev->disk->partition = container;
|
||||
free (buf);
|
||||
}
|
||||
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
finish:
|
||||
#endif
|
||||
|
||||
/* Write the boot image onto the disk. */
|
||||
if (grub_disk_write (dest_dev->disk, BOOT_SECTOR,
|
||||
0, GRUB_DISK_SECTOR_SIZE, boot_img))
|
||||
grub_util_error ("%s", grub_errmsg);
|
||||
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
finish:
|
||||
#endif
|
||||
|
||||
grub_util_biosdisk_flush (root_dev->disk);
|
||||
grub_util_biosdisk_flush (dest_dev->disk);
|
||||
|
||||
free (core_path);
|
||||
free (core_img);
|
||||
free (boot_img);
|
||||
grub_device_close (dest_dev);
|
||||
grub_device_close (root_dev);
|
||||
}
|
||||
|
@@ -121,6 +121,11 @@ elif [ "$VTOY_ARCH" = "i386" ]; then
|
||||
ln -s $VTOY_PATH/tool/dmsetup32 $VTOY_PATH/tool/dmsetup
|
||||
ln -s $VTOY_PATH/tool/lunzip32 $VTOY_PATH/tool/lunzip
|
||||
|
||||
if uname -a | egrep -q 'x86_64|amd64'; then
|
||||
echo "zstdcat use 64bit ..." >>$VTLOG
|
||||
rm -f $VTOY_PATH/tool/zstdcat
|
||||
ln -s $VTOY_PATH/tool/zstdcat64 $VTOY_PATH/tool/zstdcat
|
||||
fi
|
||||
elif [ "$VTOY_ARCH" = "mips64el" ]; then
|
||||
echo "Use MIPS64 busybox toolkit ..." >>$VTLOG
|
||||
ln -s $BUSYBOX_PATH/xzminidecm64e $BUSYBOX_PATH/xzminidec
|
||||
|
@@ -36,6 +36,10 @@ done
|
||||
$BUSYBOX_PATH/umount /vtmnt && $BUSYBOX_PATH/rm -rf /vtmnt
|
||||
$BUSYBOX_PATH/cp -a /ventoy /ventoy_rdroot
|
||||
|
||||
if [ -f /etc/default/cdlinux ]; then
|
||||
echo "CDL_WAIT=60" >> /etc/default/cdlinux
|
||||
fi
|
||||
|
||||
echo 'echo "CDL_DEV=/dev/mapper/ventoy" >>"$VAR_FILE"' >> /ventoy_rdroot/etc/rc.d/rc.var
|
||||
|
||||
ventoy_set_rule_dir_prefix /ventoy_rdroot
|
||||
|
@@ -31,10 +31,11 @@ done
|
||||
|
||||
ventoy_extract_vtloopex ${vtdiskname}2 crux
|
||||
|
||||
|
||||
vtKver=$(uname -r)
|
||||
vtLoopExDir=$VTOY_PATH/vtloopex/crux/vtloopex
|
||||
$BUSYBOX_PATH/xz -d $vtLoopExDir/dm-mod/$(uname -r)/64/dax.ko.xz
|
||||
$BUSYBOX_PATH/xz -d $vtLoopExDir/dm-mod/$(uname -r)/64/dm-mod.ko.xz
|
||||
$BUSYBOX_PATH/insmod $vtLoopExDir/dm-mod/$(uname -r)/64/dax.ko
|
||||
$BUSYBOX_PATH/insmod $vtLoopExDir/dm-mod/$(uname -r)/64/dm-mod.ko
|
||||
|
||||
ventoy_check_install_module_xz $vtLoopExDir/dm-mod/$vtKver/64/dax.ko
|
||||
ventoy_check_install_module_xz $vtLoopExDir/dm-mod/$vtKver/64/dm-mod.ko
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
|
||||
|
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
|
@@ -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
|
||||
|
||||
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
|
||||
|
@@ -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,9 @@ ventoy_get_debian_distro() {
|
||||
echo 'kerio'; return
|
||||
fi
|
||||
|
||||
if $GREP -q 'mocaccino' /proc/version; then
|
||||
echo 'mocaccino'; return
|
||||
fi
|
||||
|
||||
echo 'default'
|
||||
}
|
||||
|
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
|
||||
|
@@ -83,6 +83,7 @@ get_ventoy_iso_name() {
|
||||
}
|
||||
|
||||
wait_for_usb_disk_ready() {
|
||||
vtloop=0
|
||||
while [ -n "Y" ]; do
|
||||
usb_disk=$(get_ventoy_disk_name)
|
||||
vtlog "wait_for_usb_disk_ready $usb_disk ..."
|
||||
@@ -97,11 +98,18 @@ wait_for_usb_disk_ready() {
|
||||
vtlog "wait_for_usb_disk_ready $usb_disk finish"
|
||||
break
|
||||
else
|
||||
let vtloop=vtloop+1
|
||||
if [ $vtloop -gt 2 ]; then
|
||||
if [ "$VTLOG" != "$VTOY_PATH/log" ]; then
|
||||
$VTOY_PATH/tool/vtoydump -f /ventoy/ventoy_os_param -v > $VTLOG
|
||||
fi
|
||||
fi
|
||||
$SLEEP 0.3
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
check_usb_disk_ready() {
|
||||
if echo $1 | $EGREP -q "nvme|mmc|nbd"; then
|
||||
vtpart2=${1}p2
|
||||
@@ -554,6 +562,31 @@ ventoy_create_dev_ventoy_part() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
ventoy_create_chromeos_ventoy_part() {
|
||||
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | $GREP ventoy | $SED 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
|
||||
$BUSYBOX_PATH/mknod -m 0666 /dev/ventoy b $blkdev_num
|
||||
|
||||
if [ -e /vtoy_dm_table ]; then
|
||||
vtPartid=1
|
||||
|
||||
$CAT /vtoy_dm_table | while read vtline; do
|
||||
echo $vtline > /ventoy/dm_table_part${vtPartid}
|
||||
|
||||
if [ $vtPartid -eq $1 ]; then
|
||||
$VTOY_PATH/tool/dmsetup create ventoy${vtPartid} /ventoy/dm_table_part${vtPartid} --readonly
|
||||
else
|
||||
$VTOY_PATH/tool/dmsetup create ventoy${vtPartid} /ventoy/dm_table_part${vtPartid}
|
||||
fi
|
||||
|
||||
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | $GREP ventoy${vtPartid} | $SED 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
|
||||
$BUSYBOX_PATH/mknod -m 0666 /dev/ventoy${vtPartid} b $blkdev_num
|
||||
|
||||
vtPartid=$(expr $vtPartid + 1)
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
is_inotify_ventoy_part() {
|
||||
if echo $1 | $GREP -q "2$"; then
|
||||
if ! [ -e /sys/block/$1 ]; then
|
||||
@@ -610,3 +643,10 @@ ventoy_extract_vtloopex() {
|
||||
|
||||
cd $vtCurPwd
|
||||
}
|
||||
|
||||
ventoy_check_install_module_xz() {
|
||||
if [ -f "${1}.xz" ]; then
|
||||
$BUSYBOX_PATH/xz -d "${1}.xz"
|
||||
$BUSYBOX_PATH/insmod "$1"
|
||||
fi
|
||||
}
|
||||
|
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
|
201
IMG/cpio/ventoy/loop/fydeos/ventoy-hook.sh
Normal file
201
IMG/cpio/ventoy/loop/fydeos/ventoy-hook.sh
Normal file
@@ -0,0 +1,201 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2021, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
vtlog "####### $0 $* ########"
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
mkdir /sys
|
||||
mount -t sysfs sys /sys
|
||||
mdev -s
|
||||
sleep 2
|
||||
|
||||
while [ -n "Y" ]; do
|
||||
usb_disk=$(get_ventoy_disk_name)
|
||||
|
||||
if echo $usb_disk | egrep -q "nvme|mmc|nbd"; then
|
||||
vtpart2=${usb_disk}p2
|
||||
else
|
||||
vtpart2=${usb_disk}2
|
||||
fi
|
||||
|
||||
if [ -e "${vtpart2}" ]; then
|
||||
break
|
||||
else
|
||||
sleep 2
|
||||
mdev -s
|
||||
fi
|
||||
done
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
PATH=$VTPATH_OLD
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
|
||||
vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||
echo -n $vtDM > /ventoy/vtDM
|
||||
|
||||
ventoy_create_chromeos_ventoy_part 3
|
||||
mdev -s
|
||||
|
||||
vtlog "copy out the e2fsck program ..."
|
||||
|
||||
copy_lib() {
|
||||
cp -a /ventoy_rdroot/usr/lib64/$1 /usr/lib64/
|
||||
cp -a /ventoy_rdroot/lib64/$1 /lib64/
|
||||
}
|
||||
|
||||
mkdir /ventoy_rdroot
|
||||
mkdir -p /lib /lib64 /usr/lib64 /sbin
|
||||
|
||||
mount -o ro /dev/ventoy3 /ventoy_rdroot >>$VTLOG 2>&1
|
||||
cp -a /ventoy_rdroot/sbin/e2fsck /sbin/
|
||||
cp -a /ventoy_rdroot/sbin/dmsetup /sbin/
|
||||
|
||||
copy_lib libext2fs*
|
||||
copy_lib libcom_err*
|
||||
copy_lib libe2p*
|
||||
copy_lib libblk*
|
||||
copy_lib libuuid*
|
||||
copy_lib libdl.*
|
||||
copy_lib libdl-*
|
||||
copy_lib libc.*
|
||||
copy_lib libc-*
|
||||
copy_lib libpthread*
|
||||
copy_lib ld-*
|
||||
copy_lib libdevmapper*
|
||||
copy_lib libudev*
|
||||
copy_lib libm.*
|
||||
copy_lib libm-*
|
||||
copy_lib librt*
|
||||
copy_lib libpopt*
|
||||
copy_lib libgpg-error*
|
||||
copy_lib libselinux*
|
||||
copy_lib libsepol*
|
||||
copy_lib libpcre*
|
||||
copy_lib libcap*
|
||||
copy_lib libdw*
|
||||
copy_lib libgcc_s*
|
||||
copy_lib libattr*
|
||||
copy_lib libelf*
|
||||
copy_lib libz.*
|
||||
copy_lib libbz2*
|
||||
copy_lib libgcrypt*
|
||||
copy_lib liblvm*
|
||||
|
||||
ln -s /lib64/libdevmapper.so.1.02 /lib64/libdevmapper.so.1.02.1
|
||||
|
||||
umount /ventoy_rdroot
|
||||
|
||||
vtlog "========================================="
|
||||
vtlog "===== e2fsck -y -v /dev/ventoy1 ====="
|
||||
e2fsck -y -v /dev/ventoy1 >>$VTLOG 2>&1
|
||||
#vtlog "===== e2fsck -y -v /dev/ventoy3 ====="
|
||||
#e2fsck -y -v /dev/ventoy3 >>$VTLOG 2>&1
|
||||
vtlog "===== e2fsck -y -v /dev/ventoy8 ====="
|
||||
e2fsck -y -v /dev/ventoy8 >>$VTLOG 2>&1
|
||||
vtlog "========================================="
|
||||
|
||||
/sbin/dmsetup --version >>$VTLOG 2>&1
|
||||
veritysetup --version >>$VTLOG 2>&1
|
||||
|
||||
vtlog "proc devtmpfs ..."
|
||||
mkdir /newdev
|
||||
mount -t devtmpfs dev /newdev
|
||||
|
||||
cp -a /dev/mapper/ventoy* /newdev/mapper/
|
||||
cp -a /dev/ventoy* /newdev/
|
||||
|
||||
|
||||
vtshortname="${vtdiskname#/dev/}"
|
||||
mv /newdev/${vtshortname} /newdev/backup_${vtshortname}
|
||||
cp -a /dev/ventoy /newdev/${vtshortname}
|
||||
|
||||
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
|
||||
if [ -e /dev/ventoy${i} ]; then
|
||||
if echo $vtdiskname | egrep -q "nvme|mmc|nbd"; then
|
||||
vtpart=p$i
|
||||
else
|
||||
vtpart=$i
|
||||
fi
|
||||
|
||||
if [ -e /newdev/${vtshortname}${vtpart} ]; then
|
||||
mv /newdev/${vtshortname}${vtpart} /newdev/backup_${vtshortname}${vtpart}
|
||||
fi
|
||||
|
||||
cp -a /dev/ventoy${i} /newdev/${vtshortname}${vtpart}
|
||||
|
||||
if [ $i -eq 3 ]; then
|
||||
[ -e /dev/${vtshortname}${vtpart} ] && rm -f /dev/${vtshortname}${vtpart}
|
||||
cp -a /dev/ventoy${i} /dev/${vtshortname}${vtpart}
|
||||
vt_root_dev="/dev/${vtshortname}${vtpart}"
|
||||
vtlog "vt_root_dev=$vt_root_dev"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# if grep -q 'DM=' /proc/cmdline; then
|
||||
# vtlog "Boot verified image ..."
|
||||
|
||||
# dmP1=$(sed "s/.*\(0 [0-9]* verity\).*/\1/" /proc/cmdline)
|
||||
# alg=$(sed "s/.*alg=\([^ ]*\).*/\1/" /proc/cmdline)
|
||||
# hexdigest=$(sed "s/.*root_hexdigest=\([0-9a-fA-F][0-9a-fA-F]*\).*/\1/" /proc/cmdline)
|
||||
# salt=$(sed "s/.*salt=\([0-9a-fA-F][0-9a-fA-F]*\).*/\1/" /proc/cmdline)
|
||||
# hashstart=$(sed "s/.*hashstart=\([0-9][0-9]*\).*/\1/" /proc/cmdline)
|
||||
|
||||
#512 to 4096
|
||||
# blocknum=$(expr $hashstart / 8)
|
||||
# hashoffset=$(expr $hashstart \* 512)
|
||||
|
||||
# vtlog "veritysetup create vroot $vt_root_dev $vt_root_dev $hexdigest --data-block-size=4096 --hash-block-size=4096 --data-blocks=$blocknum --hash-offset=$hashoffset --salt=$salt --hash=$alg --no-superblock --format=0"
|
||||
# veritysetup create vroot $vt_root_dev $vt_root_dev $hexdigest --data-block-size=4096 --hash-block-size=4096 --data-blocks=$blocknum --hash-offset=$hashoffset --salt=$salt --hash=$alg --no-superblock --format=0
|
||||
# sleep 1
|
||||
# mdev -s
|
||||
|
||||
# blkdev_num=$(dmsetup ls | grep vroot | sed 's/.*(\([0-9][0-9]*\),[^0-9]*\([0-9][0-9]*\).*/\1:\2/')
|
||||
# vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||
# vtlog "blkdev_num=$blkdev_num vtDM=$vtDM"
|
||||
|
||||
# if [ -b /dev/$vtDM ]; then
|
||||
# veritysetup status vroot >> $VTLOG 2>&1
|
||||
# mount -o ro /dev/$vtDM /ventoy_rdroot
|
||||
# else
|
||||
# mount -o ro $vt_root_dev /ventoy_rdroot
|
||||
# fi
|
||||
# else
|
||||
# vtlog "Boot normal image ..."
|
||||
# mount -o ro $vt_root_dev /ventoy_rdroot
|
||||
# fi
|
||||
|
||||
vtlog "Boot normal image ..."
|
||||
mount -o ro $vt_root_dev /ventoy_rdroot
|
||||
|
||||
cp -a $VTLOG /newdev/ventoy.log
|
||||
umount /newdev
|
||||
mount -t devtmpfs dev /ventoy_rdroot/dev
|
||||
|
||||
PATH=$VTPATH_OLD
|
@@ -34,9 +34,19 @@ else
|
||||
vtBit=32
|
||||
fi
|
||||
|
||||
if grep -q "device-mapper" /proc/devices; then
|
||||
vtlog "device-mapper enabled by system"
|
||||
else
|
||||
if [ -f $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dax.ko.xz ]; then
|
||||
xz -d $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dax.ko.xz
|
||||
insmod $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dax.ko
|
||||
fi
|
||||
|
||||
if [ -f $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko.xz ]; then
|
||||
xz -d $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko.xz
|
||||
insmod $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
|
@@ -27,7 +27,83 @@ vtlog "####### $0 $* ########"
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
check_mkdev_node() {
|
||||
for i in $(ls /sys/class/block/); do
|
||||
if ! [ -e /dev/$i ]; then
|
||||
blkdev_num=$(sed 's/:/ /g' /sys/class/block/$i/dev)
|
||||
vtlog "mknod -m 0666 /dev/$i b $blkdev_num"
|
||||
mknod -m 0666 /dev/$i b $blkdev_num
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
check_insmod() {
|
||||
if [ -f "$1" ]; then
|
||||
vtlog "insmod $1"
|
||||
insmod "$1" >> $VTOY_PATH/log 2>&1
|
||||
else
|
||||
vtlog "$1 not exist"
|
||||
fi
|
||||
}
|
||||
|
||||
wrt_insmod() {
|
||||
kbit=$1
|
||||
kv=$(uname -r)
|
||||
|
||||
vtlog "insmod $kv $kbit"
|
||||
|
||||
check_insmod /ventoy_openwrt/$kv/$kbit/dax.ko
|
||||
check_insmod /ventoy_openwrt/$kv/$kbit/dm-mod.ko
|
||||
}
|
||||
|
||||
insmod_dm_mod() {
|
||||
if grep -q "device-mapper" /proc/devices; then
|
||||
vtlog "device-mapper enabled by system 0"
|
||||
return
|
||||
fi
|
||||
|
||||
check_insmod /ventoy/modules/dax.ko
|
||||
check_insmod /ventoy/modules/dm-mod.ko
|
||||
|
||||
if grep -q "device-mapper" /proc/devices; then
|
||||
vtlog "device-mapper enabled by system 1"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ -f /ventoy_openwrt.xz ]; then
|
||||
tar xf /ventoy_openwrt.xz -C /
|
||||
rm -f /ventoy_openwrt.xz
|
||||
fi
|
||||
|
||||
if uname -m | egrep -q "amd64|x86_64"; then
|
||||
wrt_insmod 64
|
||||
else
|
||||
wrt_insmod generic
|
||||
if lsmod | grep -q 'dm-mod'; then
|
||||
vterr "insmod generic failed"
|
||||
else
|
||||
wrt_insmod legacy
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
insmod_dm_mod
|
||||
|
||||
check_mkdev_node
|
||||
sleep 1
|
||||
|
||||
while [ -n "Y" ]; do
|
||||
vtusb_disk=$(get_ventoy_disk_name)
|
||||
if check_usb_disk_ready "$vtusb_disk"; then
|
||||
vtlog "get_ventoy_disk_name $vtusb_disk ready"
|
||||
break;
|
||||
else
|
||||
vtlog "get_ventoy_disk_name $vtusb_disk not ready"
|
||||
sleep 2
|
||||
check_mkdev_node
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
@@ -44,6 +120,8 @@ echo -n $vtDM > /ventoy/vtDM
|
||||
|
||||
ventoy_create_dev_ventoy_part
|
||||
mdev -s
|
||||
check_mkdev_node
|
||||
|
||||
|
||||
mkdir /ventoy_rdroot
|
||||
mount /dev/ventoy2 /ventoy_rdroot
|
||||
|
@@ -21,37 +21,8 @@
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
wrt_insmod() {
|
||||
kbit=$1
|
||||
kv=$(uname -r)
|
||||
|
||||
echo "insmod $kv $kbit" >> $VTOY_PATH/log
|
||||
|
||||
[ -f /ventoy_openwrt/$kv/$kbit/dax.ko ] && insmod /ventoy_openwrt/$kv/$kbit/dax.ko > /dev/null 2>&1
|
||||
[ -f /ventoy_openwrt/$kv/$kbit/dm-mod.ko ] && insmod /ventoy_openwrt/$kv/$kbit/dm-mod.ko > /dev/null 2>&1
|
||||
}
|
||||
|
||||
|
||||
mkdir /sys
|
||||
mount -t sysfs sys /sys
|
||||
mdev -s
|
||||
|
||||
|
||||
if [ -f /ventoy_openwrt.xz ]; then
|
||||
tar xf /ventoy_openwrt.xz -C /
|
||||
rm -f /ventoy_openwrt.xz
|
||||
fi
|
||||
|
||||
|
||||
if uname -m | egrep -q "amd64|x86_64"; then
|
||||
wrt_insmod 64
|
||||
else
|
||||
wrt_insmod generic
|
||||
if lsmod | grep -q 'dm-mod'; then
|
||||
echo "insmod generic failed" >> $VTOY_PATH/log
|
||||
else
|
||||
wrt_insmod legacy
|
||||
fi
|
||||
fi
|
||||
|
||||
sh $VTOY_PATH/loop/openwrt/ventoy-disk.sh
|
||||
|
@@ -58,6 +58,12 @@ ventoy_get_os_type() {
|
||||
|
||||
# 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
|
||||
|
@@ -82,5 +82,17 @@ else
|
||||
$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
|
||||
@@ -64,12 +64,12 @@ cp -a $VENTOY_PATH/LZIP/lunzip64 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 +95,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 +127,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/lakka/vtloopex/dm-mod/5.10.35/64/dax.ko.xz
Normal file
BIN
IMG/vtloopex/lakka/vtloopex/dm-mod/5.10.35/64/dax.ko.xz
Normal file
Binary file not shown.
BIN
IMG/vtloopex/lakka/vtloopex/dm-mod/5.10.35/64/dm-mod.ko.xz
Normal file
BIN
IMG/vtloopex/lakka/vtloopex/dm-mod/5.10.35/64/dm-mod.ko.xz
Normal file
Binary file not shown.
97
INSTALL/ExtendPersistentImg.sh
Normal file
97
INSTALL/ExtendPersistentImg.sh
Normal file
@@ -0,0 +1,97 @@
|
||||
#!/bin/sh
|
||||
|
||||
print_usage() {
|
||||
echo 'Usage: ExtendPersistentImg.sh file size'
|
||||
echo ' file persistent dat file'
|
||||
echo ' size extend size in MB'
|
||||
echo 'Example:'
|
||||
echo ' sh ExtendPersistentImg.sh ubuntu.dat 2048'
|
||||
echo ''
|
||||
}
|
||||
|
||||
if [ -z "$1" -o "$1" = "-h" ]; then
|
||||
print_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$2" ]; then
|
||||
print_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
file=$1
|
||||
size=$2
|
||||
|
||||
if [ ! -f "$file" ]; then
|
||||
echo "$file not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if echo $size | grep -q "[^0-9]"; then
|
||||
print_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fsize=$(stat -c '%s' $file)
|
||||
|
||||
fsmod=$(expr $fsize % 1024)
|
||||
if [ $fsmod -ne 0 ]; then
|
||||
echo "File size of $file is not aligned by 1MB, please check."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
fsMB=$(expr $fsize / 1024 / 1024)
|
||||
total=$(expr $fsMB + $size)
|
||||
|
||||
magic=$(hexdump -n3 -e '3/1 "%02X"' $file)
|
||||
if [ "$magic" = "584653" ]; then
|
||||
if which xfs_growfs >/dev/null 2>&1; then
|
||||
cmd=xfs_growfs
|
||||
else
|
||||
echo 'xfs_growfs not found, please install xfsprogs first'
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
if which resize2fs >/dev/null 2>&1; then
|
||||
cmd=resize2fs
|
||||
else
|
||||
echo 'resize2fs not found, please install e2fsprogs first'
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
echo "Extend dat file... (current is ${fsMB}MB, append ${size}MB, total ${total}MB)"
|
||||
dd if=/dev/zero bs=1M count=$size status=none >> "$file"
|
||||
sync
|
||||
|
||||
freeloop=$(losetup -f)
|
||||
losetup $freeloop "$file"
|
||||
|
||||
if [ "$cmd" = "resize2fs" ]; then
|
||||
echo "Extend ext filesystem by resize2fs ..."
|
||||
echo "resize2fs $freeloop ${total}M"
|
||||
e2fsck -f $freeloop
|
||||
resize2fs $freeloop ${total}M
|
||||
ret=$?
|
||||
else
|
||||
echo "Extend xfs filesystem by xfs_growfs ..."
|
||||
|
||||
tmpdir=$(mktemp -d)
|
||||
mount $freeloop $tmpdir
|
||||
xfs_growfs $freeloop
|
||||
ret=$?
|
||||
umount $tmpdir && rm -rf $tmpdir
|
||||
fi
|
||||
|
||||
losetup -d $freeloop
|
||||
|
||||
echo ""
|
||||
if [ $ret -eq 0 ]; then
|
||||
echo "======= SUCCESS ========="
|
||||
else
|
||||
echo "======= FAILED ========="
|
||||
fi
|
||||
echo ""
|
||||
|
@@ -21,8 +21,11 @@ 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
|
||||
|
||||
========= 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 ===============
|
||||
@@ -38,5 +41,12 @@ Please refer https://www.ventoy.net/en/plugin_persistence.html for details.
|
||||
|
||||
|
||||
|
||||
========== ExtendPersistentImg.sh ===============
|
||||
sudo sh ExtendPersistentImg.sh file size
|
||||
For example:
|
||||
sh ExtendPersistentImg.sh persistence.dat 2048 ----> Extend persistence.dat by 2048MB
|
||||
That is to say, persistence.dat file will grow to 3GB size (assume that it is 1GB size before extend)
|
||||
|
||||
Please refer https://www.ventoy.net/en/plugin_persistence.html for details.
|
||||
|
||||
|
||||
|
Binary file not shown.
@@ -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 ''
|
||||
|
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.
@@ -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
|
@@ -68,7 +68,7 @@ gfxterm_background: video_colors bitmap_scale gfxterm extcmd video bitmap
|
||||
search_fs_uuid:
|
||||
gcry_dsa: pgp mpi
|
||||
keystatus: extcmd
|
||||
linux: verifiers boot fdt
|
||||
linux: ventoy verifiers boot fdt
|
||||
geli: cryptodisk crypto gcry_sha512 pbkdf2 gcry_sha256
|
||||
cmdline_cat_test: font functional_test normal procfs video_fb
|
||||
part_sun:
|
||||
@@ -93,7 +93,7 @@ terminal:
|
||||
div:
|
||||
crypto:
|
||||
part_bsd: part_msdos
|
||||
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660
|
||||
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd datetime div normal video gcry_sha1 iso9660
|
||||
gcry_sha512: crypto
|
||||
password: crypto normal
|
||||
fshelp:
|
||||
|
@@ -40,6 +40,15 @@ submenu "Screen Display Mode" --class=debug_screen_mode --class=F5tool {
|
||||
|
||||
if [ "$grub_platform" != "pc" ]; then
|
||||
submenu 'Ventoy UEFI Utilities' --class=debug_util --class=F5tool {
|
||||
menuentry 'Show EFI Drivers' --class=debug_util_efidrv --class=debug_util --class=F5tool {
|
||||
vt_push_pager
|
||||
chainloader ${vtoy_path}/vtoyutil_${VTOY_EFI_ARCH}.efi env_param=${env_param} ${vtdebug_flag} feature=show_efi_drivers
|
||||
boot
|
||||
vt_pop_pager
|
||||
echo -e "\npress ENTER to exit ..."
|
||||
read vtInputKey
|
||||
}
|
||||
|
||||
menuentry 'Fixup Windows BlinitializeLibrary Failure' --class=debug_util_blinit --class=debug_util --class=F5tool {
|
||||
chainloader ${vtoy_path}/vtoyutil_${VTOY_EFI_ARCH}.efi env_param=${env_param} ${vtdebug_flag} feature=fix_windows_mmap
|
||||
boot
|
||||
|
@@ -130,9 +130,20 @@ function get_os_type {
|
||||
|
||||
function vt_check_compatible_pe {
|
||||
#Check for PE without external tools
|
||||
if [ -f "$1/HBCD_PE.ini" ]; then
|
||||
#set compatible if ISO file is less than 80MB
|
||||
if [ $vt_chosen_size -gt 33554432 -a $vt_chosen_size -le 83886080 ]; then
|
||||
set ventoy_compatible=YES
|
||||
fi
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
function vt_check_compatible_linux {
|
||||
if vt_str_begin "$vt_volume_id" "embootkit"; then
|
||||
set ventoy_compatible=YES
|
||||
fi
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
function locate_initrd {
|
||||
@@ -161,6 +172,10 @@ function distro_specify_wim_patch {
|
||||
vt_windows_collect_wim_patch wim /BOOT/H3_7PE.WIM
|
||||
vt_windows_collect_wim_patch wim /BOOT/H3_8PE.WIM
|
||||
vt_windows_collect_wim_patch wim /BOOT/H3_81PE.WIM
|
||||
elif [ -d (loop)/2k10/winpe ]; then
|
||||
vt_windows_collect_wim_patch wim /2k10/winpe/w1086pe.wim
|
||||
vt_windows_collect_wim_patch wim /2k10/winpe/w8x86pe.wim
|
||||
vt_windows_collect_wim_patch wim /2k10/winpe/w7x86pe.wim
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -550,6 +565,22 @@ function uefi_windows_menu_func {
|
||||
fi
|
||||
}
|
||||
|
||||
function uefi_find_replace_initrd {
|
||||
if vt_get_efi_vdisk_offset "${1}${2}" vt_efivdisk_offset; then
|
||||
loopback -s $vt_efivdisk_offset vtefivdisk "${1}${2}"
|
||||
|
||||
unset vt_rp_initrd
|
||||
vt_search_replace_initrd (vtefivdisk) vt_rp_initrd
|
||||
|
||||
if [ -n "$vt_rp_initrd" ]; then
|
||||
vt_add_replace_file $3 "$vt_rp_initrd"
|
||||
fi
|
||||
|
||||
loopback -d vtefivdisk
|
||||
ventoy_debug_pause
|
||||
fi
|
||||
}
|
||||
|
||||
function uefi_linux_menu_func {
|
||||
|
||||
if [ "$ventoy_compatible" = "NO" ]; then
|
||||
@@ -631,6 +662,11 @@ function uefi_linux_menu_func {
|
||||
elif [ -f (loop)/loader/entries/pisi-efi-x86_64.conf ]; then
|
||||
vt_add_replace_file $vtindex "EFI\\pisi\\initrd.img"
|
||||
fi
|
||||
|
||||
vt_get_replace_file_cnt vt_replace_cnt
|
||||
if [ $vt_replace_cnt -eq 0 ]; then
|
||||
uefi_find_replace_initrd "$1" "$2" $vtindex
|
||||
fi
|
||||
elif [ -d (loop)/EFI/boot/entries ]; then
|
||||
if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
|
||||
vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img"
|
||||
@@ -638,6 +674,8 @@ function uefi_linux_menu_func {
|
||||
vt_add_replace_file 0 "EFI\\hyperiso\\hyperiso.img"
|
||||
fi
|
||||
elif [ -d (loop)/EFI/BOOT/entries ]; then
|
||||
vt_linux_get_main_initrd_index vtindex
|
||||
|
||||
if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
|
||||
vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img"
|
||||
elif [ -f (loop)/parabola/boot/x86_64/initramfs-linux-libre.img ]; then
|
||||
@@ -731,6 +769,8 @@ function ventoy_reset_nojoliet {
|
||||
else
|
||||
vt_iso9660_nojoliet 0
|
||||
fi
|
||||
|
||||
vt_append_extra_sector 0
|
||||
}
|
||||
|
||||
function uefi_iso_menu_func {
|
||||
@@ -757,6 +797,12 @@ function uefi_iso_menu_func {
|
||||
else
|
||||
set ventoy_fs_probe=iso9660
|
||||
ventoy_reset_nojoliet
|
||||
|
||||
# Lenovo EasyStartup need an addional sector for boundary check
|
||||
if vt_str_begin "$vt_volume_id" "EasyStartup"; then
|
||||
vt_skip_svd "${vtoy_iso_part}${vt_chosen_path}"
|
||||
vt_append_extra_sector 1
|
||||
fi
|
||||
fi
|
||||
|
||||
loopback loop "${1}${chosen_path}"
|
||||
@@ -791,6 +837,7 @@ function uefi_iso_menu_func {
|
||||
elif [ "$vtoy_os" = "Unix" ]; then
|
||||
uefi_unix_menu_func "$1" "${chosen_path}"
|
||||
else
|
||||
vt_check_compatible_linux (loop)
|
||||
uefi_linux_menu_func "$1" "${chosen_path}"
|
||||
fi
|
||||
|
||||
@@ -900,7 +947,7 @@ function legacy_windows_menu_func {
|
||||
loopback loop "$1$2"
|
||||
fi
|
||||
|
||||
for file in "boot/bcd" "/efi/microsoft/boot/bcd" "SSTR/BCD"; do
|
||||
for file in "boot/bcd" "/efi/microsoft/boot/bcd" "SSTR/BCD" "boot/bce"; do
|
||||
vt_windows_collect_wim_patch bcd (loop)/$file
|
||||
done
|
||||
|
||||
@@ -941,6 +988,14 @@ function legacy_linux_menu_func {
|
||||
loopback loop "$1$2"
|
||||
fi
|
||||
|
||||
if [ -f (loop)/isolinux/isolinux.cfg ]; then
|
||||
if vt_iso9660_isjoliet; then
|
||||
vt_iso9660_nojoliet 1
|
||||
loopback -d loop
|
||||
loopback loop "$1$2"
|
||||
fi
|
||||
fi
|
||||
|
||||
vt_load_cpio $vtoy_path "$2" "$1" "busybox=$ventoy_busybox_ver"
|
||||
|
||||
vt_linux_clear_initrd
|
||||
@@ -1087,6 +1142,7 @@ function legacy_iso_menu_func {
|
||||
elif [ "$vtoy_os" = "Unix" ]; then
|
||||
legacy_unix_menu_func "$1" "${chosen_path}"
|
||||
else
|
||||
vt_check_compatible_linux (loop)
|
||||
legacy_linux_menu_func "$1" "${chosen_path}"
|
||||
fi
|
||||
}
|
||||
@@ -1169,9 +1225,8 @@ function iso_common_menuentry {
|
||||
echo -e "\n $vt_volume_space $vt_chosen_size $vt_chosen_size_mod\n"
|
||||
echo -e "\n The size of the iso file \"$vt_chosen_size\" is invalid. File corrupted ?\n"
|
||||
echo -e " 此ISO文件的大小 \"$vt_chosen_size\" 有问题,请确认文件是否损坏。\n"
|
||||
echo -e "\n press ENTER to exit (请按 回车 键返回) ..."
|
||||
echo -e "\n press ENTER to continue (请按 回车 键继续) ..."
|
||||
read vtInputKey
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1453,6 +1508,11 @@ function vtoy_unsupport_menuentry {
|
||||
#============================================================#
|
||||
#
|
||||
|
||||
function only_uefi_tip {
|
||||
echo -e "\n This IMG file is only supported in UEFI mode. \n"
|
||||
echo -e "\n press ENTER to exit ..."
|
||||
read vtInputKey
|
||||
}
|
||||
|
||||
function ventoy_img_easyos {
|
||||
vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
|
||||
@@ -1626,6 +1686,16 @@ function ventoy_img_openwrt {
|
||||
set ventoy_busybox_ver=64
|
||||
fi
|
||||
|
||||
vt_fs_enum_1st_dir (vtimghd,2) /lib/modules/ vt_dir_name
|
||||
|
||||
if [ -f (vtimghd,2)/lib/modules/$vt_dir_name/dm-mod.ko ]; then
|
||||
set openwrt_plugin_need=0
|
||||
vt_img_extra_initrd_append (vtimghd,2)/lib/modules/$vt_dir_name/dm-mod.ko
|
||||
if [ -f (vtimghd,2)/lib/modules/$vt_dir_name/dax.ko ]; then
|
||||
vt_img_extra_initrd_append (vtimghd,2)/lib/modules/$vt_dir_name/dax.ko
|
||||
fi
|
||||
else
|
||||
set openwrt_plugin_need=1
|
||||
if [ ! -f ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz ]; then
|
||||
ventoy_gui_console
|
||||
echo -e "\n ventoy_openwrt.xz not found. Please refer https://www.ventoy.net/en/doc_openwrt.html.\n"
|
||||
@@ -1635,6 +1705,7 @@ function ventoy_img_openwrt {
|
||||
ventoy_cli_console
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
if vt_img_check_range "${vtoy_iso_part}${vt_chosen_path}"; then
|
||||
ventoy_debug_pause
|
||||
@@ -1648,12 +1719,14 @@ function ventoy_img_openwrt {
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
|
||||
vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
|
||||
|
||||
if [ $openwrt_plugin_need -eq 1 ]; then
|
||||
if [ -f ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz ]; then
|
||||
vt_img_extra_initrd_append ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
#boot image file
|
||||
vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=openwrt
|
||||
@@ -1683,6 +1756,74 @@ function ventoy_img_tails {
|
||||
vt_unset_boot_opt
|
||||
}
|
||||
|
||||
function ventoy_img_fydeos {
|
||||
if [ "$grub_platform" = "pc" ]; then
|
||||
only_uefi_tip
|
||||
return
|
||||
fi
|
||||
|
||||
vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=64"
|
||||
vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
|
||||
|
||||
ventoy_debug_pause
|
||||
|
||||
#boot image file
|
||||
vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=fydeos
|
||||
vt_img_hook_root
|
||||
|
||||
set grubdisk=vtimghd
|
||||
set grubpartA=(vtimghd,3)
|
||||
set grubpartB=(vtimghd,5)
|
||||
set linuxpartA=(sda,3)
|
||||
set linuxpartB=(sda,5)
|
||||
|
||||
set root=(vtimghd,12)
|
||||
configfile (vtimghd,12)/efi/boot/grub.cfg
|
||||
|
||||
vt_img_unhook_root
|
||||
vt_unset_boot_opt
|
||||
|
||||
unset grubdisk
|
||||
unset grubpartA
|
||||
unset grubpartB
|
||||
unset linuxpartA
|
||||
unset linuxpartB
|
||||
}
|
||||
|
||||
function ventoy_img_cloudready {
|
||||
if [ "$grub_platform" = "pc" ]; then
|
||||
only_uefi_tip
|
||||
return
|
||||
fi
|
||||
|
||||
vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=64"
|
||||
vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
|
||||
|
||||
ventoy_debug_pause
|
||||
|
||||
#boot image file
|
||||
vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=cloudready
|
||||
vt_img_hook_root
|
||||
|
||||
set grubdisk=vtimghd
|
||||
set grubpartA=(vtimghd,3)
|
||||
set grubpartB=(vtimghd,5)
|
||||
set linuxpartA=(sda,3)
|
||||
set linuxpartB=(sda,5)
|
||||
|
||||
set root=(vtimghd,12)
|
||||
configfile (vtimghd,12)/efi/boot/grub.cfg
|
||||
|
||||
vt_img_unhook_root
|
||||
vt_unset_boot_opt
|
||||
|
||||
unset grubdisk
|
||||
unset grubpartA
|
||||
unset grubpartB
|
||||
unset linuxpartA
|
||||
unset linuxpartB
|
||||
}
|
||||
|
||||
function ventoy_img_memtest86 {
|
||||
chainloader (vtimghd,1)/efi/boot/BOOTX64.efi
|
||||
boot
|
||||
@@ -1695,9 +1836,19 @@ function img_unsupport_tip {
|
||||
read vtInputKey
|
||||
}
|
||||
|
||||
function legacy_img_memdisk {
|
||||
linux16 $vtoy_path/memdisk
|
||||
echo "Loading img file to memory ..."
|
||||
initrd16 "${1}${2}"
|
||||
|
||||
ventoy_cli_console
|
||||
boot
|
||||
}
|
||||
|
||||
function img_common_menuentry {
|
||||
set ventoy_compatible=YES
|
||||
set ventoy_busybox_ver=32
|
||||
unset LoadIsoEfiDriver
|
||||
|
||||
vt_chosen_img_path vt_chosen_path vt_chosen_size
|
||||
|
||||
@@ -1709,8 +1860,11 @@ function img_common_menuentry {
|
||||
return
|
||||
fi
|
||||
|
||||
if [ -d (vtimghd)/ ]; then
|
||||
loopback -d vtimghd
|
||||
if [ "$grub_platform" = "pc" ]; then
|
||||
if vt_check_mode 0; then
|
||||
legacy_img_memdisk $vtoy_iso_part "$vt_chosen_path"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
loopback vtimghd "${vtoy_iso_part}${vt_chosen_path}"
|
||||
@@ -1728,7 +1882,10 @@ function img_common_menuentry {
|
||||
|
||||
|
||||
vt_get_fs_label (vtimghd,1) vtImgHd1Label
|
||||
if [ -d (vtimghd,2)/lib ]; then
|
||||
|
||||
if [ "$vtImgHd1Label" = "STATE" ]; then
|
||||
vt_get_fs_label (vtimghd,3) vtImgHd3Label
|
||||
elif [ -d (vtimghd,2)/lib ]; then
|
||||
vt_get_fs_label (vtimghd,2) vtImgHd2Label
|
||||
fi
|
||||
|
||||
@@ -1736,11 +1893,15 @@ function img_common_menuentry {
|
||||
vt_1st_line (vtimghd,1)/etc/hostname vtImgHostname
|
||||
fi
|
||||
|
||||
|
||||
if [ -e (vtimghd,1)/easy.sfs ]; then
|
||||
ventoy_img_easyos
|
||||
elif [ -e (vtimghd,1)/volumio.initrd ]; then
|
||||
ventoy_img_volumio
|
||||
if vt_str_begin "$vtImgHd3Label" "ROOT-"; then
|
||||
if [ -f (vtimghd,3)/etc/os-release.d/ID ]; then
|
||||
vt_1st_line (vtimghd,3)/etc/os-release.d/ID vt_release_line1
|
||||
if [ vt_str_begin "$vt_release_line1" "FydeOS" ]; then
|
||||
ventoy_img_fydeos
|
||||
fi
|
||||
elif [ -f (vtimghd,3)/etc/cloudready-release ]; then
|
||||
ventoy_img_cloudready
|
||||
fi
|
||||
elif vt_str_begin "$vtImgHd1Label" "LAKKA"; then
|
||||
ventoy_img_openelec lakka
|
||||
elif vt_str_begin "$vtImgHd1Label" "LIBREELEC"; then
|
||||
@@ -1755,6 +1916,10 @@ function img_common_menuentry {
|
||||
ventoy_img_tails
|
||||
elif [ "$vtImgHd2Label" = "RECALBOX" ]; then
|
||||
ventoy_img_recalbox
|
||||
elif [ -e (vtimghd,1)/easy.sfs ]; then
|
||||
ventoy_img_easyos
|
||||
elif [ -e (vtimghd,1)/volumio.initrd ]; then
|
||||
ventoy_img_volumio
|
||||
elif [ -f (vtimghd,2)/loader/entries/ubos.conf ]; then
|
||||
ventoy_img_ubos
|
||||
elif [ -f (vtimghd,2)/etc/openwrt_version ]; then
|
||||
@@ -1777,6 +1942,8 @@ function img_common_menuentry {
|
||||
fi
|
||||
fi
|
||||
|
||||
loopback -d vtimghd
|
||||
|
||||
set root=$vtback_root
|
||||
vt_pop_last_entry
|
||||
set theme=$vtback_theme
|
||||
@@ -1796,7 +1963,7 @@ function img_unsupport_menuentry {
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
set VENTOY_VERSION="1.0.44"
|
||||
set VENTOY_VERSION="1.0.52"
|
||||
|
||||
#ACPI not compatible with Window7/8, so disable by default
|
||||
set VTOY_PARAM_NO_ACPI=1
|
||||
@@ -1877,6 +2044,8 @@ if [ -f $vtoy_iso_part/ventoy/ventoy.json ]; then
|
||||
clear
|
||||
vt_load_plugin $vtoy_iso_part
|
||||
clear
|
||||
else
|
||||
vt_check_json_path_case $vtoy_iso_part
|
||||
fi
|
||||
|
||||
if [ -n "$VTOY_MENU_TIMEOUT" ]; then
|
||||
@@ -1932,7 +2101,7 @@ elif [ "$vtoy_display_mode" = "serial_console" ]; then
|
||||
terminal_output serial console
|
||||
else
|
||||
if [ -n "$vtoy_theme" ]; then
|
||||
set theme=$vtoy_theme
|
||||
vt_set_theme
|
||||
else
|
||||
set theme=$prefix/themes/ventoy/theme.txt
|
||||
fi
|
||||
@@ -1943,6 +2112,15 @@ if [ -n "$VTOY_DEFAULT_KBD_LAYOUT" ]; then
|
||||
set_keyboard_layout "$VTOY_DEFAULT_KBD_LAYOUT"
|
||||
fi
|
||||
|
||||
if [ -n "$VTOY_PLUGIN_PATH_CASE_MISMATCH" ]; then
|
||||
clear
|
||||
echo "$VTOY_PLUGIN_PATH_CASE_MISMATCH"
|
||||
echo -e "\n\nPath case does not match! ventoy directory and ventoy.json MUST be all lowercase!"
|
||||
echo -e "\n路径大小写不匹配!ventoy 目录和 ventoy.json 文件的名字必须是全部小写,请修正!"
|
||||
echo -e "\n\npress ENTER to continue (请按回车键继续) ..."
|
||||
read vtInputKey
|
||||
fi
|
||||
|
||||
if [ -n "$VTOY_PLUGIN_SYNTAX_ERROR" ]; then
|
||||
clear
|
||||
echo -e "\n Syntax error detected in ventoy.json, please check! \n"
|
||||
@@ -1977,6 +2155,12 @@ export vtoy_efi_part
|
||||
export VENTOY_VERSION
|
||||
export VTOY_CUR_VIDEO_MODE
|
||||
export VTOY_EFI_ARCH
|
||||
export VTOY_MEM_DISK_STR
|
||||
export VTOY_ISO_RAW_STR
|
||||
export VTOY_GRUB2_MODE_STR
|
||||
export VTOY_WIMBOOT_MODE_STR
|
||||
export VTOY_ISO_UEFI_DRV_STR
|
||||
|
||||
|
||||
#special VTOY_DEFAULT_IMAGE process
|
||||
if [ -n "$VTOY_DEFAULT_IMAGE" ]; then
|
||||
|
@@ -82,7 +82,7 @@ gfxterm_background: video_colors bitmap_scale gfxterm extcmd video bitmap
|
||||
search_fs_uuid:
|
||||
gcry_dsa: pgp mpi
|
||||
keystatus: extcmd
|
||||
linux: verifiers video boot relocator mmap
|
||||
linux: ventoy verifiers video boot relocator mmap
|
||||
geli: cryptodisk crypto gcry_sha512 pbkdf2 gcry_sha256
|
||||
cmdline_cat_test: font functional_test normal procfs video_fb
|
||||
rdmsr: extcmd
|
||||
@@ -120,7 +120,7 @@ ehci: cs5536 usb boot
|
||||
crypto:
|
||||
part_bsd: part_msdos
|
||||
cs5536:
|
||||
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660
|
||||
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd datetime div normal video gcry_sha1 iso9660
|
||||
gcry_sha512: crypto
|
||||
password: crypto normal
|
||||
fshelp:
|
||||
|
@@ -82,7 +82,7 @@ gfxterm_background: video_colors bitmap_scale gfxterm extcmd video bitmap
|
||||
search_fs_uuid:
|
||||
gcry_dsa: pgp mpi
|
||||
keystatus: extcmd
|
||||
linux: verifiers normal vbe video boot relocator mmap
|
||||
linux: ventoy verifiers normal vbe video boot relocator mmap
|
||||
geli: cryptodisk crypto gcry_sha512 pbkdf2 gcry_sha256
|
||||
cmdline_cat_test: font functional_test normal procfs video_fb
|
||||
rdmsr: extcmd
|
||||
@@ -123,7 +123,7 @@ crypto:
|
||||
part_bsd: part_msdos
|
||||
cs5536: pci
|
||||
biosdisk:
|
||||
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660 acpi
|
||||
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf datetime div extcmd normal video gcry_sha1 iso9660 acpi
|
||||
lsapm:
|
||||
gcry_sha512: crypto
|
||||
password: crypto normal
|
||||
|
@@ -105,6 +105,23 @@ else
|
||||
echo "BOOTIA32.EFI NOT found ..."
|
||||
fi
|
||||
}
|
||||
|
||||
menuentry 'Search and boot xorboot' --class=boot_xorboot --class=F4boot {
|
||||
set VTOY_SEARCH_NO_VTOYEFI=1
|
||||
if search -n -s -f /efi/xorboot/xorboot32.xor; then
|
||||
unset VTOY_SEARCH_NO_VTOYEFI
|
||||
terminal_output console
|
||||
if [ -f /efi/xorboot/bootia32.efi ]; then
|
||||
chainloader /efi/xorboot/bootia32.efi
|
||||
elif [ -f /efi/xorboot/xorboot.efi ]; then
|
||||
chainloader /efi/xorboot/xorboot.efi
|
||||
fi
|
||||
boot
|
||||
else
|
||||
unset VTOY_SEARCH_NO_VTOYEFI
|
||||
echo "xorboot NOT found ..."
|
||||
fi
|
||||
}
|
||||
elif [ "$grub_cpu" = "arm64" ]; then
|
||||
menuentry 'Search and boot BOOTAA64.EFI' --class=boot_uefi --class=F4boot {
|
||||
set VTOY_SEARCH_NO_VTOYEFI=1
|
||||
@@ -131,8 +148,24 @@ else
|
||||
echo "BOOTX64.EFI NOT found ..."
|
||||
fi
|
||||
}
|
||||
fi
|
||||
|
||||
menuentry 'Search and boot xorboot' --class=boot_xorboot --class=F4boot {
|
||||
set VTOY_SEARCH_NO_VTOYEFI=1
|
||||
if search -n -s -f /efi/xorboot/xorboot.xor; then
|
||||
unset VTOY_SEARCH_NO_VTOYEFI
|
||||
terminal_output console
|
||||
if [ -f /efi/xorboot/bootx64.efi ]; then
|
||||
chainloader /efi/xorboot/bootx64.efi
|
||||
elif [ -f /efi/xorboot/xorboot.efi ]; then
|
||||
chainloader /efi/xorboot/xorboot.efi
|
||||
fi
|
||||
boot
|
||||
else
|
||||
unset VTOY_SEARCH_NO_VTOYEFI
|
||||
echo "xorboot NOT found ..."
|
||||
fi
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
fi
|
||||
|
Binary file not shown.
@@ -81,7 +81,7 @@ gfxterm_background: video_colors bitmap_scale gfxterm extcmd video bitmap
|
||||
search_fs_uuid:
|
||||
gcry_dsa: pgp mpi
|
||||
keystatus: extcmd
|
||||
linux: verifiers video boot relocator mmap
|
||||
linux: ventoy verifiers video boot relocator mmap
|
||||
geli: cryptodisk crypto gcry_sha512 pbkdf2 gcry_sha256
|
||||
cmdline_cat_test: font functional_test normal procfs video_fb
|
||||
rdmsr: extcmd
|
||||
@@ -120,7 +120,7 @@ ehci: cs5536 usb boot
|
||||
crypto:
|
||||
part_bsd: part_msdos
|
||||
cs5536:
|
||||
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660
|
||||
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd datetime div normal video gcry_sha1 iso9660
|
||||
gcry_sha512: crypto
|
||||
password: crypto normal
|
||||
fshelp:
|
||||
|
@@ -70,6 +70,22 @@ terminal-box: "terminal_box_*.png"
|
||||
}
|
||||
|
||||
|
||||
+ hbox{
|
||||
left = 30%+200
|
||||
top = 95%-50
|
||||
width = 10%
|
||||
height = 25
|
||||
+ label {text = "@VTOY_GRUB2_MODE@" color = "red" align = "left"}
|
||||
}
|
||||
|
||||
+ hbox{
|
||||
left = 30%+200
|
||||
top = 95%-25
|
||||
width = 10%
|
||||
height = 25
|
||||
+ label {text = "@VTOY_WIMBOOT_MODE@" color = "red" align = "left"}
|
||||
}
|
||||
|
||||
+ hbox{
|
||||
left = 90%
|
||||
top = 55
|
||||
|
583
INSTALL/tool/VentoyGTK.glade
Normal file
583
INSTALL/tool/VentoyGTK.glade
Normal file
@@ -0,0 +1,583 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="2.2"/>
|
||||
<object class="GtkImage" id="image_refresh">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
|
||||
<object class="GtkWindow" id="part_cfg_dlg">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="resizable">False</property>
|
||||
<property name="title" translatable="yes">Partition Configuration</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="window_position">center</property>
|
||||
<property name="default_width">460</property>
|
||||
<property name="default_height">270</property>
|
||||
<child>
|
||||
<object class="GtkFixed" id="fixed_partcfg_1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkFrame" id="frame_space_check">
|
||||
<property name="width_request">440</property>
|
||||
<property name="height_request">50</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<child>
|
||||
<object class="GtkFixed" id="fixed_space_check">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="space_check_btn">
|
||||
<property name="width_request">380</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">10</property>
|
||||
<property name="y">10</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">10</property>
|
||||
<property name="y">10</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkFrame" id="frame_space_value">
|
||||
<property name="width_request">220</property>
|
||||
<property name="height_request">60</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<child>
|
||||
<object class="GtkFixed" id="fixed_space_value">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkEntry" id="entry_reserve_space">
|
||||
<property name="width_request">200</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">*</property>
|
||||
<property name="primary_icon_activatable">False</property>
|
||||
<property name="secondary_icon_activatable">False</property>
|
||||
<property name="primary_icon_sensitive">True</property>
|
||||
<property name="secondary_icon_sensitive">True</property>
|
||||
<property name="width_chars">10</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">10</property>
|
||||
<property name="y">10</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">10</property>
|
||||
<property name="y">60</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkFrame" id="frame_space_unit">
|
||||
<property name="width_request">220</property>
|
||||
<property name="height_request">60</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<child>
|
||||
<object class="GtkFixed" id="fixed_space_unit">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="comboboxtext_unit">
|
||||
<property name="width_request">200</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="active">1</property>
|
||||
<items>
|
||||
<item translatable="yes">MB</item>
|
||||
<item translatable="yes">GB</item>
|
||||
</items>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">10</property>
|
||||
<property name="y">10</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">230</property>
|
||||
<property name="y">60</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkFrame" id="frame_space_align">
|
||||
<property name="width_request">440</property>
|
||||
<property name="height_request">50</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<child>
|
||||
<object class="GtkFixed" id="fixed_space_alian">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="space_align_btn">
|
||||
<property name="width_request">380</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="active">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">10</property>
|
||||
<property name="y">10</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">10</property>
|
||||
<property name="y">140</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkButton" id="button_partcfg_ok">
|
||||
<property name="label" translatable="yes">OK</property>
|
||||
<property name="width_request">100</property>
|
||||
<property name="height_request">40</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">90</property>
|
||||
<property name="y">210</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button_partcfg_cancel">
|
||||
<property name="label" translatable="yes">Cancel</property>
|
||||
<property name="width_request">100</property>
|
||||
<property name="height_request">40</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">270</property>
|
||||
<property name="y">210</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkFrame" id="frame_dummy1">
|
||||
<property name="width_request">460</property>
|
||||
<property name="height_request">25</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">10</property>
|
||||
<property name="y">250</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="resizable">False</property>
|
||||
<property name="title" translatable="yes">Ventoy2Disk</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="window_position">center</property>
|
||||
<property name="default_width">480</property>
|
||||
<property name="default_height">365</property>
|
||||
<child>
|
||||
<object class="GtkFixed" id="fixed_main">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkMenuBar" id="menubar1">
|
||||
<property name="width_request">480</property>
|
||||
<property name="height_request">22</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="menu_option">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Options</property>
|
||||
<property name="use_underline">True</property>
|
||||
<child type="submenu">
|
||||
<object class="GtkMenu" id="submenu_option">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkCheckMenuItem" id="menu_item_secure">
|
||||
<property name="label">Secure Boot Support</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="menu_part_style">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Partition Style</property>
|
||||
<property name="use_underline">True</property>
|
||||
<child type="submenu">
|
||||
<object class="GtkMenu" id="submenu_part_style">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkRadioMenuItem" id="menu_item_mbr">
|
||||
<property name="label">MBR</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioMenuItem" id="menu_item_gpt">
|
||||
<property name="label">GPT</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">False</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="menu_item_part_cfg">
|
||||
<property name="label">Partition Configuration</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="menu_item_clear">
|
||||
<property name="label">Clear Ventoy</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckMenuItem" id="menu_item_show_all">
|
||||
<property name="label">Show All Devices</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">False</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="menu_language">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Language</property>
|
||||
<property name="use_underline">True</property>
|
||||
<child type="submenu">
|
||||
<object class="GtkMenu" id="submenu_language">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame" id="frame_device">
|
||||
<property name="width_request">460</property>
|
||||
<property name="height_request">75</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<child>
|
||||
<object class="GtkFixed" id="fixed5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="combobox_devlist">
|
||||
<property name="width_request">380</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">10</property>
|
||||
<property name="y">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button_refresh">
|
||||
<property name="width_request">50</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="image">image_refresh</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">398</property>
|
||||
<property name="y">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
<object class="GtkLabel" id="label_device">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes"> Device </property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">10</property>
|
||||
<property name="y">40</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame" id="frame_pkg_ver">
|
||||
<property name="width_request">228</property>
|
||||
<property name="height_request">70</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0.5</property>
|
||||
<child>
|
||||
<object class="GtkFixed" id="fixed3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="image_secure_local">
|
||||
<property name="width_request">10</property>
|
||||
<property name="height_request">40</property>
|
||||
<property name="visible">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">20</property>
|
||||
<property name="y">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_local_ver_value">
|
||||
<property name="width_request">120</property>
|
||||
<property name="height_request">40</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes"></property>
|
||||
<property name="use_markup">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">45</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_local_part_style">
|
||||
<property name="width_request">45</property>
|
||||
<property name="height_request">20</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">MBR</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">180</property>
|
||||
<property name="y">30</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
<object class="GtkLabel" id="label_local_ver">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes"> Ventoy In Package </property>
|
||||
<property name="use_markup">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">10</property>
|
||||
<property name="y">132</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame" id="frame3">
|
||||
<property name="width_request">228</property>
|
||||
<property name="height_request">70</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0.5</property>
|
||||
<child>
|
||||
<object class="GtkFixed" id="fixed4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="image_secure_dev">
|
||||
<property name="width_request">10</property>
|
||||
<property name="height_request">40</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">20</property>
|
||||
<property name="y">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_dev_ver_value">
|
||||
<property name="width_request">120</property>
|
||||
<property name="height_request">40</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes"></property>
|
||||
<property name="use_markup">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">45</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_dev_part_style">
|
||||
<property name="width_request">45</property>
|
||||
<property name="height_request">20</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes"></property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">180</property>
|
||||
<property name="y">30</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
<object class="GtkLabel" id="label_device_ver">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes"> Ventoy In Device </property>
|
||||
<property name="use_markup">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">243</property>
|
||||
<property name="y">132</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame" id="frame4">
|
||||
<property name="width_request">460</property>
|
||||
<property name="height_request">50</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<child>
|
||||
<object class="GtkFixed" id="fixed2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkProgressBar" id="progressbar1">
|
||||
<property name="width_request">440</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="fraction">0.0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">8</property>
|
||||
<property name="y">10</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
<object class="GtkLabel" id="label_status">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes"> Status - READY</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">10</property>
|
||||
<property name="y">215</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button_install">
|
||||
<property name="label" translatable="yes">Install</property>
|
||||
<property name="width_request">100</property>
|
||||
<property name="height_request">40</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">100</property>
|
||||
<property name="y">300</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button_update">
|
||||
<property name="label" translatable="yes">Update</property>
|
||||
<property name="width_request">100</property>
|
||||
<property name="height_request">40</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">280</property>
|
||||
<property name="y">300</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkFrame" id="frame_dummy2">
|
||||
<property name="width_request">460</property>
|
||||
<property name="height_request">25</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">10</property>
|
||||
<property name="y">345</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
@@ -1,95 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
LOGFILE=log.txt
|
||||
VUSER=$(get_user)
|
||||
|
||||
if [ -e $LOGFILE ]; then
|
||||
chown $VUSER $LOGFILE
|
||||
else
|
||||
su $VUSER -c "touch $LOGFILE"
|
||||
fi
|
||||
|
||||
#delete the log.txt if it's more than 8MB
|
||||
if [ -f $LOGFILE ]; then
|
||||
logsize=$(stat -c '%s' $LOGFILE)
|
||||
if [ $logsize -gt 8388608 ]; then
|
||||
rm -f $LOGFILE
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ -f ./tool/$TOOLDIR/V2DServer.xz ]; then
|
||||
xz -d ./tool/$TOOLDIR/V2DServer.xz
|
||||
chmod +x ./tool/$TOOLDIR/V2DServer
|
||||
fi
|
||||
|
||||
rm -rf ./*_VTMPDIR
|
||||
vtWebTmpDir=$(mktemp -d -p ./ --suffix=_VTMPDIR)
|
||||
chown $VUSER $vtWebTmpDir
|
||||
|
||||
|
||||
V2DServer "$HOST" "$PORT" &
|
||||
V2DPid=$!
|
||||
sleep 1
|
||||
|
||||
su $VUSER -c "browser --window-size=550,400 --app=\"http://${HOST}:${PORT}/index.html?chrome-app\" --user-data-dir=$vtWebTmpDir >> $LOGFILE 2>&1" &
|
||||
WebPid=$!
|
||||
|
||||
|
||||
vtoy_trap_exit() {
|
||||
|
||||
[ -d /proc/$V2DPid ] && kill -2 $V2DPid
|
||||
[ -d /proc/$WebPid ] && kill -9 $WebPid
|
||||
|
||||
while [ -n "1" ]; do
|
||||
curPid=$(ps -ef | grep -m1 "$vtWebTmpDir" | egrep -v '\sgrep\s' | awk '{print $2}')
|
||||
if [ -z "$curPid" ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
if [ -d /proc/$curPid ]; then
|
||||
kill -9 $curPid
|
||||
fi
|
||||
done
|
||||
|
||||
[ -d $vtWebTmpDir ] && rm -rf $vtWebTmpDir
|
||||
|
||||
if [ -n "$OLDDIR" ]; then
|
||||
CURDIR=$(pwd)
|
||||
if [ "$CURDIR" != "$OLDDIR" ]; then
|
||||
cd "$OLDDIR"
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
trap vtoy_trap_exit HUP INT QUIT TSTP
|
||||
sleep 1
|
||||
|
||||
|
||||
vtVer=$(cat ventoy/version)
|
||||
echo ""
|
||||
echo "=================================================="
|
||||
if [ "$LANG" = "zh_CN.UTF-8" ]; then
|
||||
echo " Ventoy Server $vtVer 已经启动 ..."
|
||||
else
|
||||
echo " Ventoy Server $vtVer is running ..."
|
||||
fi
|
||||
echo "=================================================="
|
||||
echo ""
|
||||
echo "########### Press Ctrl + C to exit ###############"
|
||||
echo ""
|
||||
|
||||
wait $WebPid
|
||||
|
||||
[ -d /proc/$V2DPid ] && kill -2 $V2DPid
|
||||
|
||||
[ -d $vtWebTmpDir ] && rm -rf $vtWebTmpDir
|
||||
|
||||
if [ -n "$OLDDIR" ]; then
|
||||
CURDIR=$(pwd)
|
||||
if [ "$CURDIR" != "$OLDDIR" ]; then
|
||||
cd "$OLDDIR"
|
||||
fi
|
||||
fi
|
@@ -1,68 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
LOGFILE=log.txt
|
||||
|
||||
#delete the log.txt if it's more than 8MB
|
||||
if [ -f $LOGFILE ]; then
|
||||
logsize=$(stat -c '%s' $LOGFILE)
|
||||
if [ $logsize -gt 8388608 ]; then
|
||||
rm -f $LOGFILE
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ -f ./tool/$TOOLDIR/V2DServer.xz ]; then
|
||||
xz -d ./tool/$TOOLDIR/V2DServer.xz
|
||||
chmod +x ./tool/$TOOLDIR/V2DServer
|
||||
fi
|
||||
|
||||
V2DServer "$HOST" "$PORT" &
|
||||
V2DPid=$!
|
||||
sleep 1
|
||||
|
||||
|
||||
vtoy_trap_exit() {
|
||||
|
||||
[ -d /proc/$V2DPid ] && kill -2 $V2DPid
|
||||
|
||||
if [ -n "$OLDDIR" ]; then
|
||||
CURDIR=$(pwd)
|
||||
if [ "$CURDIR" != "$OLDDIR" ]; then
|
||||
cd "$OLDDIR"
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
trap vtoy_trap_exit HUP INT QUIT TSTP
|
||||
sleep 1
|
||||
|
||||
|
||||
vtVer=$(cat ventoy/version)
|
||||
echo ""
|
||||
echo "=================================================="
|
||||
if [ "$LANG" = "zh_CN.UTF-8" ]; then
|
||||
echo " Ventoy Server $vtVer 已经启动 ..."
|
||||
else
|
||||
echo " Ventoy Server $vtVer is running ..."
|
||||
fi
|
||||
echo "=================================================="
|
||||
echo ""
|
||||
echo "########### Press Ctrl + C to exit ###############"
|
||||
echo ""
|
||||
|
||||
if [ "$VERBOSE" = "1" ]; then
|
||||
uos-browser --window-size=550,400 --app="http://${HOST}:${PORT}/index.html?chrome-app"
|
||||
else
|
||||
uos-browser --window-size=550,400 --app="http://${HOST}:${PORT}/index.html?chrome-app" > /dev/null 2>&1
|
||||
fi
|
||||
|
||||
[ -d /proc/$V2DPid ] && kill -2 $V2DPid
|
||||
|
||||
if [ -n "$OLDDIR" ]; then
|
||||
CURDIR=$(pwd)
|
||||
if [ "$CURDIR" != "$OLDDIR" ]; then
|
||||
cd "$OLDDIR"
|
||||
fi
|
||||
fi
|
Binary file not shown.
BIN
INSTALL/tool/aarch64/Ventoy2Disk.gtk3
Normal file
BIN
INSTALL/tool/aarch64/Ventoy2Disk.gtk3
Normal file
Binary file not shown.
BIN
INSTALL/tool/aarch64/Ventoy2Disk.qt5
Normal file
BIN
INSTALL/tool/aarch64/Ventoy2Disk.qt5
Normal file
Binary file not shown.
Binary file not shown.
23
INSTALL/tool/distro_gui_type.json
Normal file
23
INSTALL/tool/distro_gui_type.json
Normal file
@@ -0,0 +1,23 @@
|
||||
[
|
||||
{
|
||||
"type": "env",
|
||||
"name": "DESKTOP_SESSION",
|
||||
"condition": "equal",
|
||||
"expression": "deepin",
|
||||
"gui": "qt5"
|
||||
},
|
||||
{
|
||||
"type": "env",
|
||||
"name": "DESKTOP_SESSION",
|
||||
"condition": "equal",
|
||||
"expression": "uos",
|
||||
"gui": "qt5"
|
||||
},
|
||||
{
|
||||
"type": "env",
|
||||
"name": "DESKTOP_SESSION",
|
||||
"condition": "equal",
|
||||
"expression": "ukui",
|
||||
"gui": "gtk3"
|
||||
}
|
||||
]
|
Binary file not shown.
BIN
INSTALL/tool/i386/Ventoy2Disk.gtk2
Normal file
BIN
INSTALL/tool/i386/Ventoy2Disk.gtk2
Normal file
Binary file not shown.
BIN
INSTALL/tool/i386/Ventoy2Disk.gtk3
Normal file
BIN
INSTALL/tool/i386/Ventoy2Disk.gtk3
Normal file
Binary file not shown.
BIN
INSTALL/tool/i386/Ventoy2Disk.qt5
Normal file
BIN
INSTALL/tool/i386/Ventoy2Disk.qt5
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
INSTALL/tool/mips64el/Ventoy2Disk.gtk3
Normal file
BIN
INSTALL/tool/mips64el/Ventoy2Disk.gtk3
Normal file
Binary file not shown.
BIN
INSTALL/tool/mips64el/Ventoy2Disk.qt5
Normal file
BIN
INSTALL/tool/mips64el/Ventoy2Disk.qt5
Normal file
Binary file not shown.
Binary file not shown.
@@ -320,7 +320,7 @@ EOF
|
||||
for i in 0 1 2 3 4 5 6 7 8 9; do
|
||||
check_umount_disk "$PART2"
|
||||
|
||||
if mkfs.vfat -F 16 -n VTOYEFI $PART2; then
|
||||
if mkfs.vfat -F 16 -n VTOYEFI -s 1 $PART2; then
|
||||
echo 'success'
|
||||
break
|
||||
else
|
||||
|
Binary file not shown.
BIN
INSTALL/tool/x86_64/Ventoy2Disk.gtk2
Normal file
BIN
INSTALL/tool/x86_64/Ventoy2Disk.gtk2
Normal file
Binary file not shown.
BIN
INSTALL/tool/x86_64/Ventoy2Disk.gtk3
Normal file
BIN
INSTALL/tool/x86_64/Ventoy2Disk.gtk3
Normal file
Binary file not shown.
BIN
INSTALL/tool/x86_64/Ventoy2Disk.qt5
Normal file
BIN
INSTALL/tool/x86_64/Ventoy2Disk.qt5
Normal file
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
Reference in New Issue
Block a user