mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-09-16 09:01:15 +00:00
Compare commits
46 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
d8fbd79dda | ||
|
8c192a1807 | ||
|
e8d17f9bb1 | ||
|
2283c3e8b0 | ||
|
8bbd5a14a3 | ||
|
f7d7db6a18 | ||
|
147a23c9dd | ||
|
062c71b972 | ||
|
78ab7a0759 | ||
|
3ebd58c9df | ||
|
ce6d379564 | ||
|
40fdfa66b9 | ||
|
9ddee7394d | ||
|
c9b316a757 | ||
|
1ba23bcdff | ||
|
6630ab3585 | ||
|
c0d478c2dd | ||
|
0217c5a923 | ||
|
97312d351e | ||
|
906dc4cd41 | ||
|
82a8b59bc7 | ||
|
b53e1fb8a8 | ||
|
84abffc424 | ||
|
bf4e014023 | ||
|
4f840ed673 | ||
|
d02f184a8d | ||
|
774e38928f | ||
|
0faba673a5 | ||
|
3c649b281f | ||
|
5f409a1208 | ||
|
9eb334d99a | ||
|
260a3269b7 | ||
|
a287bf8907 | ||
|
48a1b80be0 | ||
|
b9ef72fbe9 | ||
|
390507fff7 | ||
|
a29bdfbc3c | ||
|
21735f92d6 | ||
|
9a8d4d0227 | ||
|
6ebe77792c | ||
|
d678e54956 | ||
|
8dce0adda6 | ||
|
1bf3e73373 | ||
|
a9996d6761 | ||
|
dafea731c8 | ||
|
6d093e88e7 |
24
.github/workflows/ci.yml
vendored
Normal file
24
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
name: Ventoy CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run docker-compose up
|
||||
run: docker-compose up
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ventoy-linux
|
||||
path: INSTALL/ventoy-*linux*
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ventoy-windows
|
||||
path: INSTALL/ventoy-*windows*
|
||||
|
@@ -3,7 +3,7 @@
|
||||
1. Compile Enviroment
|
||||
==========================================
|
||||
My build envrioment is CentOS 7.8 x86_64. So here I first explain how to create the build environment from scratch.
|
||||
Because Ventoy is based on many open source projects, so the envrioment is important. I suggest you test it on a virtual machine first.
|
||||
Because Ventoy is based on many open source projects, so the environment is important. I suggest you test it on a virtual machine first.
|
||||
|
||||
1.1 Install CentOS 7.8
|
||||
I use CentOS-7-x86_64-Everything-2003.iso and select Minimal install
|
||||
@@ -146,6 +146,14 @@
|
||||
https://busybox.net/downloads/busybox-1.32.0.tar.bz2
|
||||
use BUSYBOX/64h.config and uclibc to build busybox-1.32
|
||||
|
||||
4.19 == Build lunzip32/lunzip64 ==
|
||||
http://mirror.yongbok.net/nongnu/lzip/lunzip/lunzip-1.11.tar.gz
|
||||
PATH=$PATH:/opt/diet/bin
|
||||
./configure --disable-nls CC='diet gcc -nostdinc'
|
||||
make
|
||||
strip --strip-all lunzip
|
||||
|
||||
|
||||
|
||||
==========================================
|
||||
5. Binaries
|
||||
|
29
DOC/LoopExBuild.txt
Normal file
29
DOC/LoopExBuild.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
1. LAKKA dm-mod.ko
|
||||
LaKKa config
|
||||
https://github.com/libretro/Lakka-LibreELEC/releases download source code
|
||||
\projects\Generic\linux\linux.x86_64.conf
|
||||
|
||||
Linux Kernel
|
||||
linux-4.11.12.tar.xz & patch-4.11.12-rt14.patch.xz
|
||||
patch -p1 < ../patch-4.11.12-rt14
|
||||
|
||||
make menuconfig
|
||||
select device mapper as module
|
||||
make -j 16
|
||||
get drivers\md\dm-mod.ko
|
||||
|
||||
2. LibreELEC dm-mod.ko
|
||||
LibreELEC config
|
||||
https://github.com/LibreELEC/LibreELEC.tv/releases download source code
|
||||
\projects\Generic\linux\linux.x86_64.conf
|
||||
|
||||
Linux Kernel
|
||||
linux-5.1.6.tar.xz
|
||||
make menuconfig
|
||||
select device mapper as module
|
||||
make -j 16
|
||||
get drivers\md\dm-mod.ko
|
||||
|
||||
|
||||
|
@@ -37,6 +37,7 @@
|
||||
#include <Ventoy.h>
|
||||
|
||||
BOOLEAN gDebugPrint = FALSE;
|
||||
BOOLEAN gDotEfiBoot = FALSE;
|
||||
BOOLEAN gLoadIsoEfi = FALSE;
|
||||
ventoy_ram_disk g_ramdisk_param;
|
||||
ventoy_chain_head *g_chain;
|
||||
@@ -49,6 +50,7 @@ ventoy_virt_chunk *g_virt_chunk;
|
||||
UINT32 g_virt_chunk_num;
|
||||
vtoy_block_data gBlockData;
|
||||
static grub_env_get_pf grub_env_get = NULL;
|
||||
static grub_env_set_pf grub_env_set = NULL;
|
||||
|
||||
ventoy_grub_param_file_replace *g_file_replace_list = NULL;
|
||||
ventoy_efi_file_replace g_efi_file_replace;
|
||||
@@ -271,19 +273,33 @@ static int ventoy_update_image_location(ventoy_os_param *param)
|
||||
}
|
||||
|
||||
CopyMem(&location->guid, ¶m->guid, sizeof(ventoy_guid));
|
||||
location->image_sector_size = 2048;
|
||||
location->image_sector_size = gSector512Mode ? 512 : 2048;
|
||||
location->disk_sector_size = g_chain->disk_sector_size;
|
||||
location->region_count = g_img_chunk_num;
|
||||
|
||||
region = location->regions;
|
||||
|
||||
for (i = 0; i < g_img_chunk_num; i++)
|
||||
if (gSector512Mode)
|
||||
{
|
||||
region->image_sector_count = chunk->img_end_sector - chunk->img_start_sector + 1;
|
||||
region->image_start_sector = chunk->img_start_sector;
|
||||
region->disk_start_sector = chunk->disk_start_sector;
|
||||
region++;
|
||||
chunk++;
|
||||
for (i = 0; i < g_img_chunk_num; i++)
|
||||
{
|
||||
region->image_sector_count = chunk->disk_end_sector - chunk->disk_start_sector + 1;
|
||||
region->image_start_sector = chunk->img_start_sector * 4;
|
||||
region->disk_start_sector = chunk->disk_start_sector;
|
||||
region++;
|
||||
chunk++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < g_img_chunk_num; i++)
|
||||
{
|
||||
region->image_sector_count = chunk->img_end_sector - chunk->img_start_sector + 1;
|
||||
region->image_start_sector = chunk->img_start_sector;
|
||||
region->disk_start_sector = chunk->disk_start_sector;
|
||||
region++;
|
||||
chunk++;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -376,6 +392,36 @@ EFI_STATUS EFIAPI ventoy_delete_variable(VOID)
|
||||
return Status;
|
||||
}
|
||||
|
||||
#if (VENTOY_DEVICE_WARN != 0)
|
||||
STATIC VOID ventoy_warn_invalid_device(VOID)
|
||||
{
|
||||
STATIC BOOLEAN flag = FALSE;
|
||||
|
||||
if (flag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
flag = TRUE;
|
||||
gST->ConOut->ClearScreen(gST->ConOut);
|
||||
gST->ConOut->OutputString(gST->ConOut, VTOY_WARNING L"\r\n");
|
||||
gST->ConOut->OutputString(gST->ConOut, VTOY_WARNING L"\r\n");
|
||||
gST->ConOut->OutputString(gST->ConOut, VTOY_WARNING L"\r\n\r\n\r\n");
|
||||
|
||||
gST->ConOut->OutputString(gST->ConOut, L"This is NOT a standard Ventoy device and is NOT supported.\r\n\r\n");
|
||||
gST->ConOut->OutputString(gST->ConOut, L"You should follow the official instructions in https://www.ventoy.net\r\n");
|
||||
|
||||
gST->ConOut->OutputString(gST->ConOut, L"\r\n\r\nWill exit after 10 seconds ...... ");
|
||||
|
||||
sleep(10);
|
||||
}
|
||||
#else
|
||||
STATIC VOID ventoy_warn_invalid_device(VOID)
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC EFI_STATUS EFIAPI ventoy_load_image
|
||||
(
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
@@ -418,6 +464,7 @@ STATIC EFI_STATUS EFIAPI ventoy_find_iso_disk(IN EFI_HANDLE ImageHandle)
|
||||
UINTN i = 0;
|
||||
UINTN Count = 0;
|
||||
UINT64 DiskSize = 0;
|
||||
MBR_HEAD *pMBR = NULL;
|
||||
UINT8 *pBuffer = NULL;
|
||||
EFI_HANDLE *Handles;
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
@@ -461,6 +508,18 @@ STATIC EFI_STATUS EFIAPI ventoy_find_iso_disk(IN EFI_HANDLE ImageHandle)
|
||||
|
||||
if (CompareMem(g_chain->os_param.vtoy_disk_guid, pBuffer + 0x180, 16) == 0)
|
||||
{
|
||||
pMBR = (MBR_HEAD *)pBuffer;
|
||||
if (pMBR->PartTbl[0].FsFlag != 0xEE)
|
||||
{
|
||||
if (pMBR->PartTbl[0].StartSectorId != 2048 ||
|
||||
pMBR->PartTbl[1].SectorCount != 65536 ||
|
||||
pMBR->PartTbl[1].StartSectorId != pMBR->PartTbl[0].StartSectorId + pMBR->PartTbl[0].SectorCount)
|
||||
{
|
||||
debug("Failed to check disk part table");
|
||||
ventoy_warn_invalid_device();
|
||||
}
|
||||
}
|
||||
|
||||
gBlockData.RawBlockIoHandle = Handles[i];
|
||||
gBlockData.pRawBlockIo = pBlockIo;
|
||||
gBS->OpenProtocol(Handles[i], &gEfiDevicePathProtocolGuid,
|
||||
@@ -580,6 +639,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
|
||||
UINT32 old_cnt = 0;
|
||||
UINTN size = 0;
|
||||
UINT8 chksum = 0;
|
||||
const char *pEnv = NULL;
|
||||
CHAR16 *pPos = NULL;
|
||||
CHAR16 *pCmdLine = NULL;
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
@@ -602,6 +662,11 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
|
||||
{
|
||||
gDebugPrint = TRUE;
|
||||
}
|
||||
|
||||
if (StrStr(pCmdLine, L"dotefi"))
|
||||
{
|
||||
gDotEfiBoot = TRUE;
|
||||
}
|
||||
|
||||
if (StrStr(pCmdLine, L"isoefi=on"))
|
||||
{
|
||||
@@ -642,8 +707,20 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
|
||||
}
|
||||
|
||||
pGrubParam = (ventoy_grub_param *)StrHexToUintn(pPos + StrLen(L"env_param="));
|
||||
grub_env_set = pGrubParam->grub_env_set;
|
||||
grub_env_get = pGrubParam->grub_env_get;
|
||||
pEnv = grub_env_get("VTOY_CHKDEV_RESULT_STRING");
|
||||
if (!pEnv)
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (pEnv[0] != '0' || pEnv[1] != 0)
|
||||
{
|
||||
ventoy_warn_invalid_device();
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
g_file_replace_list = &pGrubParam->file_replace;
|
||||
old_cnt = g_file_replace_list->old_file_cnt;
|
||||
debug("file replace: magic:0x%x virtid:%u name count:%u <%a> <%a> <%a> <%a>",
|
||||
@@ -664,6 +741,11 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
|
||||
|
||||
debug("memory addr:%p size:%lu", chain, size);
|
||||
|
||||
if (StrStr(pCmdLine, L"sector512"))
|
||||
{
|
||||
gSector512Mode = TRUE;
|
||||
}
|
||||
|
||||
if (StrStr(pCmdLine, L"memdisk"))
|
||||
{
|
||||
g_iso_data_buf = (UINT8 *)chain + sizeof(ventoy_chain_head);
|
||||
@@ -906,6 +988,11 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
|
||||
|
||||
if (Find == 0)
|
||||
{
|
||||
if (gDotEfiBoot)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
debug("Fs not found, now wait and retry...");
|
||||
sleep(2);
|
||||
}
|
||||
@@ -945,7 +1032,11 @@ EFI_STATUS EFIAPI VentoyEfiMain
|
||||
gST->ConOut->ClearScreen(gST->ConOut);
|
||||
ventoy_clear_input();
|
||||
|
||||
ventoy_parse_cmdline(ImageHandle);
|
||||
Status = ventoy_parse_cmdline(ImageHandle);
|
||||
if (EFI_ERROR(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (gMemdiskMode)
|
||||
{
|
||||
@@ -972,39 +1063,55 @@ EFI_STATUS EFIAPI VentoyEfiMain
|
||||
{
|
||||
gBS->UnloadImage(gBlockData.IsoDriverImage);
|
||||
}
|
||||
|
||||
gBS->DisconnectController(gBlockData.Handle, NULL, NULL);
|
||||
gBS->UninstallMultipleProtocolInterfaces(gBlockData.Handle,
|
||||
&gEfiBlockIoProtocolGuid, &gBlockData.BlockIo,
|
||||
&gEfiDevicePathProtocolGuid, gBlockData.Path,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
ventoy_save_variable();
|
||||
ventoy_find_iso_disk(ImageHandle);
|
||||
|
||||
if (gLoadIsoEfi)
|
||||
Status = ventoy_find_iso_disk(ImageHandle);
|
||||
if (!EFI_ERROR(Status))
|
||||
{
|
||||
ventoy_find_iso_disk_fs(ImageHandle);
|
||||
ventoy_load_isoefi_driver(ImageHandle);
|
||||
if (gLoadIsoEfi)
|
||||
{
|
||||
ventoy_find_iso_disk_fs(ImageHandle);
|
||||
ventoy_load_isoefi_driver(ImageHandle);
|
||||
}
|
||||
|
||||
ventoy_debug_pause();
|
||||
|
||||
ventoy_install_blockio(ImageHandle, g_chain->virt_img_size_in_bytes);
|
||||
|
||||
ventoy_debug_pause();
|
||||
|
||||
Status = ventoy_boot(ImageHandle);
|
||||
}
|
||||
|
||||
ventoy_debug_pause();
|
||||
|
||||
ventoy_install_blockio(ImageHandle, g_chain->virt_img_size_in_bytes);
|
||||
|
||||
ventoy_debug_pause();
|
||||
|
||||
Status = ventoy_boot(ImageHandle);
|
||||
|
||||
ventoy_clean_env();
|
||||
}
|
||||
|
||||
if (EFI_NOT_FOUND == Status)
|
||||
if (FALSE == gDotEfiBoot)
|
||||
{
|
||||
gST->ConOut->OutputString(gST->ConOut, L"No bootfile found for UEFI!\r\n");
|
||||
gST->ConOut->OutputString(gST->ConOut, L"Maybe the image does not support " VENTOY_UEFI_DESC L"!\r\n");
|
||||
sleep(30);
|
||||
if (EFI_NOT_FOUND == Status)
|
||||
{
|
||||
gST->ConOut->OutputString(gST->ConOut, L"No bootfile found for UEFI!\r\n");
|
||||
gST->ConOut->OutputString(gST->ConOut, L"Maybe the image does not support " VENTOY_UEFI_DESC L"!\r\n");
|
||||
sleep(30);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ventoy_clear_input();
|
||||
gST->ConOut->ClearScreen(gST->ConOut);
|
||||
|
||||
if (gDotEfiBoot && (EFI_NOT_FOUND == Status))
|
||||
{
|
||||
grub_env_set("vtoy_dotefi_retry", "YES");
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@@ -185,6 +185,9 @@ typedef struct ventoy_virt_chunk
|
||||
#error Unknown Processor Type
|
||||
#endif
|
||||
|
||||
#define VENTOY_DEVICE_WARN 1
|
||||
#define VTOY_WARNING L"!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!"
|
||||
|
||||
typedef struct ventoy_sector_flag
|
||||
{
|
||||
UINT8 flag; // 0:init 1:mem 2:remap
|
||||
@@ -227,6 +230,7 @@ if (gDebugPrint) \
|
||||
gBS->WaitForEvent(1, &gST->ConIn->WaitForKey, &__Index);\
|
||||
}
|
||||
|
||||
typedef int (*grub_env_set_pf)(const char *name, const char *val);
|
||||
typedef const char * (*grub_env_get_pf)(const char *name);
|
||||
typedef int (*grub_env_printf_pf)(const char *fmt, ...);
|
||||
|
||||
@@ -255,6 +259,7 @@ typedef struct ventoy_grub_param_file_replace
|
||||
typedef struct ventoy_grub_param
|
||||
{
|
||||
grub_env_get_pf grub_env_get;
|
||||
grub_env_set_pf grub_env_set;
|
||||
ventoy_grub_param_file_replace file_replace;
|
||||
grub_env_printf_pf grub_env_printf;
|
||||
}ventoy_grub_param;
|
||||
@@ -273,6 +278,32 @@ typedef struct ventoy_iso9660_override
|
||||
UINT32 size_be;
|
||||
}ventoy_iso9660_override;
|
||||
|
||||
typedef struct PART_TABLE
|
||||
{
|
||||
UINT8 Active; // 0x00 0x80
|
||||
|
||||
UINT8 StartHead;
|
||||
UINT16 StartSector : 6;
|
||||
UINT16 StartCylinder : 10;
|
||||
|
||||
UINT8 FsFlag;
|
||||
|
||||
UINT8 EndHead;
|
||||
UINT16 EndSector : 6;
|
||||
UINT16 EndCylinder : 10;
|
||||
|
||||
UINT32 StartSectorId;
|
||||
UINT32 SectorCount;
|
||||
}PART_TABLE;
|
||||
|
||||
typedef struct MBR_HEAD
|
||||
{
|
||||
UINT8 BootCode[446];
|
||||
PART_TABLE PartTbl[4];
|
||||
UINT8 Byte55;
|
||||
UINT8 ByteAA;
|
||||
}MBR_HEAD;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
|
||||
@@ -338,6 +369,7 @@ extern ventoy_efi_file_replace g_efi_file_replace;
|
||||
extern ventoy_sector_flag *g_sector_flag;
|
||||
extern UINT32 g_sector_flag_num;
|
||||
extern BOOLEAN gMemdiskMode;
|
||||
extern BOOLEAN gSector512Mode;
|
||||
extern UINTN g_iso_buf_size;
|
||||
extern UINT8 *g_iso_data_buf;
|
||||
extern ventoy_grub_param_file_replace *g_file_replace_list;
|
||||
|
@@ -39,6 +39,7 @@
|
||||
UINT8 *g_iso_data_buf = NULL;
|
||||
UINTN g_iso_buf_size = 0;
|
||||
BOOLEAN gMemdiskMode = FALSE;
|
||||
BOOLEAN gSector512Mode = FALSE;
|
||||
|
||||
ventoy_sector_flag *g_sector_flag = NULL;
|
||||
UINT32 g_sector_flag_num = 0;
|
||||
@@ -68,6 +69,10 @@ STATIC EFI_INPUT_READ_KEY g_org_read_key = NULL;
|
||||
|
||||
STATIC EFI_LOCATE_HANDLE g_org_locate_handle = NULL;
|
||||
|
||||
STATIC UINT8 g_sector_buf[2048];
|
||||
STATIC EFI_BLOCK_READ g_sector_2048_read = NULL;
|
||||
STATIC EFI_BLOCK_WRITE g_sector_2048_write = NULL;
|
||||
|
||||
BOOLEAN ventoy_is_cdrom_dp_exist(VOID)
|
||||
{
|
||||
UINTN i = 0;
|
||||
@@ -241,6 +246,87 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
STATIC EFI_STATUS EFIAPI ventoy_write_iso_sector
|
||||
(
|
||||
IN UINT64 Sector,
|
||||
IN UINTN Count,
|
||||
IN VOID *Buffer
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
EFI_LBA MapLba = 0;
|
||||
UINT32 i = 0;
|
||||
UINTN secLeft = 0;
|
||||
UINTN secRead = 0;
|
||||
UINT64 ReadStart = 0;
|
||||
UINT64 ReadEnd = 0;
|
||||
UINT8 *pCurBuf = (UINT8 *)Buffer;
|
||||
ventoy_img_chunk *pchunk = g_chunk;
|
||||
EFI_BLOCK_IO_PROTOCOL *pRawBlockIo = gBlockData.pRawBlockIo;
|
||||
|
||||
debug("write iso sector %lu count %u", Sector, Count);
|
||||
|
||||
ReadStart = Sector * 2048;
|
||||
ReadEnd = (Sector + Count) * 2048;
|
||||
|
||||
for (i = 0; Count > 0 && i < g_img_chunk_num; i++, pchunk++)
|
||||
{
|
||||
if (Sector >= pchunk->img_start_sector && Sector <= pchunk->img_end_sector)
|
||||
{
|
||||
if (g_chain->disk_sector_size == 512)
|
||||
{
|
||||
MapLba = (Sector - pchunk->img_start_sector) * 4 + pchunk->disk_start_sector;
|
||||
}
|
||||
else
|
||||
{
|
||||
MapLba = (Sector - pchunk->img_start_sector) * 2048 / g_chain->disk_sector_size + pchunk->disk_start_sector;
|
||||
}
|
||||
|
||||
secLeft = pchunk->img_end_sector + 1 - Sector;
|
||||
secRead = (Count < secLeft) ? Count : secLeft;
|
||||
|
||||
Status = pRawBlockIo->WriteBlocks(pRawBlockIo, pRawBlockIo->Media->MediaId,
|
||||
MapLba, secRead * 2048, pCurBuf);
|
||||
if (EFI_ERROR(Status))
|
||||
{
|
||||
debug("Raw disk write block failed %r LBA:%lu Count:%u", Status, MapLba, secRead);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Count -= secRead;
|
||||
Sector += secRead;
|
||||
pCurBuf += secRead * 2048;
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS EFIAPI ventoy_block_io_ramdisk_write
|
||||
(
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN BufferSize,
|
||||
IN VOID *Buffer
|
||||
)
|
||||
{
|
||||
(VOID)This;
|
||||
(VOID)MediaId;
|
||||
(VOID)Lba;
|
||||
(VOID)BufferSize;
|
||||
(VOID)Buffer;
|
||||
|
||||
if (!gSector512Mode)
|
||||
{
|
||||
return EFI_WRITE_PROTECTED;
|
||||
}
|
||||
|
||||
CopyMem(g_iso_data_buf + (Lba * 2048), Buffer, BufferSize);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS EFIAPI ventoy_block_io_ramdisk_read
|
||||
(
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
@@ -434,12 +520,21 @@ EFI_STATUS EFIAPI ventoy_block_io_write
|
||||
IN VOID *Buffer
|
||||
)
|
||||
{
|
||||
UINT32 secNum = 0;
|
||||
UINT64 offset = 0;
|
||||
|
||||
(VOID)This;
|
||||
(VOID)MediaId;
|
||||
(VOID)Lba;
|
||||
(VOID)BufferSize;
|
||||
(VOID)Buffer;
|
||||
return EFI_WRITE_PROTECTED;
|
||||
|
||||
if (!gSector512Mode)
|
||||
{
|
||||
return EFI_WRITE_PROTECTED;
|
||||
}
|
||||
|
||||
secNum = BufferSize / 2048;
|
||||
offset = Lba * 2048;
|
||||
|
||||
return ventoy_write_iso_sector(Lba, secNum, Buffer);
|
||||
}
|
||||
|
||||
EFI_STATUS EFIAPI ventoy_block_io_flush(IN EFI_BLOCK_IO_PROTOCOL *This)
|
||||
@@ -571,6 +666,126 @@ end:
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS EFIAPI ventoy_block_io_read_512
|
||||
(
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN BufferSize,
|
||||
OUT VOID *Buffer
|
||||
)
|
||||
{
|
||||
EFI_LBA Mod;
|
||||
UINTN ReadSize;
|
||||
UINT8 *CurBuf = NULL;
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
|
||||
debug("ventoy_block_io_read_512 %lu %lu\n", Lba, BufferSize / 512);
|
||||
|
||||
CurBuf = (UINT8 *)Buffer;
|
||||
|
||||
Mod = Lba % 4;
|
||||
if (Mod > 0)
|
||||
{
|
||||
Status |= g_sector_2048_read(This, MediaId, Lba / 4, 2048, g_sector_buf);
|
||||
|
||||
if (BufferSize <= (4 - Mod) * 512)
|
||||
{
|
||||
CopyMem(CurBuf, g_sector_buf + Mod * 512, BufferSize);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadSize = (4 - Mod) * 512;
|
||||
CopyMem(CurBuf, g_sector_buf + Mod * 512, ReadSize);
|
||||
CurBuf += ReadSize;
|
||||
Lba += (4 - Mod);
|
||||
BufferSize -= ReadSize;
|
||||
}
|
||||
}
|
||||
|
||||
if (BufferSize >= 2048)
|
||||
{
|
||||
ReadSize = BufferSize / 2048 * 2048;
|
||||
|
||||
Status |= g_sector_2048_read(This, MediaId, Lba / 4, ReadSize, CurBuf);
|
||||
CurBuf += ReadSize;
|
||||
|
||||
Lba += ReadSize / 512;
|
||||
BufferSize -= ReadSize;
|
||||
}
|
||||
|
||||
if (BufferSize > 0)
|
||||
{
|
||||
Status |= g_sector_2048_read(This, MediaId, Lba / 4, 2048, g_sector_buf);
|
||||
CopyMem(CurBuf, g_sector_buf, BufferSize);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS EFIAPI ventoy_block_io_write_512
|
||||
(
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN BufferSize,
|
||||
IN VOID *Buffer
|
||||
)
|
||||
{
|
||||
EFI_LBA Mod;
|
||||
UINTN ReadSize;
|
||||
UINT8 *CurBuf = NULL;
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
|
||||
debug("ventoy_block_io_write_512 %lu %lu\n", Lba, BufferSize / 512);
|
||||
|
||||
CurBuf = (UINT8 *)Buffer;
|
||||
|
||||
Mod = Lba % 4;
|
||||
if (Mod > 0)
|
||||
{
|
||||
Status |= g_sector_2048_read(This, MediaId, Lba / 4, 2048, g_sector_buf);
|
||||
|
||||
if (BufferSize <= (4 - Mod) * 512)
|
||||
{
|
||||
CopyMem(g_sector_buf + Mod * 512, CurBuf, BufferSize);
|
||||
return g_sector_2048_write(This, MediaId, Lba / 4, 2048, g_sector_buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadSize = (4 - Mod) * 512;
|
||||
CopyMem(g_sector_buf + Mod * 512, CurBuf, ReadSize);
|
||||
g_sector_2048_write(This, MediaId, Lba / 4, 2048, g_sector_buf);
|
||||
|
||||
CurBuf += ReadSize;
|
||||
Lba += (4 - Mod);
|
||||
BufferSize -= ReadSize;
|
||||
}
|
||||
}
|
||||
|
||||
if (BufferSize >= 2048)
|
||||
{
|
||||
ReadSize = BufferSize / 2048 * 2048;
|
||||
|
||||
Status |= g_sector_2048_write(This, MediaId, Lba / 4, ReadSize, CurBuf);
|
||||
CurBuf += ReadSize;
|
||||
|
||||
Lba += ReadSize / 512;
|
||||
BufferSize -= ReadSize;
|
||||
}
|
||||
|
||||
if (BufferSize > 0)
|
||||
{
|
||||
Status |= g_sector_2048_read(This, MediaId, Lba / 4, 2048, g_sector_buf);
|
||||
|
||||
CopyMem(g_sector_buf, CurBuf, BufferSize);
|
||||
g_sector_2048_write(This, MediaId, Lba / 4, 2048, g_sector_buf);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 ImgSize)
|
||||
{
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
@@ -580,9 +795,18 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im
|
||||
|
||||
debug("install block io protocol %p", ImageHandle);
|
||||
ventoy_debug_pause();
|
||||
|
||||
if (gSector512Mode)
|
||||
{
|
||||
gBlockData.Media.BlockSize = 512;
|
||||
gBlockData.Media.LastBlock = ImgSize / 512 - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
gBlockData.Media.BlockSize = 2048;
|
||||
gBlockData.Media.LastBlock = ImgSize / 2048 - 1;
|
||||
}
|
||||
|
||||
gBlockData.Media.BlockSize = 2048;
|
||||
gBlockData.Media.LastBlock = ImgSize / 2048 - 1;
|
||||
gBlockData.Media.ReadOnly = TRUE;
|
||||
gBlockData.Media.MediaPresent = 1;
|
||||
gBlockData.Media.LogicalBlocksPerPhysicalBlock = 1;
|
||||
@@ -590,8 +814,20 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im
|
||||
pBlockIo->Revision = EFI_BLOCK_IO_PROTOCOL_REVISION3;
|
||||
pBlockIo->Media = &(gBlockData.Media);
|
||||
pBlockIo->Reset = ventoy_block_io_reset;
|
||||
pBlockIo->ReadBlocks = gMemdiskMode ? ventoy_block_io_ramdisk_read : ventoy_block_io_read;
|
||||
pBlockIo->WriteBlocks = ventoy_block_io_write;
|
||||
|
||||
if (gSector512Mode)
|
||||
{
|
||||
g_sector_2048_read = gMemdiskMode ? ventoy_block_io_ramdisk_read : ventoy_block_io_read;
|
||||
g_sector_2048_write = gMemdiskMode ? ventoy_block_io_ramdisk_write : ventoy_block_io_write;
|
||||
pBlockIo->ReadBlocks = ventoy_block_io_read_512;
|
||||
pBlockIo->WriteBlocks = ventoy_block_io_write_512;
|
||||
}
|
||||
else
|
||||
{
|
||||
pBlockIo->ReadBlocks = gMemdiskMode ? ventoy_block_io_ramdisk_read : ventoy_block_io_read;
|
||||
pBlockIo->WriteBlocks = ventoy_block_io_write;
|
||||
}
|
||||
|
||||
pBlockIo->FlushBlocks = ventoy_block_io_flush;
|
||||
|
||||
Status = gBS->InstallMultipleProtocolInterfaces(&gBlockData.Handle,
|
||||
@@ -603,10 +839,10 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
Status = ventoy_connect_driver(gBlockData.Handle, L"Disk I/O Driver");
|
||||
debug("Connect disk IO driver %r", Status);
|
||||
|
||||
|
||||
Status = ventoy_connect_driver(gBlockData.Handle, L"Partition Driver");
|
||||
debug("Connect partition driver %r", Status);
|
||||
if (EFI_ERROR(Status))
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#pragma pack(1)
|
||||
|
||||
typedef EFI_STATUS (*VTOY_UTIL_PROC_PF)(IN EFI_HANDLE ImageHandle, IN CONST CHAR16 *CmdLine);
|
||||
typedef int (*grub_env_set_pf)(const char *name, const char *val);
|
||||
typedef const char * (*grub_env_get_pf)(const char *name);
|
||||
typedef int (*grub_env_printf_pf)(const char *fmt, ...);
|
||||
|
||||
@@ -38,6 +39,7 @@ typedef struct ventoy_grub_param_file_replace
|
||||
typedef struct ventoy_grub_param
|
||||
{
|
||||
grub_env_get_pf grub_env_get;
|
||||
grub_env_set_pf grub_env_set;
|
||||
ventoy_grub_param_file_replace file_replace;
|
||||
grub_env_printf_pf grub_env_printf;
|
||||
}ventoy_grub_param;
|
||||
|
1
EfiISO/ISO/EFI/BOOT/BOOTX64.EFI
Normal file
1
EfiISO/ISO/EFI/BOOT/BOOTX64.EFI
Normal file
@@ -0,0 +1 @@
|
||||
1
|
13
EfiISO/mkefiiso.sh
Normal file
13
EfiISO/mkefiiso.sh
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
rm -f ventoy_efiboot.img.*
|
||||
|
||||
cd ISO
|
||||
mkisofs -R -D -sysid VENTOY -V VENTOY -P "longpanda admin@ventoy.net" -p 'https://www.ventoy.net' -o ../ventoy_efiboot.img ./
|
||||
cd ..
|
||||
|
||||
xz --check=crc32 ventoy_efiboot.img
|
||||
|
||||
rm -f ../INSTALL/ventoy/ventoy_efiboot.img.xz
|
||||
cp -a ventoy_efiboot.img.xz ../INSTALL/ventoy/
|
||||
|
@@ -1591,6 +1591,7 @@ module = {
|
||||
common = ventoy/ventoy_linux.c;
|
||||
common = ventoy/ventoy_unix.c;
|
||||
common = ventoy/ventoy_windows.c;
|
||||
common = ventoy/ventoy_vhd.c;
|
||||
common = ventoy/ventoy_plugin.c;
|
||||
common = ventoy/ventoy_json.c;
|
||||
common = ventoy/lzx.c;
|
||||
|
353
GRUB2/MOD_SRC/grub-2.04/grub-core/commands/search.c
Normal file
353
GRUB2/MOD_SRC/grub-2.04/grub-core/commands/search.c
Normal file
@@ -0,0 +1,353 @@
|
||||
/* search.c - search devices based on a file or a filesystem label */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2005,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/device.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/search.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/partition.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
static int g_no_vtoyefi_part = 0;
|
||||
static char g_vtoyefi_dosname[64];
|
||||
static char g_vtoyefi_gptname[64];
|
||||
|
||||
struct cache_entry
|
||||
{
|
||||
struct cache_entry *next;
|
||||
char *key;
|
||||
char *value;
|
||||
};
|
||||
|
||||
static struct cache_entry *cache;
|
||||
|
||||
/* Context for FUNC_NAME. */
|
||||
struct search_ctx
|
||||
{
|
||||
const char *key;
|
||||
const char *var;
|
||||
int no_floppy;
|
||||
char **hints;
|
||||
unsigned nhints;
|
||||
int count;
|
||||
int is_cache;
|
||||
};
|
||||
|
||||
/* Helper for FUNC_NAME. */
|
||||
static int
|
||||
iterate_device (const char *name, void *data)
|
||||
{
|
||||
struct search_ctx *ctx = data;
|
||||
int found = 0;
|
||||
|
||||
/* Skip floppy drives when requested. */
|
||||
if (ctx->no_floppy &&
|
||||
name[0] == 'f' && name[1] == 'd' && name[2] >= '0' && name[2] <= '9')
|
||||
return 1;
|
||||
|
||||
if (g_no_vtoyefi_part && (grub_strcmp(name, g_vtoyefi_dosname) == 0 || grub_strcmp(name, g_vtoyefi_gptname) == 0)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef DO_SEARCH_FS_UUID
|
||||
#define compare_fn grub_strcasecmp
|
||||
#else
|
||||
#define compare_fn grub_strcmp
|
||||
#endif
|
||||
|
||||
#ifdef DO_SEARCH_FILE
|
||||
{
|
||||
char *buf;
|
||||
grub_file_t file;
|
||||
|
||||
buf = grub_xasprintf ("(%s)%s", name, ctx->key);
|
||||
if (! buf)
|
||||
return 1;
|
||||
|
||||
file = grub_file_open (buf, GRUB_FILE_TYPE_FS_SEARCH
|
||||
| GRUB_FILE_TYPE_NO_DECOMPRESS);
|
||||
if (file)
|
||||
{
|
||||
found = 1;
|
||||
grub_file_close (file);
|
||||
}
|
||||
grub_free (buf);
|
||||
}
|
||||
#else
|
||||
{
|
||||
/* SEARCH_FS_UUID or SEARCH_LABEL */
|
||||
grub_device_t dev;
|
||||
grub_fs_t fs;
|
||||
char *quid;
|
||||
|
||||
dev = grub_device_open (name);
|
||||
if (dev)
|
||||
{
|
||||
fs = grub_fs_probe (dev);
|
||||
|
||||
#ifdef DO_SEARCH_FS_UUID
|
||||
#define read_fn fs_uuid
|
||||
#else
|
||||
#define read_fn fs_label
|
||||
#endif
|
||||
|
||||
if (fs && fs->read_fn)
|
||||
{
|
||||
fs->read_fn (dev, &quid);
|
||||
|
||||
if (grub_errno == GRUB_ERR_NONE && quid)
|
||||
{
|
||||
if (compare_fn (quid, ctx->key) == 0)
|
||||
found = 1;
|
||||
|
||||
grub_free (quid);
|
||||
}
|
||||
}
|
||||
|
||||
grub_device_close (dev);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!ctx->is_cache && found && ctx->count == 0)
|
||||
{
|
||||
struct cache_entry *cache_ent;
|
||||
cache_ent = grub_malloc (sizeof (*cache_ent));
|
||||
if (cache_ent)
|
||||
{
|
||||
cache_ent->key = grub_strdup (ctx->key);
|
||||
cache_ent->value = grub_strdup (name);
|
||||
if (cache_ent->value && cache_ent->key)
|
||||
{
|
||||
cache_ent->next = cache;
|
||||
cache = cache_ent;
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_free (cache_ent->value);
|
||||
grub_free (cache_ent->key);
|
||||
grub_free (cache_ent);
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
}
|
||||
else
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
if (found)
|
||||
{
|
||||
ctx->count++;
|
||||
if (ctx->var)
|
||||
grub_env_set (ctx->var, name);
|
||||
else
|
||||
grub_printf (" %s", name);
|
||||
}
|
||||
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
return (found && ctx->var);
|
||||
}
|
||||
|
||||
/* Helper for FUNC_NAME. */
|
||||
static int
|
||||
part_hook (grub_disk_t disk, const grub_partition_t partition, void *data)
|
||||
{
|
||||
struct search_ctx *ctx = data;
|
||||
char *partition_name, *devname;
|
||||
int ret;
|
||||
|
||||
partition_name = grub_partition_get_name (partition);
|
||||
if (! partition_name)
|
||||
return 1;
|
||||
|
||||
devname = grub_xasprintf ("%s,%s", disk->name, partition_name);
|
||||
grub_free (partition_name);
|
||||
if (!devname)
|
||||
return 1;
|
||||
ret = iterate_device (devname, ctx);
|
||||
grub_free (devname);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Helper for FUNC_NAME. */
|
||||
static void
|
||||
try (struct search_ctx *ctx)
|
||||
{
|
||||
unsigned i;
|
||||
struct cache_entry **prev;
|
||||
struct cache_entry *cache_ent;
|
||||
|
||||
for (prev = &cache, cache_ent = *prev; cache_ent;
|
||||
prev = &cache_ent->next, cache_ent = *prev)
|
||||
if (compare_fn (cache_ent->key, ctx->key) == 0)
|
||||
break;
|
||||
if (cache_ent)
|
||||
{
|
||||
ctx->is_cache = 1;
|
||||
if (iterate_device (cache_ent->value, ctx))
|
||||
{
|
||||
ctx->is_cache = 0;
|
||||
return;
|
||||
}
|
||||
ctx->is_cache = 0;
|
||||
/* Cache entry was outdated. Remove it. */
|
||||
if (!ctx->count)
|
||||
{
|
||||
*prev = cache_ent->next;
|
||||
grub_free (cache_ent->key);
|
||||
grub_free (cache_ent->value);
|
||||
grub_free (cache_ent);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ctx->nhints; i++)
|
||||
{
|
||||
char *end;
|
||||
if (!ctx->hints[i][0])
|
||||
continue;
|
||||
end = ctx->hints[i] + grub_strlen (ctx->hints[i]) - 1;
|
||||
if (*end == ',')
|
||||
*end = 0;
|
||||
if (iterate_device (ctx->hints[i], ctx))
|
||||
{
|
||||
if (!*end)
|
||||
*end = ',';
|
||||
return;
|
||||
}
|
||||
if (!*end)
|
||||
{
|
||||
grub_device_t dev;
|
||||
int ret;
|
||||
dev = grub_device_open (ctx->hints[i]);
|
||||
if (!dev)
|
||||
{
|
||||
if (!*end)
|
||||
*end = ',';
|
||||
continue;
|
||||
}
|
||||
if (!dev->disk)
|
||||
{
|
||||
grub_device_close (dev);
|
||||
if (!*end)
|
||||
*end = ',';
|
||||
continue;
|
||||
}
|
||||
ret = grub_partition_iterate (dev->disk, part_hook, ctx);
|
||||
if (!*end)
|
||||
*end = ',';
|
||||
grub_device_close (dev);
|
||||
if (ret)
|
||||
return;
|
||||
}
|
||||
}
|
||||
grub_device_iterate (iterate_device, ctx);
|
||||
}
|
||||
|
||||
void
|
||||
FUNC_NAME (const char *key, const char *var, int no_floppy,
|
||||
char **hints, unsigned nhints)
|
||||
{
|
||||
struct search_ctx ctx = {
|
||||
.key = key,
|
||||
.var = var,
|
||||
.no_floppy = no_floppy,
|
||||
.hints = hints,
|
||||
.nhints = nhints,
|
||||
.count = 0,
|
||||
.is_cache = 0
|
||||
};
|
||||
grub_fs_autoload_hook_t saved_autoload;
|
||||
|
||||
g_no_vtoyefi_part = 0;
|
||||
if (grub_env_get("VTOY_SEARCH_NO_VTOYEFI"))
|
||||
{
|
||||
grub_snprintf(g_vtoyefi_dosname, sizeof(g_vtoyefi_dosname), "%s,msdos2", grub_env_get("vtoydev"));
|
||||
grub_snprintf(g_vtoyefi_gptname, sizeof(g_vtoyefi_gptname), "%s,gpt2", grub_env_get("vtoydev"));
|
||||
g_no_vtoyefi_part = 1;
|
||||
}
|
||||
|
||||
/* First try without autoloading if we're setting variable. */
|
||||
if (var)
|
||||
{
|
||||
saved_autoload = grub_fs_autoload_hook;
|
||||
grub_fs_autoload_hook = 0;
|
||||
try (&ctx);
|
||||
|
||||
/* Restore autoload hook. */
|
||||
grub_fs_autoload_hook = saved_autoload;
|
||||
|
||||
/* Retry with autoload if nothing found. */
|
||||
if (grub_errno == GRUB_ERR_NONE && ctx.count == 0)
|
||||
try (&ctx);
|
||||
}
|
||||
else
|
||||
try (&ctx);
|
||||
|
||||
if (grub_errno == GRUB_ERR_NONE && ctx.count == 0)
|
||||
grub_error (GRUB_ERR_FILE_NOT_FOUND, "no such device: %s", key);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_do_search (grub_command_t cmd __attribute__ ((unused)), int argc,
|
||||
char **args)
|
||||
{
|
||||
if (argc == 0)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
|
||||
|
||||
FUNC_NAME (args[0], argc == 1 ? 0 : args[1], 0, (args + 2),
|
||||
argc > 2 ? argc - 2 : 0);
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
#ifdef DO_SEARCH_FILE
|
||||
GRUB_MOD_INIT(search_fs_file)
|
||||
#elif defined (DO_SEARCH_FS_UUID)
|
||||
GRUB_MOD_INIT(search_fs_uuid)
|
||||
#else
|
||||
GRUB_MOD_INIT(search_label)
|
||||
#endif
|
||||
{
|
||||
cmd =
|
||||
grub_register_command (COMMAND_NAME, grub_cmd_do_search,
|
||||
N_("NAME [VARIABLE] [HINTS]"),
|
||||
HELP_MESSAGE);
|
||||
}
|
||||
|
||||
#ifdef DO_SEARCH_FILE
|
||||
GRUB_MOD_FINI(search_fs_file)
|
||||
#elif defined (DO_SEARCH_FS_UUID)
|
||||
GRUB_MOD_FINI(search_fs_uuid)
|
||||
#else
|
||||
GRUB_MOD_FINI(search_label)
|
||||
#endif
|
||||
{
|
||||
grub_unregister_command (cmd);
|
||||
}
|
839
GRUB2/MOD_SRC/grub-2.04/grub-core/gfxmenu/theme_loader.c
Normal file
839
GRUB2/MOD_SRC/grub-2.04/grub-core/gfxmenu/theme_loader.c
Normal file
@@ -0,0 +1,839 @@
|
||||
/* theme_loader.c - Theme file loader for gfxmenu. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 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/types.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/video.h>
|
||||
#include <grub/gui_string_util.h>
|
||||
#include <grub/bitmap.h>
|
||||
#include <grub/bitmap_scale.h>
|
||||
#include <grub/gfxwidgets.h>
|
||||
#include <grub/gfxmenu_view.h>
|
||||
#include <grub/gui.h>
|
||||
#include <grub/color.h>
|
||||
#include <grub/env.h>
|
||||
|
||||
static grub_err_t
|
||||
parse_proportional_spec (const char *value, signed *abs, grub_fixed_signed_t *prop);
|
||||
|
||||
/* Construct a new box widget using ABSPATTERN to find the pixmap files for
|
||||
it, storing the new box instance at *BOXPTR.
|
||||
PATTERN should be of the form: "(hd0,0)/somewhere/style*.png".
|
||||
The '*' then gets substituted with the various pixmap names that the
|
||||
box uses. */
|
||||
static grub_err_t
|
||||
recreate_box_absolute (grub_gfxmenu_box_t *boxptr, const char *abspattern)
|
||||
{
|
||||
char *prefix;
|
||||
char *suffix;
|
||||
char *star;
|
||||
grub_gfxmenu_box_t box;
|
||||
|
||||
star = grub_strchr (abspattern, '*');
|
||||
if (! star)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"missing `*' in box pixmap pattern `%s'", abspattern);
|
||||
|
||||
/* Prefix: Get the part before the '*'. */
|
||||
prefix = grub_malloc (star - abspattern + 1);
|
||||
if (! prefix)
|
||||
return grub_errno;
|
||||
|
||||
grub_memcpy (prefix, abspattern, star - abspattern);
|
||||
prefix[star - abspattern] = '\0';
|
||||
|
||||
/* Suffix: Everything after the '*' is the suffix. */
|
||||
suffix = star + 1;
|
||||
|
||||
box = grub_gfxmenu_create_box (prefix, suffix);
|
||||
grub_free (prefix);
|
||||
if (! box)
|
||||
return grub_errno;
|
||||
|
||||
if (*boxptr)
|
||||
(*boxptr)->destroy (*boxptr);
|
||||
*boxptr = box;
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
|
||||
/* Construct a new box widget using PATTERN to find the pixmap files for it,
|
||||
storing the new widget at *BOXPTR. PATTERN should be of the form:
|
||||
"somewhere/style*.png". The '*' then gets substituted with the various
|
||||
pixmap names that the widget uses.
|
||||
|
||||
Important! The value of *BOXPTR must be initialized! It must either
|
||||
(1) Be 0 (a NULL pointer), or
|
||||
(2) Be a pointer to a valid 'grub_gfxmenu_box_t' instance.
|
||||
In this case, the previous instance is destroyed. */
|
||||
grub_err_t
|
||||
grub_gui_recreate_box (grub_gfxmenu_box_t *boxptr,
|
||||
const char *pattern, const char *theme_dir)
|
||||
{
|
||||
char *abspattern;
|
||||
|
||||
/* Check arguments. */
|
||||
if (! pattern)
|
||||
{
|
||||
/* If no pixmap pattern is given, then just create an empty box. */
|
||||
if (*boxptr)
|
||||
(*boxptr)->destroy (*boxptr);
|
||||
*boxptr = grub_gfxmenu_create_box (0, 0);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
if (! theme_dir)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"styled box missing theme directory");
|
||||
|
||||
/* Resolve to an absolute path. */
|
||||
abspattern = grub_resolve_relative_path (theme_dir, pattern);
|
||||
if (! abspattern)
|
||||
return grub_errno;
|
||||
|
||||
/* Create the box. */
|
||||
recreate_box_absolute (boxptr, abspattern);
|
||||
grub_free (abspattern);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
theme_get_unsigned_int_from_proportional (const char *value,
|
||||
unsigned absolute_value,
|
||||
unsigned int *parsed_value)
|
||||
{
|
||||
grub_err_t err;
|
||||
grub_fixed_signed_t frac;
|
||||
signed pixels;
|
||||
err = parse_proportional_spec (value, &pixels, &frac);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
return err;
|
||||
int result = grub_fixed_sfs_multiply (absolute_value, frac) + pixels;
|
||||
if (result < 0)
|
||||
result = 0;
|
||||
*parsed_value = result;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/* Set the specified property NAME on the view to the given string VALUE.
|
||||
The caller is responsible for the lifetimes of NAME and VALUE. */
|
||||
static grub_err_t
|
||||
theme_set_string (grub_gfxmenu_view_t view,
|
||||
const char *name,
|
||||
const char *value,
|
||||
const char *theme_dir,
|
||||
const char *filename,
|
||||
int line_num,
|
||||
int col_num)
|
||||
{
|
||||
if (! grub_strcmp ("title-font", name))
|
||||
view->title_font = grub_font_get (value);
|
||||
else if (! grub_strcmp ("message-font", name))
|
||||
view->message_font = grub_font_get (value);
|
||||
else if (! grub_strcmp ("terminal-font", name))
|
||||
{
|
||||
grub_free (view->terminal_font_name);
|
||||
view->terminal_font_name = grub_strdup (value);
|
||||
if (! view->terminal_font_name)
|
||||
return grub_errno;
|
||||
}
|
||||
else if (! grub_strcmp ("title-color", name))
|
||||
grub_video_parse_color (value, &view->title_color);
|
||||
else if (! grub_strcmp ("message-color", name))
|
||||
grub_video_parse_color (value, &view->message_color);
|
||||
else if (! grub_strcmp ("message-bg-color", name))
|
||||
grub_video_parse_color (value, &view->message_bg_color);
|
||||
else if (! grub_strcmp ("desktop-image", name))
|
||||
{
|
||||
struct grub_video_bitmap *raw_bitmap;
|
||||
char *path;
|
||||
path = grub_resolve_relative_path (theme_dir, value);
|
||||
if (! path)
|
||||
return grub_errno;
|
||||
if (grub_video_bitmap_load (&raw_bitmap, path) != GRUB_ERR_NONE)
|
||||
{
|
||||
grub_free (path);
|
||||
return grub_errno;
|
||||
}
|
||||
grub_free(path);
|
||||
grub_video_bitmap_destroy (view->raw_desktop_image);
|
||||
view->raw_desktop_image = raw_bitmap;
|
||||
}
|
||||
else if (! grub_strcmp ("desktop-image-scale-method", name))
|
||||
{
|
||||
if (! value || ! grub_strcmp ("stretch", value))
|
||||
view->desktop_image_scale_method =
|
||||
GRUB_VIDEO_BITMAP_SELECTION_METHOD_STRETCH;
|
||||
else if (! grub_strcmp ("crop", value))
|
||||
view->desktop_image_scale_method =
|
||||
GRUB_VIDEO_BITMAP_SELECTION_METHOD_CROP;
|
||||
else if (! grub_strcmp ("padding", value))
|
||||
view->desktop_image_scale_method =
|
||||
GRUB_VIDEO_BITMAP_SELECTION_METHOD_PADDING;
|
||||
else if (! grub_strcmp ("fitwidth", value))
|
||||
view->desktop_image_scale_method =
|
||||
GRUB_VIDEO_BITMAP_SELECTION_METHOD_FITWIDTH;
|
||||
else if (! grub_strcmp ("fitheight", value))
|
||||
view->desktop_image_scale_method =
|
||||
GRUB_VIDEO_BITMAP_SELECTION_METHOD_FITHEIGHT;
|
||||
else
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"Unsupported scale method: %s",
|
||||
value);
|
||||
}
|
||||
else if (! grub_strcmp ("desktop-image-h-align", name))
|
||||
{
|
||||
if (! grub_strcmp ("left", value))
|
||||
view->desktop_image_h_align = GRUB_VIDEO_BITMAP_H_ALIGN_LEFT;
|
||||
else if (! grub_strcmp ("center", value))
|
||||
view->desktop_image_h_align = GRUB_VIDEO_BITMAP_H_ALIGN_CENTER;
|
||||
else if (! grub_strcmp ("right", value))
|
||||
view->desktop_image_h_align = GRUB_VIDEO_BITMAP_H_ALIGN_RIGHT;
|
||||
else
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"Unsupported horizontal align method: %s",
|
||||
value);
|
||||
}
|
||||
else if (! grub_strcmp ("desktop-image-v-align", name))
|
||||
{
|
||||
if (! grub_strcmp ("top", value))
|
||||
view->desktop_image_v_align = GRUB_VIDEO_BITMAP_V_ALIGN_TOP;
|
||||
else if (! grub_strcmp ("center", value))
|
||||
view->desktop_image_v_align = GRUB_VIDEO_BITMAP_V_ALIGN_CENTER;
|
||||
else if (! grub_strcmp ("bottom", value))
|
||||
view->desktop_image_v_align = GRUB_VIDEO_BITMAP_V_ALIGN_BOTTOM;
|
||||
else
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"Unsupported vertical align method: %s",
|
||||
value);
|
||||
}
|
||||
else if (! grub_strcmp ("desktop-color", name))
|
||||
grub_video_parse_color (value, &view->desktop_color);
|
||||
else if (! grub_strcmp ("terminal-box", name))
|
||||
{
|
||||
grub_err_t err;
|
||||
err = grub_gui_recreate_box (&view->terminal_box, value, theme_dir);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
return err;
|
||||
}
|
||||
else if (! grub_strcmp ("terminal-border", name))
|
||||
{
|
||||
view->terminal_border = grub_strtoul (value, 0, 10);
|
||||
if (grub_errno)
|
||||
return grub_errno;
|
||||
}
|
||||
else if (! grub_strcmp ("terminal-left", name))
|
||||
{
|
||||
unsigned int tmp;
|
||||
int err = theme_get_unsigned_int_from_proportional (value,
|
||||
view->screen.width,
|
||||
&tmp);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
return err;
|
||||
view->terminal_rect.x = tmp;
|
||||
}
|
||||
else if (! grub_strcmp ("terminal-top", name))
|
||||
{
|
||||
unsigned int tmp;
|
||||
int err = theme_get_unsigned_int_from_proportional (value,
|
||||
view->screen.height,
|
||||
&tmp);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
return err;
|
||||
view->terminal_rect.y = tmp;
|
||||
}
|
||||
else if (! grub_strcmp ("terminal-width", name))
|
||||
{
|
||||
unsigned int tmp;
|
||||
int err = theme_get_unsigned_int_from_proportional (value,
|
||||
view->screen.width,
|
||||
&tmp);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
return err;
|
||||
view->terminal_rect.width = tmp;
|
||||
}
|
||||
else if (! grub_strcmp ("terminal-height", name))
|
||||
{
|
||||
unsigned int tmp;
|
||||
int err = theme_get_unsigned_int_from_proportional (value,
|
||||
view->screen.height,
|
||||
&tmp);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
return err;
|
||||
view->terminal_rect.height = tmp;
|
||||
}
|
||||
else if (! grub_strcmp ("title-text", name))
|
||||
{
|
||||
grub_free (view->title_text);
|
||||
view->title_text = grub_strdup (value);
|
||||
if (! view->title_text)
|
||||
return grub_errno;
|
||||
}
|
||||
else
|
||||
{
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"%s:%d:%d unknown property `%s'",
|
||||
filename, line_num, col_num, name);
|
||||
}
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
struct parsebuf
|
||||
{
|
||||
char *buf;
|
||||
int pos;
|
||||
int len;
|
||||
int line_num;
|
||||
int col_num;
|
||||
const char *filename;
|
||||
char *theme_dir;
|
||||
grub_gfxmenu_view_t view;
|
||||
};
|
||||
|
||||
static int
|
||||
has_more (struct parsebuf *p)
|
||||
{
|
||||
return p->pos < p->len;
|
||||
}
|
||||
|
||||
static int
|
||||
read_char (struct parsebuf *p)
|
||||
{
|
||||
if (has_more (p))
|
||||
{
|
||||
char c;
|
||||
c = p->buf[p->pos++];
|
||||
if (c == '\n')
|
||||
{
|
||||
p->line_num++;
|
||||
p->col_num = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->col_num++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
peek_char (struct parsebuf *p)
|
||||
{
|
||||
if (has_more (p))
|
||||
return p->buf[p->pos];
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
is_whitespace (char c)
|
||||
{
|
||||
return (c == ' '
|
||||
|| c == '\t'
|
||||
|| c == '\r'
|
||||
|| c == '\n'
|
||||
|| c == '\f');
|
||||
}
|
||||
|
||||
static void
|
||||
skip_whitespace (struct parsebuf *p)
|
||||
{
|
||||
while (has_more (p) && is_whitespace(peek_char (p)))
|
||||
read_char (p);
|
||||
}
|
||||
|
||||
static void
|
||||
advance_to_next_line (struct parsebuf *p)
|
||||
{
|
||||
int c;
|
||||
|
||||
/* Eat characters up to the newline. */
|
||||
do
|
||||
{
|
||||
c = read_char (p);
|
||||
}
|
||||
while (c != -1 && c != '\n');
|
||||
}
|
||||
|
||||
static int
|
||||
is_identifier_char (int c)
|
||||
{
|
||||
return (c != -1
|
||||
&& (grub_isalpha(c)
|
||||
|| grub_isdigit(c)
|
||||
|| c == '_'
|
||||
|| c == '-'));
|
||||
}
|
||||
|
||||
static char *
|
||||
read_identifier (struct parsebuf *p)
|
||||
{
|
||||
/* Index of the first character of the identifier in p->buf. */
|
||||
int start;
|
||||
/* Next index after the last character of the identifer in p->buf. */
|
||||
int end;
|
||||
|
||||
skip_whitespace (p);
|
||||
|
||||
/* Capture the start of the identifier. */
|
||||
start = p->pos;
|
||||
|
||||
/* Scan for the end. */
|
||||
while (is_identifier_char (peek_char (p)))
|
||||
read_char (p);
|
||||
end = p->pos;
|
||||
|
||||
if (end - start < 1)
|
||||
return 0;
|
||||
|
||||
return grub_new_substring (p->buf, start, end);
|
||||
}
|
||||
|
||||
static char *
|
||||
read_expression (struct parsebuf *p)
|
||||
{
|
||||
int start;
|
||||
int end;
|
||||
|
||||
skip_whitespace (p);
|
||||
if (peek_char (p) == '"')
|
||||
{
|
||||
/* Read as a quoted string.
|
||||
The quotation marks are not included in the expression value. */
|
||||
/* Skip opening quotation mark. */
|
||||
read_char (p);
|
||||
start = p->pos;
|
||||
while (has_more (p) && peek_char (p) != '"')
|
||||
read_char (p);
|
||||
end = p->pos;
|
||||
/* Skip the terminating quotation mark. */
|
||||
read_char (p);
|
||||
}
|
||||
else if (peek_char (p) == '(')
|
||||
{
|
||||
/* Read as a parenthesized string -- for tuples/coordinates. */
|
||||
/* The parentheses are included in the expression value. */
|
||||
int c;
|
||||
|
||||
start = p->pos;
|
||||
do
|
||||
{
|
||||
c = read_char (p);
|
||||
}
|
||||
while (c != -1 && c != ')');
|
||||
end = p->pos;
|
||||
}
|
||||
else if (has_more (p))
|
||||
{
|
||||
/* Read as a single word -- for numeric values or words without
|
||||
whitespace. */
|
||||
start = p->pos;
|
||||
while (has_more (p) && ! is_whitespace (peek_char (p)))
|
||||
read_char (p);
|
||||
end = p->pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The end of the theme file has been reached. */
|
||||
grub_error (GRUB_ERR_IO, "%s:%d:%d expression expected in theme file",
|
||||
p->filename, p->line_num, p->col_num);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return grub_new_substring (p->buf, start, end);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
parse_proportional_spec (const char *value, signed *abs, grub_fixed_signed_t *prop)
|
||||
{
|
||||
signed num;
|
||||
const char *ptr;
|
||||
int sig = 0;
|
||||
*abs = 0;
|
||||
*prop = 0;
|
||||
ptr = value;
|
||||
while (*ptr)
|
||||
{
|
||||
sig = 0;
|
||||
|
||||
while (*ptr == '-' || *ptr == '+')
|
||||
{
|
||||
if (*ptr == '-')
|
||||
sig = !sig;
|
||||
ptr++;
|
||||
}
|
||||
|
||||
num = grub_strtoul (ptr, (char **) &ptr, 0);
|
||||
if (grub_errno)
|
||||
return grub_errno;
|
||||
if (sig)
|
||||
num = -num;
|
||||
if (*ptr == '%')
|
||||
{
|
||||
*prop += grub_fixed_fsf_divide (grub_signed_to_fixed (num), 100);
|
||||
ptr++;
|
||||
}
|
||||
else
|
||||
*abs += num;
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
||||
/* Read a GUI object specification from the theme file.
|
||||
Any components created will be added to the GUI container PARENT. */
|
||||
static grub_err_t
|
||||
read_object (struct parsebuf *p, grub_gui_container_t parent)
|
||||
{
|
||||
grub_video_rect_t bounds;
|
||||
|
||||
char *name;
|
||||
name = read_identifier (p);
|
||||
if (! name)
|
||||
goto cleanup;
|
||||
|
||||
grub_gui_component_t component = 0;
|
||||
if (grub_strcmp (name, "label") == 0)
|
||||
{
|
||||
component = grub_gui_label_new ();
|
||||
}
|
||||
else if (grub_strcmp (name, "image") == 0)
|
||||
{
|
||||
component = grub_gui_image_new ();
|
||||
}
|
||||
else if (grub_strcmp (name, "vbox") == 0)
|
||||
{
|
||||
component = (grub_gui_component_t) grub_gui_vbox_new ();
|
||||
}
|
||||
else if (grub_strcmp (name, "hbox") == 0)
|
||||
{
|
||||
component = (grub_gui_component_t) grub_gui_hbox_new ();
|
||||
}
|
||||
else if (grub_strcmp (name, "canvas") == 0)
|
||||
{
|
||||
component = (grub_gui_component_t) grub_gui_canvas_new ();
|
||||
}
|
||||
else if (grub_strcmp (name, "progress_bar") == 0)
|
||||
{
|
||||
component = grub_gui_progress_bar_new ();
|
||||
}
|
||||
else if (grub_strcmp (name, "circular_progress") == 0)
|
||||
{
|
||||
component = grub_gui_circular_progress_new ();
|
||||
}
|
||||
else if (grub_strcmp (name, "boot_menu") == 0)
|
||||
{
|
||||
component = grub_gui_list_new ();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Unknown type. */
|
||||
grub_error (GRUB_ERR_IO, "%s:%d:%d unknown object type `%s'",
|
||||
p->filename, p->line_num, p->col_num, name);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (! component)
|
||||
goto cleanup;
|
||||
|
||||
/* Inform the component about the theme so it can find its resources. */
|
||||
component->ops->set_property (component, "theme_dir", p->theme_dir);
|
||||
component->ops->set_property (component, "theme_path", p->filename);
|
||||
|
||||
/* Add the component as a child of PARENT. */
|
||||
bounds.x = 0;
|
||||
bounds.y = 0;
|
||||
bounds.width = -1;
|
||||
bounds.height = -1;
|
||||
component->ops->set_bounds (component, &bounds);
|
||||
parent->ops->add (parent, component);
|
||||
|
||||
skip_whitespace (p);
|
||||
if (read_char (p) != '{')
|
||||
{
|
||||
grub_error (GRUB_ERR_IO,
|
||||
"%s:%d:%d expected `{' after object type name `%s'",
|
||||
p->filename, p->line_num, p->col_num, name);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
while (has_more (p))
|
||||
{
|
||||
skip_whitespace (p);
|
||||
|
||||
/* Check whether the end has been encountered. */
|
||||
if (peek_char (p) == '}')
|
||||
{
|
||||
/* Skip the closing brace. */
|
||||
read_char (p);
|
||||
break;
|
||||
}
|
||||
|
||||
if (peek_char (p) == '#')
|
||||
{
|
||||
/* Skip comments. */
|
||||
advance_to_next_line (p);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (peek_char (p) == '+')
|
||||
{
|
||||
/* Skip the '+'. */
|
||||
read_char (p);
|
||||
|
||||
/* Check whether this component is a container. */
|
||||
if (component->ops->is_instance (component, "container"))
|
||||
{
|
||||
/* Read the sub-object recursively and add it as a child. */
|
||||
if (read_object (p, (grub_gui_container_t) component) != 0)
|
||||
goto cleanup;
|
||||
/* After reading the sub-object, resume parsing, expecting
|
||||
another property assignment or sub-object definition. */
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_error (GRUB_ERR_IO,
|
||||
"%s:%d:%d attempted to add object to non-container",
|
||||
p->filename, p->line_num, p->col_num);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
char *property;
|
||||
property = read_identifier (p);
|
||||
if (! property)
|
||||
{
|
||||
grub_error (GRUB_ERR_IO, "%s:%d:%d identifier expected in theme file",
|
||||
p->filename, p->line_num, p->col_num);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
skip_whitespace (p);
|
||||
if (read_char (p) != '=')
|
||||
{
|
||||
grub_error (GRUB_ERR_IO,
|
||||
"%s:%d:%d expected `=' after property name `%s'",
|
||||
p->filename, p->line_num, p->col_num, property);
|
||||
grub_free (property);
|
||||
goto cleanup;
|
||||
}
|
||||
skip_whitespace (p);
|
||||
|
||||
char *value;
|
||||
value = read_expression (p);
|
||||
if (! value)
|
||||
{
|
||||
grub_free (property);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Handle the property value. */
|
||||
if (grub_strcmp (property, "left") == 0)
|
||||
parse_proportional_spec (value, &component->x, &component->xfrac);
|
||||
else if (grub_strcmp (property, "top") == 0)
|
||||
parse_proportional_spec (value, &component->y, &component->yfrac);
|
||||
else if (grub_strcmp (property, "width") == 0)
|
||||
parse_proportional_spec (value, &component->w, &component->wfrac);
|
||||
else if (grub_strcmp (property, "height") == 0)
|
||||
parse_proportional_spec (value, &component->h, &component->hfrac);
|
||||
else
|
||||
/* General property handling. */
|
||||
component->ops->set_property (component, property, value);
|
||||
|
||||
grub_free (value);
|
||||
grub_free (property);
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
grub_free (name);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
read_property (struct parsebuf *p)
|
||||
{
|
||||
char *name;
|
||||
|
||||
/* Read the property name. */
|
||||
name = read_identifier (p);
|
||||
if (! name)
|
||||
{
|
||||
advance_to_next_line (p);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
/* Skip whitespace before separator. */
|
||||
skip_whitespace (p);
|
||||
|
||||
/* Read separator. */
|
||||
if (read_char (p) != ':')
|
||||
{
|
||||
grub_error (GRUB_ERR_IO,
|
||||
"%s:%d:%d missing separator after property name `%s'",
|
||||
p->filename, p->line_num, p->col_num, name);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Skip whitespace after separator. */
|
||||
skip_whitespace (p);
|
||||
|
||||
/* Get the value based on its type. */
|
||||
if (peek_char (p) == '"')
|
||||
{
|
||||
/* String value (e.g., '"My string"'). */
|
||||
char *value = read_expression (p);
|
||||
if (! value)
|
||||
{
|
||||
grub_error (GRUB_ERR_IO, "%s:%d:%d missing property value",
|
||||
p->filename, p->line_num, p->col_num);
|
||||
goto done;
|
||||
}
|
||||
/* If theme_set_string results in an error, grub_errno will be returned
|
||||
below. */
|
||||
theme_set_string (p->view, name, value, p->theme_dir,
|
||||
p->filename, p->line_num, p->col_num);
|
||||
grub_free (value);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_error (GRUB_ERR_IO,
|
||||
"%s:%d:%d property value invalid; "
|
||||
"enclose literal values in quotes (\")",
|
||||
p->filename, p->line_num, p->col_num);
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
grub_free (name);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
/* Set properties on the view based on settings from the specified
|
||||
theme file. */
|
||||
grub_err_t
|
||||
grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
|
||||
{
|
||||
grub_file_t file;
|
||||
struct parsebuf p;
|
||||
|
||||
p.view = view;
|
||||
p.theme_dir = grub_get_dirname (theme_path);
|
||||
|
||||
file = grub_file_open (theme_path, GRUB_FILE_TYPE_THEME);
|
||||
if (! file)
|
||||
{
|
||||
grub_free (p.theme_dir);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
p.len = grub_file_size (file);
|
||||
p.buf = grub_malloc (p.len + 4096);
|
||||
p.pos = 0;
|
||||
p.line_num = 1;
|
||||
p.col_num = 1;
|
||||
p.filename = theme_path;
|
||||
if (! p.buf)
|
||||
{
|
||||
grub_file_close (file);
|
||||
grub_free (p.theme_dir);
|
||||
return grub_errno;
|
||||
}
|
||||
if (grub_file_read (file, p.buf, p.len) != p.len)
|
||||
{
|
||||
grub_free (p.buf);
|
||||
grub_file_close (file);
|
||||
grub_free (p.theme_dir);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
{
|
||||
const char *checkret = grub_env_get("VTOY_CHKDEV_RESULT_STRING");
|
||||
if (checkret == NULL || checkret[0] != '0')
|
||||
{
|
||||
p.len += grub_snprintf(p.buf + p.len, 4096, "\n+ hbox{\n left = 1%%\n top = 90%%\n"
|
||||
" + label {text = \"[Unofficial Ventoy]\" color = \"red\" align = \"left\"}\n"
|
||||
"}\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (view->canvas)
|
||||
view->canvas->component.ops->destroy (view->canvas);
|
||||
|
||||
view->canvas = grub_gui_canvas_new ();
|
||||
if (!view->canvas)
|
||||
goto fail;
|
||||
((grub_gui_component_t) view->canvas)
|
||||
->ops->set_bounds ((grub_gui_component_t) view->canvas,
|
||||
&view->screen);
|
||||
|
||||
while (has_more (&p))
|
||||
{
|
||||
/* Skip comments (lines beginning with #). */
|
||||
if (peek_char (&p) == '#')
|
||||
{
|
||||
advance_to_next_line (&p);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Find the first non-whitespace character. */
|
||||
skip_whitespace (&p);
|
||||
|
||||
/* Handle the content. */
|
||||
if (peek_char (&p) == '+')
|
||||
{
|
||||
/* Skip the '+'. */
|
||||
read_char (&p);
|
||||
read_object (&p, view->canvas);
|
||||
}
|
||||
else
|
||||
{
|
||||
read_property (&p);
|
||||
}
|
||||
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Set the new theme path. */
|
||||
grub_free (view->theme_path);
|
||||
view->theme_path = grub_strdup (theme_path);
|
||||
goto cleanup;
|
||||
|
||||
fail:
|
||||
if (view->canvas)
|
||||
{
|
||||
view->canvas->component.ops->destroy (view->canvas);
|
||||
view->canvas = 0;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
grub_free (p.buf);
|
||||
grub_file_close (file);
|
||||
grub_free (p.theme_dir);
|
||||
return grub_errno;
|
||||
}
|
647
GRUB2/MOD_SRC/grub-2.04/grub-core/gfxmenu/view.c
Normal file
647
GRUB2/MOD_SRC/grub-2.04/grub-core/gfxmenu/view.c
Normal file
@@ -0,0 +1,647 @@
|
||||
/* view.c - Graphical menu interface MVC view. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 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/types.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/video.h>
|
||||
#include <grub/gfxterm.h>
|
||||
#include <grub/bitmap.h>
|
||||
#include <grub/bitmap_scale.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/gfxwidgets.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/menu.h>
|
||||
#include <grub/menu_viewer.h>
|
||||
#include <grub/gfxmenu_view.h>
|
||||
#include <grub/gui_string_util.h>
|
||||
#include <grub/icon_manager.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
static void
|
||||
init_terminal (grub_gfxmenu_view_t view);
|
||||
static void
|
||||
init_background (grub_gfxmenu_view_t view);
|
||||
static grub_gfxmenu_view_t term_view;
|
||||
|
||||
/* Create a new view object, loading the theme specified by THEME_PATH and
|
||||
associating MODEL with the view. */
|
||||
grub_gfxmenu_view_t
|
||||
grub_gfxmenu_view_new (const char *theme_path,
|
||||
int width, int height)
|
||||
{
|
||||
grub_gfxmenu_view_t view;
|
||||
grub_font_t default_font;
|
||||
grub_video_rgba_color_t default_fg_color;
|
||||
grub_video_rgba_color_t default_bg_color;
|
||||
|
||||
view = grub_malloc (sizeof (*view));
|
||||
if (! view)
|
||||
return 0;
|
||||
|
||||
while (grub_gfxmenu_timeout_notifications)
|
||||
{
|
||||
struct grub_gfxmenu_timeout_notify *p;
|
||||
p = grub_gfxmenu_timeout_notifications;
|
||||
grub_gfxmenu_timeout_notifications = grub_gfxmenu_timeout_notifications->next;
|
||||
grub_free (p);
|
||||
}
|
||||
|
||||
view->screen.x = 0;
|
||||
view->screen.y = 0;
|
||||
view->screen.width = width;
|
||||
view->screen.height = height;
|
||||
|
||||
view->need_to_check_sanity = 1;
|
||||
view->terminal_border = 3;
|
||||
view->terminal_rect.width = view->screen.width * 7 / 10;
|
||||
view->terminal_rect.height = view->screen.height * 7 / 10;
|
||||
view->terminal_rect.x = view->screen.x + (view->screen.width
|
||||
- view->terminal_rect.width) / 2;
|
||||
view->terminal_rect.y = view->screen.y + (view->screen.height
|
||||
- view->terminal_rect.height) / 2;
|
||||
|
||||
default_font = grub_font_get ("Unknown Regular 16");
|
||||
default_fg_color = grub_video_rgba_color_rgb (0, 0, 0);
|
||||
default_bg_color = grub_video_rgba_color_rgb (255, 255, 255);
|
||||
|
||||
view->canvas = 0;
|
||||
|
||||
view->title_font = default_font;
|
||||
view->message_font = default_font;
|
||||
view->terminal_font_name = grub_strdup ("Fixed 10");
|
||||
view->title_color = default_fg_color;
|
||||
view->message_color = default_bg_color;
|
||||
view->message_bg_color = default_fg_color;
|
||||
view->raw_desktop_image = 0;
|
||||
view->scaled_desktop_image = 0;
|
||||
view->desktop_image_scale_method = GRUB_VIDEO_BITMAP_SELECTION_METHOD_STRETCH;
|
||||
view->desktop_image_h_align = GRUB_VIDEO_BITMAP_H_ALIGN_CENTER;
|
||||
view->desktop_image_v_align = GRUB_VIDEO_BITMAP_V_ALIGN_CENTER;
|
||||
view->desktop_color = default_bg_color;
|
||||
view->terminal_box = grub_gfxmenu_create_box (0, 0);
|
||||
view->title_text = grub_strdup (_("GRUB Boot Menu"));
|
||||
view->progress_message_text = 0;
|
||||
view->theme_path = 0;
|
||||
|
||||
/* Set the timeout bar's frame. */
|
||||
view->progress_message_frame.width = view->screen.width * 4 / 5;
|
||||
view->progress_message_frame.height = 50;
|
||||
view->progress_message_frame.x = view->screen.x
|
||||
+ (view->screen.width - view->progress_message_frame.width) / 2;
|
||||
view->progress_message_frame.y = view->screen.y
|
||||
+ view->screen.height - 90 - 20 - view->progress_message_frame.height;
|
||||
|
||||
if (grub_gfxmenu_view_load_theme (view, theme_path) != 0)
|
||||
{
|
||||
grub_gfxmenu_view_destroy (view);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
/* Destroy the view object. All used memory is freed. */
|
||||
void
|
||||
grub_gfxmenu_view_destroy (grub_gfxmenu_view_t view)
|
||||
{
|
||||
if (!view)
|
||||
return;
|
||||
while (grub_gfxmenu_timeout_notifications)
|
||||
{
|
||||
struct grub_gfxmenu_timeout_notify *p;
|
||||
p = grub_gfxmenu_timeout_notifications;
|
||||
grub_gfxmenu_timeout_notifications = grub_gfxmenu_timeout_notifications->next;
|
||||
grub_free (p);
|
||||
}
|
||||
grub_video_bitmap_destroy (view->raw_desktop_image);
|
||||
grub_video_bitmap_destroy (view->scaled_desktop_image);
|
||||
if (view->terminal_box)
|
||||
view->terminal_box->destroy (view->terminal_box);
|
||||
grub_free (view->terminal_font_name);
|
||||
grub_free (view->title_text);
|
||||
grub_free (view->progress_message_text);
|
||||
grub_free (view->theme_path);
|
||||
if (view->canvas)
|
||||
view->canvas->component.ops->destroy (view->canvas);
|
||||
grub_free (view);
|
||||
}
|
||||
|
||||
static void
|
||||
redraw_background (grub_gfxmenu_view_t view,
|
||||
const grub_video_rect_t *bounds)
|
||||
{
|
||||
if (view->scaled_desktop_image)
|
||||
{
|
||||
struct grub_video_bitmap *img = view->scaled_desktop_image;
|
||||
grub_video_blit_bitmap (img, GRUB_VIDEO_BLIT_REPLACE,
|
||||
bounds->x, bounds->y,
|
||||
bounds->x - view->screen.x,
|
||||
bounds->y - view->screen.y,
|
||||
bounds->width, bounds->height);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_video_fill_rect (grub_video_map_rgba_color (view->desktop_color),
|
||||
bounds->x, bounds->y,
|
||||
bounds->width, bounds->height);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_title (grub_gfxmenu_view_t view)
|
||||
{
|
||||
if (! view->title_text)
|
||||
return;
|
||||
|
||||
/* Center the title. */
|
||||
int title_width = grub_font_get_string_width (view->title_font,
|
||||
view->title_text);
|
||||
int x = (view->screen.width - title_width) / 2;
|
||||
int y = 40 + grub_font_get_ascent (view->title_font);
|
||||
grub_font_draw_string (view->title_text,
|
||||
view->title_font,
|
||||
grub_video_map_rgba_color (view->title_color),
|
||||
x, y);
|
||||
}
|
||||
|
||||
struct progress_value_data
|
||||
{
|
||||
int visible;
|
||||
int start;
|
||||
int end;
|
||||
int value;
|
||||
};
|
||||
|
||||
struct grub_gfxmenu_timeout_notify *grub_gfxmenu_timeout_notifications;
|
||||
|
||||
static void
|
||||
update_timeouts (int visible, int start, int value, int end)
|
||||
{
|
||||
struct grub_gfxmenu_timeout_notify *cur;
|
||||
|
||||
for (cur = grub_gfxmenu_timeout_notifications; cur; cur = cur->next)
|
||||
cur->set_state (cur->self, visible, start, value, end);
|
||||
}
|
||||
|
||||
static void
|
||||
redraw_timeouts (struct grub_gfxmenu_view *view)
|
||||
{
|
||||
struct grub_gfxmenu_timeout_notify *cur;
|
||||
|
||||
for (cur = grub_gfxmenu_timeout_notifications; cur; cur = cur->next)
|
||||
{
|
||||
grub_video_rect_t bounds;
|
||||
cur->self->ops->get_bounds (cur->self, &bounds);
|
||||
grub_video_set_area_status (GRUB_VIDEO_AREA_ENABLED);
|
||||
grub_gfxmenu_view_redraw (view, &bounds);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
grub_gfxmenu_print_timeout (int timeout, void *data)
|
||||
{
|
||||
struct grub_gfxmenu_view *view = data;
|
||||
|
||||
if (view->first_timeout == -1)
|
||||
view->first_timeout = timeout;
|
||||
|
||||
update_timeouts (1, -view->first_timeout, -timeout, 0);
|
||||
redraw_timeouts (view);
|
||||
grub_video_swap_buffers ();
|
||||
if (view->double_repaint)
|
||||
redraw_timeouts (view);
|
||||
}
|
||||
|
||||
void
|
||||
grub_gfxmenu_clear_timeout (void *data)
|
||||
{
|
||||
struct grub_gfxmenu_view *view = data;
|
||||
|
||||
update_timeouts (0, 1, 0, 0);
|
||||
redraw_timeouts (view);
|
||||
grub_video_swap_buffers ();
|
||||
if (view->double_repaint)
|
||||
redraw_timeouts (view);
|
||||
}
|
||||
|
||||
static void
|
||||
update_menu_visit (grub_gui_component_t component,
|
||||
void *userdata)
|
||||
{
|
||||
grub_gfxmenu_view_t view;
|
||||
view = userdata;
|
||||
if (component->ops->is_instance (component, "list"))
|
||||
{
|
||||
grub_gui_list_t list = (grub_gui_list_t) component;
|
||||
list->ops->set_view_info (list, view);
|
||||
}
|
||||
}
|
||||
|
||||
/* Update any boot menu components with the current menu model and
|
||||
theme path. */
|
||||
static void
|
||||
update_menu_components (grub_gfxmenu_view_t view)
|
||||
{
|
||||
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
|
||||
update_menu_visit, view);
|
||||
}
|
||||
|
||||
static void
|
||||
refresh_menu_visit (grub_gui_component_t component,
|
||||
void *userdata)
|
||||
{
|
||||
grub_gfxmenu_view_t view;
|
||||
view = userdata;
|
||||
if (component->ops->is_instance (component, "list"))
|
||||
{
|
||||
grub_gui_list_t list = (grub_gui_list_t) component;
|
||||
list->ops->refresh_list (list, view);
|
||||
}
|
||||
}
|
||||
|
||||
/* Refresh list information (useful for submenus) */
|
||||
static void
|
||||
refresh_menu_components (grub_gfxmenu_view_t view)
|
||||
{
|
||||
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
|
||||
refresh_menu_visit, view);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_message (grub_gfxmenu_view_t view)
|
||||
{
|
||||
char *text = view->progress_message_text;
|
||||
grub_video_rect_t f = view->progress_message_frame;
|
||||
if (! text)
|
||||
return;
|
||||
|
||||
grub_font_t font = view->message_font;
|
||||
grub_video_color_t color = grub_video_map_rgba_color (view->message_color);
|
||||
|
||||
/* Border. */
|
||||
grub_video_fill_rect (color,
|
||||
f.x-1, f.y-1, f.width+2, f.height+2);
|
||||
/* Fill. */
|
||||
grub_video_fill_rect (grub_video_map_rgba_color (view->message_bg_color),
|
||||
f.x, f.y, f.width, f.height);
|
||||
|
||||
/* Center the text. */
|
||||
int text_width = grub_font_get_string_width (font, text);
|
||||
int x = f.x + (f.width - text_width) / 2;
|
||||
int y = (f.y + (f.height - grub_font_get_descent (font)) / 2
|
||||
+ grub_font_get_ascent (font) / 2);
|
||||
grub_font_draw_string (text, font, color, x, y);
|
||||
}
|
||||
|
||||
void
|
||||
grub_gfxmenu_view_redraw (grub_gfxmenu_view_t view,
|
||||
const grub_video_rect_t *region)
|
||||
{
|
||||
if (grub_video_have_common_points (&view->terminal_rect, region))
|
||||
grub_gfxterm_schedule_repaint ();
|
||||
|
||||
grub_video_set_active_render_target (GRUB_VIDEO_RENDER_TARGET_DISPLAY);
|
||||
grub_video_area_status_t area_status;
|
||||
grub_video_get_area_status (&area_status);
|
||||
if (area_status == GRUB_VIDEO_AREA_ENABLED)
|
||||
grub_video_set_region (region->x, region->y,
|
||||
region->width, region->height);
|
||||
|
||||
redraw_background (view, region);
|
||||
if (view->canvas)
|
||||
view->canvas->component.ops->paint (view->canvas, region);
|
||||
draw_title (view);
|
||||
if (grub_video_have_common_points (&view->progress_message_frame, region))
|
||||
draw_message (view);
|
||||
|
||||
if (area_status == GRUB_VIDEO_AREA_ENABLED)
|
||||
grub_video_set_area_status (GRUB_VIDEO_AREA_ENABLED);
|
||||
}
|
||||
|
||||
void
|
||||
grub_gfxmenu_view_draw (grub_gfxmenu_view_t view)
|
||||
{
|
||||
init_terminal (view);
|
||||
|
||||
init_background (view);
|
||||
|
||||
/* Clear the screen; there may be garbage left over in video memory. */
|
||||
grub_video_fill_rect (grub_video_map_rgb (0, 0, 0),
|
||||
view->screen.x, view->screen.y,
|
||||
view->screen.width, view->screen.height);
|
||||
grub_video_swap_buffers ();
|
||||
if (view->double_repaint)
|
||||
grub_video_fill_rect (grub_video_map_rgb (0, 0, 0),
|
||||
view->screen.x, view->screen.y,
|
||||
view->screen.width, view->screen.height);
|
||||
|
||||
refresh_menu_components (view);
|
||||
update_menu_components (view);
|
||||
|
||||
grub_video_set_area_status (GRUB_VIDEO_AREA_DISABLED);
|
||||
grub_gfxmenu_view_redraw (view, &view->screen);
|
||||
grub_video_swap_buffers ();
|
||||
if (view->double_repaint)
|
||||
{
|
||||
grub_video_set_area_status (GRUB_VIDEO_AREA_DISABLED);
|
||||
grub_gfxmenu_view_redraw (view, &view->screen);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
redraw_menu_visit (grub_gui_component_t component,
|
||||
void *userdata)
|
||||
{
|
||||
grub_gfxmenu_view_t view;
|
||||
view = userdata;
|
||||
if (component->ops->is_instance (component, "list"))
|
||||
{
|
||||
grub_video_rect_t bounds;
|
||||
|
||||
component->ops->get_bounds (component, &bounds);
|
||||
grub_video_set_area_status (GRUB_VIDEO_AREA_ENABLED);
|
||||
grub_gfxmenu_view_redraw (view, &bounds);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
grub_gfxmenu_redraw_menu (grub_gfxmenu_view_t view)
|
||||
{
|
||||
update_menu_components (view);
|
||||
|
||||
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
|
||||
redraw_menu_visit, view);
|
||||
grub_video_swap_buffers ();
|
||||
if (view->double_repaint)
|
||||
{
|
||||
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
|
||||
redraw_menu_visit, view);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
grub_gfxmenu_set_chosen_entry (int entry, void *data)
|
||||
{
|
||||
grub_gfxmenu_view_t view = data;
|
||||
|
||||
view->selected = entry;
|
||||
grub_gfxmenu_redraw_menu (view);
|
||||
}
|
||||
|
||||
static void
|
||||
grub_gfxmenu_draw_terminal_box (void)
|
||||
{
|
||||
grub_gfxmenu_box_t term_box;
|
||||
|
||||
term_box = term_view->terminal_box;
|
||||
if (!term_box)
|
||||
return;
|
||||
|
||||
grub_video_set_area_status (GRUB_VIDEO_AREA_DISABLED);
|
||||
|
||||
term_box->set_content_size (term_box, term_view->terminal_rect.width,
|
||||
term_view->terminal_rect.height);
|
||||
|
||||
term_box->draw (term_box,
|
||||
term_view->terminal_rect.x - term_box->get_left_pad (term_box),
|
||||
term_view->terminal_rect.y - term_box->get_top_pad (term_box));
|
||||
}
|
||||
|
||||
static void
|
||||
get_min_terminal (grub_font_t terminal_font,
|
||||
unsigned int border_width,
|
||||
unsigned int *min_terminal_width,
|
||||
unsigned int *min_terminal_height)
|
||||
{
|
||||
struct grub_font_glyph *glyph;
|
||||
glyph = grub_font_get_glyph (terminal_font, 'M');
|
||||
*min_terminal_width = (glyph? glyph->device_width : 8) * 80
|
||||
+ 2 * border_width;
|
||||
*min_terminal_height = grub_font_get_max_char_height (terminal_font) * 24
|
||||
+ 2 * border_width;
|
||||
}
|
||||
|
||||
static void
|
||||
terminal_sanity_check (grub_gfxmenu_view_t view)
|
||||
{
|
||||
if (!view->need_to_check_sanity)
|
||||
return;
|
||||
|
||||
/* terminal_font was checked before in the init_terminal function. */
|
||||
grub_font_t terminal_font = grub_font_get (view->terminal_font_name);
|
||||
|
||||
/* Non-negative numbers below. */
|
||||
int scr_x = view->screen.x;
|
||||
int scr_y = view->screen.y;
|
||||
int scr_width = view->screen.width;
|
||||
int scr_height = view->screen.height;
|
||||
int term_x = view->terminal_rect.x;
|
||||
int term_y = view->terminal_rect.y;
|
||||
int term_width = view->terminal_rect.width;
|
||||
int term_height = view->terminal_rect.height;
|
||||
|
||||
/* Check that border_width isn't too big. */
|
||||
unsigned int border_width = view->terminal_border;
|
||||
unsigned int min_terminal_width;
|
||||
unsigned int min_terminal_height;
|
||||
get_min_terminal (terminal_font, border_width,
|
||||
&min_terminal_width, &min_terminal_height);
|
||||
if (border_width > 3 && ((int) min_terminal_width >= scr_width
|
||||
|| (int) min_terminal_height >= scr_height))
|
||||
{
|
||||
border_width = 3;
|
||||
get_min_terminal (terminal_font, border_width,
|
||||
&min_terminal_width, &min_terminal_height);
|
||||
}
|
||||
|
||||
/* Sanity checks. */
|
||||
if (term_width > scr_width)
|
||||
term_width = scr_width;
|
||||
if (term_height > scr_height)
|
||||
term_height = scr_height;
|
||||
|
||||
if (scr_width <= (int) min_terminal_width
|
||||
|| scr_height <= (int) min_terminal_height)
|
||||
{
|
||||
/* The screen resulution is too low. Use all space, except a small border
|
||||
to show the user, that it is a window. Then center the window. */
|
||||
term_width = scr_width - 6 * border_width;
|
||||
term_height = scr_height - 6 * border_width;
|
||||
term_x = scr_x + (scr_width - term_width) / 2;
|
||||
term_y = scr_y + (scr_height - term_height) / 2;
|
||||
}
|
||||
else if (term_width < (int) min_terminal_width
|
||||
|| term_height < (int) min_terminal_height)
|
||||
{
|
||||
/* The screen resolution is big enough. Make sure, that terminal screen
|
||||
dimensions aren't less than minimal values. Then center the window. */
|
||||
term_width = (int) min_terminal_width;
|
||||
term_height = (int) min_terminal_height;
|
||||
term_x = scr_x + (scr_width - term_width) / 2;
|
||||
term_y = scr_y + (scr_height - term_height) / 2;
|
||||
}
|
||||
|
||||
/* At this point w and h are satisfying. */
|
||||
if (term_x + term_width > scr_width)
|
||||
term_x = scr_width - term_width;
|
||||
if (term_y + term_height > scr_height)
|
||||
term_y = scr_height - term_height;
|
||||
|
||||
/* Write down corrected data. */
|
||||
view->terminal_rect.x = (unsigned int) term_x;
|
||||
view->terminal_rect.y = (unsigned int) term_y;
|
||||
view->terminal_rect.width = (unsigned int) term_width;
|
||||
view->terminal_rect.height = (unsigned int) term_height;
|
||||
view->terminal_border = border_width;
|
||||
|
||||
view->need_to_check_sanity = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
init_terminal (grub_gfxmenu_view_t view)
|
||||
{
|
||||
grub_font_t terminal_font;
|
||||
|
||||
terminal_font = grub_font_get (view->terminal_font_name);
|
||||
if (!terminal_font)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FONT, "no font loaded");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check that terminal window size and position are sane. */
|
||||
terminal_sanity_check (view);
|
||||
|
||||
term_view = view;
|
||||
|
||||
/* Note: currently there is no API for changing the gfxterm font
|
||||
on the fly, so whatever font the initially loaded theme specifies
|
||||
will be permanent. */
|
||||
grub_gfxterm_set_window (GRUB_VIDEO_RENDER_TARGET_DISPLAY,
|
||||
view->terminal_rect.x,
|
||||
view->terminal_rect.y,
|
||||
view->terminal_rect.width,
|
||||
view->terminal_rect.height,
|
||||
view->double_repaint,
|
||||
terminal_font,
|
||||
view->terminal_border);
|
||||
grub_gfxterm_decorator_hook = grub_gfxmenu_draw_terminal_box;
|
||||
}
|
||||
|
||||
static void
|
||||
init_background (grub_gfxmenu_view_t view)
|
||||
{
|
||||
if (view->scaled_desktop_image || (!view->raw_desktop_image))
|
||||
return;
|
||||
|
||||
struct grub_video_bitmap *scaled_bitmap;
|
||||
if (view->desktop_image_scale_method ==
|
||||
GRUB_VIDEO_BITMAP_SELECTION_METHOD_STRETCH)
|
||||
grub_video_bitmap_create_scaled (&scaled_bitmap,
|
||||
view->screen.width,
|
||||
view->screen.height,
|
||||
view->raw_desktop_image,
|
||||
GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST);
|
||||
else
|
||||
grub_video_bitmap_scale_proportional (&scaled_bitmap,
|
||||
view->screen.width,
|
||||
view->screen.height,
|
||||
view->raw_desktop_image,
|
||||
GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST,
|
||||
view->desktop_image_scale_method,
|
||||
view->desktop_image_v_align,
|
||||
view->desktop_image_h_align);
|
||||
if (! scaled_bitmap)
|
||||
return;
|
||||
view->scaled_desktop_image = scaled_bitmap;
|
||||
|
||||
}
|
||||
|
||||
/* FIXME: previously notifications were displayed in special case.
|
||||
Is it necessary?
|
||||
*/
|
||||
#if 0
|
||||
/* Sets MESSAGE as the progress message for the view.
|
||||
MESSAGE can be 0, in which case no message is displayed. */
|
||||
static void
|
||||
set_progress_message (grub_gfxmenu_view_t view, const char *message)
|
||||
{
|
||||
grub_free (view->progress_message_text);
|
||||
if (message)
|
||||
view->progress_message_text = grub_strdup (message);
|
||||
else
|
||||
view->progress_message_text = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
notify_booting (grub_menu_entry_t entry, void *userdata)
|
||||
{
|
||||
grub_gfxmenu_view_t view = (grub_gfxmenu_view_t) userdata;
|
||||
|
||||
char *s = grub_malloc (100 + grub_strlen (entry->title));
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
grub_sprintf (s, "Booting '%s'", entry->title);
|
||||
set_progress_message (view, s);
|
||||
grub_free (s);
|
||||
grub_gfxmenu_view_redraw (view, &view->progress_message_frame);
|
||||
grub_video_swap_buffers ();
|
||||
if (view->double_repaint)
|
||||
grub_gfxmenu_view_redraw (view, &view->progress_message_frame);
|
||||
}
|
||||
|
||||
static void
|
||||
notify_fallback (grub_menu_entry_t entry, void *userdata)
|
||||
{
|
||||
grub_gfxmenu_view_t view = (grub_gfxmenu_view_t) userdata;
|
||||
|
||||
char *s = grub_malloc (100 + grub_strlen (entry->title));
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
grub_sprintf (s, "Falling back to '%s'", entry->title);
|
||||
set_progress_message (view, s);
|
||||
grub_free (s);
|
||||
grub_gfxmenu_view_redraw (view, &view->progress_message_frame);
|
||||
grub_video_swap_buffers ();
|
||||
if (view->double_repaint)
|
||||
grub_gfxmenu_view_redraw (view, &view->progress_message_frame);
|
||||
}
|
||||
|
||||
static void
|
||||
notify_execution_failure (void *userdata __attribute__ ((unused)))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static struct grub_menu_execute_callback execute_callback =
|
||||
{
|
||||
.notify_booting = notify_booting,
|
||||
.notify_fallback = notify_fallback,
|
||||
.notify_failure = notify_execution_failure
|
||||
};
|
||||
|
||||
#endif
|
@@ -485,6 +485,11 @@ static int ventoy_boot_opt_filter(char *opt)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (grub_strcmp(opt, "vga=current") == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (grub_strncmp(opt, "rdinit=", 7) == 0)
|
||||
{
|
||||
if (grub_strcmp(opt, "rdinit=/vtoy/vtoy") != 0)
|
||||
@@ -1224,7 +1229,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
linux_mem_size = 0;
|
||||
for (i = 1; i < argc; i++)
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
if (grub_memcmp (argv[i], "vga=", 4) == 0)
|
||||
if (grub_memcmp (argv[i], "vga=", 4) == 0 && (grub_memcmp (argv[i], "vga=current", 11) != 0))
|
||||
{
|
||||
/* Video mode selection support. */
|
||||
char *val = argv[i] + 4;
|
||||
|
@@ -969,19 +969,28 @@ static struct grub_menu_execute_callback execution_callback =
|
||||
static grub_err_t
|
||||
show_menu (grub_menu_t menu, int nested, int autobooted)
|
||||
{
|
||||
const char *def;
|
||||
def = grub_env_get("VTOY_DEFAULT_IMAGE");
|
||||
|
||||
while (1)
|
||||
{
|
||||
int boot_entry;
|
||||
grub_menu_entry_t e;
|
||||
int auto_boot;
|
||||
|
||||
|
||||
boot_entry = run_menu (menu, nested, &auto_boot);
|
||||
if (boot_entry < 0)
|
||||
break;
|
||||
|
||||
g_ventoy_last_entry = boot_entry;
|
||||
if (g_ventoy_menu_esc)
|
||||
break;
|
||||
if (auto_boot && def && grub_strcmp(def, "VTOY_EXIT") == 0) {
|
||||
grub_exit();
|
||||
}
|
||||
|
||||
if (autobooted == 0 && auto_boot == 0) {
|
||||
g_ventoy_last_entry = boot_entry;
|
||||
if (g_ventoy_menu_esc)
|
||||
break;
|
||||
}
|
||||
|
||||
e = grub_menu_get_entry (menu, boot_entry);
|
||||
if (! e)
|
||||
@@ -999,6 +1008,9 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
|
||||
grub_menu_execute_entry (e, 0);
|
||||
if (autobooted)
|
||||
break;
|
||||
|
||||
if (2 == e->argc && e->args && e->args[1] && grub_strncmp(e->args[1], "VTOY_RUN_RET", 12) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
|
@@ -190,10 +190,17 @@ command-line or ESC to discard edits and return to the GRUB menu."),
|
||||
}
|
||||
else
|
||||
{
|
||||
char szLine[128];
|
||||
const char *checkret = grub_env_get("VTOY_CHKDEV_RESULT_STRING");
|
||||
if (checkret == NULL || checkret[0] != '0') {
|
||||
grub_snprintf(szLine, sizeof(szLine), "%s [Unofficial Ventoy]", grub_env_get("VTOY_TEXT_MENU_VER"));
|
||||
} else {
|
||||
grub_snprintf(szLine, sizeof(szLine), "%s", grub_env_get("VTOY_TEXT_MENU_VER"));
|
||||
}
|
||||
|
||||
ret += grub_print_message_indented_real("\n", STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run);
|
||||
|
||||
ret += grub_print_message_indented_real(grub_env_get("VTOY_TEXT_MENU_VER"),
|
||||
STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run);
|
||||
ret += grub_print_message_indented_real(szLine, STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run);
|
||||
|
||||
ret += grub_print_message_indented_real("\n", STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run);
|
||||
ret += grub_print_message_indented_real(grub_env_get("VTOY_HOTKEY_TIP"),
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -28,7 +28,9 @@
|
||||
#define VTOY_FILT_MIN_FILE_SIZE 32768
|
||||
|
||||
#define VTOY_SIZE_1GB 1073741824
|
||||
#define VTOY_SIZE_512KB (512 * 1024)
|
||||
#define VTOY_SIZE_1MB (1024 * 1024)
|
||||
#define VTOY_SIZE_512KB (512 * 1024)
|
||||
#define VTOY_SIZE_1KB 1024
|
||||
|
||||
#define JSON_SUCCESS 0
|
||||
#define JSON_FAILED 1
|
||||
@@ -48,6 +50,14 @@
|
||||
#define ventoy_get_env(key) ventoy_env_op1(get, key)
|
||||
#define ventoy_set_env(key, val) ventoy_env_op2(set, key, val)
|
||||
|
||||
#define VTOY_WARNING "!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!"
|
||||
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
#define VTOY_DUAL_MODE_SUFFIX "uefi"
|
||||
#else
|
||||
#define VTOY_DUAL_MODE_SUFFIX "legacy"
|
||||
#endif
|
||||
|
||||
typedef struct ventoy_initrd_ctx
|
||||
{
|
||||
const char *path_prefix;
|
||||
@@ -99,6 +109,18 @@ typedef int (*grub_char_check_func)(int c);
|
||||
#define ventoy_is_decimal(str) ventoy_string_check(str, grub_isdigit)
|
||||
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct ventoy_patch_vhd
|
||||
{
|
||||
grub_uint8_t part_offset_or_guid[16];
|
||||
grub_uint32_t reserved1;
|
||||
grub_uint32_t part_type;
|
||||
grub_uint8_t disk_signature_or_guid[16];
|
||||
grub_uint8_t reserved2[16];
|
||||
grub_uint8_t vhd_file_path[1];
|
||||
}ventoy_patch_vhd;
|
||||
#pragma pack()
|
||||
|
||||
// El Torito Boot Record Volume Descriptor
|
||||
#pragma pack(1)
|
||||
typedef struct eltorito_descriptor
|
||||
@@ -137,10 +159,12 @@ typedef struct ventoy_iso9660_vd
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#define img_type_iso 0
|
||||
#define img_type_wim 1
|
||||
#define img_type_efi 2
|
||||
#define img_type_img 3
|
||||
#define img_type_iso 0
|
||||
#define img_type_wim 1
|
||||
#define img_type_efi 2
|
||||
#define img_type_img 3
|
||||
#define img_type_vhd 4
|
||||
#define img_type_vtoy 5
|
||||
|
||||
typedef struct img_info
|
||||
{
|
||||
@@ -154,6 +178,7 @@ typedef struct img_info
|
||||
|
||||
int id;
|
||||
int type;
|
||||
int plugin_list_index;
|
||||
grub_uint64_t size;
|
||||
int select;
|
||||
int unsupport;
|
||||
@@ -174,6 +199,8 @@ typedef struct img_iterator_node
|
||||
int done;
|
||||
int select;
|
||||
|
||||
int plugin_list_index;
|
||||
|
||||
struct img_iterator_node *parent;
|
||||
struct img_iterator_node *firstchild;
|
||||
|
||||
@@ -469,6 +496,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_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);
|
||||
int ventoy_cpio_newc_fill_head(void *buf, int filesize, const void *filedata, const char *name);
|
||||
grub_file_t ventoy_grub_file_open(enum grub_file_type type, const char *fmt, ...);
|
||||
@@ -480,6 +508,7 @@ grub_err_t ventoy_cmd_load_plugin(grub_extcmd_context_t ctxt, int argc, char **a
|
||||
grub_err_t ventoy_cmd_wimdows_reset(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_wim_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_wim_check_bootable(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_dump_wim_patch(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
|
||||
VTOY_JSON *vtoy_json_find_item
|
||||
@@ -603,8 +632,88 @@ typedef struct ventoy_mbr_head
|
||||
grub_uint8_t Byte55;
|
||||
grub_uint8_t ByteAA;
|
||||
}ventoy_mbr_head;
|
||||
|
||||
typedef struct ventoy_gpt_head
|
||||
{
|
||||
char Signature[8]; /* EFI PART */
|
||||
grub_uint8_t Version[4];
|
||||
grub_uint32_t Length;
|
||||
grub_uint32_t Crc;
|
||||
grub_uint8_t Reserved1[4];
|
||||
grub_uint64_t EfiStartLBA;
|
||||
grub_uint64_t EfiBackupLBA;
|
||||
grub_uint64_t PartAreaStartLBA;
|
||||
grub_uint64_t PartAreaEndLBA;
|
||||
grub_uint8_t DiskGuid[16];
|
||||
grub_uint64_t PartTblStartLBA;
|
||||
grub_uint32_t PartTblTotNum;
|
||||
grub_uint32_t PartTblEntryLen;
|
||||
grub_uint32_t PartTblCrc;
|
||||
grub_uint8_t Reserved2[420];
|
||||
}ventoy_gpt_head;
|
||||
|
||||
typedef struct ventoy_gpt_part_tbl
|
||||
{
|
||||
grub_uint8_t PartType[16];
|
||||
grub_uint8_t PartGuid[16];
|
||||
grub_uint64_t StartLBA;
|
||||
grub_uint64_t LastLBA;
|
||||
grub_uint64_t Attr;
|
||||
grub_uint16_t Name[36];
|
||||
}ventoy_gpt_part_tbl;
|
||||
|
||||
typedef struct ventoy_gpt_info
|
||||
{
|
||||
ventoy_mbr_head MBR;
|
||||
ventoy_gpt_head Head;
|
||||
ventoy_gpt_part_tbl PartTbl[128];
|
||||
}ventoy_gpt_info;
|
||||
|
||||
typedef struct vhd_footer_t
|
||||
{
|
||||
char cookie[8]; // Cookie
|
||||
grub_uint32_t features; // Features
|
||||
grub_uint32_t ffversion; // File format version
|
||||
grub_uint32_t dataoffset; // Data offset
|
||||
grub_uint32_t timestamp; // Timestamp
|
||||
grub_uint32_t creatorapp; // Creator application
|
||||
grub_uint32_t creatorver; // Creator version
|
||||
grub_uint32_t creatorhos; // Creator host OS
|
||||
grub_uint32_t origsize; // Original size
|
||||
grub_uint32_t currsize; // Current size
|
||||
grub_uint32_t diskgeom; // Disk geometry
|
||||
grub_uint32_t disktype; // Disk type
|
||||
grub_uint32_t checksum; // Checksum
|
||||
grub_uint8_t uniqueid[16]; // Unique ID
|
||||
grub_uint8_t savedst; // Saved state
|
||||
}vhd_footer_t;
|
||||
|
||||
#define VDI_IMAGE_FILE_INFO "<<< Oracle VM VirtualBox Disk Image >>>\n"
|
||||
|
||||
/** Image signature. */
|
||||
#define VDI_IMAGE_SIGNATURE (0xbeda107f)
|
||||
|
||||
typedef struct VDIPREHEADER
|
||||
{
|
||||
/** Just text info about image type, for eyes only. */
|
||||
char szFileInfo[64];
|
||||
/** The image signature (VDI_IMAGE_SIGNATURE). */
|
||||
grub_uint32_t u32Signature;
|
||||
/** The image version (VDI_IMAGE_VERSION). */
|
||||
grub_uint32_t u32Version;
|
||||
} VDIPREHEADER, *PVDIPREHEADER;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
typedef struct ventoy_video_mode
|
||||
{
|
||||
grub_uint32_t width;
|
||||
grub_uint32_t height;
|
||||
grub_uint32_t bpp;
|
||||
}ventoy_video_mode;
|
||||
|
||||
|
||||
|
||||
typedef struct file_fullpath
|
||||
{
|
||||
char path[256];
|
||||
@@ -623,6 +732,24 @@ typedef struct install_template
|
||||
struct install_template *next;
|
||||
}install_template;
|
||||
|
||||
typedef struct dudfile
|
||||
{
|
||||
int size;
|
||||
char *buf;
|
||||
}dudfile;
|
||||
|
||||
typedef struct dud
|
||||
{
|
||||
int pathlen;
|
||||
char isopath[256];
|
||||
|
||||
int dudnum;
|
||||
file_fullpath *dudpath;
|
||||
dudfile *files;
|
||||
|
||||
struct dud *next;
|
||||
}dud;
|
||||
|
||||
typedef struct persistence_config
|
||||
{
|
||||
int pathlen;
|
||||
@@ -662,6 +789,17 @@ typedef struct menu_class
|
||||
struct menu_class *next;
|
||||
}menu_class;
|
||||
|
||||
#define vtoy_max_replace_file_size (2 * 1024 * 1024)
|
||||
typedef struct conf_replace
|
||||
{
|
||||
int pathlen;
|
||||
char isopath[256];
|
||||
char orgconf[256];
|
||||
char newconf[256];
|
||||
|
||||
struct conf_replace *next;
|
||||
}conf_replace;
|
||||
|
||||
typedef struct injection_config
|
||||
{
|
||||
int pathlen;
|
||||
@@ -671,6 +809,22 @@ typedef struct injection_config
|
||||
struct injection_config *next;
|
||||
}injection_config;
|
||||
|
||||
typedef struct auto_memdisk
|
||||
{
|
||||
int pathlen;
|
||||
char isopath[256];
|
||||
|
||||
struct auto_memdisk *next;
|
||||
}auto_memdisk;
|
||||
|
||||
typedef struct image_list
|
||||
{
|
||||
int pathlen;
|
||||
char isopath[256];
|
||||
|
||||
struct image_list *next;
|
||||
}image_list;
|
||||
|
||||
extern int g_ventoy_menu_esc;
|
||||
extern int g_ventoy_suppress_esc;
|
||||
extern int g_ventoy_last_entry;
|
||||
@@ -679,7 +833,14 @@ extern int g_ventoy_iso_raw;
|
||||
extern int g_ventoy_iso_uefi_drv;
|
||||
extern int g_ventoy_case_insensitive;
|
||||
extern grub_uint8_t g_ventoy_chain_type;
|
||||
|
||||
extern int g_vhdboot_enable;
|
||||
extern int g_plugin_image_list;
|
||||
extern ventoy_gpt_info *g_ventoy_part_info;
|
||||
extern grub_uint64_t g_conf_replace_offset;
|
||||
extern conf_replace *g_conf_replace_node;
|
||||
extern grub_uint8_t *g_conf_replace_new_buf;
|
||||
extern int g_conf_replace_new_len;
|
||||
extern int g_conf_replace_new_len_align;
|
||||
|
||||
#define ventoy_unix_fill_virt(new_data, new_len) \
|
||||
{ \
|
||||
@@ -710,6 +871,11 @@ int ventoy_plugin_get_persistent_chunklist(const char *isopath, int index, vento
|
||||
const char * ventoy_plugin_get_injection(const char *isopath);
|
||||
const char * ventoy_plugin_get_menu_alias(int type, const char *isopath);
|
||||
const char * ventoy_plugin_get_menu_class(int type, const char *name);
|
||||
int ventoy_plugin_check_memdisk(const char *isopath);
|
||||
int ventoy_plugin_get_image_list_index(int type, const char *name);
|
||||
conf_replace * ventoy_plugin_find_conf_replace(const char *iso);
|
||||
dud * ventoy_plugin_find_dud(const char *iso);
|
||||
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);
|
||||
@@ -719,12 +885,19 @@ grub_err_t ventoy_cmd_collect_wim_patch(grub_extcmd_context_t ctxt, int argc, ch
|
||||
grub_err_t ventoy_cmd_wim_patch_count(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_locate_wim_patch(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
int ventoy_get_disk_guid(const char *filename, grub_uint8_t *guid);
|
||||
int ventoy_get_disk_guid(const char *filename, grub_uint8_t *guid, grub_uint8_t *signature);
|
||||
grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_unix_freebsd_ver(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_parse_freenas_ver(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
int ventoy_check_device_result(int ret);
|
||||
int ventoy_check_device(grub_device_t dev);
|
||||
void ventoy_debug_dump_guid(const char *prefix, grub_uint8_t *guid);
|
||||
grub_err_t ventoy_cmd_load_vhdboot(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_patch_vhdboot(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_raw_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
|
||||
#endif /* __VENTOY_DEF_H__ */
|
||||
|
||||
|
@@ -333,6 +333,7 @@ end:
|
||||
static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName)
|
||||
{
|
||||
int i = 0;
|
||||
int dollar = 0;
|
||||
grub_file_t file = NULL;
|
||||
char *buf = NULL;
|
||||
char *start = NULL;
|
||||
@@ -388,13 +389,18 @@ static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
dollar = 0;
|
||||
for (i = 0; i < 255 && (0 == ventoy_is_word_end(*start)); i++)
|
||||
{
|
||||
img->name[i] = *start++;
|
||||
if (img->name[i] == '$')
|
||||
{
|
||||
dollar = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (ventoy_find_initrd_by_name(g_initrd_img_list, img->name))
|
||||
if (dollar == 1 || ventoy_find_initrd_by_name(g_initrd_img_list, img->name))
|
||||
{
|
||||
grub_free(img);
|
||||
}
|
||||
@@ -625,9 +631,30 @@ int ventoy_cpio_newc_fill_head(void *buf, int filesize, const void *filedata, co
|
||||
return headlen;
|
||||
}
|
||||
|
||||
static grub_uint32_t ventoy_linux_get_virt_chunk_count(void)
|
||||
{
|
||||
grub_uint32_t count = g_valid_initrd_count;
|
||||
|
||||
if (g_conf_replace_offset > 0)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static grub_uint32_t ventoy_linux_get_virt_chunk_size(void)
|
||||
{
|
||||
return (sizeof(ventoy_virt_chunk) + g_ventoy_cpio_size) * g_valid_initrd_count;
|
||||
grub_uint32_t size;
|
||||
|
||||
size = (sizeof(ventoy_virt_chunk) + g_ventoy_cpio_size) * g_valid_initrd_count;
|
||||
|
||||
if (g_conf_replace_offset > 0)
|
||||
{
|
||||
size += sizeof(ventoy_virt_chunk) + g_conf_replace_new_len_align;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_head *chain)
|
||||
@@ -646,7 +673,7 @@ static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_
|
||||
sector = (isosize + 2047) / 2048;
|
||||
cpio_secs = g_ventoy_cpio_size / 2048;
|
||||
|
||||
offset = g_valid_initrd_count * sizeof(ventoy_virt_chunk);
|
||||
offset = ventoy_linux_get_virt_chunk_count() * sizeof(ventoy_virt_chunk);
|
||||
cur = (ventoy_virt_chunk *)override;
|
||||
|
||||
for (node = g_initrd_img_list; node; node = node->next)
|
||||
@@ -682,12 +709,51 @@ static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_
|
||||
cur++;
|
||||
}
|
||||
|
||||
if (g_conf_replace_offset > 0)
|
||||
{
|
||||
cpio_secs = g_conf_replace_new_len_align / 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_memcpy(override + offset, g_conf_replace_new_buf, g_conf_replace_new_len);
|
||||
|
||||
chain->virt_img_size_in_bytes += g_conf_replace_new_len_align;
|
||||
|
||||
offset += g_conf_replace_new_len_align;
|
||||
sector += cpio_secs;
|
||||
cur++;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static grub_uint32_t ventoy_linux_get_override_chunk_count(void)
|
||||
{
|
||||
grub_uint32_t count = g_valid_initrd_count;
|
||||
|
||||
if (g_conf_replace_offset > 0)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static grub_uint32_t ventoy_linux_get_override_chunk_size(void)
|
||||
{
|
||||
return sizeof(ventoy_override_chunk) * g_valid_initrd_count;
|
||||
int count = g_valid_initrd_count;
|
||||
|
||||
if (g_conf_replace_offset > 0)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
||||
return sizeof(ventoy_override_chunk) * count;
|
||||
}
|
||||
|
||||
static void ventoy_linux_fill_override_data( grub_uint64_t isosize, void *override)
|
||||
@@ -697,6 +763,8 @@ static void ventoy_linux_fill_override_data( grub_uint64_t isosize, void *ove
|
||||
grub_uint32_t newlen;
|
||||
grub_uint64_t sector;
|
||||
ventoy_override_chunk *cur;
|
||||
ventoy_iso9660_override *dirent;
|
||||
ventoy_udf_override *udf;
|
||||
|
||||
sector = (isosize + 2047) / 2048;
|
||||
|
||||
@@ -712,12 +780,12 @@ static void ventoy_linux_fill_override_data( grub_uint64_t isosize, void *ove
|
||||
mod = newlen % 4;
|
||||
if (mod > 0)
|
||||
{
|
||||
newlen += 4 - mod;
|
||||
newlen += 4 - mod; /* cpio must align with 4 */
|
||||
}
|
||||
|
||||
if (node->iso_type == 0)
|
||||
{
|
||||
ventoy_iso9660_override *dirent = (ventoy_iso9660_override *)node->override_data;
|
||||
dirent = (ventoy_iso9660_override *)node->override_data;
|
||||
|
||||
node->override_length = sizeof(ventoy_iso9660_override);
|
||||
dirent->first_sector = (grub_uint32_t)sector;
|
||||
@@ -729,7 +797,7 @@ static void ventoy_linux_fill_override_data( grub_uint64_t isosize, void *ove
|
||||
}
|
||||
else
|
||||
{
|
||||
ventoy_udf_override *udf = (ventoy_udf_override *)node->override_data;
|
||||
udf = (ventoy_udf_override *)node->override_data;
|
||||
|
||||
node->override_length = sizeof(ventoy_udf_override);
|
||||
udf->length = newlen;
|
||||
@@ -744,6 +812,23 @@ static void ventoy_linux_fill_override_data( grub_uint64_t isosize, void *ove
|
||||
cur++;
|
||||
}
|
||||
|
||||
if (g_conf_replace_offset > 0)
|
||||
{
|
||||
cur->img_offset = g_conf_replace_offset;
|
||||
cur->override_size = sizeof(ventoy_iso9660_override);
|
||||
|
||||
newlen = (grub_uint32_t)(g_conf_replace_new_len);
|
||||
|
||||
dirent = (ventoy_iso9660_override *)cur->override_data;
|
||||
dirent->first_sector = (grub_uint32_t)sector;
|
||||
dirent->size = newlen;
|
||||
dirent->first_sector_be = grub_swap_bytes32(dirent->first_sector);
|
||||
dirent->size_be = grub_swap_bytes32(dirent->size);
|
||||
|
||||
sector += (dirent->size + 2047) / 2048;
|
||||
cur++;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -944,13 +1029,30 @@ static int ventoy_cpio_busybox64(cpio_newc_header *head)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
grub_err_t ventoy_cmd_cpio_busybox_64(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
debug("ventoy_cmd_busybox_64 %d\n", argc);
|
||||
ventoy_cpio_busybox64((cpio_newc_header *)g_ventoy_cpio_buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int i;
|
||||
int rc;
|
||||
char *pos = NULL;
|
||||
char *template_file = NULL;
|
||||
char *template_buf = NULL;
|
||||
char *persistent_buf = NULL;
|
||||
char *injection_buf = NULL;
|
||||
dud *dudnode = NULL;
|
||||
char tmpname[128];
|
||||
const char *injection_file = NULL;
|
||||
grub_uint8_t *buf = NULL;
|
||||
grub_uint32_t mod;
|
||||
@@ -961,6 +1063,7 @@ grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **arg
|
||||
grub_uint32_t template_size = 0;
|
||||
grub_uint32_t persistent_size = 0;
|
||||
grub_uint32_t injection_size = 0;
|
||||
grub_uint32_t dud_size = 0;
|
||||
grub_file_t file;
|
||||
grub_file_t tmpfile;
|
||||
ventoy_img_chunk_list chunk_list;
|
||||
@@ -1054,11 +1157,30 @@ grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **arg
|
||||
debug("injection not configed %s\n", args[1]);
|
||||
}
|
||||
|
||||
g_ventoy_cpio_buf = grub_malloc(file->size + 4096 + template_size + persistent_size + injection_size + img_chunk_size);
|
||||
dudnode = ventoy_plugin_find_dud(args[1]);
|
||||
if (dudnode)
|
||||
{
|
||||
debug("dud file: <%d>\n", dudnode->dudnum);
|
||||
ventoy_plugin_load_dud(dudnode, args[2]);
|
||||
for (i = 0; i < dudnode->dudnum; i++)
|
||||
{
|
||||
if (dudnode->files[i].size > 0)
|
||||
{
|
||||
dud_size += dudnode->files[i].size + sizeof(cpio_newc_header);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("dud not configed %s\n", args[1]);
|
||||
}
|
||||
|
||||
g_ventoy_cpio_buf = grub_malloc(file->size + 40960 + template_size +
|
||||
persistent_size + injection_size + dud_size + img_chunk_size);
|
||||
if (NULL == g_ventoy_cpio_buf)
|
||||
{
|
||||
grub_file_close(file);
|
||||
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Can't alloc memory %llu\n", file->size + 4096 + img_chunk_size);
|
||||
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Can't alloc memory %llu\n", file->size);
|
||||
}
|
||||
|
||||
grub_file_read(file, g_ventoy_cpio_buf, file->size);
|
||||
@@ -1100,6 +1222,18 @@ grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **arg
|
||||
injection_buf = NULL;
|
||||
}
|
||||
|
||||
if (dud_size > 0)
|
||||
{
|
||||
for (i = 0; i < dudnode->dudnum; i++)
|
||||
{
|
||||
pos = grub_strrchr(dudnode->dudpath[i].path, '.');
|
||||
grub_snprintf(tmpname, sizeof(tmpname), "ventoy/ventoy_dud%d%s", i, (pos ? pos : ".iso"));
|
||||
dud_size = dudnode->files[i].size;
|
||||
headlen = ventoy_cpio_newc_fill_head(buf, dud_size, dudnode->files[i].buf, tmpname);
|
||||
buf += headlen + ventoy_align(dud_size, 4);
|
||||
}
|
||||
}
|
||||
|
||||
/* step2: insert os param to cpio */
|
||||
headlen = ventoy_cpio_newc_fill_head(buf, 0, NULL, "ventoy/ventoy_os_param");
|
||||
padlen = sizeof(ventoy_os_param);
|
||||
@@ -1228,7 +1362,9 @@ grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, cha
|
||||
grub_uint64_t isosize = 0;
|
||||
grub_uint32_t boot_catlog = 0;
|
||||
grub_uint32_t img_chunk_size = 0;
|
||||
grub_uint32_t override_count = 0;
|
||||
grub_uint32_t override_size = 0;
|
||||
grub_uint32_t virt_chunk_count = 0;
|
||||
grub_uint32_t virt_chunk_size = 0;
|
||||
grub_file_t file;
|
||||
grub_disk_t disk;
|
||||
@@ -1281,6 +1417,9 @@ grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, cha
|
||||
}
|
||||
|
||||
img_chunk_size = g_img_chunk_list.cur_chunk * sizeof(ventoy_img_chunk);
|
||||
|
||||
override_count = ventoy_linux_get_override_chunk_count();
|
||||
virt_chunk_count = ventoy_linux_get_virt_chunk_count();
|
||||
|
||||
if (ventoy_compatible)
|
||||
{
|
||||
@@ -1347,20 +1486,21 @@ grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, cha
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (g_valid_initrd_count == 0)
|
||||
/* part 4: override chunk */
|
||||
if (override_count > 0)
|
||||
{
|
||||
return 0;
|
||||
chain->override_chunk_offset = chain->img_chunk_offset + img_chunk_size;
|
||||
chain->override_chunk_num = override_count;
|
||||
ventoy_linux_fill_override_data(isosize, (char *)chain + chain->override_chunk_offset);
|
||||
}
|
||||
|
||||
/* part 4: override chunk */
|
||||
chain->override_chunk_offset = chain->img_chunk_offset + img_chunk_size;
|
||||
chain->override_chunk_num = g_valid_initrd_count;
|
||||
ventoy_linux_fill_override_data(isosize, (char *)chain + chain->override_chunk_offset);
|
||||
|
||||
/* part 5: virt chunk */
|
||||
chain->virt_chunk_offset = chain->override_chunk_offset + override_size;
|
||||
chain->virt_chunk_num = g_valid_initrd_count;
|
||||
ventoy_linux_fill_virt_data(isosize, chain);
|
||||
if (virt_chunk_count > 0)
|
||||
{
|
||||
chain->virt_chunk_offset = chain->override_chunk_offset + override_size;
|
||||
chain->virt_chunk_num = virt_chunk_count;
|
||||
ventoy_linux_fill_virt_data(isosize, chain);
|
||||
}
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
@@ -41,10 +41,14 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
static char g_iso_disk_name[128];
|
||||
static install_template *g_install_template_head = NULL;
|
||||
static dud *g_dud_head = NULL;
|
||||
static persistence_config *g_persistence_head = NULL;
|
||||
static menu_alias *g_menu_alias_head = NULL;
|
||||
static menu_class *g_menu_class_head = NULL;
|
||||
static injection_config *g_injection_head = NULL;
|
||||
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 ventoy_plugin_control_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
@@ -67,7 +71,15 @@ static int ventoy_plugin_control_check(VTOY_JSON *json, const char *isodisk)
|
||||
pChild = pNode->pstChild;
|
||||
if (pChild->enDataType == JSON_TYPE_STRING)
|
||||
{
|
||||
grub_printf("%s: %s\n", pChild->pcName, pChild->unData.pcStrVal);
|
||||
if (grub_strcmp(pChild->pcName, "VTOY_DEFAULT_IMAGE") == 0)
|
||||
{
|
||||
grub_printf("%s: %s [%s]\n", pChild->pcName, pChild->unData.pcStrVal,
|
||||
ventoy_check_file_exist("%s%s", isodisk, pChild->unData.pcStrVal) ? "OK" : "NOT EXIST");
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("%s: %s\n", pChild->pcName, pChild->unData.pcStrVal);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -579,6 +591,110 @@ static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_plugin_dud_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int pathnum = 0;
|
||||
const char *iso = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
|
||||
if (json->enDataType != JSON_TYPE_ARRAY)
|
||||
{
|
||||
grub_printf("Not array type %d\n", json->enDataType);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
if (pNode->enDataType != JSON_TYPE_OBJECT)
|
||||
{
|
||||
grub_printf("NOT object type\n");
|
||||
}
|
||||
|
||||
iso = vtoy_json_get_string_ex(pNode->pstChild, "image");
|
||||
if (iso)
|
||||
{
|
||||
if (0 == ventoy_plugin_check_path(isodisk, iso))
|
||||
{
|
||||
grub_printf("image: %s [OK]\n", iso);
|
||||
ventoy_plugin_check_fullpath(pNode->pstChild, isodisk, "dud", &pathnum);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("image: %s [FAIL]\n", iso);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("image not found\n");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_plugin_dud_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int pathnum = 0;
|
||||
const char *iso = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
dud *node = NULL;
|
||||
dud *next = NULL;
|
||||
file_fullpath *dudpath = NULL;
|
||||
|
||||
if (json->enDataType != JSON_TYPE_ARRAY)
|
||||
{
|
||||
debug("Not array %d\n", json->enDataType);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (g_dud_head)
|
||||
{
|
||||
for (node = g_dud_head; node; node = next)
|
||||
{
|
||||
next = node->next;
|
||||
grub_check_free(node->dudpath);
|
||||
grub_free(node);
|
||||
}
|
||||
|
||||
g_dud_head = NULL;
|
||||
}
|
||||
|
||||
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
iso = vtoy_json_get_string_ex(pNode->pstChild, "image");
|
||||
if (iso && iso[0] == '/')
|
||||
{
|
||||
if (0 == ventoy_plugin_parse_fullpath(pNode->pstChild, isodisk, "dud", &dudpath, &pathnum))
|
||||
{
|
||||
node = grub_zalloc(sizeof(dud));
|
||||
if (node)
|
||||
{
|
||||
node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", iso);
|
||||
node->dudpath = dudpath;
|
||||
node->dudnum = pathnum;
|
||||
node->files = grub_zalloc(sizeof(dudfile) * pathnum);
|
||||
|
||||
if (node->files)
|
||||
{
|
||||
if (g_dud_head)
|
||||
{
|
||||
node->next = g_dud_head;
|
||||
}
|
||||
|
||||
g_dud_head = node;
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_free(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_plugin_persistence_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int autosel = 0;
|
||||
@@ -1010,6 +1126,306 @@ static int ventoy_plugin_menuclass_check(VTOY_JSON *json, const char *isodisk)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_plugin_conf_replace_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
const char *isof = NULL;
|
||||
const char *orgf = NULL;
|
||||
const char *newf = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
conf_replace *tail = NULL;
|
||||
conf_replace *node = NULL;
|
||||
conf_replace *next = NULL;
|
||||
|
||||
(void)isodisk;
|
||||
|
||||
if (json->enDataType != JSON_TYPE_ARRAY)
|
||||
{
|
||||
debug("Not array %d\n", json->enDataType);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (g_conf_replace_head)
|
||||
{
|
||||
for (node = g_conf_replace_head; node; node = next)
|
||||
{
|
||||
next = node->next;
|
||||
grub_free(node);
|
||||
}
|
||||
|
||||
g_conf_replace_head = NULL;
|
||||
}
|
||||
|
||||
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
isof = vtoy_json_get_string_ex(pNode->pstChild, "iso");
|
||||
orgf = vtoy_json_get_string_ex(pNode->pstChild, "org");
|
||||
newf = vtoy_json_get_string_ex(pNode->pstChild, "new");
|
||||
if (isof && orgf && newf && isof[0] == '/' && orgf[0] == '/' && newf[0] == '/')
|
||||
{
|
||||
node = grub_zalloc(sizeof(conf_replace));
|
||||
if (node)
|
||||
{
|
||||
node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", isof);
|
||||
grub_snprintf(node->orgconf, sizeof(node->orgconf), "%s", orgf);
|
||||
grub_snprintf(node->newconf, sizeof(node->newconf), "%s", newf);
|
||||
|
||||
if (g_conf_replace_head)
|
||||
{
|
||||
tail->next = node;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_conf_replace_head = node;
|
||||
}
|
||||
tail = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_plugin_conf_replace_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
const char *isof = NULL;
|
||||
const char *orgf = NULL;
|
||||
const char *newf = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
grub_file_t file = NULL;
|
||||
char cmd[256];
|
||||
|
||||
(void)isodisk;
|
||||
|
||||
if (json->enDataType != JSON_TYPE_ARRAY)
|
||||
{
|
||||
grub_printf("Not array %d\n", json->enDataType);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
isof = vtoy_json_get_string_ex(pNode->pstChild, "iso");
|
||||
orgf = vtoy_json_get_string_ex(pNode->pstChild, "org");
|
||||
newf = vtoy_json_get_string_ex(pNode->pstChild, "new");
|
||||
if (isof && orgf && newf && isof[0] == '/' && orgf[0] == '/' && newf[0] == '/')
|
||||
{
|
||||
if (ventoy_check_file_exist("%s%s", isodisk, isof))
|
||||
{
|
||||
grub_printf("iso:<%s> [OK]\n", isof);
|
||||
|
||||
grub_snprintf(cmd, sizeof(cmd), "loopback vtisocheck %s%s", isodisk, isof);
|
||||
grub_script_execute_sourcecode(cmd);
|
||||
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "(vtisocheck)/%s", orgf);
|
||||
if (file)
|
||||
{
|
||||
if (grub_strcmp(file->fs->name, "iso9660") == 0)
|
||||
{
|
||||
grub_printf("org:<%s> [OK]\n", orgf);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("org:<%s> [Exist But NOT ISO9660]\n", orgf);
|
||||
}
|
||||
grub_file_close(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("org:<%s> [NOT Exist]\n", orgf);
|
||||
}
|
||||
|
||||
grub_script_execute_sourcecode("loopback -d vtisocheck");
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("iso:<%s> [NOT Exist]\n", isof);
|
||||
grub_printf("org:<%s>\n", orgf);
|
||||
}
|
||||
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s%s", isodisk, newf);
|
||||
if (file)
|
||||
{
|
||||
if (file->size > vtoy_max_replace_file_size)
|
||||
{
|
||||
grub_printf("new:<%s> [Too Big %lu] \n", newf, (ulong)file->size);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("new:<%s> [OK]\n", newf);
|
||||
}
|
||||
grub_file_close(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("new:<%s> [NOT Exist]\n", newf);
|
||||
}
|
||||
grub_printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_plugin_auto_memdisk_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
VTOY_JSON *pNode = NULL;
|
||||
auto_memdisk *node = NULL;
|
||||
auto_memdisk *next = NULL;
|
||||
|
||||
(void)isodisk;
|
||||
|
||||
if (json->enDataType != JSON_TYPE_ARRAY)
|
||||
{
|
||||
debug("Not array %d\n", json->enDataType);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (g_auto_memdisk_head)
|
||||
{
|
||||
for (node = g_auto_memdisk_head; node; node = next)
|
||||
{
|
||||
next = node->next;
|
||||
grub_free(node);
|
||||
}
|
||||
|
||||
g_auto_memdisk_head = NULL;
|
||||
}
|
||||
|
||||
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
if (pNode->enDataType == JSON_TYPE_STRING)
|
||||
{
|
||||
node = grub_zalloc(sizeof(auto_memdisk));
|
||||
if (node)
|
||||
{
|
||||
node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", pNode->unData.pcStrVal);
|
||||
|
||||
if (g_auto_memdisk_head)
|
||||
{
|
||||
node->next = g_auto_memdisk_head;
|
||||
}
|
||||
|
||||
g_auto_memdisk_head = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_plugin_auto_memdisk_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
VTOY_JSON *pNode = NULL;
|
||||
|
||||
if (json->enDataType != JSON_TYPE_ARRAY)
|
||||
{
|
||||
grub_printf("Not array %d\n", json->enDataType);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
if (pNode->enDataType == JSON_TYPE_STRING)
|
||||
{
|
||||
grub_printf("<%s> ", pNode->unData.pcStrVal);
|
||||
|
||||
if (ventoy_check_file_exist("%s%s", isodisk, pNode->unData.pcStrVal))
|
||||
{
|
||||
grub_printf(" [OK]\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf(" [NOT EXIST]\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_plugin_image_list_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
VTOY_JSON *pNode = NULL;
|
||||
image_list *node = NULL;
|
||||
image_list *next = NULL;
|
||||
image_list *tail = NULL;
|
||||
|
||||
(void)isodisk;
|
||||
|
||||
if (json->enDataType != JSON_TYPE_ARRAY)
|
||||
{
|
||||
debug("Not array %d\n", json->enDataType);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (g_image_list_head)
|
||||
{
|
||||
for (node = g_image_list_head; node; node = next)
|
||||
{
|
||||
next = node->next;
|
||||
grub_free(node);
|
||||
}
|
||||
|
||||
g_image_list_head = NULL;
|
||||
}
|
||||
|
||||
g_plugin_image_list = 1;
|
||||
|
||||
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
if (pNode->enDataType == JSON_TYPE_STRING)
|
||||
{
|
||||
node = grub_zalloc(sizeof(image_list));
|
||||
if (node)
|
||||
{
|
||||
node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", pNode->unData.pcStrVal);
|
||||
|
||||
if (g_image_list_head)
|
||||
{
|
||||
tail->next = node;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_image_list_head = node;
|
||||
}
|
||||
tail = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_plugin_image_list_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
VTOY_JSON *pNode = NULL;
|
||||
|
||||
if (json->enDataType != JSON_TYPE_ARRAY)
|
||||
{
|
||||
grub_printf("Not array %d\n", json->enDataType);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
if (pNode->enDataType == JSON_TYPE_STRING)
|
||||
{
|
||||
grub_printf("<%s> ", pNode->unData.pcStrVal);
|
||||
|
||||
if (ventoy_check_file_exist("%s%s", isodisk, pNode->unData.pcStrVal))
|
||||
{
|
||||
grub_printf(" [OK]\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf(" [NOT EXIST]\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static plugin_entry g_plugin_entries[] =
|
||||
{
|
||||
{ "control", ventoy_plugin_control_entry, ventoy_plugin_control_check },
|
||||
@@ -1019,11 +1435,16 @@ static plugin_entry g_plugin_entries[] =
|
||||
{ "menu_alias", ventoy_plugin_menualias_entry, ventoy_plugin_menualias_check },
|
||||
{ "menu_class", ventoy_plugin_menuclass_entry, ventoy_plugin_menuclass_check },
|
||||
{ "injection", ventoy_plugin_injection_entry, ventoy_plugin_injection_check },
|
||||
{ "auto_memdisk", ventoy_plugin_auto_memdisk_entry, ventoy_plugin_auto_memdisk_check },
|
||||
{ "image_list", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check },
|
||||
{ "conf_replace", ventoy_plugin_conf_replace_entry, ventoy_plugin_conf_replace_check },
|
||||
{ "dud", ventoy_plugin_dud_entry, ventoy_plugin_dud_check },
|
||||
};
|
||||
|
||||
static int ventoy_parse_plugin_config(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int i;
|
||||
char key[128];
|
||||
VTOY_JSON *cur = json;
|
||||
|
||||
grub_snprintf(g_iso_disk_name, sizeof(g_iso_disk_name), "%s", isodisk);
|
||||
@@ -1032,7 +1453,8 @@ static int ventoy_parse_plugin_config(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
for (i = 0; i < (int)ARRAY_SIZE(g_plugin_entries); i++)
|
||||
{
|
||||
if (grub_strcmp(g_plugin_entries[i].key, cur->pcName) == 0)
|
||||
grub_snprintf(key, sizeof(key), "%s_%s", g_plugin_entries[i].key, VTOY_DUAL_MODE_SUFFIX);
|
||||
if (grub_strcmp(g_plugin_entries[i].key, cur->pcName) == 0 || grub_strcmp(key, cur->pcName) == 0)
|
||||
{
|
||||
debug("Plugin entry for %s\n", g_plugin_entries[i].key);
|
||||
g_plugin_entries[i].entryfunc(cur, isodisk);
|
||||
@@ -1063,7 +1485,7 @@ grub_err_t ventoy_cmd_load_plugin(grub_extcmd_context_t ctxt, int argc, char **a
|
||||
}
|
||||
|
||||
debug("json configuration file size %d\n", (int)file->size);
|
||||
|
||||
|
||||
buf = grub_malloc(file->size + 1);
|
||||
if (!buf)
|
||||
{
|
||||
@@ -1086,6 +1508,9 @@ grub_err_t ventoy_cmd_load_plugin(grub_extcmd_context_t ctxt, int argc, char **a
|
||||
ret = vtoy_json_parse(json, buf);
|
||||
if (ret)
|
||||
{
|
||||
grub_env_set("VTOY_PLUGIN_SYNTAX_ERROR", "1");
|
||||
grub_env_export("VTOY_PLUGIN_SYNTAX_ERROR");
|
||||
|
||||
debug("Failed to parse json string %d\n", ret);
|
||||
grub_free(buf);
|
||||
return 1;
|
||||
@@ -1163,9 +1588,15 @@ void ventoy_plugin_dump_persistence(void)
|
||||
|
||||
install_template * ventoy_plugin_find_install_template(const char *isopath)
|
||||
{
|
||||
int len;
|
||||
install_template *node = NULL;
|
||||
int len = (int)grub_strlen(isopath);
|
||||
|
||||
|
||||
if (!g_install_template_head)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = (int)grub_strlen(isopath);
|
||||
for (node = g_install_template_head; node; node = node->next)
|
||||
{
|
||||
if (node->pathlen == len && grub_strcmp(node->isopath, isopath) == 0)
|
||||
@@ -1197,9 +1628,15 @@ char * ventoy_plugin_get_cur_install_template(const char *isopath)
|
||||
|
||||
persistence_config * ventoy_plugin_find_persistent(const char *isopath)
|
||||
{
|
||||
int len;
|
||||
persistence_config *node = NULL;
|
||||
int len = (int)grub_strlen(isopath);
|
||||
|
||||
|
||||
if (!g_persistence_head)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = (int)grub_strlen(isopath);
|
||||
for (node = g_persistence_head; node; node = node->next)
|
||||
{
|
||||
if ((len == node->pathlen) && (grub_strcmp(node->isopath, isopath) == 0))
|
||||
@@ -1272,9 +1709,15 @@ end:
|
||||
|
||||
const char * ventoy_plugin_get_injection(const char *isopath)
|
||||
{
|
||||
int len;
|
||||
injection_config *node = NULL;
|
||||
int len = (int)grub_strlen(isopath);
|
||||
|
||||
if (!g_injection_head)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = (int)grub_strlen(isopath);
|
||||
for (node = g_injection_head; node; node = node->next)
|
||||
{
|
||||
if (node->pathlen == len && grub_strcmp(node->isopath, isopath) == 0)
|
||||
@@ -1288,9 +1731,15 @@ const char * ventoy_plugin_get_injection(const char *isopath)
|
||||
|
||||
const char * ventoy_plugin_get_menu_alias(int type, const char *isopath)
|
||||
{
|
||||
int len;
|
||||
menu_alias *node = NULL;
|
||||
int len = (int)grub_strlen(isopath);
|
||||
|
||||
if (!g_menu_alias_head)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = (int)grub_strlen(isopath);
|
||||
for (node = g_menu_alias_head; node; node = node->next)
|
||||
{
|
||||
if (node->type == type && node->pathlen &&
|
||||
@@ -1305,9 +1754,16 @@ const char * ventoy_plugin_get_menu_alias(int type, const char *isopath)
|
||||
|
||||
const char * ventoy_plugin_get_menu_class(int type, const char *name)
|
||||
{
|
||||
int len;
|
||||
menu_class *node = NULL;
|
||||
int len = (int)grub_strlen(name);
|
||||
|
||||
if (!g_menu_class_head)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = (int)grub_strlen(name);
|
||||
|
||||
if (vtoy_class_image_file == type)
|
||||
{
|
||||
for (node = g_menu_class_head; node; node = node->next)
|
||||
@@ -1332,11 +1788,144 @@ const char * ventoy_plugin_get_menu_class(int type, const char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int ventoy_plugin_check_memdisk(const char *isopath)
|
||||
{
|
||||
int len;
|
||||
auto_memdisk *node = NULL;
|
||||
|
||||
if (!g_auto_memdisk_head)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
len = (int)grub_strlen(isopath);
|
||||
for (node = g_auto_memdisk_head; node; node = node->next)
|
||||
{
|
||||
if (node->pathlen == len && grub_strncmp(isopath, node->isopath, len) == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ventoy_plugin_get_image_list_index(int type, const char *name)
|
||||
{
|
||||
int len;
|
||||
int index = 1;
|
||||
image_list *node = NULL;
|
||||
|
||||
if (!g_image_list_head)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
len = (int)grub_strlen(name);
|
||||
|
||||
for (node = g_image_list_head; node; node = node->next, index++)
|
||||
{
|
||||
if (vtoy_class_directory == type)
|
||||
{
|
||||
if (len < node->pathlen && grub_strncmp(name, node->isopath, len) == 0)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (len == node->pathlen && grub_strncmp(name, node->isopath, len) == 0)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
conf_replace * ventoy_plugin_find_conf_replace(const char *iso)
|
||||
{
|
||||
int len;
|
||||
conf_replace *node;
|
||||
|
||||
if (!g_conf_replace_head)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = (int)grub_strlen(iso);
|
||||
|
||||
for (node = g_conf_replace_head; node; node = node->next)
|
||||
{
|
||||
if (node->pathlen == len && grub_strncmp(iso, node->isopath, len) == 0)
|
||||
{
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dud * ventoy_plugin_find_dud(const char *iso)
|
||||
{
|
||||
int len;
|
||||
dud *node;
|
||||
|
||||
if (!g_dud_head)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = (int)grub_strlen(iso);
|
||||
for (node = g_dud_head; node; node = node->next)
|
||||
{
|
||||
if (node->pathlen == len && grub_strncmp(iso, node->isopath, len) == 0)
|
||||
{
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int ventoy_plugin_load_dud(dud *node, const char *isopart)
|
||||
{
|
||||
int i;
|
||||
char *buf;
|
||||
grub_file_t file;
|
||||
|
||||
for (i = 0; i < node->dudnum; i++)
|
||||
{
|
||||
if (node->files[i].size > 0)
|
||||
{
|
||||
debug("file %d has been loaded\n", i);
|
||||
continue;
|
||||
}
|
||||
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s%s", isopart, node->dudpath[i].path);
|
||||
if (file)
|
||||
{
|
||||
buf = grub_malloc(file->size);
|
||||
if (buf)
|
||||
{
|
||||
grub_file_read(file, buf, file->size);
|
||||
node->files[i].size = (int)file->size;
|
||||
node->files[i].buf = buf;
|
||||
}
|
||||
grub_file_close(file);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_plugin_check_json(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int i = 0;
|
||||
int ret = 0;
|
||||
char *buf = NULL;
|
||||
char key[128];
|
||||
grub_file_t file;
|
||||
VTOY_JSON *node = NULL;
|
||||
VTOY_JSON *json = NULL;
|
||||
@@ -1352,6 +1941,7 @@ grub_err_t ventoy_cmd_plugin_check_json(grub_extcmd_context_t ctxt, int argc, ch
|
||||
if (!file)
|
||||
{
|
||||
grub_printf("Plugin json file /ventoy/ventoy.json does NOT exist.\n");
|
||||
grub_printf("Attention: directory name and filename are both case-sensitive.\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -1379,9 +1969,10 @@ grub_err_t ventoy_cmd_plugin_check_json(grub_extcmd_context_t ctxt, int argc, ch
|
||||
goto end;
|
||||
}
|
||||
|
||||
grub_snprintf(key, sizeof(key), "%s_%s", args[1], VTOY_DUAL_MODE_SUFFIX);
|
||||
for (node = json->pstChild; node; node = node->pstNext)
|
||||
{
|
||||
if (grub_strcmp(node->pcName, args[1]) == 0)
|
||||
if (grub_strcmp(node->pcName, args[1]) == 0 || grub_strcmp(node->pcName, key) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@@ -194,6 +194,7 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath)
|
||||
grub_file_t isofile;
|
||||
char uuid[64] = {0};
|
||||
ventoy_img_chunk *chunk;
|
||||
grub_uint8_t disk_sig[4];
|
||||
grub_uint8_t disk_guid[16];
|
||||
|
||||
debug("ventoy_freebsd_append_conf %s\n", isopath);
|
||||
@@ -209,7 +210,7 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath)
|
||||
|
||||
disk = isofile->device->disk;
|
||||
|
||||
ventoy_get_disk_guid(isofile->name, disk_guid);
|
||||
ventoy_get_disk_guid(isofile->name, disk_guid, disk_sig);
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
@@ -217,7 +218,8 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath)
|
||||
}
|
||||
|
||||
vtoy_ssprintf(buf, pos, "hint.ventoy.0.disksize=%llu\n", (ulonglong)(disk->total_sectors * (1 << disk->log_sector_size)));
|
||||
vtoy_ssprintf(buf, pos, "hint.ventoy.0.diskuuid=\"%s\"\n", uuid);
|
||||
vtoy_ssprintf(buf, pos, "hint.ventoy.0.diskuuid=\"%s\"\n", uuid);
|
||||
vtoy_ssprintf(buf, pos, "hint.ventoy.0.disksignature=%02x%02x%02x%02x\n", disk_sig[0], disk_sig[1], disk_sig[2], disk_sig[3]);
|
||||
vtoy_ssprintf(buf, pos, "hint.ventoy.0.segnum=%u\n", g_img_chunk_list.cur_chunk);
|
||||
|
||||
for (i = 0; i < g_img_chunk_list.cur_chunk; i++)
|
||||
|
559
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_vhd.c
Normal file
559
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_vhd.c
Normal file
@@ -0,0 +1,559 @@
|
||||
/******************************************************************************
|
||||
* ventoy_vhd.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 <grub/types.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/device.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/partition.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/extcmd.h>
|
||||
#include <grub/datetime.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/net.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/crypto.h>
|
||||
#include <grub/charset.h>
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
#include <grub/efi/efi.h>
|
||||
#endif
|
||||
#include <grub/ventoy.h>
|
||||
#include "ventoy_def.h"
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
static int g_vhdboot_bcd_offset = 0;
|
||||
static int g_vhdboot_bcd_len = 0;
|
||||
static int g_vhdboot_isolen = 0;
|
||||
static char *g_vhdboot_totbuf = NULL;
|
||||
static char *g_vhdboot_isobuf = NULL;
|
||||
static grub_uint64_t g_img_trim_head_secnum = 0;
|
||||
|
||||
static int ventoy_vhd_find_bcd(int *bcdoffset, int *bcdlen)
|
||||
{
|
||||
grub_uint32_t offset;
|
||||
grub_file_t file;
|
||||
char cmdbuf[128];
|
||||
|
||||
grub_snprintf(cmdbuf, sizeof(cmdbuf), "loopback vhdiso mem:0x%lx:size:%d", (ulong)g_vhdboot_isobuf, g_vhdboot_isolen);
|
||||
|
||||
grub_script_execute_sourcecode(cmdbuf);
|
||||
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", "(vhdiso)/boot/bcd");
|
||||
if (!file)
|
||||
{
|
||||
grub_printf("Failed to open bcd file in the image file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
grub_file_read(file, &offset, 4);
|
||||
offset = (grub_uint32_t)grub_iso9660_get_last_read_pos(file);
|
||||
|
||||
*bcdoffset = (int)offset;
|
||||
*bcdlen = (int)file->size;
|
||||
|
||||
debug("vhdiso bcd file offset:%d len:%d\n", *bcdoffset, *bcdlen);
|
||||
|
||||
grub_file_close(file);
|
||||
|
||||
grub_script_execute_sourcecode("loopback -d vhdiso");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_vhd_patch_path(char *vhdpath, ventoy_patch_vhd *patch1, ventoy_patch_vhd *patch2)
|
||||
{
|
||||
int i;
|
||||
int cnt = 0;
|
||||
char *pos;
|
||||
grub_size_t pathlen;
|
||||
const char *plat;
|
||||
grub_uint16_t *unicode_path;
|
||||
const grub_uint8_t winloadexe[] =
|
||||
{
|
||||
0x77, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x61, 0x00, 0x64, 0x00, 0x2E, 0x00,
|
||||
0x65, 0x00, 0x78, 0x00, 0x65, 0x00
|
||||
};
|
||||
|
||||
pathlen = sizeof(grub_uint16_t) * (grub_strlen(vhdpath) + 1);
|
||||
debug("unicode path for <%s> len:%d\n", vhdpath, (int)pathlen);
|
||||
|
||||
unicode_path = grub_zalloc(pathlen);
|
||||
if (!unicode_path)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
plat = grub_env_get("grub_platform");
|
||||
|
||||
if (plat && (plat[0] == 'e')) /* UEFI */
|
||||
{
|
||||
pos = g_vhdboot_isobuf + g_vhdboot_bcd_offset;
|
||||
|
||||
/* winload.exe ==> winload.efi */
|
||||
for (i = 0; i + (int)sizeof(winloadexe) < g_vhdboot_bcd_len; i++)
|
||||
{
|
||||
if (*((grub_uint32_t *)(pos + i)) == 0x00690077 &&
|
||||
grub_memcmp(pos + i, winloadexe, sizeof(winloadexe)) == 0)
|
||||
{
|
||||
pos[i + sizeof(winloadexe) - 4] = 0x66;
|
||||
pos[i + sizeof(winloadexe) - 2] = 0x69;
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
debug("winload patch %d times\n", cnt);
|
||||
}
|
||||
|
||||
for (pos = vhdpath; *pos; pos++)
|
||||
{
|
||||
if (*pos == '/')
|
||||
{
|
||||
*pos = '\\';
|
||||
}
|
||||
}
|
||||
|
||||
grub_utf8_to_utf16(unicode_path, pathlen, (grub_uint8_t *)vhdpath, -1, NULL);
|
||||
grub_memcpy(patch1->vhd_file_path, unicode_path, pathlen);
|
||||
grub_memcpy(patch2->vhd_file_path, unicode_path, pathlen);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_vhd_patch_disk(ventoy_patch_vhd *patch1, ventoy_patch_vhd *patch2)
|
||||
{
|
||||
char efipart[16] = {0};
|
||||
|
||||
grub_memcpy(efipart, g_ventoy_part_info->Head.Signature, sizeof(g_ventoy_part_info->Head.Signature));
|
||||
|
||||
debug("part1 type: 0x%x <%s>\n", g_ventoy_part_info->MBR.PartTbl[0].FsFlag, efipart);
|
||||
|
||||
if (grub_strncmp(efipart, "EFI PART", 8) == 0)
|
||||
{
|
||||
ventoy_debug_dump_guid("GPT disk GUID: ", g_ventoy_part_info->Head.DiskGuid);
|
||||
ventoy_debug_dump_guid("GPT part GUID: ", g_ventoy_part_info->PartTbl[0].PartGuid);
|
||||
|
||||
grub_memcpy(patch1->disk_signature_or_guid, g_ventoy_part_info->Head.DiskGuid, 16);
|
||||
grub_memcpy(patch1->part_offset_or_guid, g_ventoy_part_info->PartTbl[0].PartGuid, 16);
|
||||
grub_memcpy(patch2->disk_signature_or_guid, g_ventoy_part_info->Head.DiskGuid, 16);
|
||||
grub_memcpy(patch2->part_offset_or_guid, g_ventoy_part_info->PartTbl[0].PartGuid, 16);
|
||||
|
||||
patch1->part_type = patch2->part_type = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("MBR disk signature: %02x%02x%02x%02x\n",
|
||||
g_ventoy_part_info->MBR.BootCode[0x1b8 + 0], g_ventoy_part_info->MBR.BootCode[0x1b8 + 1],
|
||||
g_ventoy_part_info->MBR.BootCode[0x1b8 + 2], g_ventoy_part_info->MBR.BootCode[0x1b8 + 3]);
|
||||
grub_memcpy(patch1->disk_signature_or_guid, g_ventoy_part_info->MBR.BootCode + 0x1b8, 4);
|
||||
grub_memcpy(patch2->disk_signature_or_guid, g_ventoy_part_info->MBR.BootCode + 0x1b8, 4);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_patch_vhdboot(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int rc;
|
||||
ventoy_patch_vhd *patch1;
|
||||
ventoy_patch_vhd *patch2;
|
||||
char envbuf[64];
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
|
||||
grub_env_unset("vtoy_vhd_buf_addr");
|
||||
|
||||
debug("patch vhd <%s>\n", args[0]);
|
||||
|
||||
if ((!g_vhdboot_enable) || (!g_vhdboot_totbuf))
|
||||
{
|
||||
debug("vhd boot not ready %d %p\n", g_vhdboot_enable, g_vhdboot_totbuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
rc = ventoy_vhd_find_bcd(&g_vhdboot_bcd_offset, &g_vhdboot_bcd_len);
|
||||
if (rc)
|
||||
{
|
||||
debug("failed to get bcd location %d\n", rc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
patch1 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + g_vhdboot_bcd_offset + 0x495a);
|
||||
patch2 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + g_vhdboot_bcd_offset + 0x50aa);
|
||||
|
||||
ventoy_vhd_patch_disk(patch1, patch2);
|
||||
ventoy_vhd_patch_path(args[0], patch1, patch2);
|
||||
|
||||
/* set buffer and size */
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
grub_snprintf(envbuf, sizeof(envbuf), "0x%lx", (ulong)g_vhdboot_totbuf);
|
||||
grub_env_set("vtoy_vhd_buf_addr", envbuf);
|
||||
grub_snprintf(envbuf, sizeof(envbuf), "%d", (int)(g_vhdboot_isolen + sizeof(ventoy_chain_head)));
|
||||
grub_env_set("vtoy_vhd_buf_size", envbuf);
|
||||
#else
|
||||
grub_snprintf(envbuf, sizeof(envbuf), "0x%lx", (ulong)g_vhdboot_isobuf);
|
||||
grub_env_set("vtoy_vhd_buf_addr", envbuf);
|
||||
grub_snprintf(envbuf, sizeof(envbuf), "%d", g_vhdboot_isolen);
|
||||
grub_env_set("vtoy_vhd_buf_size", envbuf);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_load_vhdboot(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int buflen;
|
||||
grub_file_t file;
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
|
||||
g_vhdboot_enable = 0;
|
||||
grub_check_free(g_vhdboot_totbuf);
|
||||
|
||||
file = grub_file_open(args[0], VENTOY_FILE_TYPE);
|
||||
if (!file)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
debug("load vhd boot: <%s> <%lu>\n", args[0], (ulong)file->size);
|
||||
|
||||
if (file->size < VTOY_SIZE_1KB * 32)
|
||||
{
|
||||
grub_file_close(file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_vhdboot_isolen = (int)file->size;
|
||||
|
||||
buflen = (int)(file->size + sizeof(ventoy_chain_head));
|
||||
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
g_vhdboot_totbuf = (char *)grub_efi_allocate_iso_buf(buflen);
|
||||
#else
|
||||
g_vhdboot_totbuf = (char *)grub_malloc(buflen);
|
||||
#endif
|
||||
|
||||
if (!g_vhdboot_totbuf)
|
||||
{
|
||||
grub_file_close(file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_vhdboot_isobuf = g_vhdboot_totbuf + sizeof(ventoy_chain_head);
|
||||
|
||||
grub_file_read(file, g_vhdboot_isobuf, file->size);
|
||||
grub_file_close(file);
|
||||
|
||||
g_vhdboot_enable = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_raw_trim_head(grub_uint64_t offset)
|
||||
{
|
||||
grub_uint32_t i;
|
||||
grub_uint32_t memsize;
|
||||
grub_uint32_t imgstart = 0;
|
||||
grub_uint32_t imgsecs = 0;
|
||||
grub_uint64_t sectors = 0;
|
||||
grub_uint64_t cursecs = 0;
|
||||
grub_uint64_t delta = 0;
|
||||
|
||||
if ((!g_img_chunk_list.chunk) || (!offset))
|
||||
{
|
||||
debug("image chunk not ready %p %lu\n", g_img_chunk_list.chunk, (ulong)offset);
|
||||
return 0;
|
||||
}
|
||||
|
||||
debug("image trim head %lu\n", (ulong)offset);
|
||||
|
||||
for (i = 0; i < g_img_chunk_list.cur_chunk; i++)
|
||||
{
|
||||
cursecs = g_img_chunk_list.chunk[i].disk_end_sector + 1 - g_img_chunk_list.chunk[i].disk_start_sector;
|
||||
sectors += cursecs;
|
||||
if (sectors >= offset)
|
||||
{
|
||||
delta = cursecs - (sectors - offset);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sectors < offset || i >= g_img_chunk_list.cur_chunk)
|
||||
{
|
||||
debug("Invalid size %lu %lu\n", (ulong)sectors, (ulong)offset);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sectors == offset)
|
||||
{
|
||||
memsize = (g_img_chunk_list.cur_chunk - (i + 1)) * sizeof(ventoy_img_chunk);
|
||||
grub_memmove(g_img_chunk_list.chunk, g_img_chunk_list.chunk + i + 1, memsize);
|
||||
g_img_chunk_list.cur_chunk -= (i + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_img_chunk_list.chunk[i].disk_start_sector += delta;
|
||||
g_img_chunk_list.chunk[i].img_start_sector += (grub_uint32_t)(delta / 4);
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
memsize = (g_img_chunk_list.cur_chunk - i) * sizeof(ventoy_img_chunk);
|
||||
grub_memmove(g_img_chunk_list.chunk, g_img_chunk_list.chunk + i, memsize);
|
||||
g_img_chunk_list.cur_chunk -= i;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < g_img_chunk_list.cur_chunk; i++)
|
||||
{
|
||||
imgsecs = g_img_chunk_list.chunk[i].img_end_sector + 1 - g_img_chunk_list.chunk[i].img_start_sector;
|
||||
g_img_chunk_list.chunk[i].img_start_sector = imgstart;
|
||||
g_img_chunk_list.chunk[i].img_end_sector = imgstart + (imgsecs - 1);
|
||||
imgstart += imgsecs;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int i;
|
||||
int offset = -1;
|
||||
grub_file_t file;
|
||||
vhd_footer_t vhdfoot;
|
||||
VDIPREHEADER vdihdr;
|
||||
char type[16] = {0};
|
||||
ventoy_gpt_info *gpt;
|
||||
|
||||
(void)ctxt;
|
||||
|
||||
g_img_trim_head_secnum = 0;
|
||||
|
||||
if (argc != 4)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
file = grub_file_open(args[0], VENTOY_FILE_TYPE);
|
||||
if (!file)
|
||||
{
|
||||
debug("Failed to open file %s\n", args[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_snprintf(type, sizeof(type), "unknown");
|
||||
|
||||
grub_file_seek(file, file->size - 512);
|
||||
grub_file_read(file, &vhdfoot, sizeof(vhdfoot));
|
||||
|
||||
if (grub_strncmp(vhdfoot.cookie, "conectix", 8) == 0)
|
||||
{
|
||||
offset = 0;
|
||||
grub_snprintf(type, sizeof(type), "vhd%u", grub_swap_bytes32(vhdfoot.disktype));
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_file_seek(file, 0);
|
||||
grub_file_read(file, &vdihdr, sizeof(vdihdr));
|
||||
if (vdihdr.u32Signature == VDI_IMAGE_SIGNATURE &&
|
||||
grub_strncmp(vdihdr.szFileInfo, VDI_IMAGE_FILE_INFO, grub_strlen(VDI_IMAGE_FILE_INFO)) == 0)
|
||||
{
|
||||
offset = 2 * 1048576;
|
||||
g_img_trim_head_secnum = offset / 512;
|
||||
grub_snprintf(type, sizeof(type), "vdi");
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = 0;
|
||||
grub_snprintf(type, sizeof(type), "raw");
|
||||
}
|
||||
}
|
||||
|
||||
grub_env_set(args[1], type);
|
||||
debug("<%s> vtoy type: <%s> ", args[0], type);
|
||||
|
||||
if (offset >= 0)
|
||||
{
|
||||
gpt = grub_zalloc(sizeof(ventoy_gpt_info));
|
||||
if (!gpt)
|
||||
{
|
||||
grub_env_set(args[1], "unknown");
|
||||
goto end;
|
||||
}
|
||||
|
||||
grub_file_seek(file, offset);
|
||||
grub_file_read(file, gpt, sizeof(ventoy_gpt_info));
|
||||
|
||||
if (gpt->MBR.Byte55 != 0x55 || gpt->MBR.ByteAA != 0xAA)
|
||||
{
|
||||
grub_env_set(args[1], "unknown");
|
||||
debug("invalid mbr signature: 0x%x 0x%x\n", gpt->MBR.Byte55, gpt->MBR.ByteAA);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (grub_memcmp(gpt->Head.Signature, "EFI PART", 8) == 0)
|
||||
{
|
||||
grub_env_set(args[2], "gpt");
|
||||
debug("part type: %s\n", "GPT");
|
||||
|
||||
if (gpt->MBR.PartTbl[0].FsFlag == 0xEE)
|
||||
{
|
||||
for (i = 0; i < 128; i++)
|
||||
{
|
||||
if (grub_memcmp(gpt->PartTbl[i].PartType, "Hah!IdontNeedEFI", 16) == 0)
|
||||
{
|
||||
debug("part %d is grub_bios part\n", i);
|
||||
grub_env_set(args[3], "1");
|
||||
break;
|
||||
}
|
||||
else if (gpt->PartTbl[i].LastLBA == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_env_set(args[2], "mbr");
|
||||
debug("part type: %s\n", "MBR");
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (gpt->MBR.PartTbl[i].FsFlag == 0xEF)
|
||||
{
|
||||
debug("part %d is esp part in MBR mode\n", i);
|
||||
grub_env_set(args[3], "1");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("part type: %s\n", "xxx");
|
||||
}
|
||||
|
||||
end:
|
||||
grub_check_free(gpt);
|
||||
grub_file_close(file);
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_raw_chain_data(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
grub_uint32_t size = 0;
|
||||
grub_uint32_t img_chunk_size = 0;
|
||||
grub_file_t file;
|
||||
grub_disk_t disk;
|
||||
const char *pLastChain = NULL;
|
||||
ventoy_chain_head *chain;
|
||||
char envbuf[64];
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
|
||||
if (NULL == g_img_chunk_list.chunk)
|
||||
{
|
||||
grub_printf("ventoy not ready\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (g_img_trim_head_secnum > 0)
|
||||
{
|
||||
ventoy_raw_trim_head(g_img_trim_head_secnum);
|
||||
}
|
||||
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", args[0]);
|
||||
if (!file)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
img_chunk_size = g_img_chunk_list.cur_chunk * sizeof(ventoy_img_chunk);
|
||||
|
||||
size = sizeof(ventoy_chain_head) + img_chunk_size;
|
||||
|
||||
pLastChain = grub_env_get("vtoy_chain_mem_addr");
|
||||
if (pLastChain)
|
||||
{
|
||||
chain = (ventoy_chain_head *)grub_strtoul(pLastChain, NULL, 16);
|
||||
if (chain)
|
||||
{
|
||||
debug("free last chain memory %p\n", chain);
|
||||
grub_free(chain);
|
||||
}
|
||||
}
|
||||
|
||||
chain = grub_malloc(size);
|
||||
if (!chain)
|
||||
{
|
||||
grub_printf("Failed to alloc chain memory size %u\n", size);
|
||||
grub_file_close(file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
grub_snprintf(envbuf, sizeof(envbuf), "0x%lx", (unsigned long)chain);
|
||||
grub_env_set("vtoy_chain_mem_addr", envbuf);
|
||||
grub_snprintf(envbuf, sizeof(envbuf), "%u", size);
|
||||
grub_env_set("vtoy_chain_mem_size", envbuf);
|
||||
|
||||
grub_env_export("vtoy_chain_mem_addr");
|
||||
grub_env_export("vtoy_chain_mem_size");
|
||||
|
||||
grub_memset(chain, 0, sizeof(ventoy_chain_head));
|
||||
|
||||
/* part 1: os parameter */
|
||||
g_ventoy_chain_type = ventoy_chain_linux;
|
||||
ventoy_fill_os_param(file, &(chain->os_param));
|
||||
|
||||
/* part 2: chain head */
|
||||
disk = file->device->disk;
|
||||
chain->disk_drive = disk->id;
|
||||
chain->disk_sector_size = (1 << disk->log_sector_size);
|
||||
|
||||
chain->real_img_size_in_bytes = file->size;
|
||||
if (g_img_trim_head_secnum > 0)
|
||||
{
|
||||
chain->real_img_size_in_bytes -= g_img_trim_head_secnum * 512;
|
||||
}
|
||||
|
||||
chain->virt_img_size_in_bytes = chain->real_img_size_in_bytes;
|
||||
chain->boot_catalog = 0;
|
||||
|
||||
/* part 3: image chunk */
|
||||
chain->img_chunk_offset = sizeof(ventoy_chain_head);
|
||||
chain->img_chunk_num = g_img_chunk_list.cur_chunk;
|
||||
grub_memcpy((char *)chain + chain->img_chunk_offset, g_img_chunk_list.chunk, img_chunk_size);
|
||||
|
||||
grub_file_seek(file, g_img_trim_head_secnum * 512);
|
||||
grub_file_read(file, chain->boot_catalog_sector, 512);
|
||||
|
||||
grub_file_close(file);
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
@@ -1542,6 +1542,41 @@ static int ventoy_get_wim_chunklist(const char *filename, ventoy_img_chunk_list
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_wim_check_bootable(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
grub_uint32_t boot_index;
|
||||
grub_file_t file = NULL;
|
||||
wim_header *wimhdr = NULL;
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
|
||||
wimhdr = grub_zalloc(sizeof(wim_header));
|
||||
if (!wimhdr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", args[0]);
|
||||
if (!file)
|
||||
{
|
||||
grub_free(wimhdr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
grub_file_read(file, wimhdr, sizeof(wim_header));
|
||||
grub_file_close(file);
|
||||
boot_index = wimhdr->boot_index;
|
||||
grub_free(wimhdr);
|
||||
|
||||
if (boot_index == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_wim_chain_data(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
grub_uint32_t i = 0;
|
||||
|
@@ -71,7 +71,7 @@ typedef struct ventoy_image_location
|
||||
{
|
||||
ventoy_guid guid;
|
||||
|
||||
/* image sector size, currently this value is always 2048 */
|
||||
/* image sector size, 2048/512 */
|
||||
grub_uint32_t image_sector_size;
|
||||
|
||||
/* disk sector size, normally the value is 512 */
|
||||
@@ -125,7 +125,9 @@ typedef struct ventoy_os_param
|
||||
*/
|
||||
grub_uint8_t vtoy_reserved[32]; // Internal use by ventoy
|
||||
|
||||
grub_uint8_t reserved[31];
|
||||
grub_uint8_t vtoy_disk_signature[4];
|
||||
|
||||
grub_uint8_t reserved[27];
|
||||
}ventoy_os_param;
|
||||
|
||||
|
||||
@@ -219,6 +221,7 @@ typedef struct ventoy_img_chunk_list
|
||||
#define GRUB_FILE_REPLACE_MAGIC 0x1258BEEF
|
||||
|
||||
typedef const char * (*grub_env_get_pf)(const char *name);
|
||||
typedef int (*grub_env_set_pf)(const char *name, const char *val);
|
||||
typedef int (*grub_env_printf_pf)(const char *fmt, ...);
|
||||
|
||||
typedef struct ventoy_grub_param_file_replace
|
||||
@@ -232,6 +235,7 @@ typedef struct ventoy_grub_param_file_replace
|
||||
typedef struct ventoy_grub_param
|
||||
{
|
||||
grub_env_get_pf grub_env_get;
|
||||
grub_env_set_pf grub_env_set;
|
||||
ventoy_grub_param_file_replace file_replace;
|
||||
grub_env_printf_pf grub_env_printf;
|
||||
}ventoy_grub_param;
|
||||
|
@@ -12,17 +12,23 @@ make install
|
||||
PATH=$PATH:$VT_DIR/GRUB2/INSTALL/bin/:$VT_DIR/GRUB2/INSTALL/sbin/
|
||||
|
||||
net_modules_legacy="net tftp http"
|
||||
all_modules_legacy="date drivemap blocklist newc vga_text ntldr search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio lspci pci ext2 xfs ventoy chain read halt iso9660 linux16 test true sleep reboot echo videotest videoinfo videotest_checksum video_colors video_cirrus video_bochs vga vbe video_fb font video gettext extcmd terminal linux minicmd help configfile tr trig boot biosdisk disk ls tar squash4 password_pbkdf2 all_video png jpeg part_gpt part_msdos fat exfat ntfs loopback gzio normal udf gfxmenu gfxterm gfxterm_background gfxterm_menu"
|
||||
all_modules_legacy="date drivemap blocklist regexp newc vga_text ntldr search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio lspci pci ext2 xfs ventoy chain read halt iso9660 linux16 test true sleep reboot echo videotest videoinfo videotest_checksum video_colors video_cirrus video_bochs vga vbe video_fb font video gettext extcmd terminal linux minicmd help configfile tr trig boot biosdisk disk ls tar squash4 password_pbkdf2 all_video png jpeg part_gpt part_msdos fat exfat ntfs loopback gzio normal udf gfxmenu gfxterm gfxterm_background gfxterm_menu"
|
||||
|
||||
net_modules_uefi="efinet net tftp http"
|
||||
all_modules_uefi="blocklist ventoy test newc search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux relocator jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop efi_uga video_bochs video_cirrus video video_fb gfxterm_background gfxterm_menu"
|
||||
all_modules_uefi="blocklist ventoy test regexp newc search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux relocator jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop efi_uga video_bochs video_cirrus video video_fb gfxterm_background gfxterm_menu"
|
||||
|
||||
if [ "$1" = "uefi" ]; then
|
||||
all_modules="$net_modules_uefi $all_modules_uefi "
|
||||
grub-mkimage -v --directory "$VT_DIR/GRUB2/INSTALL/lib/grub/x86_64-efi" --prefix '(,2)/grub' --output "$VT_DIR/INSTALL/EFI/BOOT/grubx64_real.efi" --format 'x86_64-efi' --compression 'auto' $all_modules_uefi 'fat' 'part_msdos'
|
||||
|
||||
#grub-mkimage -v --directory "$VT_DIR/GRUB2/INSTALL/lib/grub/x86_64-efi" -c "$VT_DIR/LiveCD/GRUB/embed.cfg" --prefix '/EFI/boot' --output "$VT_DIR/LiveCD/GRUB/bootx64.efi" --format 'x86_64-efi' --compression 'auto' $all_modules_uefi 'fat' 'part_msdos'
|
||||
else
|
||||
all_modules="$net_modules_legacy $all_modules_legacy "
|
||||
grub-mkimage -v --directory "$VT_DIR/GRUB2/INSTALL/lib/grub/i386-pc" --prefix '(,2)/grub' --output "$VT_DIR/INSTALL/grub/i386-pc/core.img" --format 'i386-pc' --compression 'auto' $all_modules_legacy 'fat' 'part_msdos' 'biosdisk'
|
||||
|
||||
#grub-mkimage -v --directory "$VT_DIR/GRUB2/INSTALL/lib/grub/i386-pc" -c "$VT_DIR/LiveCD/GRUB/embed.cfg" --prefix '/EFI/boot' --output "$VT_DIR/LiveCD/GRUB/cdrom.img" --format 'i386-pc-eltorito' --compression 'auto' $all_modules_legacy 'biosdisk' 'iso9660' 'fat' 'part_msdos'
|
||||
#rm -f $VT_DIR/LiveCD/GRUB/boot_hybrid.img
|
||||
#cp -a $VT_DIR/GRUB2/INSTALL/lib/grub/i386-pc/boot_hybrid.img $VT_DIR/LiveCD/GRUB/boot_hybrid.img
|
||||
fi
|
||||
|
||||
grub-mknetdir --modules="$all_modules" --net-directory=$VT_DIR/GRUB2/PXE --subdir=grub2 --locales=en@quot || exit 1
|
||||
|
@@ -40,11 +40,21 @@ if [ -e $BUSYBOX_PATH/64h ]; then
|
||||
$BUSYBOX_PATH/xzminidec32 < $BUSYBOX_PATH/busybox32.xz > $BUSYBOX_PATH/busybox
|
||||
$BUSYBOX_PATH/vtchmod32 $BUSYBOX_PATH/busybox
|
||||
else
|
||||
$BUSYBOX_PATH/xzminidec64 < $BUSYBOX_PATH/busybox64.xz > $BUSYBOX_PATH/busybox
|
||||
$BUSYBOX_PATH/vtchmod64 $BUSYBOX_PATH/busybox
|
||||
$BUSYBOX_PATH/xzminidec64 < $BUSYBOX_PATH/busybox64.xz > $BUSYBOX_PATH/busybox
|
||||
if [ -s $BUSYBOX_PATH/busybox ]; then
|
||||
$BUSYBOX_PATH/vtchmod64 $BUSYBOX_PATH/busybox
|
||||
else
|
||||
$BUSYBOX_PATH/xzminidec64_uclibc < $BUSYBOX_PATH/busybox64.xz > $BUSYBOX_PATH/busybox
|
||||
$BUSYBOX_PATH/vtchmod64_uclibc $BUSYBOX_PATH/busybox
|
||||
fi
|
||||
fi
|
||||
|
||||
$BUSYBOX_PATH/busybox --install $BUSYBOX_PATH
|
||||
if [ -e $BUSYBOX_PATH/busybox ]; then
|
||||
$BUSYBOX_PATH/busybox --install $BUSYBOX_PATH
|
||||
else
|
||||
$BUSYBOX_PATH/tmpxz -d $BUSYBOX_PATH/busybox32.xz
|
||||
$BUSYBOX_PATH/busybox32 --install $BUSYBOX_PATH
|
||||
fi
|
||||
|
||||
export PATH=$BUSYBOX_PATH/:$VTOY_PATH/tool
|
||||
|
||||
@@ -78,10 +88,12 @@ if [ -e $BUSYBOX_PATH/64h ]; then
|
||||
echo "Use busybox32 toolkit ..." >>$VTLOG
|
||||
ln -s $BUSYBOX_PATH/xzminidec32 $BUSYBOX_PATH/xzminidec
|
||||
ln -s $VTOY_PATH/tool/dmsetup32 $VTOY_PATH/tool/dmsetup
|
||||
ln -s $VTOY_PATH/tool/lunzip32 $VTOY_PATH/tool/lunzip
|
||||
else
|
||||
echo "Use busybox64 toolkit ..." >>$VTLOG
|
||||
ln -s $BUSYBOX_PATH/xzminidec64 $BUSYBOX_PATH/xzminidec
|
||||
ln -s $VTOY_PATH/tool/dmsetup64 $VTOY_PATH/tool/dmsetup
|
||||
ln -s $VTOY_PATH/tool/lunzip64 $VTOY_PATH/tool/lunzip
|
||||
fi
|
||||
|
||||
rm -f *.xz
|
||||
|
BIN
IMG/cpio/ventoy/busybox/vtchmod64_uclibc
Normal file
BIN
IMG/cpio/ventoy/busybox/vtchmod64_uclibc
Normal file
Binary file not shown.
BIN
IMG/cpio/ventoy/busybox/xzminidec64_uclibc
Normal file
BIN
IMG/cpio/ventoy/busybox/xzminidec64_uclibc
Normal file
Binary file not shown.
@@ -59,7 +59,15 @@ mkdir -p $VTOY_PATH/mnt
|
||||
mount /vt_modloop $VTOY_PATH/mnt
|
||||
|
||||
KoModPath=$(find $VTOY_PATH/mnt/ -name 'dm-mod.ko*')
|
||||
vtlog "insmod $KoModPath"
|
||||
vtlog "KoModPath=$KoModPath"
|
||||
|
||||
if modinfo $KoModPath | grep -q 'depend.*dax'; then
|
||||
vtlog "First install dax mod ..."
|
||||
DaxModPath=$(echo $KoModPath | sed 's#md/dm-mod#dax/dax#')
|
||||
vtlog "insmod $DaxModPath"
|
||||
insmod $DaxModPath
|
||||
fi
|
||||
|
||||
insmod $KoModPath
|
||||
|
||||
umount $VTOY_PATH/mnt
|
||||
|
@@ -35,14 +35,32 @@ fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
|
||||
vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||
vtlog "blkdev_num=$blkdev_num vtDM=$vtDM ..."
|
||||
|
||||
while [ -n "Y" ]; do
|
||||
if [ -b /dev/$vtDM ]; then
|
||||
break
|
||||
else
|
||||
sleep 0.3
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
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 "ln -s /dev/$vtDM $1"
|
||||
ln -s /dev/$vtDM "$1"
|
||||
else
|
||||
vtLABEL=$($BUSYBOX_PATH/blkid /dev/$vtDM | $SED 's/.*LABEL="\([^"]*\)".*/\1/')
|
||||
vtlog "vtLABEL is $vtLABEL"
|
||||
|
||||
if [ -z "$vtLABEL" ]; then
|
||||
vtLABEL=$($SED "s/.*label=\([^ ]*\)/\1/" /proc/cmdline)
|
||||
vtlog "vtLABEL is $vtLABEL from cmdline"
|
||||
fi
|
||||
|
||||
ln -s /dev/$vtDM "/dev/disk/by-label/$vtLABEL"
|
||||
fi
|
||||
|
||||
# OK finish
|
||||
set_ventoy_hook_finish
|
||||
|
||||
|
@@ -21,11 +21,23 @@
|
||||
|
||||
if $GREP -q '^"$mount_handler"' /init; then
|
||||
echo 'use mount_handler ...' >> $VTLOG
|
||||
$SED "/^\"\$mount_handler\"/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/arch/ventoy-disk.sh \"\$archisodevice\"" -i /init
|
||||
|
||||
if [ -f /hooks/archiso ]; then
|
||||
$SED '/while ! poll_device "${dev}"/a\ if /ventoy/busybox/sh /ventoy/hook/arch/ventoy-timeout.sh ${dev}; then break; fi' -i /hooks/archiso
|
||||
vthookfile=/hooks/archiso
|
||||
|
||||
if [ -e /hooks/miso ]; then
|
||||
vthookfile=/hooks/miso
|
||||
$SED "/^\"\$mount_handler\"/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/arch/ventoy-disk.sh \"\$misodevice\"" -i /init
|
||||
elif [ -e /hooks/artix ]; then
|
||||
vthookfile=/hooks/artix
|
||||
$SED "/^\"\$mount_handler\"/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/arch/ventoy-disk.sh \"\$artixdevice\"" -i /init
|
||||
else
|
||||
$SED "/^\"\$mount_handler\"/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/arch/ventoy-disk.sh \"\$archisodevice\"" -i /init
|
||||
fi
|
||||
|
||||
if [ -f $vthookfile ]; then
|
||||
$SED '/while ! poll_device "${dev}"/a\ if /ventoy/busybox/sh /ventoy/hook/arch/ventoy-timeout.sh ${dev}; then break; fi' -i $vthookfile
|
||||
fi
|
||||
|
||||
elif $GREP -q '^KEEP_SEARCHING' /init; then
|
||||
echo 'KEEP_SEARCHING found ...' >> $VTLOG
|
||||
$SED "/^KEEP_SEARCHING/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/arch/ovios-disk.sh " -i /init
|
||||
|
51
IMG/cpio/ventoy/hook/aryalinux/disk_hook.sh
Normal file
51
IMG/cpio/ventoy/hook/aryalinux/disk_hook.sh
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/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
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
mkdir /sys
|
||||
mount -t sysfs sys /sys
|
||||
|
||||
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/')
|
||||
blkdev_num_mknod=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
|
||||
vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||
|
||||
vtlog "blkdev_num=$blkdev_num blkdev_num_mknod=$blkdev_num_mknod vtDM=$vtDM"
|
||||
|
||||
if [ -b /dev/$vtDM ]; then
|
||||
vtlog "dev already exist ..."
|
||||
else
|
||||
vtlog "mknode dev ..."
|
||||
mknod -m 660 /dev/$vtDM b $blkdev_num_mknod
|
||||
fi
|
||||
|
||||
PATH=$VTPATH_OLD
|
26
IMG/cpio/ventoy/hook/aryalinux/ventoy-hook.sh
Normal file
26
IMG/cpio/ventoy/hook/aryalinux/ventoy-hook.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$BUSYBOX_PATH/mkdir /dev
|
||||
$BUSYBOX_PATH/mknod -m 660 /dev/console b 5 1
|
||||
|
||||
$SED "/for device in/i $BUSYBOX_PATH/sh $VTOY_PATH/hook/aryalinux/disk_hook.sh" -i /init
|
||||
#$SED "/for device in/i exec $BUSYBOX_PATH/sh" -i /init
|
25
IMG/cpio/ventoy/hook/blackPanther/ventoy-hook.sh
Normal file
25
IMG/cpio/ventoy/hook/blackPanther/ventoy-hook.sh
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
ventoy_set_inotify_script blackPanther/ventoy-inotifyd-hook.sh
|
||||
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/blackPanther/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/00-ventoy-inotifyd-start.sh
|
||||
|
||||
$SED "s#printf\(.*\)\$CMDLINE#printf\1 root=/dev/dm-0 \$CMDLINE root=/dev/dm-0#" -i /lib/dracut-lib.sh
|
46
IMG/cpio/ventoy/hook/blackPanther/ventoy-inotifyd-hook.sh
Normal file
46
IMG/cpio/ventoy/hook/blackPanther/ventoy-inotifyd-hook.sh
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if is_ventoy_hook_finished; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
if is_inotify_ventoy_part $3; then
|
||||
|
||||
vtlog "##### INOTIFYD: $2/$3 is created (YES) ..."
|
||||
|
||||
vtlog "find ventoy partition ..."
|
||||
$BUSYBOX_PATH/sh $VTOY_PATH/hook/default/udev_disk_hook.sh $3 noreplace
|
||||
|
||||
blkdev_num_dev=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
|
||||
if ! [ -e /dev/dm-0 ]; then
|
||||
mknod -m 660 /dev/dm-0 b $blkdev_num_dev
|
||||
fi
|
||||
blackPanther-root /dev/dm-0
|
||||
|
||||
set_ventoy_hook_finish
|
||||
else
|
||||
vtlog "##### INOTIFYD: $2/$3 is created (NO) ..."
|
||||
fi
|
||||
|
||||
PATH=$VTPATH_OLD
|
32
IMG/cpio/ventoy/hook/blackPanther/ventoy-inotifyd-start.sh
Normal file
32
IMG/cpio/ventoy/hook/blackPanther/ventoy-inotifyd-start.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/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
|
||||
|
||||
vtHook=$($CAT $VTOY_PATH/inotifyd-hook-script.txt)
|
||||
|
||||
vtdisk=$(get_ventoy_disk_name)
|
||||
if [ "$vtdisk" = "unknown" ]; then
|
||||
vtlog "... start inotifyd listen $vtHook ..."
|
||||
$BUSYBOX_PATH/nohup $VTOY_PATH/tool/inotifyd $vtHook /dev:n 2>&- &
|
||||
else
|
||||
vtlog "... $vtdisk already exist ..."
|
||||
$BUSYBOX_PATH/sh $vtHook n /dev "${vtdisk#/dev/}2"
|
||||
fi
|
||||
|
@@ -29,7 +29,7 @@ for i in 0 1 2 3 4 5 6 7 8 9; do
|
||||
fi
|
||||
done
|
||||
|
||||
ventoy_extract_vtloopex /dev/${vtdiskname#/dev/}2 crux
|
||||
ventoy_extract_vtloopex ${vtdiskname}2 crux
|
||||
|
||||
vtLoopExDir=$VTOY_PATH/vtloopex/crux/vtloopex
|
||||
$BUSYBOX_PATH/xz -d $vtLoopExDir/dm-mod/$(uname -r)/64/dax.ko.xz
|
||||
|
@@ -33,12 +33,11 @@ if [ -e /init ] && $GREP -q '^mountroot$' /init; then
|
||||
fi
|
||||
elif [ -e "$CD_DETECT" ]; then
|
||||
echo "$CD_DETECT exist, now add hook in it..." >> $VTLOG
|
||||
|
||||
$SED "1 a $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/disk_mount_hook.sh" -i "$CD_DETECT"
|
||||
TITLE_LINE=$($GREP -m1 '^hw-detect.*detect_progress_title' "$CD_DETECT")
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "add $TITLE_LINE for hook" >> $VTLOG
|
||||
$SED "1 a$TITLE_LINE" -i "$CD_DETECT"
|
||||
|
||||
if [ -e /bin/list-devices ]; then
|
||||
mv /bin/list-devices /bin/list-devices-bk
|
||||
cp -a /ventoy/hook/debian/list-devices /bin/list-devices
|
||||
fi
|
||||
elif [ -e /init ] && $GREP -q '/start-udev$' /init; then
|
||||
echo "Here use notify ..." >> $VTLOG
|
||||
@@ -60,3 +59,21 @@ if [ -f $VTOY_PATH/autoinstall ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
#for ARMA aka Omoikane
|
||||
if [ -f /mod.img ] && [ -f /mod/fs/cramfs.ko ]; then
|
||||
echo "mount mod.img and install dm-mod.ko" >> $VTLOG
|
||||
$BUSYBOX_PATH/insmod /mod/fs/cramfs.ko
|
||||
|
||||
$BUSYBOX_PATH/mkdir $VTOY_PATH/modmnt
|
||||
$BUSYBOX_PATH/mount /mod.img $VTOY_PATH/modmnt
|
||||
$BUSYBOX_PATH/insmod $VTOY_PATH/modmnt/md/dm-mod.ko
|
||||
$BUSYBOX_PATH/umount $VTOY_PATH/modmnt
|
||||
|
||||
$BUSYBOX_PATH/rmmod cramfs
|
||||
fi
|
||||
|
||||
#for siduction-patience-nox-
|
||||
if [ -f /scripts/fll ]; then
|
||||
$SED "/unset FINGERED/a\\echo '/dev/mapper/ventoy';return;" -i /scripts/fll
|
||||
fi
|
||||
|
||||
|
9
IMG/cpio/ventoy/hook/debian/list-devices
Normal file
9
IMG/cpio/ventoy/hook/debian/list-devices
Normal file
@@ -0,0 +1,9 @@
|
||||
#! /bin/sh
|
||||
|
||||
if [ "$1" = "usb-partition" -a -z "$2" ]; then
|
||||
if [ -f /ventoy/list-devices-usb-part ]; then
|
||||
cat /ventoy/list-devices-usb-part
|
||||
fi
|
||||
fi
|
||||
|
||||
/bin/list-devices-bk $*
|
43
IMG/cpio/ventoy/hook/debian/mll-disk.sh
Normal file
43
IMG/cpio/ventoy/hook/debian/mll-disk.sh
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if is_ventoy_hook_finished; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
vtlog "####### $0 $* ########"
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
PATH=$VTPATH_OLD
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
||||
set_ventoy_hook_finish
|
21
IMG/cpio/ventoy/hook/debian/mll-hook.sh
Normal file
21
IMG/cpio/ventoy/hook/debian/mll-hook.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
$SED "/^for DEVICE in/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/mll-disk.sh" -i /etc/02_overlay.sh
|
||||
|
@@ -42,6 +42,7 @@ if ! [ -e $VTOY_DM_PATH ]; then
|
||||
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
|
||||
mknod -m 0666 $VTOY_DM_PATH b $blkdev_num
|
||||
fi
|
||||
cp -a $VTOY_DM_PATH /dev/ventoy
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
||||
|
@@ -19,4 +19,4 @@
|
||||
|
||||
$SED '1 apmedia=usbhd' -i /init
|
||||
$SED "/^ *HAVE_PARTS=/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/puppy-disk.sh" -i /init
|
||||
$SED "/^ *HAVE_PARTS=/a\ HAVE_PARTS='mapper/ventoy|iso9660'" -i /init
|
||||
$SED "/^ *HAVE_PARTS=/a\ HAVE_PARTS='ventoy|iso9660'" -i /init
|
||||
|
@@ -47,7 +47,13 @@ ventoy_os_install_dmsetup() {
|
||||
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)
|
||||
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)
|
||||
fi
|
||||
fi
|
||||
install_udeb_from_line "$LINE" ${vt_usb_disk}
|
||||
fi
|
||||
@@ -127,15 +133,7 @@ else
|
||||
vtlog "boot=, or casper, don't mount"
|
||||
else
|
||||
vtlog "No boot param, need to mount"
|
||||
$BUSYBOX_PATH/mkdir /cdrom
|
||||
|
||||
if [ -b $VTOY_DM_PATH ]; then
|
||||
vtlog "mount $VTOY_DM_PATH ..."
|
||||
$BUSYBOX_PATH/mount -t iso9660 $VTOY_DM_PATH /cdrom
|
||||
else
|
||||
vtlog "mount /dev/$1 ..."
|
||||
$BUSYBOX_PATH/mount -t iso9660 /dev/$1 /cdrom
|
||||
fi
|
||||
echo /dev/$1 > /ventoy/list-devices-usb-part
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@@ -35,6 +35,8 @@ ventoy_get_debian_distro() {
|
||||
else
|
||||
echo 'puppy'; return
|
||||
fi
|
||||
elif $GREP -m1 -q 'Minimal.*Linux.*Live' /init; then
|
||||
echo 'mll'; return
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -76,10 +78,10 @@ DISTRO=$(ventoy_get_debian_distro)
|
||||
echo "##### distribution = $DISTRO ######" >> $VTLOG
|
||||
. $VTOY_PATH/hook/debian/${DISTRO}-hook.sh
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if [ -f /bin/env2debconf ]; then
|
||||
$SED "1a /bin/sh $VTOY_PATH/hook/debian/ventoy_env2debconf.sh" -i /bin/env2debconf
|
||||
$SED "s#in *\$(set)#in \$(cat /ventoy/envset)#" -i /bin/env2debconf
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
33
IMG/cpio/ventoy/hook/debian/ventoy_env2debconf.sh
Normal file
33
IMG/cpio/ventoy/hook/debian/ventoy_env2debconf.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
PATH=$PATH:/ventoy/busybox
|
||||
|
||||
set > /ventoy/tmpenvset
|
||||
|
||||
for i in $(cat /proc/cmdline); do
|
||||
if echo $i | grep -q "="; then
|
||||
vtKey=${i%=*}
|
||||
if ! grep -q "^$vtKey" /ventoy/tmpenvset; then
|
||||
echo $i >> /ventoy/envset
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
cat /ventoy/tmpenvset >> /ventoy/envset
|
@@ -22,3 +22,12 @@
|
||||
ventoy_systemd_udevd_work_around
|
||||
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k"
|
||||
|
||||
if [ -f /init ]; then
|
||||
vtSize=$($BUSYBOX_PATH/stat -c '%s' /init)
|
||||
if ! [ -L /init ]; then
|
||||
if [ $vtSize -eq 0 ]; then
|
||||
rm -f /init
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
41
IMG/cpio/ventoy/hook/dragora/disk_hook.sh
Normal file
41
IMG/cpio/ventoy/hook/dragora/disk_hook.sh
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/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
|
||||
|
||||
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_extract_vtloopex ${vtdiskname}2 dragora
|
||||
vtLoopExDir=$VTOY_PATH/vtloopex/dragora/vtloopex
|
||||
$BUSYBOX_PATH/xz -d $vtLoopExDir/dm-mod/$(uname -r)/64/dm-mod.ko.xz
|
||||
$BUSYBOX_PATH/insmod $vtLoopExDir/dm-mod/$(uname -r)/64/dm-mod.ko
|
||||
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
PATH=$VTPATH_OLD
|
22
IMG/cpio/ventoy/hook/dragora/ventoy-hook.sh
Normal file
22
IMG/cpio/ventoy/hook/dragora/ventoy-hook.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "/iso9660/i $BUSYBOX_PATH/sh $VTOY_PATH/hook/dragora/disk_hook.sh" -i /init
|
@@ -21,6 +21,9 @@
|
||||
|
||||
if $GREP -q kaspersky /proc/version; then
|
||||
$SED "/sysresccd_stage1_normal[^(]*$/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/gentoo/disk_hook.sh" -i /init
|
||||
if [ -f /ventoy/ventoy_persistent_map ]; then
|
||||
$SED "/sysresccd_parsecmdline[^(]*$/a\ BACKSTORE_CMD='LABEL=casper-rw,noloop'" -i /init
|
||||
fi
|
||||
elif [ -d /etc/udev/rules.d ] || [ -d /lib/udev/rules.d ]; then
|
||||
ventoy_systemd_udevd_work_around
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k noreplace"
|
||||
|
27
IMG/cpio/ventoy/hook/lunar/ventoy-hook.sh
Normal file
27
IMG/cpio/ventoy/hook/lunar/ventoy-hook.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE root=/dev/dm-0#" -i /lib/dracut-lib.sh
|
||||
|
||||
$BUSYBOX_PATH/rm -f /usr/lib/systemd/system-generators/systemd-fstab-generator /lib/systemd/system-generators/systemd-fstab-generator
|
||||
|
||||
ventoy_set_inotify_script lunar/ventoy-inotifyd-hook.sh
|
||||
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/lunar/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/01-ventoy-inotifyd-start.sh
|
45
IMG/cpio/ventoy/hook/lunar/ventoy-inotifyd-hook.sh
Normal file
45
IMG/cpio/ventoy/hook/lunar/ventoy-inotifyd-hook.sh
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/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
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
if is_inotify_ventoy_part $3; then
|
||||
|
||||
vtlog "##### INOTIFYD: $2/$3 is created (YES) ..."
|
||||
|
||||
vtlog "find ventoy partition ..."
|
||||
$BUSYBOX_PATH/sh $VTOY_PATH/hook/default/udev_disk_hook.sh $3 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})
|
||||
|
||||
mount -t iso9660 /dev/$vtDM /sysroot
|
||||
|
||||
set_ventoy_hook_finish
|
||||
else
|
||||
vtlog "##### INOTIFYD: $2/$3 is created (NO) ..."
|
||||
fi
|
||||
|
||||
PATH=$VTPATH_OLD
|
31
IMG/cpio/ventoy/hook/lunar/ventoy-inotifyd-start.sh
Normal file
31
IMG/cpio/ventoy/hook/lunar/ventoy-inotifyd-start.sh
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/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
|
||||
|
||||
vtHook=$($CAT $VTOY_PATH/inotifyd-hook-script.txt)
|
||||
|
||||
vtdisk=$(get_ventoy_disk_name)
|
||||
if [ "$vtdisk" = "unknown" ]; then
|
||||
vtlog "... start inotifyd listen $vtHook ..."
|
||||
$BUSYBOX_PATH/nohup $VTOY_PATH/tool/inotifyd $vtHook /dev:n 2>&- &
|
||||
else
|
||||
vtlog "... $vtdisk already exist ..."
|
||||
$BUSYBOX_PATH/sh $vtHook n /dev "${vtdisk#/dev/}2"
|
||||
fi
|
66
IMG/cpio/ventoy/hook/manjaro/ventoy-disk.sh
Normal file
66
IMG/cpio/ventoy/hook/manjaro/ventoy-disk.sh
Normal file
@@ -0,0 +1,66 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
vtlog "######### $0 $* ############"
|
||||
|
||||
if is_ventoy_hook_finished; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
|
||||
vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||
vtlog "blkdev_num=$blkdev_num vtDM=$vtDM ..."
|
||||
|
||||
while [ -n "Y" ]; do
|
||||
if [ -b /dev/$vtDM ]; then
|
||||
break
|
||||
else
|
||||
sleep 0.3
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
vtlog "ln -s /dev/$vtDM $1"
|
||||
ln -s /dev/$vtDM "$1"
|
||||
else
|
||||
vtLABEL=$($BUSYBOX_PATH/blkid /dev/$vtDM | $SED 's/.*LABEL="\([^"]*\)".*/\1/')
|
||||
vtlog "vtLABEL is $vtLABEL"
|
||||
|
||||
if [ -z "$vtLABEL" ]; then
|
||||
vtLABEL=$($SED "s/.*label=\([^ ]*\)/\1/" /proc/cmdline)
|
||||
vtlog "vtLABEL is $vtLABEL from cmdline"
|
||||
fi
|
||||
|
||||
ln -s /dev/$vtDM "/dev/disk/by-label/$vtLABEL"
|
||||
fi
|
||||
|
||||
# OK finish
|
||||
set_ventoy_hook_finish
|
@@ -28,8 +28,22 @@ else
|
||||
$CAT $VTOY_PATH/hook/default/13-dm-disk.rules > "$DISTRO_UDEV_DIR/13-dm-disk.rules"
|
||||
fi
|
||||
|
||||
|
||||
if $GREP -q '^mount_setup$' init; then
|
||||
if $GREP -q '^"$mount_handler"' /init; then
|
||||
echo 'use mount_handler ...' >> $VTLOG
|
||||
|
||||
vthookfile=/hooks/archiso
|
||||
|
||||
if [ -e /hooks/miso ]; then
|
||||
vthookfile=/hooks/miso
|
||||
$SED "/^\"\$mount_handler\"/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/manjaro/ventoy-disk.sh \"\$misodevice\"" -i /init
|
||||
else
|
||||
$SED "/^\"\$mount_handler\"/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/manjaro/ventoy-disk.sh \"\$archisodevice\"" -i /init
|
||||
fi
|
||||
|
||||
if [ -f $vthookfile ]; then
|
||||
$SED '/while ! poll_device "${dev}"/a\ if /ventoy/busybox/sh /ventoy/hook/manjaro/ventoy-timeout.sh ${dev}; then break; fi' -i $vthookfile
|
||||
fi
|
||||
elif $GREP -q '^mount_setup$' init; then
|
||||
echo "Here use notify ..." >> $VTLOG
|
||||
|
||||
ventoy_set_inotify_script manjaro/ventoy-inotifyd-hook.sh
|
||||
|
34
IMG/cpio/ventoy/hook/photon/ventoy-hook.sh
Normal file
34
IMG/cpio/ventoy/hook/photon/ventoy-hook.sh
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED 's#/dev/cdrom#/dev/ventoy#' -i /installer/isoInstaller.py
|
||||
|
||||
ventoy_set_inotify_script photon/ventoy-inotifyd-hook.sh
|
||||
|
||||
[ -d /dev ] || $BUSYBOX_PATH/mkdir /dev
|
||||
[ -d /sys ] || $BUSYBOX_PATH/mkdir /sys
|
||||
|
||||
$BUSYBOX_PATH/mount -t devtmpfs -o mode=0755,noexec,nosuid,strictatime devtmpfs /dev
|
||||
$BUSYBOX_PATH/mount -t sysfs sys /sys
|
||||
|
||||
$BUSYBOX_PATH/rm -f /init
|
||||
$BUSYBOX_PATH/sh $VTOY_PATH/hook/photon/ventoy-inotifyd-start.sh
|
||||
|
43
IMG/cpio/ventoy/hook/photon/ventoy-inotifyd-hook.sh
Normal file
43
IMG/cpio/ventoy/hook/photon/ventoy-inotifyd-hook.sh
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if is_ventoy_hook_finished; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
if is_inotify_ventoy_part $3; then
|
||||
|
||||
vtlog "##### INOTIFYD: $2/$3 is created (YES) ..."
|
||||
|
||||
vtlog "find ventoy partition ..."
|
||||
$BUSYBOX_PATH/sh $VTOY_PATH/hook/default/udev_disk_hook.sh $3 noreplace
|
||||
|
||||
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
|
||||
mknod -m 0660 /dev/ventoy b $blkdev_num
|
||||
|
||||
set_ventoy_hook_finish
|
||||
else
|
||||
vtlog "##### INOTIFYD: $2/$3 is created (NO) ..."
|
||||
fi
|
||||
|
||||
PATH=$VTPATH_OLD
|
31
IMG/cpio/ventoy/hook/photon/ventoy-inotifyd-start.sh
Normal file
31
IMG/cpio/ventoy/hook/photon/ventoy-inotifyd-start.sh
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/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
|
||||
|
||||
vtHook=$($CAT $VTOY_PATH/inotifyd-hook-script.txt)
|
||||
|
||||
vtdisk=$(get_ventoy_disk_name)
|
||||
if [ "$vtdisk" = "unknown" ]; then
|
||||
vtlog "... start inotifyd listen $vtHook ..."
|
||||
$BUSYBOX_PATH/nohup $VTOY_PATH/tool/inotifyd $vtHook /dev:n 2>&- &
|
||||
else
|
||||
vtlog "... $vtdisk already exist ..."
|
||||
$BUSYBOX_PATH/sh $vtHook n /dev "${vtdisk#/dev/}2"
|
||||
fi
|
47
IMG/cpio/ventoy/hook/pisilinux/ventoy-disk.sh
Normal file
47
IMG/cpio/ventoy/hook/pisilinux/ventoy-disk.sh
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if is_ventoy_hook_finished; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
vtlog "####### $0 $* ########"
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
PATH=$VTPATH_OLD
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
blkdev_num=$(dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
|
||||
mknod -m 660 /dev/ventoy b $blkdev_num
|
||||
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
||||
set_ventoy_hook_finish
|
24
IMG/cpio/ventoy/hook/pisilinux/ventoy-hook.sh
Normal file
24
IMG/cpio/ventoy/hook/pisilinux/ventoy-hook.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "/^\"\$mount_handler\"/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/pisilinux/ventoy-disk.sh" -i /init
|
||||
$SED "/^\"\$mount_handler\"/i\ export root=/dev/ventoy" -i /init
|
||||
|
38
IMG/cpio/ventoy/hook/ploplinux/disk_hook.sh
Normal file
38
IMG/cpio/ventoy/hook/ploplinux/disk_hook.sh
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
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/')
|
||||
mknod -m 0660 /dev/ventoy b $blkdev_num
|
||||
|
||||
PATH=$VTPATH_OLD
|
24
IMG/cpio/ventoy/hook/ploplinux/ventoy-hook.sh
Normal file
24
IMG/cpio/ventoy/hook/ploplinux/ventoy-hook.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "/export *CMDLINE/i CMDLINE=\"root=/dev/ventoy \${CMDLINE}\"" -i /etc/rc.d/init.d/rc.S
|
||||
$SED "1a $BUSYBOX_PATH/sh $VTOY_PATH/hook/ploplinux/disk_hook.sh" -i /etc/rc.d/init.d/rootmount
|
||||
|
38
IMG/cpio/ventoy/hook/rancher/disk_hook.sh
Normal file
38
IMG/cpio/ventoy/hook/rancher/disk_hook.sh
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
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/')
|
||||
mknod -m 0660 /dev/ventoy b $blkdev_num
|
||||
|
||||
PATH=$VTPATH_OLD
|
21
IMG/cpio/ventoy/hook/rancher/ventoy-hook.sh
Normal file
21
IMG/cpio/ventoy/hook/rancher/ventoy-hook.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
@@ -42,10 +42,17 @@ fi
|
||||
|
||||
echo "VTKS=$VTKS" >> $VTLOG
|
||||
|
||||
if ls $VTOY_PATH | $GREP -q 'ventoy_dud[0-9]'; then
|
||||
for vtDud in $(ls $VTOY_PATH/ventoy_dud*); do
|
||||
vtInstDD="$vtInstDD inst.dd=file:$vtDud"
|
||||
done
|
||||
fi
|
||||
echo "vtInstDD=$vtInstDD" >> $VTLOG
|
||||
|
||||
if $GREP -q 'root=live' /proc/cmdline; then
|
||||
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE root=live:/dev/dm-0 $VTKS#" -i /lib/dracut-lib.sh
|
||||
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE root=live:/dev/dm-0 $VTKS $vtInstDD#" -i /lib/dracut-lib.sh
|
||||
else
|
||||
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/dm-0 $VTKS#" -i /lib/dracut-lib.sh
|
||||
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/dm-0 $VTKS $vtInstDD#" -i /lib/dracut-lib.sh
|
||||
fi
|
||||
|
||||
ventoy_set_inotify_script rhel7/ventoy-inotifyd-hook.sh
|
||||
|
35
IMG/cpio/ventoy/hook/slackware/disk_hook.sh
Normal file
35
IMG/cpio/ventoy/hook/slackware/disk_hook.sh
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
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"
|
||||
|
||||
PATH=$VTPATH_OLD
|
@@ -2,7 +2,11 @@
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
ventoy_systemd_udevd_work_around
|
||||
if $GREP '^mediadetected=' /init; then
|
||||
$SED "/^mediadetected=/i $BUSYBOX_PATH/sh $VTOY_PATH/hook/slackware/disk_hook.sh" -i /init
|
||||
else
|
||||
ventoy_systemd_udevd_work_around
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/slackware/udev_disk_hook.sh %k noreplace"
|
||||
fi
|
||||
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/slackware/udev_disk_hook.sh %k noreplace"
|
||||
|
||||
|
42
IMG/cpio/ventoy/hook/smgl/disk_hook.sh
Normal file
42
IMG/cpio/ventoy/hook/smgl/disk_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
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
#exec /ventoy/busybox/sh
|
||||
|
||||
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/')
|
||||
mknod -m 660 /dev/ventoy b $blkdev_num
|
||||
|
||||
echo "/dev/ventoy" > cdrom.hint
|
||||
|
||||
PATH=$VTPATH_OLD
|
45
IMG/cpio/ventoy/hook/smgl/ventoy-hook.sh
Normal file
45
IMG/cpio/ventoy/hook/smgl/ventoy-hook.sh
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
PATH=$PATH:$VTOY_PATH/busybox
|
||||
|
||||
mkdir /ventoy_rdroot
|
||||
|
||||
mknod -m 660 /ram0 b 1 0
|
||||
|
||||
dd if=/initrd001 of=/ram0
|
||||
rm -f /initrd001
|
||||
|
||||
mount /ram0 /ventoy_rdroot
|
||||
|
||||
vtSize=$(du -m -s $VTOY_PATH | awk '{print $1}')
|
||||
let vtSize=vtSize+4
|
||||
|
||||
mkdir -p /ventoy_rdroot/ventoy
|
||||
mount -t tmpfs -o size=${vtSize}m tmpfs /ventoy_rdroot/ventoy
|
||||
cp -a /ventoy/* /ventoy_rdroot/ventoy/
|
||||
|
||||
|
||||
cd /ventoy_rdroot
|
||||
|
||||
sed "/scan_cdroms *$/i $BUSYBOX_PATH/sh $VTOY_PATH/hook/smgl/disk_hook.sh" -i sbin/smgl.init
|
||||
|
||||
|
33
IMG/cpio/ventoy/hook/smoothwall/cd_list.sh
Normal file
33
IMG/cpio/ventoy/hook/smoothwall/cd_list.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/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
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
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})
|
||||
vtSize=$(cat /sys/block/$vtDM/size)
|
||||
|
||||
cp -a /tmp/cd.list /tmp/cd_new.list
|
||||
echo "$vtDM $vtSize UNK_MODEL " > /tmp/cd.list
|
||||
cat /tmp/cd_new.list >> /tmp/cd.list
|
||||
rm -f /tmp/cd_new.list
|
||||
|
||||
PATH=$VTPATH_OLD
|
52
IMG/cpio/ventoy/hook/smoothwall/disk_hook.sh
Normal file
52
IMG/cpio/ventoy/hook/smoothwall/disk_hook.sh
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
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})
|
||||
|
||||
if [ "$1" = "fakecdrom" ]; then
|
||||
if [ -e /dev/sr0 ]; then
|
||||
for i in 0 1 2 3 4 5 6 7 8; do
|
||||
if ! [ -e /dev/sr$i ]; then
|
||||
mv /dev/sr0 /dev/sr$i
|
||||
cp -a /dev/$vtDM /dev/sr0
|
||||
break
|
||||
fi
|
||||
done
|
||||
else
|
||||
cp -a /dev/$vtDM /dev/sr0
|
||||
fi
|
||||
fi
|
||||
|
||||
PATH=$VTPATH_OLD
|
25
IMG/cpio/ventoy/hook/smoothwall/ventoy-hook.sh
Normal file
25
IMG/cpio/ventoy/hook/smoothwall/ventoy-hook.sh
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "/Running installer/i $BUSYBOX_PATH/sh $VTOY_PATH/hook/smoothwall/disk_hook.sh fakecdrom" -i /etc/install.rc
|
||||
|
||||
$SED "/cd \/sys\/block/a $BUSYBOX_PATH/sh $VTOY_PATH/hook/smoothwall/disk_hook.sh" -i /etc/config-install.rc
|
||||
$SED "/wc *-l *\/tmp\/cd.list/i $BUSYBOX_PATH/sh $VTOY_PATH/hook/smoothwall/cd_list.sh" -i /etc/config-install.rc
|
64
IMG/cpio/ventoy/hook/suse/disk_hook.sh
Normal file
64
IMG/cpio/ventoy/hook/suse/disk_hook.sh
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/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
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
|
||||
ventoy_os_install_dmsetup_by_fuse() {
|
||||
vtlog "ventoy_os_install_dmsetup_by_fuse $*"
|
||||
|
||||
mkdir -p $VTOY_PATH/mnt/fuse $VTOY_PATH/mnt/iso $VTOY_PATH/mnt/squashfs
|
||||
|
||||
vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_dm_table
|
||||
vtoy_fuse_iso -f $VTOY_PATH/ventoy_dm_table -m $VTOY_PATH/mnt/fuse
|
||||
|
||||
mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso $VTOY_PATH/mnt/iso
|
||||
|
||||
mount -t squashfs $VTOY_PATH/mnt/iso/system/squashfs_sys.img $VTOY_PATH/mnt/squashfs
|
||||
|
||||
KoName=$(ls $VTOY_PATH/mnt/squashfs/lib/modules/$2/kernel/drivers/md/dm-mod.ko*)
|
||||
vtlog "insmod $KoName"
|
||||
insmod $KoName
|
||||
|
||||
umount $VTOY_PATH/mnt/squashfs 2>>$VTLOG
|
||||
umount $VTOY_PATH/mnt/iso 2>>$VTLOG
|
||||
umount $VTOY_PATH/mnt/fuse 2>>$VTLOG
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
|
||||
modprobe fuse
|
||||
ventoy_os_install_dmsetup_by_fuse $vtdiskname $(uname -r)
|
||||
|
||||
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/')
|
||||
mknod -m 0660 /dev/ventoy b $blkdev_num
|
||||
|
||||
PATH=$VTPATH_OLD
|
@@ -26,10 +26,45 @@ if [ -f $VTOY_PATH/autoinstall ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if $BUSYBOX_PATH/ls $VTOY_PATH | $GREP -q 'ventoy_dud[0-9]'; then
|
||||
if [ -f /linuxrc.config ]; then
|
||||
vtKerVer=$($BUSYBOX_PATH/uname -r)
|
||||
ventoy_check_insmod /modules/loop.ko
|
||||
ventoy_check_insmod /modules/squashfs.ko
|
||||
|
||||
ventoy_check_mount /parts/00_lib /modules
|
||||
ventoy_check_insmod /modules/lib/modules/$vtKerVer/initrd/isofs.ko
|
||||
$BUSYBOX_PATH/umount /modules
|
||||
|
||||
for vtDud in $($BUSYBOX_PATH/ls $VTOY_PATH/ventoy_dud*); do
|
||||
$BUSYBOX_PATH/mkdir -p ${vtDud%.*}_mnt
|
||||
if $BUSYBOX_PATH/mount $vtDud ${vtDud%.*}_mnt > /dev/null 2>&1; then
|
||||
$BUSYBOX_PATH/cp -a ${vtDud%.*}_mnt ${vtDud%.*}_data
|
||||
$BUSYBOX_PATH/umount ${vtDud%.*}_mnt
|
||||
echo "dud: file://${vtDud%.*}_data" >> /linuxrc.config
|
||||
else
|
||||
echo "mount $vtDud failed" >> $VTLOG
|
||||
fi
|
||||
done
|
||||
|
||||
$BUSYBOX_PATH/rmmod isofs >> $VTLOG 2>&1
|
||||
$BUSYBOX_PATH/rmmod squashfs >> $VTLOG 2>&1
|
||||
$BUSYBOX_PATH/rmmod loop >> $VTLOG 2>&1
|
||||
fi
|
||||
fi
|
||||
|
||||
#echo "Exec: /bin/sh $VTOY_PATH/hook/suse/cdrom-hook.sh" >> /info-ventoy
|
||||
#echo "install: hd:/?device=/dev/mapper/ventoy" >> /info-ventoy
|
||||
#$SED "1 iinfo: file:/info-ventoy" -i /linuxrc.config
|
||||
|
||||
ventoy_systemd_udevd_work_around
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/suse/udev_disk_hook.sh %k"
|
||||
if [ -e /etc/initrd.functions ] && $GREP -q 'HPIP' /etc/initrd.functions; then
|
||||
echo "HPIP" >> $VTLOG
|
||||
$BUSYBOX_PATH/mkdir /dev
|
||||
$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
|
||||
else
|
||||
echo "SUSE" >> $VTLOG
|
||||
ventoy_systemd_udevd_work_around
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/suse/udev_disk_hook.sh %k"
|
||||
fi
|
||||
|
47
IMG/cpio/ventoy/hook/t2/disk_hook.sh
Normal file
47
IMG/cpio/ventoy/hook/t2/disk_hook.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
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
modprobe dm-mod
|
||||
|
||||
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/')
|
||||
mknod -m 0660 /dev/ventoy b $blkdev_num
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
||||
set_ventoy_hook_finish
|
||||
|
24
IMG/cpio/ventoy/hook/t2/ventoy-hook.sh
Normal file
24
IMG/cpio/ventoy/hook/t2/ventoy-hook.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "/getdevice *devicefile/i $BUSYBOX_PATH/sh $VTOY_PATH/hook/t2/disk_hook.sh" -i /init
|
||||
$SED "/getdevice *devicefile/a devicefile=/dev/ventoy" -i /init
|
||||
|
@@ -87,7 +87,13 @@ wait_for_usb_disk_ready() {
|
||||
usb_disk=$(get_ventoy_disk_name)
|
||||
vtlog "wait_for_usb_disk_ready $usb_disk ..."
|
||||
|
||||
if [ -e "${usb_disk}2" ]; then
|
||||
if echo $usb_disk | $EGREP -q "nvme|mmc"; then
|
||||
vtpart2=${usb_disk}p2
|
||||
else
|
||||
vtpart2=${usb_disk}2
|
||||
fi
|
||||
|
||||
if [ -e "${vtpart2}" ]; then
|
||||
vtlog "wait_for_usb_disk_ready $usb_disk finish"
|
||||
break
|
||||
else
|
||||
@@ -105,7 +111,13 @@ is_ventoy_disk() {
|
||||
}
|
||||
|
||||
not_ventoy_disk() {
|
||||
if $VTOY_PATH/tool/vtoydump -f $VTOY_PATH/ventoy_os_param -c "$1"; then
|
||||
if echo $1 | $EGREP -q "nvme.*p$|mmc.*p$"; then
|
||||
vtDiskName=${1:0:-1}
|
||||
else
|
||||
vtDiskName=$1
|
||||
fi
|
||||
|
||||
if $VTOY_PATH/tool/vtoydump -f $VTOY_PATH/ventoy_os_param -c "$vtDiskName"; then
|
||||
$BUSYBOX_PATH/false
|
||||
else
|
||||
$BUSYBOX_PATH/true
|
||||
@@ -343,6 +355,37 @@ extract_file_from_line() {
|
||||
fi
|
||||
}
|
||||
|
||||
extract_rpm_from_line() {
|
||||
vtlog "extract_rpm_from_line $1 disk=#$2#"
|
||||
|
||||
if ! [ -b "$2" ]; then
|
||||
vterr "disk #$2# not exist"
|
||||
return
|
||||
fi
|
||||
|
||||
sector=$(echo $1 | $AWK '{print $(NF-1)}')
|
||||
length=$(echo $1 | $AWK '{print $NF}')
|
||||
vtlog "sector=$sector length=$length"
|
||||
|
||||
$VTOY_PATH/tool/vtoydm -e -f $VTOY_PATH/ventoy_image_map -d ${2} -s $sector -l $length -o /tmp/xxx.rpm
|
||||
if [ -e /tmp/xxx.rpm ]; then
|
||||
vtlog "extract rpm file from iso success"
|
||||
else
|
||||
vterr "extract rpm file from iso fail"
|
||||
return
|
||||
fi
|
||||
|
||||
CURPWD=$($BUSYBOX_PATH/pwd)
|
||||
|
||||
$BUSYBOX_PATH/mkdir -p $VTOY_PATH/rpm
|
||||
cd $VTOY_PATH/rpm
|
||||
vtlog "extract rpm..."
|
||||
$BUSYBOX_PATH/rpm2cpio /tmp/xxx.rpm | $BUSYBOX_PATH/cpio -idm 2>>$VTLOG
|
||||
cd $CURPWD
|
||||
|
||||
$BUSYBOX_PATH/rm -f /tmp/xxx.rpm
|
||||
}
|
||||
|
||||
install_rpm_from_line() {
|
||||
vtlog "install_rpm_from_line $1 disk=#$2#"
|
||||
|
||||
@@ -432,9 +475,12 @@ ventoy_create_persistent_link() {
|
||||
fi
|
||||
}
|
||||
|
||||
ventoy_udev_disk_common_hook() {
|
||||
|
||||
VTDISK="${1:0:-1}"
|
||||
ventoy_udev_disk_common_hook() {
|
||||
if echo $1 | $EGREP -q "nvme.*p[0-9]$|mmc.*p[0-9]$"; then
|
||||
VTDISK="${1:0:-2}"
|
||||
else
|
||||
VTDISK="${1:0:-1}"
|
||||
fi
|
||||
|
||||
if [ -e /vtoy/vtoy ]; then
|
||||
VTRWMOD=""
|
||||
@@ -502,8 +548,14 @@ is_inotify_ventoy_part() {
|
||||
if echo $1 | $GREP -q "2$"; then
|
||||
if ! [ -e /sys/block/$1 ]; then
|
||||
if [ -e /sys/class/block/$1 ]; then
|
||||
if [ -e /dev/${1:0:-1} ]; then
|
||||
$VTOY_PATH/tool/vtoydump -f $VTOY_PATH/ventoy_os_param -c ${1:0:-1}
|
||||
if echo $1 | $EGREP -q "nvme|mmc"; then
|
||||
vtShortName=${1:0:-2}
|
||||
else
|
||||
vtShortName=${1:0:-1}
|
||||
fi
|
||||
|
||||
if [ -e /dev/$vtShortName ]; then
|
||||
$VTOY_PATH/tool/vtoydump -f $VTOY_PATH/ventoy_os_param -c $vtShortName
|
||||
return
|
||||
fi
|
||||
fi
|
||||
@@ -535,9 +587,9 @@ ventoy_swap_device() {
|
||||
ventoy_extract_vtloopex() {
|
||||
vtCurPwd=$PWD
|
||||
$BUSYBOX_PATH/mkdir -p $VTOY_PATH/partmnt $VTOY_PATH/vtloopex
|
||||
$BUSYBOX_PATH/mount -o ro -t vfat /dev/${vtdiskname#/dev/}2 $VTOY_PATH/partmnt
|
||||
$BUSYBOX_PATH/mount -o ro -t vfat $1 $VTOY_PATH/partmnt
|
||||
cd $VTOY_PATH/vtloopex
|
||||
$CAT $VTOY_PATH/partmnt/ventoy/vtloopex.cpio | $BUSYBOX_PATH/cpio -idm
|
||||
$CAT $VTOY_PATH/partmnt/ventoy/vtloopex.cpio | $BUSYBOX_PATH/cpio -idm >> $VTLOG 2>&1
|
||||
$BUSYBOX_PATH/umount $VTOY_PATH/partmnt
|
||||
$BUSYBOX_PATH/rm -rf $VTOY_PATH/partmnt
|
||||
|
||||
|
@@ -110,4 +110,14 @@ ventoy_set_loop_inotify_script() {
|
||||
echo $VTOY_PATH/loop/$1 > $VTOY_PATH/inotifyd-loop-script.txt
|
||||
}
|
||||
|
||||
ventoy_check_insmod() {
|
||||
if [ -e $1 ]; then
|
||||
$BUSYBOX_PATH/insmod $1
|
||||
fi
|
||||
}
|
||||
|
||||
ventoy_check_mount() {
|
||||
if [ -e $1 ]; then
|
||||
$BUSYBOX_PATH/mount $1 $2
|
||||
fi
|
||||
}
|
||||
|
@@ -19,21 +19,20 @@
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
while [ -n "1" ]; do
|
||||
if [ -e /dev/null ]; then
|
||||
break
|
||||
else
|
||||
$SLEEP 0.5
|
||||
fi
|
||||
done
|
||||
vine_wait_for_exist() {
|
||||
while [ -n "1" ]; do
|
||||
if [ -e $1 ]; then
|
||||
break
|
||||
else
|
||||
$SLEEP 0.5
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
vine_wait_for_exist /dev/null
|
||||
vine_wait_for_exist /sys/block
|
||||
vine_wait_for_exist /proc/ide
|
||||
|
||||
while [ -n "1" ]; do
|
||||
if [ -e /sys/block ]; then
|
||||
break
|
||||
else
|
||||
$SLEEP 0.5
|
||||
fi
|
||||
done
|
||||
|
||||
while [ -n "Y" ]; do
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
@@ -51,13 +50,14 @@ if ! [ -b $vtdiskname ]; then
|
||||
$BUSYBOX_PATH/mknod -m 0660 $vtdiskname b $blkdev
|
||||
fi
|
||||
|
||||
if ! [ -b "${vtdiskname}1" ]; then
|
||||
blkdev=$($CAT /sys/class/block/${vtshortdev}1/dev | $SED 's/:/ /g')
|
||||
$BUSYBOX_PATH/mknod -m 0660 "${vtdiskname}1" b $blkdev
|
||||
fi
|
||||
|
||||
if ! [ -b "${vtdiskname}2" ]; then
|
||||
blkdev=$($CAT /sys/class/block/${vtshortdev}2/dev | $SED 's/:/ /g')
|
||||
$BUSYBOX_PATH/mknod -m 0660 "${vtdiskname}2" b $blkdev
|
||||
fi
|
||||
|
||||
$BUSYBOX_PATH/ls /dev/ > /dev/console
|
||||
|
||||
$BUSYBOX_PATH/sh $VTOY_PATH/hook/vine/udev_disk_hook.sh "${vtdiskname#/dev/}2"
|
||||
|
||||
|
||||
|
@@ -19,10 +19,27 @@
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
vtCheatLoop=loop6
|
||||
ventoy_os_install_dmsetup_by_ko() {
|
||||
vtlog "ventoy_os_install_dmsetup_by_ko $1"
|
||||
|
||||
vtVer=$($BUSYBOX_PATH/uname -r)
|
||||
if $BUSYBOX_PATH/uname -m | $GREP -q 64; then
|
||||
vtBit=64
|
||||
else
|
||||
vtBit=32
|
||||
fi
|
||||
|
||||
ventoy_extract_vtloopex $1 vine
|
||||
vtLoopExDir=$VTOY_PATH/vtloopex/vine/vtloopex
|
||||
|
||||
if [ -e $vtLoopExDir/dm-mod/$vtVer/$vtBit/dm-mod.ko.xz ]; then
|
||||
$BUSYBOX_PATH/xz -d $vtLoopExDir/dm-mod/$vtVer/$vtBit/dm-mod.ko.xz
|
||||
insmod $vtLoopExDir/dm-mod/$vtVer/$vtBit/dm-mod.ko
|
||||
fi
|
||||
}
|
||||
|
||||
ventoy_os_install_dmsetup() {
|
||||
vtlog "ventoy_os_install_dmsetup $1"
|
||||
ventoy_os_install_dmsetup_by_rpm() {
|
||||
vtlog "ventoy_os_install_dmsetup_by_rpm $1"
|
||||
|
||||
vt_usb_disk=$1
|
||||
|
||||
@@ -32,48 +49,47 @@ ventoy_os_install_dmsetup() {
|
||||
# install dmsetup
|
||||
LINE=$($GREP 'kernel-[0-9].*\.rpm' $VTOY_PATH/iso_file_list)
|
||||
if [ $? -eq 0 ]; then
|
||||
install_rpm_from_line "$LINE" ${vt_usb_disk}
|
||||
extract_rpm_from_line "$LINE" ${vt_usb_disk}
|
||||
fi
|
||||
|
||||
$BUSYBOX_PATH/modprobe dm-mod
|
||||
vtKoName=$($BUSYBOX_PATH/find $VTOY_PATH/rpm/ -name dm-mod.ko*)
|
||||
vtlog "vtKoName=$vtKoName"
|
||||
|
||||
vtlog "dmsetup install finish, now check it..."
|
||||
insmod $vtKoName
|
||||
|
||||
dmsetup_path=/ventoy/tool/dmsetup
|
||||
if [ -z "$dmsetup_path" ]; then
|
||||
vterr "dmsetup still not found after install"
|
||||
elif $dmsetup_path info >> $VTLOG 2>&1; then
|
||||
vtlog "$dmsetup_path work ok"
|
||||
else
|
||||
vterr "$dmsetup_path not work"
|
||||
fi
|
||||
$BUSYBOX_PATH/rm -rf $VTOY_PATH/rpm/
|
||||
}
|
||||
|
||||
|
||||
if is_ventoy_hook_finished || not_ventoy_disk "${1:0:-1}"; then
|
||||
# /dev/vtCheatLoop come first
|
||||
if [ "$1" = "$vtCheatLoop" ] && [ -b $VTOY_DM_PATH ]; then
|
||||
ventoy_copy_device_mapper /dev/$vtCheatLoop
|
||||
fi
|
||||
if is_ventoy_hook_finished || not_ventoy_disk "${1:0:-1}"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_os_install_dmsetup "/dev/${1:0:-1}"
|
||||
ventoy_os_install_dmsetup_by_ko "/dev/$1"
|
||||
if $GREP -q 'device.mapper' /proc/devices; then
|
||||
vtlog "device-mapper module install OK"
|
||||
else
|
||||
ventoy_os_install_dmsetup_by_rpm "/dev/${1:0:-1}"
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook $* "noreplace"
|
||||
ventoy_udev_disk_common_hook $*
|
||||
|
||||
$BUSYBOX_PATH/mount $VTOY_DM_PATH /mnt/ventoy
|
||||
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | $GREP ventoy | $SED 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
|
||||
blkdev_num_dev=$($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})
|
||||
|
||||
#
|
||||
# We do a trick for rhel6 series here.
|
||||
# Use /dev/$vtCheatLoop and wapper it as a removable cdrom with bind mount.
|
||||
# Then the anaconda installer will accept /dev/$vtCheatLoop as the install medium.
|
||||
#
|
||||
ventoy_copy_device_mapper /dev/$vtCheatLoop
|
||||
[ -b /dev/$vtDM ] || $BUSYBOX_PATH/mknod -m 0660 /dev/$vtDM b $blkdev_num_dev
|
||||
$BUSYBOX_PATH/rm -rf /dev/mapper
|
||||
|
||||
#Create a fake IDE-CDROM driver can't be ide-scsi /proc has been patched to /vtoy
|
||||
$BUSYBOX_PATH/mkdir -p /vtoy
|
||||
$BUSYBOX_PATH/cp -a /proc/ide /vtoy/
|
||||
$BUSYBOX_PATH/mkdir -p /vtoy/ide/aztcd
|
||||
|
||||
echo 'ide' > /vtoy/ide/aztcd/driver
|
||||
echo 'cdrom' > /vtoy/ide/aztcd/media
|
||||
|
||||
$BUSYBOX_PATH/cp -a /sys/devices/virtual/block/$vtCheatLoop /tmp/ >> $VTLOG 2>&1
|
||||
echo 19 > /tmp/$vtCheatLoop/capability
|
||||
$BUSYBOX_PATH/mount --bind /tmp/$vtCheatLoop /sys/block/$vtCheatLoop >> $VTLOG 2>&1
|
||||
|
||||
# OK finish
|
||||
set_ventoy_hook_finish
|
||||
|
||||
exit 0
|
||||
|
@@ -19,10 +19,8 @@
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$BUSYBOX_PATH/mkdir -p /etc/anaconda.repos.d /mnt/ventoy
|
||||
ventoy_print_yum_repo "ventoy" "file:///mnt/ventoy" > /etc/anaconda.repos.d/ventoy.repo
|
||||
|
||||
$BUSYBOX_PATH/cp -a /sbin/loader /sbin/loader_bk
|
||||
$VTOY_PATH/tool/vine_patch_loader /sbin/loader 253 -v >> $VTLOG
|
||||
|
||||
$BUSYBOX_PATH/mknod -m 0660 /dev/null c 1 3
|
||||
$VTOY_PATH/hook/vine/dev-listen.sh &
|
||||
|
||||
|
48
IMG/cpio/ventoy/hook/wifislax/disk_hook.sh
Normal file
48
IMG/cpio/ventoy/hook/wifislax/disk_hook.sh
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/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
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
vtlog "##### $0 $* #####"
|
||||
|
||||
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"
|
||||
|
||||
while true; do
|
||||
if blkid | grep -q '/dev/dm'; then
|
||||
vtlog 'Find /dev/dm ...'
|
||||
break
|
||||
else
|
||||
vtlog 'Wait /dev/dm ...'
|
||||
sleep 0.3
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
PATH=$VTPATH_OLD
|
26
IMG/cpio/ventoy/hook/wifislax/ventoy-hook.sh
Normal file
26
IMG/cpio/ventoy/hook/wifislax/ventoy-hook.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "/mount.*devtmpfs/a $BUSYBOX_PATH/sh $VTOY_PATH/hook/wifislax/disk_hook.sh" -i /linuxrc
|
||||
|
||||
#replace original blkid
|
||||
$BUSYBOX_PATH/rm -f /usr/bin/blkid
|
||||
$BUSYBOX_PATH/cp -a $BUSYBOX_PATH/blkid /usr/bin/blkid
|
@@ -37,9 +37,11 @@ else
|
||||
fi
|
||||
|
||||
ventoy_is_initrd_ramdisk() {
|
||||
#As I known, PCLinuxOS use ramdisk
|
||||
#As I known, PCLinuxOS/smgl use ramdisk
|
||||
if echo $vtkerver | grep -i -q 'PCLinuxOS'; then
|
||||
true
|
||||
elif echo $vtkerver | grep -i -q 'SMGL-'; then
|
||||
true
|
||||
else
|
||||
false
|
||||
fi
|
||||
@@ -68,7 +70,7 @@ ventoy_unpack_initramfs() {
|
||||
return
|
||||
fi
|
||||
|
||||
for vtx in '1F8B zcat' '1F9E zcat' '425A bzcat' '5D00 lzcat' 'FD37 xzcat' '894C lzopcat' '0221 lz4cat' '28B5 zstdcat' '3037 cat'; do
|
||||
for vtx in '1F8B zcat' '1F9E zcat' '425A bzcat' '5D00 lzcat' 'FD37 xzcat' '894C lzopcat' '0221 lz4cat' '28B5 zstdcat' '3037 cat' '4C5A lunzip -c'; do
|
||||
if [ "${vtx:0:4}" = "${vtmagic:0:4}" ]; then
|
||||
echo "vtx=$vtx" >> $VTLOG
|
||||
if [ $vtskip -eq 0 ]; then
|
||||
|
62
IMG/cpio/ventoy/loop/LibreELEC/ventoy-disk.sh
Normal file
62
IMG/cpio/ventoy/loop/LibreELEC/ventoy-disk.sh
Normal file
@@ -0,0 +1,62 @@
|
||||
#!/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
|
||||
|
||||
vtKerVer=$(uname -r)
|
||||
if uname -m | grep -q 64; then
|
||||
vtBit=64
|
||||
else
|
||||
vtBit=32
|
||||
fi
|
||||
|
||||
xz -d $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko.xz
|
||||
insmod $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko
|
||||
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
PATH=$VTPATH_OLD
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
ventoy_create_dev_ventoy_part
|
||||
|
||||
mkdir /ventoy/mnt
|
||||
mount /dev/ventoy2 /ventoy/mnt
|
||||
rm -f /ventoy/mnt/.please_resize_me
|
||||
sync
|
||||
umount /ventoy/mnt
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
||||
set_ventoy_hook_finish
|
23
IMG/cpio/ventoy/loop/LibreELEC/ventoy-hook.sh
Normal file
23
IMG/cpio/ventoy/loop/LibreELEC/ventoy-hook.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "/mount_flash.*{/a\ $BUSYBOX_PATH/sh $VTOY_PATH/loop/LibreELEC/ventoy-disk.sh" -i /init
|
||||
|
45
IMG/cpio/ventoy/loop/batocera/ventoy-disk.sh
Normal file
45
IMG/cpio/ventoy/loop/batocera/ventoy-disk.sh
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if is_ventoy_hook_finished; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
vtlog "####### $0 $* ########"
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
PATH=$VTPATH_OLD
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
ventoy_create_dev_ventoy_part
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
||||
set_ventoy_hook_finish
|
23
IMG/cpio/ventoy/loop/batocera/ventoy-hook.sh
Normal file
23
IMG/cpio/ventoy/loop/batocera/ventoy-hook.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "/mount.*devtmpfs/a\ $BUSYBOX_PATH/sh $VTOY_PATH/loop/batocera/ventoy-disk.sh" -i /init
|
||||
|
47
IMG/cpio/ventoy/loop/freedombox/ventoy-disk.sh
Normal file
47
IMG/cpio/ventoy/loop/freedombox/ventoy-disk.sh
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if is_ventoy_hook_finished; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
vtlog "####### $0 $* ########"
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
insmod $VTOY_PATH/modules/dm-mod.ko
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
PATH=$VTPATH_OLD
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
ventoy_create_dev_ventoy_part
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
||||
set_ventoy_hook_finish
|
22
IMG/cpio/ventoy/loop/freedombox/ventoy-hook.sh
Normal file
22
IMG/cpio/ventoy/loop/freedombox/ventoy-hook.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "/local_mount_root *$/i $BUSYBOX_PATH/sh $VTOY_PATH/loop/freedombox/ventoy-disk.sh" -i /scripts/local
|
62
IMG/cpio/ventoy/loop/lakka/ventoy-disk.sh
Normal file
62
IMG/cpio/ventoy/loop/lakka/ventoy-disk.sh
Normal file
@@ -0,0 +1,62 @@
|
||||
#!/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
|
||||
|
||||
vtKerVer=$(uname -r)
|
||||
if uname -m | grep -q 64; then
|
||||
vtBit=64
|
||||
else
|
||||
vtBit=32
|
||||
fi
|
||||
|
||||
xz -d $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko.xz
|
||||
insmod $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko
|
||||
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
PATH=$VTPATH_OLD
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
ventoy_create_dev_ventoy_part
|
||||
|
||||
mkdir /ventoy/mnt
|
||||
mount /dev/ventoy2 /ventoy/mnt
|
||||
rm -f /ventoy/mnt/.please_resize_me
|
||||
sync
|
||||
umount /ventoy/mnt
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
||||
set_ventoy_hook_finish
|
23
IMG/cpio/ventoy/loop/lakka/ventoy-hook.sh
Normal file
23
IMG/cpio/ventoy/loop/lakka/ventoy-hook.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "/mount_flash.*{/a\ $BUSYBOX_PATH/sh $VTOY_PATH/loop/lakka/ventoy-disk.sh" -i /init
|
||||
|
47
IMG/cpio/ventoy/loop/paldo/ventoy-disk.sh
Normal file
47
IMG/cpio/ventoy/loop/paldo/ventoy-disk.sh
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if is_ventoy_hook_finished; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
vtlog "####### $0 $* ########"
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
modprobe dm-mod
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
PATH=$VTPATH_OLD
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
ventoy_create_dev_ventoy_part
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
||||
set_ventoy_hook_finish
|
22
IMG/cpio/ventoy/loop/paldo/ventoy-hook.sh
Normal file
22
IMG/cpio/ventoy/loop/paldo/ventoy-hook.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "/for *dev *in .*root/i $BUSYBOX_PATH/sh $VTOY_PATH/loop/paldo/ventoy-disk.sh" -i /init
|
45
IMG/cpio/ventoy/loop/recalbox/ventoy-disk.sh
Normal file
45
IMG/cpio/ventoy/loop/recalbox/ventoy-disk.sh
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if is_ventoy_hook_finished; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
vtlog "####### $0 $* ########"
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
PATH=$VTPATH_OLD
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
ventoy_create_dev_ventoy_part
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
||||
set_ventoy_hook_finish
|
23
IMG/cpio/ventoy/loop/recalbox/ventoy-hook.sh
Normal file
23
IMG/cpio/ventoy/loop/recalbox/ventoy-hook.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "/mount.*devtmpfs/a\ $BUSYBOX_PATH/sh $VTOY_PATH/loop/recalbox/ventoy-disk.sh" -i /init
|
||||
|
26
IMG/cpio/ventoy/loop/ubos/newroot-hook.sh
Normal file
26
IMG/cpio/ventoy/loop/ubos/newroot-hook.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
sed "/.* \/boot /d" -i /new_root/etc/fstab
|
||||
|
||||
PATH=$VTPATH_OLD
|
48
IMG/cpio/ventoy/loop/ubos/ventoy-disk.sh
Normal file
48
IMG/cpio/ventoy/loop/ubos/ventoy-disk.sh
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/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
|
||||
|
||||
xz -d $VTOY_PATH/modules/dm-mod.ko.xz
|
||||
insmod $VTOY_PATH/modules/dm-mod.ko
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
PATH=$VTPATH_OLD
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
ventoy_create_dev_ventoy_part
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
||||
set_ventoy_hook_finish
|
30
IMG/cpio/ventoy/loop/ubos/ventoy-hook.sh
Normal file
30
IMG/cpio/ventoy/loop/ubos/ventoy-hook.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/default/10-dm.rules /lib/udev/rules.d/
|
||||
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/default/13-dm-disk.rules /lib/udev/rules.d/
|
||||
|
||||
$SED "/^\"\$mount_handler\"/i\ $BUSYBOX_PATH/sh $VTOY_PATH/loop/ubos/ventoy-disk.sh" -i /init
|
||||
|
||||
$SED "/^\"\$mount_handler\"/a\ $BUSYBOX_PATH/sh $VTOY_PATH/loop/ubos/newroot-hook.sh" -i /init
|
||||
|
||||
$SED "/^\"\$mount_handler\"/a\ init=/usr/lib/systemd/systemd" -i /init
|
||||
|
@@ -53,6 +53,7 @@ else
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if $VTOY_PATH/tool/unsquashfs_64 -t 2>>$VTLOG; then
|
||||
echo "use unsquashfs_64" >>$VTLOG
|
||||
$BUSYBOX_PATH/cp -a $VTOY_PATH/tool/unsquashfs_64 $VTOY_PATH/tool/vtoy_unsquashfs
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user