Commit 8dce0add authored by longpanda's avatar longpanda
Browse files

update for new release

parent 1bf3e733
...@@ -146,6 +146,14 @@ ...@@ -146,6 +146,14 @@
https://busybox.net/downloads/busybox-1.32.0.tar.bz2 https://busybox.net/downloads/busybox-1.32.0.tar.bz2
use BUSYBOX/64h.config and uclibc to build busybox-1.32 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 5. Binaries
......
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
\ No newline at end of file
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <Ventoy.h> #include <Ventoy.h>
BOOLEAN gDebugPrint = FALSE; BOOLEAN gDebugPrint = FALSE;
BOOLEAN gDotEfiBoot = FALSE;
BOOLEAN gLoadIsoEfi = FALSE; BOOLEAN gLoadIsoEfi = FALSE;
ventoy_ram_disk g_ramdisk_param; ventoy_ram_disk g_ramdisk_param;
ventoy_chain_head *g_chain; ventoy_chain_head *g_chain;
...@@ -49,6 +50,7 @@ ventoy_virt_chunk *g_virt_chunk; ...@@ -49,6 +50,7 @@ ventoy_virt_chunk *g_virt_chunk;
UINT32 g_virt_chunk_num; UINT32 g_virt_chunk_num;
vtoy_block_data gBlockData; vtoy_block_data gBlockData;
static grub_env_get_pf grub_env_get = NULL; 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_grub_param_file_replace *g_file_replace_list = NULL;
ventoy_efi_file_replace g_efi_file_replace; ventoy_efi_file_replace g_efi_file_replace;
...@@ -602,6 +604,11 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle) ...@@ -602,6 +604,11 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
{ {
gDebugPrint = TRUE; gDebugPrint = TRUE;
} }
if (StrStr(pCmdLine, L"dotefi"))
{
gDotEfiBoot = TRUE;
}
if (StrStr(pCmdLine, L"isoefi=on")) if (StrStr(pCmdLine, L"isoefi=on"))
{ {
...@@ -643,6 +650,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle) ...@@ -643,6 +650,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
pGrubParam = (ventoy_grub_param *)StrHexToUintn(pPos + StrLen(L"env_param=")); pGrubParam = (ventoy_grub_param *)StrHexToUintn(pPos + StrLen(L"env_param="));
grub_env_get = pGrubParam->grub_env_get; grub_env_get = pGrubParam->grub_env_get;
grub_env_set = pGrubParam->grub_env_set;
g_file_replace_list = &pGrubParam->file_replace; g_file_replace_list = &pGrubParam->file_replace;
old_cnt = g_file_replace_list->old_file_cnt; old_cnt = g_file_replace_list->old_file_cnt;
...@@ -664,6 +672,11 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle) ...@@ -664,6 +672,11 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
debug("memory addr:%p size:%lu", chain, size); debug("memory addr:%p size:%lu", chain, size);
if (StrStr(pCmdLine, L"sector512"))
{
gSector512Mode = TRUE;
}
if (StrStr(pCmdLine, L"memdisk")) if (StrStr(pCmdLine, L"memdisk"))
{ {
g_iso_data_buf = (UINT8 *)chain + sizeof(ventoy_chain_head); g_iso_data_buf = (UINT8 *)chain + sizeof(ventoy_chain_head);
...@@ -906,6 +919,11 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle) ...@@ -906,6 +919,11 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
if (Find == 0) if (Find == 0)
{ {
if (gDotEfiBoot)
{
break;
}
debug("Fs not found, now wait and retry..."); debug("Fs not found, now wait and retry...");
sleep(2); sleep(2);
} }
...@@ -972,6 +990,12 @@ EFI_STATUS EFIAPI VentoyEfiMain ...@@ -972,6 +990,12 @@ EFI_STATUS EFIAPI VentoyEfiMain
{ {
gBS->UnloadImage(gBlockData.IsoDriverImage); gBS->UnloadImage(gBlockData.IsoDriverImage);
} }
gBS->DisconnectController(gBlockData.Handle, NULL, NULL);
gBS->UninstallMultipleProtocolInterfaces(gBlockData.Handle,
&gEfiBlockIoProtocolGuid, &gBlockData.BlockIo,
&gEfiDevicePathProtocolGuid, gBlockData.Path,
NULL);
} }
else else
{ {
...@@ -995,16 +1019,24 @@ EFI_STATUS EFIAPI VentoyEfiMain ...@@ -995,16 +1019,24 @@ EFI_STATUS EFIAPI VentoyEfiMain
ventoy_clean_env(); ventoy_clean_env();
} }
if (EFI_NOT_FOUND == Status) if (FALSE == gDotEfiBoot)
{ {
gST->ConOut->OutputString(gST->ConOut, L"No bootfile found for UEFI!\r\n"); if (EFI_NOT_FOUND == Status)
gST->ConOut->OutputString(gST->ConOut, L"Maybe the image does not support " VENTOY_UEFI_DESC L"!\r\n"); {
sleep(30); 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(); ventoy_clear_input();
gST->ConOut->ClearScreen(gST->ConOut); gST->ConOut->ClearScreen(gST->ConOut);
if (gDotEfiBoot && (EFI_NOT_FOUND == Status))
{
grub_env_set("vtoy_dotefi_retry", "YES");
}
return EFI_SUCCESS; return EFI_SUCCESS;
} }
...@@ -227,6 +227,7 @@ if (gDebugPrint) \ ...@@ -227,6 +227,7 @@ if (gDebugPrint) \
gBS->WaitForEvent(1, &gST->ConIn->WaitForKey, &__Index);\ 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 const char * (*grub_env_get_pf)(const char *name);
typedef int (*grub_env_printf_pf)(const char *fmt, ...); typedef int (*grub_env_printf_pf)(const char *fmt, ...);
...@@ -255,6 +256,7 @@ typedef struct ventoy_grub_param_file_replace ...@@ -255,6 +256,7 @@ typedef struct ventoy_grub_param_file_replace
typedef struct ventoy_grub_param typedef struct ventoy_grub_param
{ {
grub_env_get_pf grub_env_get; grub_env_get_pf grub_env_get;
grub_env_set_pf grub_env_set;
ventoy_grub_param_file_replace file_replace; ventoy_grub_param_file_replace file_replace;
grub_env_printf_pf grub_env_printf; grub_env_printf_pf grub_env_printf;
}ventoy_grub_param; }ventoy_grub_param;
...@@ -338,6 +340,7 @@ extern ventoy_efi_file_replace g_efi_file_replace; ...@@ -338,6 +340,7 @@ extern ventoy_efi_file_replace g_efi_file_replace;
extern ventoy_sector_flag *g_sector_flag; extern ventoy_sector_flag *g_sector_flag;
extern UINT32 g_sector_flag_num; extern UINT32 g_sector_flag_num;
extern BOOLEAN gMemdiskMode; extern BOOLEAN gMemdiskMode;
extern BOOLEAN gSector512Mode;
extern UINTN g_iso_buf_size; extern UINTN g_iso_buf_size;
extern UINT8 *g_iso_data_buf; extern UINT8 *g_iso_data_buf;
extern ventoy_grub_param_file_replace *g_file_replace_list; extern ventoy_grub_param_file_replace *g_file_replace_list;
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
UINT8 *g_iso_data_buf = NULL; UINT8 *g_iso_data_buf = NULL;
UINTN g_iso_buf_size = 0; UINTN g_iso_buf_size = 0;
BOOLEAN gMemdiskMode = FALSE; BOOLEAN gMemdiskMode = FALSE;
BOOLEAN gSector512Mode = FALSE;
ventoy_sector_flag *g_sector_flag = NULL; ventoy_sector_flag *g_sector_flag = NULL;
UINT32 g_sector_flag_num = 0; UINT32 g_sector_flag_num = 0;
...@@ -68,6 +69,9 @@ STATIC EFI_INPUT_READ_KEY g_org_read_key = NULL; ...@@ -68,6 +69,9 @@ STATIC EFI_INPUT_READ_KEY g_org_read_key = NULL;
STATIC EFI_LOCATE_HANDLE g_org_locate_handle = 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;
BOOLEAN ventoy_is_cdrom_dp_exist(VOID) BOOLEAN ventoy_is_cdrom_dp_exist(VOID)
{ {
UINTN i = 0; UINTN i = 0;
...@@ -571,6 +575,64 @@ end: ...@@ -571,6 +575,64 @@ end:
return Status; 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_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 ImgSize) EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 ImgSize)
{ {
EFI_STATUS Status = EFI_SUCCESS; EFI_STATUS Status = EFI_SUCCESS;
...@@ -580,9 +642,18 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im ...@@ -580,9 +642,18 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im
debug("install block io protocol %p", ImageHandle); debug("install block io protocol %p", ImageHandle);
ventoy_debug_pause(); 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.ReadOnly = TRUE;
gBlockData.Media.MediaPresent = 1; gBlockData.Media.MediaPresent = 1;
gBlockData.Media.LogicalBlocksPerPhysicalBlock = 1; gBlockData.Media.LogicalBlocksPerPhysicalBlock = 1;
...@@ -590,7 +661,17 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im ...@@ -590,7 +661,17 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im
pBlockIo->Revision = EFI_BLOCK_IO_PROTOCOL_REVISION3; pBlockIo->Revision = EFI_BLOCK_IO_PROTOCOL_REVISION3;
pBlockIo->Media = &(gBlockData.Media); pBlockIo->Media = &(gBlockData.Media);
pBlockIo->Reset = ventoy_block_io_reset; pBlockIo->Reset = ventoy_block_io_reset;
pBlockIo->ReadBlocks = gMemdiskMode ? ventoy_block_io_ramdisk_read : ventoy_block_io_read;
if (gSector512Mode)
{
g_sector_2048_read = gMemdiskMode ? ventoy_block_io_ramdisk_read : ventoy_block_io_read;
pBlockIo->ReadBlocks = ventoy_block_io_read_512;
}
else
{
pBlockIo->ReadBlocks = gMemdiskMode ? ventoy_block_io_ramdisk_read : ventoy_block_io_read;
}
pBlockIo->WriteBlocks = ventoy_block_io_write; pBlockIo->WriteBlocks = ventoy_block_io_write;
pBlockIo->FlushBlocks = ventoy_block_io_flush; pBlockIo->FlushBlocks = ventoy_block_io_flush;
...@@ -603,10 +684,10 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im ...@@ -603,10 +684,10 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im
{ {
return Status; return Status;
} }
Status = ventoy_connect_driver(gBlockData.Handle, L"Disk I/O Driver"); Status = ventoy_connect_driver(gBlockData.Handle, L"Disk I/O Driver");
debug("Connect disk IO driver %r", Status); debug("Connect disk IO driver %r", Status);
Status = ventoy_connect_driver(gBlockData.Handle, L"Partition Driver"); Status = ventoy_connect_driver(gBlockData.Handle, L"Partition Driver");
debug("Connect partition driver %r", Status); debug("Connect partition driver %r", Status);
if (EFI_ERROR(Status)) if (EFI_ERROR(Status))
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#pragma pack(1) #pragma pack(1)
typedef EFI_STATUS (*VTOY_UTIL_PROC_PF)(IN EFI_HANDLE ImageHandle, IN CONST CHAR16 *CmdLine); 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 const char * (*grub_env_get_pf)(const char *name);
typedef int (*grub_env_printf_pf)(const char *fmt, ...); typedef int (*grub_env_printf_pf)(const char *fmt, ...);
...@@ -38,6 +39,7 @@ typedef struct ventoy_grub_param_file_replace ...@@ -38,6 +39,7 @@ typedef struct ventoy_grub_param_file_replace
typedef struct ventoy_grub_param typedef struct ventoy_grub_param
{ {
grub_env_get_pf grub_env_get; grub_env_get_pf grub_env_get;
grub_env_set_pf grub_env_set;
ventoy_grub_param_file_replace file_replace; ventoy_grub_param_file_replace file_replace;
grub_env_printf_pf grub_env_printf; grub_env_printf_pf grub_env_printf;
}ventoy_grub_param; }ventoy_grub_param;
......
#!/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/
...@@ -485,6 +485,11 @@ static int ventoy_boot_opt_filter(char *opt) ...@@ -485,6 +485,11 @@ static int ventoy_boot_opt_filter(char *opt)
return 1; return 1;
} }
if (grub_strcmp(opt, "vga=current") == 0)
{
return 1;
}
if (grub_strncmp(opt, "rdinit=", 7) == 0) if (grub_strncmp(opt, "rdinit=", 7) == 0)
{ {
if (grub_strcmp(opt, "rdinit=/vtoy/vtoy") != 0) if (grub_strcmp(opt, "rdinit=/vtoy/vtoy") != 0)
...@@ -1224,7 +1229,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), ...@@ -1224,7 +1229,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
linux_mem_size = 0; linux_mem_size = 0;
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
#ifdef GRUB_MACHINE_PCBIOS #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. */ /* Video mode selection support. */
char *val = argv[i] + 4; char *val = argv[i] + 4;
......
...@@ -2883,6 +2883,109 @@ end: ...@@ -2883,6 +2883,109 @@ end:
return rc; return rc;
} }
static int ventoy_fs_enum_1st_file(const char *filename, const struct grub_dirhook_info *info, void *data)
{
if (!info->dir)
{
grub_snprintf((char *)data, 256, "%s", filename);
return 1;
}
return 0;
}
static grub_err_t ventoy_cmd_fs_enum_1st_file(grub_extcmd_context_t ctxt, int argc, char **args)
{
int rc = 1;
char *device_name = NULL;
grub_device_t dev = NULL;
grub_fs_t fs = NULL;
char name[256] ={0};
(void)ctxt;
if (argc != 3)
{
debug("ventoy_cmd_fs_enum_1st_file, invalid param num %d\n", argc);
return 1;
}
device_name = grub_file_get_device_name(args[0]);
if (!device_name)
{
debug("grub_file_get_device_name failed, %s\n", args[0]);
goto end;
}
dev = grub_device_open(device_name);
if (!dev)
{
debug("grub_device_open failed, %s\n", device_name);
goto end;
}
fs = grub_fs_probe(dev);
if (!fs)
{
debug("grub_fs_probe failed, %s\n", device_name);
goto end;
}
fs->fs_dir(dev, args[1], ventoy_fs_enum_1st_file, name);
if (name[0])
{
ventoy_set_env(args[2], name);
}
rc = 0;
end:
check_free(device_name, grub_free);
check_free(dev, grub_device_close);
return rc;
}
static grub_err_t ventoy_cmd_basename(grub_extcmd_context_t ctxt, int argc, char **args)
{
char c;
char *pos = NULL;
char *end = NULL;
(void)ctxt;
if (argc != 2)
{
debug("ventoy_cmd_basename, invalid param num %d\n", argc);
return 1;
}
for (pos = args[0]; *pos; pos++)
{
if (*pos == '.')
{
end = pos;
}
}
if (end)
{
c = *end;
*end = 0;
}
grub_env_set(args[1], args[0]);
if (end)
{
*end = c;
}
return 0;
}
grub_uint64_t ventoy_grub_get_file_size(const char *fmt, ...) grub_uint64_t ventoy_grub_get_file_size(const char *fmt, ...)
{ {
grub_uint64_t size = 0; grub_uint64_t size = 0;
...@@ -2920,7 +3023,7 @@ grub_file_t ventoy_grub_file_open(enum grub_file_type type, const char *fmt, ... ...@@ -2920,7 +3023,7 @@ grub_file_t ventoy_grub_file_open(enum grub_file_type type, const char *fmt, ...
file = grub_file_open(fullpath, type); file = grub_file_open(fullpath, type);
if (!file) if (!file)
{ {
debug("grub_file_open failed <%s>\n", fullpath); debug("grub_file_open failed <%s> %d\n", fullpath, grub_errno);
grub_errno = 0; grub_errno = 0;
} }
...@@ -2995,6 +3098,7 @@ static int ventoy_env_init(void) ...@@ -2995,6 +3098,7 @@ static int ventoy_env_init(void)
if (g_grub_param) if (g_grub_param)
{ {
g_grub_param->grub_env_get = grub_env_get; g_grub_param->grub_env_get = grub_env_get;
g_grub_param->grub_env_set = (grub_env_set_pf)grub_env_set;
g_grub_param->grub_env_printf = (grub_env_printf_pf)grub_printf; g_grub_param->grub_env_printf = (grub_env_printf_pf)grub_printf;
grub_snprintf(buf, sizeof(buf), "%p", g_grub_param); grub_snprintf(buf, sizeof(buf), "%p", g_grub_param);
grub_env_set("env_param", buf); grub_env_set("env_param", buf);
...@@ -3022,12 +3126,18 @@ static cmd_para ventoy_cmds[] = ...@@ -3022,12 +3126,18 @@ static cmd_para ventoy_cmds[] =
{ "vt_dump_img_sector", ventoy_cmd_dump_img_sector, 0, NULL, "", "", NULL }, { "vt_dump_img_sector", ventoy_cmd_dump_img_sector, 0, NULL, "", "", NULL },
{ "vt_load_wimboot", ventoy_cmd_load_wimboot, 0, NULL, "", "", NULL }, { "vt_load_wimboot", ventoy_cmd_load_wimboot, 0, NULL, "", "", NULL },
{ "vt_cpio_busybox64", ventoy_cmd_cpio_busybox_64, 0, NULL, "", "", NULL },
{ "vt_load_cpio", ventoy_cmd_load_cpio, 0, NULL, "", "", NULL }, { "vt_load_cpio", ventoy_cmd_load_cpio, 0, NULL, "", "", NULL },
{ "vt_trailer_cpio", ventoy_cmd_trailer_cpio, 0, NULL, "", "", NULL }, { "vt_trailer_cpio", ventoy_cmd_trailer_cpio, 0, NULL, "", "", NULL },
{ "vt_push_last_entry", ventoy_cmd_push_last_entry, 0, NULL, "", "", NULL }, { "vt_push_last_entry", ventoy_cmd_push_last_entry, 0, NULL, "", "", NULL },
{ "vt_pop_last_entry", ventoy_cmd_pop_last_entry, 0, NULL, "", "", NULL }, { "vt_pop_last_entry", ventoy_cmd_pop_last_entry, 0, NULL, "", "", NULL },
{ "vt_get_lib_module_ver", ventoy_cmd_lib_module_ver, 0, NULL, "", "", NULL }, { "vt_get_lib_module_ver", ventoy_cmd_lib_module_ver, 0, NULL, "", "", NULL },
{ "vt_get_fs_label", ventoy_cmd_get_fs_label, 0, NULL, "", "", NULL }, { "vt_get_fs_label", ventoy_cmd_get_fs_label, 0, NULL, "", "", NULL },
{ "vt_fs_enum_1st_file", ventoy_cmd_fs_enum_1st_file, 0, NULL, "", "", NULL },
{ "vt_file_basename", ventoy_cmd_basename, 0, NULL, "", "", NULL },
{ "vt_find_first_bootable_hd", ventoy_cmd_find_bootable_hdd, 0, NULL, "", "", NULL }, { "vt_find_first_bootable_hd", ventoy_cmd_find_bootable_hdd, 0, NULL, "", "", NULL },
{ "vt_dump_menu", ventoy_cmd_dump_menu, 0, NULL, "", "", NULL }, { "vt_dump_menu", ventoy_cmd_dump_menu, 0, NULL, "", "", NULL },
......
...@@ -469,6 +469,7 @@ grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc, ...@@ -469,6 +469,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_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_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_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); 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); 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, ...); grub_file_t ventoy_grub_file_open(enum grub_file_type type, const char *fmt, ...);
......
...@@ -944,6 +944,19 @@ static int ventoy_cpio_busybox64(cpio_newc_header *head) ...@@ -944,6 +944,19 @@ static int ventoy_cpio_busybox64(cpio_newc_header *head)
return 0; 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) grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **args)
{ {
int rc; int rc;
......
...@@ -219,6 +219,7 @@ typedef struct ventoy_img_chunk_list ...@@ -219,6 +219,7 @@ typedef struct ventoy_img_chunk_list
#define GRUB_FILE_REPLACE_MAGIC 0x1258BEEF #define GRUB_FILE_REPLACE_MAGIC 0x1258BEEF
typedef const char * (*grub_env_get_pf)(const char *name); 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 int (*grub_env_printf_pf)(const char *fmt, ...);
typedef struct ventoy_grub_param_file_replace typedef struct ventoy_grub_param_file_replace
...@@ -232,6 +233,7 @@ typedef struct ventoy_grub_param_file_replace ...@@ -232,6 +233,7 @@ typedef struct ventoy_grub_param_file_replace
typedef struct ventoy_grub_param typedef struct ventoy_grub_param
{ {
grub_env_get_pf grub_env_get; grub_env_get_pf grub_env_get;
grub_env_set_pf grub_env_set;
ventoy_grub_param_file_replace file_replace; ventoy_grub_param_file_replace file_replace;
grub_env_printf_pf grub_env_printf; grub_env_printf_pf grub_env_printf;
}ventoy_grub_param; }ventoy_grub_param;
......
...@@ -40,11 +40,21 @@ if [ -e $BUSYBOX_PATH/64h ]; then ...@@ -40,11 +40,21 @@ if [ -e $BUSYBOX_PATH/64h ]; then
$BUSYBOX_PATH/xzminidec32 < $BUSYBOX_PATH/busybox32.xz > $BUSYBOX_PATH/busybox $BUSYBOX_PATH/xzminidec32 < $BUSYBOX_PATH/busybox32.xz > $BUSYBOX_PATH/busybox
$BUSYBOX_PATH/vtchmod32 $BUSYBOX_PATH/busybox $BUSYBOX_PATH/vtchmod32 $BUSYBOX_PATH/busybox
else else
$BUSYBOX_PATH/xzminidec64 < $BUSYBOX_PATH/busybox64.xz > $BUSYBOX_PATH/busybox $BUSYBOX_PATH/xzminidec64 < $BUSYBOX_PATH/busybox64.xz > $BUSYBOX_PATH/busybox
$BUSYBOX_PATH/vtchmod64 $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 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 export PATH=$BUSYBOX_PATH/:$VTOY_PATH/tool
...@@ -78,10 +88,12 @@ if [ -e $BUSYBOX_PATH/64h ]; then ...@@ -78,10 +88,12 @@ if [ -e $BUSYBOX_PATH/64h ]; then
echo "Use busybox32 toolkit ..." >>$VTLOG echo "Use busybox32 toolkit ..." >>$VTLOG
ln -s $BUSYBOX_PATH/xzminidec32 $BUSYBOX_PATH/xzminidec ln -s $BUSYBOX_PATH/xzminidec32 $BUSYBOX_PATH/xzminidec
ln -s $VTOY_PATH/tool/dmsetup32 $VTOY_PATH/tool/dmsetup ln -s $VTOY_PATH/tool/dmsetup32 $VTOY_PATH/tool/dmsetup
ln -s $VTOY_PATH/tool/lunzip32 $VTOY_PATH/tool/lunzip
else else
echo "Use busybox64 toolkit ..." >>$VTLOG echo "Use busybox64 toolkit ..." >>$VTLOG
ln -s $BUSYBOX_PATH/xzminidec64 $BUSYBOX_PATH/xzminidec ln -s $BUSYBOX_PATH/xzminidec64 $BUSYBOX_PATH/xzminidec
ln -s $VTOY_PATH/tool/dmsetup64 $VTOY_PATH/tool/dmsetup ln -s $VTOY_PATH/tool/dmsetup64 $VTOY_PATH/tool/dmsetup
ln -s $VTOY_PATH/tool/lunzip64 $VTOY_PATH/tool/lunzip
fi fi
rm -f *.xz rm -f *.xz
......
...@@ -59,7 +59,15 @@ mkdir -p $VTOY_PATH/mnt ...@@ -59,7 +59,15 @@ mkdir -p $VTOY_PATH/mnt
mount /vt_modloop $VTOY_PATH/mnt mount /vt_modloop $VTOY_PATH/mnt
KoModPath=$(find $VTOY_PATH/mnt/ -name 'dm-mod.ko*') 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 insmod $KoModPath
umount $VTOY_PATH/mnt umount $VTOY_PATH/mnt
......
...@@ -21,11 +21,20 @@ ...@@ -21,11 +21,20 @@
if $GREP -q '^"$mount_handler"' /init; then if $GREP -q '^"$mount_handler"' /init; then
echo 'use mount_handler ...' >> $VTLOG 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 vthookfile=/hooks/archiso
$SED '/while ! poll_device "${dev}"/a\ if /ventoy/busybox/sh /ventoy/hook/arch/ventoy-timeout.sh ${dev}; then break; fi' -i /hooks/archiso
if [ -e /hook/miso ]; then
vthookfile=/hooks/miso
$SED "/^\"\$mount_handler\"/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/arch/ventoy-disk.sh \"\$misodevice\"" -i /init
else
$SED "/^\"\$mount_handler\"/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/arch/ventoy-disk.sh \"\$archisodevice\"" -i /init
fi 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 elif $GREP -q '^KEEP_SEARCHING' /init; then
echo 'KEEP_SEARCHING found ...' >> $VTLOG echo 'KEEP_SEARCHING found ...' >> $VTLOG
$SED "/^KEEP_SEARCHING/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/arch/ovios-disk.sh " -i /init $SED "/^KEEP_SEARCHING/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/arch/ovios-disk.sh " -i /init
......
#!/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
#!/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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment