mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-09-16 17:11:13 +00:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
d71514f23e | ||
|
c5af17e04e | ||
|
05e208ea2a | ||
|
112c557428 | ||
|
92db873b5c | ||
|
3c01eec4af | ||
|
5c6d18fcd4 | ||
|
84ec4b0de4 | ||
|
9615e7eaa0 | ||
|
6a244ff260 |
2
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
2
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
@@ -21,7 +21,7 @@ body:
|
|||||||
attributes:
|
attributes:
|
||||||
label: Ventoy Version
|
label: Ventoy Version
|
||||||
description: What version of ventoy are you running?
|
description: What version of ventoy are you running?
|
||||||
placeholder: 1.0.49
|
placeholder: 1.0.51
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: dropdown
|
- type: dropdown
|
||||||
|
@@ -1138,14 +1138,15 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im
|
|||||||
{
|
{
|
||||||
gBlockData.Media.BlockSize = 512;
|
gBlockData.Media.BlockSize = 512;
|
||||||
gBlockData.Media.LastBlock = ImgSize / 512 - 1;
|
gBlockData.Media.LastBlock = ImgSize / 512 - 1;
|
||||||
|
gBlockData.Media.ReadOnly = FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gBlockData.Media.BlockSize = 2048;
|
gBlockData.Media.BlockSize = 2048;
|
||||||
gBlockData.Media.LastBlock = ImgSize / 2048 - 1;
|
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;
|
||||||
|
|
||||||
|
@@ -279,6 +279,13 @@ static int ventoy_boot_opt_filter(char *opt)
|
|||||||
opt[1] = 't';
|
opt[1] = 't';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (grub_strncmp(opt, "dm=", 3) == 0)
|
||||||
|
{
|
||||||
|
opt[0] = 'D';
|
||||||
|
opt[1] = 'M';
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (ventoy_debug)
|
if (ventoy_debug)
|
||||||
{
|
{
|
||||||
|
@@ -506,6 +506,13 @@ static int ventoy_boot_opt_filter(char *opt)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (grub_strncmp(opt, "dm=", 3) == 0)
|
||||||
|
{
|
||||||
|
opt[0] = 'D';
|
||||||
|
opt[1] = 'M';
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (ventoy_debug)
|
if (ventoy_debug)
|
||||||
{
|
{
|
||||||
if (grub_strcmp(opt, "quiet") == 0)
|
if (grub_strcmp(opt, "quiet") == 0)
|
||||||
|
@@ -228,6 +228,13 @@ static int ventoy_boot_opt_filter(char *opt)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (grub_strncmp(opt, "dm=", 3) == 0)
|
||||||
|
{
|
||||||
|
opt[0] = 'D';
|
||||||
|
opt[1] = 'M';
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (ventoy_debug)
|
if (ventoy_debug)
|
||||||
{
|
{
|
||||||
if (grub_strcmp(opt, "quiet") == 0)
|
if (grub_strcmp(opt, "quiet") == 0)
|
||||||
|
232
GRUB2/MOD_SRC/grub-2.04/grub-core/partmap/gpt.c
Normal file
232
GRUB2/MOD_SRC/grub-2.04/grub-core/partmap/gpt.c
Normal file
@@ -0,0 +1,232 @@
|
|||||||
|
/* gpt.c - Read GUID Partition Tables (GPT). */
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2002,2005,2006,2007,2008 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* GRUB is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <grub/disk.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
#include <grub/mm.h>
|
||||||
|
#include <grub/partition.h>
|
||||||
|
#include <grub/dl.h>
|
||||||
|
#include <grub/msdos_partition.h>
|
||||||
|
#include <grub/gpt_partition.h>
|
||||||
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
|
GRUB_MOD_LICENSE ("GPLv3+");
|
||||||
|
|
||||||
|
static grub_uint8_t grub_gpt_magic[8] =
|
||||||
|
{
|
||||||
|
0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54
|
||||||
|
};
|
||||||
|
|
||||||
|
static const grub_gpt_part_guid_t grub_gpt_partition_type_empty = GRUB_GPT_PARTITION_TYPE_EMPTY;
|
||||||
|
|
||||||
|
#ifdef GRUB_UTIL
|
||||||
|
static const grub_gpt_part_guid_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* 512 << 7 = 65536 byte sectors. */
|
||||||
|
#define MAX_SECTOR_LOG 7
|
||||||
|
|
||||||
|
static struct grub_partition_map grub_gpt_partition_map;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
grub_err_t
|
||||||
|
grub_gpt_partition_map_iterate (grub_disk_t disk,
|
||||||
|
grub_partition_iterate_hook_t hook,
|
||||||
|
void *hook_data)
|
||||||
|
{
|
||||||
|
struct grub_partition part;
|
||||||
|
struct grub_gpt_header gpt;
|
||||||
|
struct grub_gpt_partentry entry;
|
||||||
|
struct grub_msdos_partition_mbr mbr;
|
||||||
|
grub_uint64_t entries;
|
||||||
|
unsigned int i;
|
||||||
|
int last_offset = 0;
|
||||||
|
int sector_log = 0;
|
||||||
|
|
||||||
|
/* Read the protective MBR. */
|
||||||
|
if (grub_disk_read (disk, 0, 0, sizeof (mbr), &mbr))
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
/* Check if it is valid. */
|
||||||
|
if (mbr.signature != grub_cpu_to_le16_compile_time (GRUB_PC_PARTITION_SIGNATURE))
|
||||||
|
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature");
|
||||||
|
|
||||||
|
/* Make sure the MBR is a protective MBR and not a normal MBR. */
|
||||||
|
for (i = 0; i < 4; i++)
|
||||||
|
if (mbr.entries[i].type == GRUB_PC_PARTITION_TYPE_GPT_DISK)
|
||||||
|
break;
|
||||||
|
if (i == 4)
|
||||||
|
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no GPT partition map found");
|
||||||
|
|
||||||
|
/* Read the GPT header. */
|
||||||
|
for (sector_log = 0; sector_log < MAX_SECTOR_LOG; sector_log++)
|
||||||
|
{
|
||||||
|
if (grub_disk_read (disk, 1 << sector_log, 0, sizeof (gpt), &gpt))
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
if (grub_memcmp (gpt.magic, grub_gpt_magic, sizeof (grub_gpt_magic)) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (sector_log == MAX_SECTOR_LOG)
|
||||||
|
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no valid GPT header");
|
||||||
|
|
||||||
|
grub_dprintf ("gpt", "Read a valid GPT header\n");
|
||||||
|
|
||||||
|
entries = grub_le_to_cpu64 (gpt.partitions) << sector_log;
|
||||||
|
for (i = 0; i < grub_le_to_cpu32 (gpt.maxpart); i++)
|
||||||
|
{
|
||||||
|
if (grub_disk_read (disk, entries, last_offset,
|
||||||
|
sizeof (entry), &entry))
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
if (grub_memcmp (&grub_gpt_partition_type_empty, &entry.type,
|
||||||
|
sizeof (grub_gpt_partition_type_empty)))
|
||||||
|
{
|
||||||
|
/* Calculate the first block and the size of the partition. */
|
||||||
|
part.start = grub_le_to_cpu64 (entry.start) << sector_log;
|
||||||
|
part.len = (grub_le_to_cpu64 (entry.end)
|
||||||
|
- grub_le_to_cpu64 (entry.start) + 1) << sector_log;
|
||||||
|
part.offset = entries;
|
||||||
|
part.number = i;
|
||||||
|
part.index = last_offset;
|
||||||
|
part.partmap = &grub_gpt_partition_map;
|
||||||
|
part.parent = disk->partition;
|
||||||
|
part.gpt_attrib = entry.attrib;
|
||||||
|
|
||||||
|
grub_dprintf ("gpt", "GPT entry %d: start=%lld, length=%lld\n", i,
|
||||||
|
(unsigned long long) part.start,
|
||||||
|
(unsigned long long) part.len);
|
||||||
|
|
||||||
|
if (hook (disk, &part, hook_data))
|
||||||
|
return grub_errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
last_offset += grub_le_to_cpu32 (gpt.partentry_size);
|
||||||
|
if (last_offset == GRUB_DISK_SECTOR_SIZE)
|
||||||
|
{
|
||||||
|
last_offset = 0;
|
||||||
|
entries++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef GRUB_UTIL
|
||||||
|
/* Context for gpt_partition_map_embed. */
|
||||||
|
struct gpt_partition_map_embed_ctx
|
||||||
|
{
|
||||||
|
grub_disk_addr_t start, len;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Helper for gpt_partition_map_embed. */
|
||||||
|
static int
|
||||||
|
find_usable_region (grub_disk_t disk __attribute__ ((unused)),
|
||||||
|
const grub_partition_t p, void *data)
|
||||||
|
{
|
||||||
|
struct gpt_partition_map_embed_ctx *ctx = data;
|
||||||
|
struct grub_gpt_partentry gptdata;
|
||||||
|
grub_partition_t p2;
|
||||||
|
|
||||||
|
p2 = disk->partition;
|
||||||
|
disk->partition = p->parent;
|
||||||
|
if (grub_disk_read (disk, p->offset, p->index,
|
||||||
|
sizeof (gptdata), &gptdata))
|
||||||
|
{
|
||||||
|
disk->partition = p2;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
disk->partition = p2;
|
||||||
|
|
||||||
|
/* If there's an embed region, it is in a dedicated partition. */
|
||||||
|
if (! grub_memcmp (&gptdata.type, &grub_gpt_partition_type_bios_boot, 16))
|
||||||
|
{
|
||||||
|
ctx->start = p->start;
|
||||||
|
ctx->len = p->len;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
gpt_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors,
|
||||||
|
unsigned int max_nsectors,
|
||||||
|
grub_embed_type_t embed_type,
|
||||||
|
grub_disk_addr_t **sectors)
|
||||||
|
{
|
||||||
|
struct gpt_partition_map_embed_ctx ctx = {
|
||||||
|
.start = 0,
|
||||||
|
.len = 0
|
||||||
|
};
|
||||||
|
unsigned i;
|
||||||
|
grub_err_t err;
|
||||||
|
|
||||||
|
if (embed_type != GRUB_EMBED_PCBIOS)
|
||||||
|
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||||
|
"GPT currently supports only PC-BIOS embedding");
|
||||||
|
|
||||||
|
err = grub_gpt_partition_map_iterate (disk, find_usable_region, &ctx);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
if (ctx.len == 0)
|
||||||
|
return grub_error (GRUB_ERR_FILE_NOT_FOUND,
|
||||||
|
N_("this GPT partition label contains no BIOS Boot Partition;"
|
||||||
|
" embedding won't be possible"));
|
||||||
|
|
||||||
|
if (ctx.len < *nsectors)
|
||||||
|
return grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||||
|
N_("your BIOS Boot Partition is too small;"
|
||||||
|
" embedding won't be possible"));
|
||||||
|
|
||||||
|
*nsectors = ctx.len;
|
||||||
|
if (*nsectors > max_nsectors)
|
||||||
|
*nsectors = max_nsectors;
|
||||||
|
*sectors = grub_malloc (*nsectors * sizeof (**sectors));
|
||||||
|
if (!*sectors)
|
||||||
|
return grub_errno;
|
||||||
|
for (i = 0; i < *nsectors; i++)
|
||||||
|
(*sectors)[i] = ctx.start + i;
|
||||||
|
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Partition map type. */
|
||||||
|
static struct grub_partition_map grub_gpt_partition_map =
|
||||||
|
{
|
||||||
|
.name = "gpt",
|
||||||
|
.iterate = grub_gpt_partition_map_iterate,
|
||||||
|
#ifdef GRUB_UTIL
|
||||||
|
.embed = gpt_partition_map_embed
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
GRUB_MOD_INIT(part_gpt)
|
||||||
|
{
|
||||||
|
grub_partition_map_register (&grub_gpt_partition_map);
|
||||||
|
}
|
||||||
|
|
||||||
|
GRUB_MOD_FINI(part_gpt)
|
||||||
|
{
|
||||||
|
grub_partition_map_unregister (&grub_gpt_partition_map);
|
||||||
|
}
|
@@ -145,6 +145,8 @@ const char *g_menu_prefix[img_type_max] =
|
|||||||
static int g_vtoy_load_prompt = 0;
|
static int g_vtoy_load_prompt = 0;
|
||||||
static char g_vtoy_prompt_msg[64];
|
static char g_vtoy_prompt_msg[64];
|
||||||
|
|
||||||
|
static char g_json_case_mis_path[32];
|
||||||
|
|
||||||
static int ventoy_get_fs_type(const char *fs)
|
static int ventoy_get_fs_type(const char *fs)
|
||||||
{
|
{
|
||||||
if (NULL == fs)
|
if (NULL == fs)
|
||||||
@@ -3489,9 +3491,11 @@ end:
|
|||||||
|
|
||||||
static int ventoy_img_partition_callback (struct grub_disk *disk, const grub_partition_t partition, void *data)
|
static int ventoy_img_partition_callback (struct grub_disk *disk, const grub_partition_t partition, void *data)
|
||||||
{
|
{
|
||||||
|
int *pCnt = (int *)data;
|
||||||
|
|
||||||
(void)disk;
|
(void)disk;
|
||||||
(void)data;
|
|
||||||
|
|
||||||
|
(*pCnt)++;
|
||||||
g_part_list_pos += grub_snprintf(g_part_list_buf + g_part_list_pos, VTOY_MAX_SCRIPT_BUF - g_part_list_pos,
|
g_part_list_pos += grub_snprintf(g_part_list_buf + g_part_list_pos, VTOY_MAX_SCRIPT_BUF - g_part_list_pos,
|
||||||
"0 %llu linear /dev/ventoy %llu\n",
|
"0 %llu linear /dev/ventoy %llu\n",
|
||||||
(ulonglong)partition->len, (ulonglong)partition->start);
|
(ulonglong)partition->len, (ulonglong)partition->start);
|
||||||
@@ -3501,6 +3505,7 @@ static int ventoy_img_partition_callback (struct grub_disk *disk, const grub_par
|
|||||||
|
|
||||||
static grub_err_t ventoy_cmd_img_part_info(grub_extcmd_context_t ctxt, int argc, char **args)
|
static grub_err_t ventoy_cmd_img_part_info(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
{
|
{
|
||||||
|
int cnt = 0;
|
||||||
char *device_name = NULL;
|
char *device_name = NULL;
|
||||||
grub_device_t dev = NULL;
|
grub_device_t dev = NULL;
|
||||||
char buf[64];
|
char buf[64];
|
||||||
@@ -3529,11 +3534,14 @@ static grub_err_t ventoy_cmd_img_part_info(grub_extcmd_context_t ctxt, int argc,
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_partition_iterate(dev->disk, ventoy_img_partition_callback, NULL);
|
grub_partition_iterate(dev->disk, ventoy_img_partition_callback, &cnt);
|
||||||
|
|
||||||
grub_snprintf(buf, sizeof(buf), "newc:vtoy_dm_table:mem:0x%llx:size:%d", (ulonglong)(ulong)g_part_list_buf, g_part_list_pos);
|
grub_snprintf(buf, sizeof(buf), "newc:vtoy_dm_table:mem:0x%llx:size:%d", (ulonglong)(ulong)g_part_list_buf, g_part_list_pos);
|
||||||
grub_env_set("vtoy_img_part_file", buf);
|
grub_env_set("vtoy_img_part_file", buf);
|
||||||
|
|
||||||
|
grub_snprintf(buf, sizeof(buf), "%d", cnt);
|
||||||
|
grub_env_set("vtoy_img_part_cnt", buf);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
|
||||||
check_free(device_name, grub_free);
|
check_free(device_name, grub_free);
|
||||||
@@ -4695,6 +4703,154 @@ static grub_err_t ventoy_cmd_pop_pager(grub_extcmd_context_t ctxt, int argc, cha
|
|||||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ventoy_chk_case_file(const char *filename, const struct grub_dirhook_info *info, void *data)
|
||||||
|
{
|
||||||
|
if (g_json_case_mis_path[0])
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 == info->dir && grub_strncasecmp(filename, "ventoy.json", 11) == 0)
|
||||||
|
{
|
||||||
|
grub_snprintf(g_json_case_mis_path, 32, "%s/%s", (char *)data, filename);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ventoy_chk_case_dir(const char *filename, const struct grub_dirhook_info *info, void *data)
|
||||||
|
{
|
||||||
|
char path[16];
|
||||||
|
chk_case_fs_dir *fs_dir = (chk_case_fs_dir *)data;
|
||||||
|
|
||||||
|
if (g_json_case_mis_path[0])
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info->dir && (filename[0] == 'v' || filename[0] == 'V'))
|
||||||
|
{
|
||||||
|
if (grub_strncasecmp(filename, "ventoy", 6) == 0)
|
||||||
|
{
|
||||||
|
grub_snprintf(path, sizeof(path), "/%s", filename);
|
||||||
|
fs_dir->fs->fs_dir(fs_dir->dev, path, ventoy_chk_case_file, path);
|
||||||
|
if (g_json_case_mis_path[0])
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t ventoy_cmd_chk_json_pathcase(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
|
{
|
||||||
|
int fstype = 0;
|
||||||
|
char *device_name = NULL;
|
||||||
|
grub_device_t dev = NULL;
|
||||||
|
grub_fs_t fs = NULL;
|
||||||
|
chk_case_fs_dir fs_dir;
|
||||||
|
|
||||||
|
(void)ctxt;
|
||||||
|
(void)argc;
|
||||||
|
(void)args;
|
||||||
|
|
||||||
|
device_name = grub_file_get_device_name(args[0]);
|
||||||
|
if (!device_name)
|
||||||
|
{
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev = grub_device_open(device_name);
|
||||||
|
if (!dev)
|
||||||
|
{
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs = grub_fs_probe(dev);
|
||||||
|
if (!fs)
|
||||||
|
{
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
fstype = ventoy_get_fs_type(fs->name);
|
||||||
|
if (fstype == ventoy_fs_fat || fstype == ventoy_fs_exfat || fstype >= ventoy_fs_max)
|
||||||
|
{
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_json_case_mis_path[0] = 0;
|
||||||
|
fs_dir.dev = dev;
|
||||||
|
fs_dir.fs = fs;
|
||||||
|
fs->fs_dir(dev, "/", ventoy_chk_case_dir, &fs_dir);
|
||||||
|
|
||||||
|
if (g_json_case_mis_path[0])
|
||||||
|
{
|
||||||
|
grub_env_set("VTOY_PLUGIN_PATH_CASE_MISMATCH", g_json_case_mis_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
|
||||||
|
grub_check_free(device_name);
|
||||||
|
check_free(dev, grub_device_close);
|
||||||
|
|
||||||
|
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t grub_cmd_gptpriority(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
|
{
|
||||||
|
grub_disk_t disk;
|
||||||
|
grub_partition_t part;
|
||||||
|
char priority_str[3]; /* Maximum value 15 */
|
||||||
|
|
||||||
|
(void)ctxt;
|
||||||
|
|
||||||
|
if (argc < 2 || argc > 3)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||||
|
"gptpriority DISKNAME PARTITIONNUM [VARNAME]");
|
||||||
|
|
||||||
|
/* Open the disk if it exists */
|
||||||
|
disk = grub_disk_open (args[0]);
|
||||||
|
if (!disk)
|
||||||
|
{
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||||
|
"Not a disk");
|
||||||
|
}
|
||||||
|
|
||||||
|
part = grub_partition_probe (disk, args[1]);
|
||||||
|
if (!part)
|
||||||
|
{
|
||||||
|
grub_disk_close (disk);
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||||
|
"No such partition");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (grub_strcmp (part->partmap->name, "gpt"))
|
||||||
|
{
|
||||||
|
grub_disk_close (disk);
|
||||||
|
return grub_error (GRUB_ERR_BAD_PART_TABLE,
|
||||||
|
"Not a GPT partition");
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_snprintf (priority_str, sizeof(priority_str), "%u",
|
||||||
|
(grub_uint32_t)((part->gpt_attrib >> 48) & 0xfULL));
|
||||||
|
|
||||||
|
if (argc == 3)
|
||||||
|
{
|
||||||
|
grub_env_set (args[2], priority_str);
|
||||||
|
grub_env_export (args[2]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
grub_printf ("Priority is %s\n", priority_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_disk_close (disk);
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int ventoy_env_init(void)
|
int ventoy_env_init(void)
|
||||||
{
|
{
|
||||||
char buf[64];
|
char buf[64];
|
||||||
@@ -4742,6 +4898,8 @@ int ventoy_env_init(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static cmd_para ventoy_cmds[] =
|
static cmd_para ventoy_cmds[] =
|
||||||
{
|
{
|
||||||
{ "vt_incr", ventoy_cmd_incr, 0, NULL, "{Var} {INT}", "Increase integer variable", NULL },
|
{ "vt_incr", ventoy_cmd_incr, 0, NULL, "{Var} {INT}", "Increase integer variable", NULL },
|
||||||
@@ -4872,6 +5030,9 @@ static cmd_para ventoy_cmds[] =
|
|||||||
{ "vt_search_replace_initrd", ventoy_cmd_search_replace_initrd, 0, NULL, "", "", NULL },
|
{ "vt_search_replace_initrd", ventoy_cmd_search_replace_initrd, 0, NULL, "", "", NULL },
|
||||||
{ "vt_push_pager", ventoy_cmd_push_pager, 0, NULL, "", "", NULL },
|
{ "vt_push_pager", ventoy_cmd_push_pager, 0, NULL, "", "", NULL },
|
||||||
{ "vt_pop_pager", ventoy_cmd_pop_pager, 0, NULL, "", "", NULL },
|
{ "vt_pop_pager", ventoy_cmd_pop_pager, 0, NULL, "", "", NULL },
|
||||||
|
{ "vt_check_json_path_case", ventoy_cmd_chk_json_pathcase, 0, NULL, "", "", NULL },
|
||||||
|
{ "vt_append_extra_sector", ventoy_cmd_append_ext_sector, 0, NULL, "", "", NULL },
|
||||||
|
{ "gptpriority", grub_cmd_gptpriority, 0, NULL, "", "", NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
int ventoy_register_all_cmd(void)
|
int ventoy_register_all_cmd(void)
|
||||||
|
@@ -547,6 +547,12 @@ typedef struct replace_fs_dir
|
|||||||
int filecnt;
|
int filecnt;
|
||||||
}replace_fs_dir;
|
}replace_fs_dir;
|
||||||
|
|
||||||
|
typedef struct chk_case_fs_dir
|
||||||
|
{
|
||||||
|
grub_device_t dev;
|
||||||
|
grub_fs_t fs;
|
||||||
|
}chk_case_fs_dir;
|
||||||
|
|
||||||
int ventoy_strcmp(const char *pattern, const char *str);
|
int ventoy_strcmp(const char *pattern, const char *str);
|
||||||
int ventoy_strncmp (const char *pattern, const char *str, grub_size_t n);
|
int ventoy_strncmp (const char *pattern, const char *str, grub_size_t n);
|
||||||
void ventoy_fill_os_param(grub_file_t file, ventoy_os_param *param);
|
void ventoy_fill_os_param(grub_file_t file, ventoy_os_param *param);
|
||||||
@@ -562,6 +568,7 @@ grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc,
|
|||||||
grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
|
grub_err_t ventoy_cmd_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_append_ext_sector(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
grub_err_t ventoy_cmd_skip_svd(grub_extcmd_context_t ctxt, int argc, char **args);
|
grub_err_t ventoy_cmd_skip_svd(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
grub_err_t ventoy_cmd_cpio_busybox_64(grub_extcmd_context_t ctxt, int argc, char **args);
|
grub_err_t ventoy_cmd_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);
|
||||||
|
@@ -152,6 +152,23 @@ static int vtoy_json_parse_string
|
|||||||
return JSON_FAILED;
|
return JSON_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (*(pcPos - 1) == '\\')
|
||||||
|
{
|
||||||
|
for (pcPos++; *pcPos; pcPos++)
|
||||||
|
{
|
||||||
|
if (*pcPos == '"' && *(pcPos - 1) != '\\')
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*pcPos == 0 || pcPos < pcTmp)
|
||||||
|
{
|
||||||
|
json_debug("Invalid quotes string %s.", pcData);
|
||||||
|
return JSON_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*ppcEnd = pcPos + 1;
|
*ppcEnd = pcPos + 1;
|
||||||
uiLen = (grub_uint32_t)(unsigned long)(pcPos - pcTmp);
|
uiLen = (grub_uint32_t)(unsigned long)(pcPos - pcTmp);
|
||||||
|
|
||||||
|
@@ -38,6 +38,9 @@
|
|||||||
|
|
||||||
GRUB_MOD_LICENSE ("GPLv3+");
|
GRUB_MOD_LICENSE ("GPLv3+");
|
||||||
|
|
||||||
|
#define VTOY_APPEND_EXT_SIZE 4096
|
||||||
|
static int g_append_ext_sector = 0;
|
||||||
|
|
||||||
char * ventoy_get_line(char *start)
|
char * ventoy_get_line(char *start)
|
||||||
{
|
{
|
||||||
if (start == NULL)
|
if (start == NULL)
|
||||||
@@ -658,6 +661,11 @@ static grub_uint32_t ventoy_linux_get_virt_chunk_count(void)
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_append_ext_sector > 0)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -671,6 +679,11 @@ static grub_uint32_t ventoy_linux_get_virt_chunk_size(void)
|
|||||||
{
|
{
|
||||||
size += sizeof(ventoy_virt_chunk) + g_conf_replace_new_len_align;
|
size += sizeof(ventoy_virt_chunk) + g_conf_replace_new_len_align;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_append_ext_sector > 0)
|
||||||
|
{
|
||||||
|
size += sizeof(ventoy_virt_chunk) + VTOY_APPEND_EXT_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
@@ -727,6 +740,27 @@ static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_
|
|||||||
cur++;
|
cur++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Lenovo EasyStartup need an addional sector for boundary check */
|
||||||
|
if (g_append_ext_sector > 0)
|
||||||
|
{
|
||||||
|
cpio_secs = VTOY_APPEND_EXT_SIZE / 2048;
|
||||||
|
|
||||||
|
cur->mem_sector_start = sector;
|
||||||
|
cur->mem_sector_end = cur->mem_sector_start + cpio_secs;
|
||||||
|
cur->mem_sector_offset = offset;
|
||||||
|
cur->remap_sector_start = 0;
|
||||||
|
cur->remap_sector_end = 0;
|
||||||
|
cur->org_sector_start = 0;
|
||||||
|
|
||||||
|
grub_memset(override + offset, 0, VTOY_APPEND_EXT_SIZE);
|
||||||
|
|
||||||
|
chain->virt_img_size_in_bytes += VTOY_APPEND_EXT_SIZE;
|
||||||
|
|
||||||
|
offset += VTOY_APPEND_EXT_SIZE;
|
||||||
|
sector += cpio_secs;
|
||||||
|
cur++;
|
||||||
|
}
|
||||||
|
|
||||||
if (g_conf_replace_offset > 0)
|
if (g_conf_replace_offset > 0)
|
||||||
{
|
{
|
||||||
cpio_secs = g_conf_replace_new_len_align / 2048;
|
cpio_secs = g_conf_replace_new_len_align / 2048;
|
||||||
@@ -1119,6 +1153,24 @@ grub_err_t ventoy_cmd_skip_svd(grub_extcmd_context_t ctxt, int argc, char **args
|
|||||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
grub_err_t ventoy_cmd_append_ext_sector(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
|
{
|
||||||
|
(void)ctxt;
|
||||||
|
(void)argc;
|
||||||
|
(void)args;
|
||||||
|
|
||||||
|
if (args[0][0] == '1')
|
||||||
|
{
|
||||||
|
g_append_ext_sector = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_append_ext_sector = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **args)
|
grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -1501,20 +1553,20 @@ grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, cha
|
|||||||
|
|
||||||
isosize = file->size;
|
isosize = file->size;
|
||||||
|
|
||||||
boot_catlog = ventoy_get_iso_boot_catlog(file);
|
len = (int)grub_strlen(args[0]);
|
||||||
if (boot_catlog)
|
if (len >= 4 && 0 == grub_strcasecmp(args[0] + len - 4, ".img"))
|
||||||
{
|
{
|
||||||
if (ventoy_is_efi_os() && (!ventoy_has_efi_eltorito(file, boot_catlog)))
|
debug("boot catlog %u for img file\n", boot_catlog);
|
||||||
{
|
|
||||||
grub_env_set("LoadIsoEfiDriver", "on");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
len = (int)grub_strlen(args[0]);
|
boot_catlog = ventoy_get_iso_boot_catlog(file);
|
||||||
if (len >= 4 && 0 == grub_strcasecmp(args[0] + len - 4, ".img"))
|
if (boot_catlog)
|
||||||
{
|
{
|
||||||
debug("boot catlog %u for img file\n", boot_catlog);
|
if (ventoy_is_efi_os() && (!ventoy_has_efi_eltorito(file, boot_catlog)))
|
||||||
|
{
|
||||||
|
grub_env_set("LoadIsoEfiDriver", "on");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
141
GRUB2/MOD_SRC/grub-2.04/include/grub/partition.h
Normal file
141
GRUB2/MOD_SRC/grub-2.04/include/grub/partition.h
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 1999,2000,2001,2002,2004,2006,2007 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* GRUB is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GRUB_PART_HEADER
|
||||||
|
#define GRUB_PART_HEADER 1
|
||||||
|
|
||||||
|
#include <grub/dl.h>
|
||||||
|
#include <grub/list.h>
|
||||||
|
|
||||||
|
struct grub_disk;
|
||||||
|
|
||||||
|
typedef struct grub_partition *grub_partition_t;
|
||||||
|
|
||||||
|
#ifdef GRUB_UTIL
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
GRUB_EMBED_PCBIOS
|
||||||
|
} grub_embed_type_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef int (*grub_partition_iterate_hook_t) (struct grub_disk *disk,
|
||||||
|
const grub_partition_t partition,
|
||||||
|
void *data);
|
||||||
|
|
||||||
|
/* Partition map type. */
|
||||||
|
struct grub_partition_map
|
||||||
|
{
|
||||||
|
/* The next partition map type. */
|
||||||
|
struct grub_partition_map *next;
|
||||||
|
struct grub_partition_map **prev;
|
||||||
|
|
||||||
|
/* The name of the partition map type. */
|
||||||
|
const char *name;
|
||||||
|
|
||||||
|
/* Call HOOK with each partition, until HOOK returns non-zero. */
|
||||||
|
grub_err_t (*iterate) (struct grub_disk *disk,
|
||||||
|
grub_partition_iterate_hook_t hook, void *hook_data);
|
||||||
|
#ifdef GRUB_UTIL
|
||||||
|
/* Determine sectors available for embedding. */
|
||||||
|
grub_err_t (*embed) (struct grub_disk *disk, unsigned int *nsectors,
|
||||||
|
unsigned int max_nsectors,
|
||||||
|
grub_embed_type_t embed_type,
|
||||||
|
grub_disk_addr_t **sectors);
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
typedef struct grub_partition_map *grub_partition_map_t;
|
||||||
|
|
||||||
|
/* Partition description. */
|
||||||
|
struct grub_partition
|
||||||
|
{
|
||||||
|
/* The partition number. */
|
||||||
|
int number;
|
||||||
|
|
||||||
|
/* The start sector (relative to parent). */
|
||||||
|
grub_disk_addr_t start;
|
||||||
|
|
||||||
|
/* The length in sector units. */
|
||||||
|
grub_uint64_t len;
|
||||||
|
|
||||||
|
/* The offset of the partition table. */
|
||||||
|
grub_disk_addr_t offset;
|
||||||
|
|
||||||
|
/* The index of this partition in the partition table. */
|
||||||
|
int index;
|
||||||
|
|
||||||
|
/* Parent partition (physically contains this partition). */
|
||||||
|
struct grub_partition *parent;
|
||||||
|
|
||||||
|
/* The type partition map. */
|
||||||
|
grub_partition_map_t partmap;
|
||||||
|
|
||||||
|
/* The type of partition whne it's on MSDOS.
|
||||||
|
Used for embedding detection. */
|
||||||
|
grub_uint8_t msdostype;
|
||||||
|
|
||||||
|
/* The attrib field for GPT. Needed for priority detection. */
|
||||||
|
grub_uint64_t gpt_attrib;
|
||||||
|
};
|
||||||
|
|
||||||
|
grub_partition_t EXPORT_FUNC(grub_partition_probe) (struct grub_disk *disk,
|
||||||
|
const char *str);
|
||||||
|
int EXPORT_FUNC(grub_partition_iterate) (struct grub_disk *disk,
|
||||||
|
grub_partition_iterate_hook_t hook,
|
||||||
|
void *hook_data);
|
||||||
|
char *EXPORT_FUNC(grub_partition_get_name) (const grub_partition_t partition);
|
||||||
|
|
||||||
|
|
||||||
|
extern grub_partition_map_t EXPORT_VAR(grub_partition_map_list);
|
||||||
|
|
||||||
|
#ifndef GRUB_LST_GENERATOR
|
||||||
|
static inline void
|
||||||
|
grub_partition_map_register (grub_partition_map_t partmap)
|
||||||
|
{
|
||||||
|
grub_list_push (GRUB_AS_LIST_P (&grub_partition_map_list),
|
||||||
|
GRUB_AS_LIST (partmap));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
grub_partition_map_unregister (grub_partition_map_t partmap)
|
||||||
|
{
|
||||||
|
grub_list_remove (GRUB_AS_LIST (partmap));
|
||||||
|
}
|
||||||
|
|
||||||
|
#define FOR_PARTITION_MAPS(var) FOR_LIST_ELEMENTS((var), (grub_partition_map_list))
|
||||||
|
|
||||||
|
|
||||||
|
static inline grub_disk_addr_t
|
||||||
|
grub_partition_get_start (const grub_partition_t p)
|
||||||
|
{
|
||||||
|
grub_partition_t part;
|
||||||
|
grub_uint64_t part_start = 0;
|
||||||
|
|
||||||
|
for (part = p; part; part = part->parent)
|
||||||
|
part_start += part->start;
|
||||||
|
|
||||||
|
return part_start;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline grub_uint64_t
|
||||||
|
grub_partition_get_len (const grub_partition_t p)
|
||||||
|
{
|
||||||
|
return p->len;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* ! GRUB_PART_HEADER */
|
@@ -97,6 +97,8 @@ elif [ "$1" = "arm64" ]; then
|
|||||||
if ! echo $all_modules | grep -q " ${line%.mod} "; then
|
if ! echo $all_modules | grep -q " ${line%.mod} "; then
|
||||||
echo "Copy $line ..."
|
echo "Copy $line ..."
|
||||||
cp -a $VT_DIR/GRUB2/INSTALL/lib/grub/arm64-efi/$line $VT_DIR/INSTALL/grub/arm64-efi/
|
cp -a $VT_DIR/GRUB2/INSTALL/lib/grub/arm64-efi/$line $VT_DIR/INSTALL/grub/arm64-efi/
|
||||||
|
xz $VT_DIR/INSTALL/grub/arm64-efi/$line
|
||||||
|
mv $VT_DIR/INSTALL/grub/arm64-efi/${line}.xz $VT_DIR/INSTALL/grub/arm64-efi/${line}
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
elif [ "$1" = "mips64el" ]; then
|
elif [ "$1" = "mips64el" ]; then
|
||||||
|
83
IMG/cpio/ventoy/hook/easystartup/disk_hook.sh
Normal file
83
IMG/cpio/ventoy/hook/easystartup/disk_hook.sh
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
#!/ventoy/busybox/sh
|
||||||
|
#************************************************************************************
|
||||||
|
# Copyright (c) 2021, longpanda <admin@ventoy.net>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#************************************************************************************
|
||||||
|
|
||||||
|
. /ventoy/hook/ventoy-hook-lib.sh
|
||||||
|
|
||||||
|
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||||
|
|
||||||
|
get_rhel_ver() {
|
||||||
|
if uname -m | grep -q '64'; then
|
||||||
|
machine='_X64'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep -q '6[.]1' /etc/redhat-release; then
|
||||||
|
echo "RHAS6U1$machine"; return
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "RHAS6U1$machine"
|
||||||
|
}
|
||||||
|
|
||||||
|
install_dm_mod_ko() {
|
||||||
|
# dump iso file location
|
||||||
|
vtoydm -i -f $VTOY_PATH/ventoy_image_map -d ${vtdiskname} > $VTOY_PATH/iso_file_list
|
||||||
|
|
||||||
|
sysver=$(get_rhel_ver)
|
||||||
|
vtlog "sysver=$sysver"
|
||||||
|
|
||||||
|
LINE=$(grep "$sysver" -n -m1 $VTOY_PATH/iso_file_list | awk -F: '{print $1}')
|
||||||
|
vtlog "LINE=$LINE"
|
||||||
|
|
||||||
|
LINE=$(sed -n "$LINE,\$p" $VTOY_PATH/iso_file_list | grep -m1 'initrd.img')
|
||||||
|
vtlog "LINE=$LINE"
|
||||||
|
|
||||||
|
sector=$(echo $LINE | $AWK '{print $(NF-1)}')
|
||||||
|
length=$(echo $LINE | $AWK '{print $NF}')
|
||||||
|
vtlog "sector=$sector length=$length"
|
||||||
|
|
||||||
|
mkdir xxx
|
||||||
|
vtoydm -e -f $VTOY_PATH/ventoy_image_map -d ${vtdiskname} -s $sector -l $length -o ./xxx.img
|
||||||
|
|
||||||
|
cd xxx/
|
||||||
|
zcat ../xxx.img | cpio -idmu
|
||||||
|
ko=$(find -name dm-mod.ko*)
|
||||||
|
vtlog "ko=$ko ..."
|
||||||
|
insmod $ko
|
||||||
|
|
||||||
|
cd ../
|
||||||
|
rm -f xxx.img
|
||||||
|
rm -rf xxx
|
||||||
|
}
|
||||||
|
|
||||||
|
vtdiskname=$(get_ventoy_disk_name)
|
||||||
|
vtlog "vtdiskname=$vtdiskname ..."
|
||||||
|
if [ "$vtdiskname" = "unknown" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep -q 'device-mapper' /proc/devices; then
|
||||||
|
vtlog "device-mapper module check ko"
|
||||||
|
else
|
||||||
|
install_dm_mod_ko
|
||||||
|
fi
|
||||||
|
|
||||||
|
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||||
|
|
||||||
|
ln -s /dev/dm-0 /dev/root
|
||||||
|
|
||||||
|
PATH=$VTPATH_OLD
|
23
IMG/cpio/ventoy/hook/easystartup/ventoy-hook.sh
Normal file
23
IMG/cpio/ventoy/hook/easystartup/ventoy-hook.sh
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/ventoy/busybox/sh
|
||||||
|
#************************************************************************************
|
||||||
|
# Copyright (c) 2021, longpanda <admin@ventoy.net>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#************************************************************************************
|
||||||
|
|
||||||
|
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||||
|
|
||||||
|
$SED "s#^CDROM=.*#CDROM=/dev/dm-0#" -i /init
|
||||||
|
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/easystartup/ventoy-initqueue.sh /initqueue/ventoy.sh
|
20
IMG/cpio/ventoy/hook/easystartup/ventoy-initqueue.sh
Normal file
20
IMG/cpio/ventoy/hook/easystartup/ventoy-initqueue.sh
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/ventoy/busybox/sh
|
||||||
|
#************************************************************************************
|
||||||
|
# Copyright (c) 2021, longpanda <admin@ventoy.net>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#************************************************************************************
|
||||||
|
|
||||||
|
/ventoy/busybox/sh /ventoy/hook/easystartup/disk_hook.sh $*
|
@@ -562,6 +562,31 @@ ventoy_create_dev_ventoy_part() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ventoy_create_chromeos_ventoy_part() {
|
||||||
|
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | $GREP ventoy | $SED 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
|
||||||
|
$BUSYBOX_PATH/mknod -m 0666 /dev/ventoy b $blkdev_num
|
||||||
|
|
||||||
|
if [ -e /vtoy_dm_table ]; then
|
||||||
|
vtPartid=1
|
||||||
|
|
||||||
|
$CAT /vtoy_dm_table | while read vtline; do
|
||||||
|
echo $vtline > /ventoy/dm_table_part${vtPartid}
|
||||||
|
|
||||||
|
if [ $vtPartid -eq $1 ]; then
|
||||||
|
$VTOY_PATH/tool/dmsetup create ventoy${vtPartid} /ventoy/dm_table_part${vtPartid} --readonly
|
||||||
|
else
|
||||||
|
$VTOY_PATH/tool/dmsetup create ventoy${vtPartid} /ventoy/dm_table_part${vtPartid}
|
||||||
|
fi
|
||||||
|
|
||||||
|
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | $GREP ventoy${vtPartid} | $SED 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
|
||||||
|
$BUSYBOX_PATH/mknod -m 0666 /dev/ventoy${vtPartid} b $blkdev_num
|
||||||
|
|
||||||
|
vtPartid=$(expr $vtPartid + 1)
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
is_inotify_ventoy_part() {
|
is_inotify_ventoy_part() {
|
||||||
if echo $1 | $GREP -q "2$"; then
|
if echo $1 | $GREP -q "2$"; then
|
||||||
if ! [ -e /sys/block/$1 ]; then
|
if ! [ -e /sys/block/$1 ]; then
|
||||||
|
201
IMG/cpio/ventoy/loop/cloudready/ventoy-hook.sh
Normal file
201
IMG/cpio/ventoy/loop/cloudready/ventoy-hook.sh
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
#!/ventoy/busybox/sh
|
||||||
|
#************************************************************************************
|
||||||
|
# Copyright (c) 2021, longpanda <admin@ventoy.net>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#************************************************************************************
|
||||||
|
|
||||||
|
. /ventoy/hook/ventoy-hook-lib.sh
|
||||||
|
|
||||||
|
vtlog "####### $0 $* ########"
|
||||||
|
|
||||||
|
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||||
|
|
||||||
|
mkdir /sys
|
||||||
|
mount -t sysfs sys /sys
|
||||||
|
mdev -s
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
while [ -n "Y" ]; do
|
||||||
|
usb_disk=$(get_ventoy_disk_name)
|
||||||
|
|
||||||
|
if echo $usb_disk | egrep -q "nvme|mmc|nbd"; then
|
||||||
|
vtpart2=${usb_disk}p2
|
||||||
|
else
|
||||||
|
vtpart2=${usb_disk}2
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e "${vtpart2}" ]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
sleep 2
|
||||||
|
mdev -s
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
vtdiskname=$(get_ventoy_disk_name)
|
||||||
|
if [ "$vtdiskname" = "unknown" ]; then
|
||||||
|
vtlog "ventoy disk not found"
|
||||||
|
PATH=$VTPATH_OLD
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||||
|
|
||||||
|
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
|
||||||
|
vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||||
|
echo -n $vtDM > /ventoy/vtDM
|
||||||
|
|
||||||
|
ventoy_create_chromeos_ventoy_part 3
|
||||||
|
mdev -s
|
||||||
|
|
||||||
|
vtlog "copy out the e2fsck program ..."
|
||||||
|
|
||||||
|
copy_lib() {
|
||||||
|
cp -a /ventoy_rdroot/usr/lib64/$1 /usr/lib64/
|
||||||
|
cp -a /ventoy_rdroot/lib64/$1 /lib64/
|
||||||
|
}
|
||||||
|
|
||||||
|
mkdir /ventoy_rdroot
|
||||||
|
mkdir -p /lib /lib64 /usr/lib64 /sbin
|
||||||
|
|
||||||
|
mount -o ro /dev/ventoy3 /ventoy_rdroot >>$VTLOG 2>&1
|
||||||
|
cp -a /ventoy_rdroot/sbin/e2fsck /sbin/
|
||||||
|
cp -a /ventoy_rdroot/sbin/dmsetup /sbin/
|
||||||
|
|
||||||
|
copy_lib libext2fs*
|
||||||
|
copy_lib libcom_err*
|
||||||
|
copy_lib libe2p*
|
||||||
|
copy_lib libblk*
|
||||||
|
copy_lib libuuid*
|
||||||
|
copy_lib libdl.*
|
||||||
|
copy_lib libdl-*
|
||||||
|
copy_lib libc.*
|
||||||
|
copy_lib libc-*
|
||||||
|
copy_lib libpthread*
|
||||||
|
copy_lib ld-*
|
||||||
|
copy_lib libdevmapper*
|
||||||
|
copy_lib libudev*
|
||||||
|
copy_lib libm.*
|
||||||
|
copy_lib libm-*
|
||||||
|
copy_lib librt*
|
||||||
|
copy_lib libpopt*
|
||||||
|
copy_lib libgpg-error*
|
||||||
|
copy_lib libselinux*
|
||||||
|
copy_lib libsepol*
|
||||||
|
copy_lib libpcre*
|
||||||
|
copy_lib libcap*
|
||||||
|
copy_lib libdw*
|
||||||
|
copy_lib libgcc_s*
|
||||||
|
copy_lib libattr*
|
||||||
|
copy_lib libelf*
|
||||||
|
copy_lib libz.*
|
||||||
|
copy_lib libbz2*
|
||||||
|
copy_lib libgcrypt*
|
||||||
|
copy_lib liblvm*
|
||||||
|
|
||||||
|
ln -s /lib64/libdevmapper.so.1.02 /lib64/libdevmapper.so.1.02.1
|
||||||
|
|
||||||
|
umount /ventoy_rdroot
|
||||||
|
|
||||||
|
vtlog "========================================="
|
||||||
|
vtlog "===== e2fsck -y -v /dev/ventoy1 ====="
|
||||||
|
e2fsck -y -v /dev/ventoy1 >>$VTLOG 2>&1
|
||||||
|
#vtlog "===== e2fsck -y -v /dev/ventoy3 ====="
|
||||||
|
#e2fsck -y -v /dev/ventoy3 >>$VTLOG 2>&1
|
||||||
|
vtlog "===== e2fsck -y -v /dev/ventoy8 ====="
|
||||||
|
e2fsck -y -v /dev/ventoy8 >>$VTLOG 2>&1
|
||||||
|
vtlog "========================================="
|
||||||
|
|
||||||
|
/sbin/dmsetup --version >>$VTLOG 2>&1
|
||||||
|
veritysetup --version >>$VTLOG 2>&1
|
||||||
|
|
||||||
|
vtlog "proc devtmpfs ..."
|
||||||
|
mkdir /newdev
|
||||||
|
mount -t devtmpfs dev /newdev
|
||||||
|
|
||||||
|
cp -a /dev/mapper/ventoy* /newdev/mapper/
|
||||||
|
cp -a /dev/ventoy* /newdev/
|
||||||
|
|
||||||
|
|
||||||
|
vtshortname="${vtdiskname#/dev/}"
|
||||||
|
mv /newdev/${vtshortname} /newdev/backup_${vtshortname}
|
||||||
|
cp -a /dev/ventoy /newdev/${vtshortname}
|
||||||
|
|
||||||
|
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
|
||||||
|
if [ -e /dev/ventoy${i} ]; then
|
||||||
|
if echo $vtdiskname | egrep -q "nvme|mmc|nbd"; then
|
||||||
|
vtpart=p$i
|
||||||
|
else
|
||||||
|
vtpart=$i
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e /newdev/${vtshortname}${vtpart} ]; then
|
||||||
|
mv /newdev/${vtshortname}${vtpart} /newdev/backup_${vtshortname}${vtpart}
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp -a /dev/ventoy${i} /newdev/${vtshortname}${vtpart}
|
||||||
|
|
||||||
|
if [ $i -eq 3 ]; then
|
||||||
|
[ -e /dev/${vtshortname}${vtpart} ] && rm -f /dev/${vtshortname}${vtpart}
|
||||||
|
cp -a /dev/ventoy${i} /dev/${vtshortname}${vtpart}
|
||||||
|
vt_root_dev="/dev/${vtshortname}${vtpart}"
|
||||||
|
vtlog "vt_root_dev=$vt_root_dev"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
# if grep -q 'DM=' /proc/cmdline; then
|
||||||
|
# vtlog "Boot verified image ..."
|
||||||
|
|
||||||
|
# dmP1=$(sed "s/.*\(0 [0-9]* verity\).*/\1/" /proc/cmdline)
|
||||||
|
# alg=$(sed "s/.*alg=\([^ ]*\).*/\1/" /proc/cmdline)
|
||||||
|
# hexdigest=$(sed "s/.*root_hexdigest=\([0-9a-fA-F][0-9a-fA-F]*\).*/\1/" /proc/cmdline)
|
||||||
|
# salt=$(sed "s/.*salt=\([0-9a-fA-F][0-9a-fA-F]*\).*/\1/" /proc/cmdline)
|
||||||
|
# hashstart=$(sed "s/.*hashstart=\([0-9][0-9]*\).*/\1/" /proc/cmdline)
|
||||||
|
|
||||||
|
#512 to 4096
|
||||||
|
# blocknum=$(expr $hashstart / 8)
|
||||||
|
# hashoffset=$(expr $hashstart \* 512)
|
||||||
|
|
||||||
|
# vtlog "veritysetup create vroot $vt_root_dev $vt_root_dev $hexdigest --data-block-size=4096 --hash-block-size=4096 --data-blocks=$blocknum --hash-offset=$hashoffset --salt=$salt --hash=$alg --no-superblock --format=0"
|
||||||
|
# veritysetup create vroot $vt_root_dev $vt_root_dev $hexdigest --data-block-size=4096 --hash-block-size=4096 --data-blocks=$blocknum --hash-offset=$hashoffset --salt=$salt --hash=$alg --no-superblock --format=0
|
||||||
|
# sleep 1
|
||||||
|
# mdev -s
|
||||||
|
|
||||||
|
# blkdev_num=$(dmsetup ls | grep vroot | sed 's/.*(\([0-9][0-9]*\),[^0-9]*\([0-9][0-9]*\).*/\1:\2/')
|
||||||
|
# vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||||
|
# vtlog "blkdev_num=$blkdev_num vtDM=$vtDM"
|
||||||
|
|
||||||
|
# if [ -b /dev/$vtDM ]; then
|
||||||
|
# veritysetup status vroot >> $VTLOG 2>&1
|
||||||
|
# mount -o ro /dev/$vtDM /ventoy_rdroot
|
||||||
|
# else
|
||||||
|
# mount -o ro $vt_root_dev /ventoy_rdroot
|
||||||
|
# fi
|
||||||
|
# else
|
||||||
|
# vtlog "Boot normal image ..."
|
||||||
|
# mount -o ro $vt_root_dev /ventoy_rdroot
|
||||||
|
# fi
|
||||||
|
|
||||||
|
vtlog "Boot normal image ..."
|
||||||
|
mount -o ro $vt_root_dev /ventoy_rdroot
|
||||||
|
|
||||||
|
cp -a $VTLOG /newdev/ventoy.log
|
||||||
|
umount /newdev
|
||||||
|
mount -t devtmpfs dev /ventoy_rdroot/dev
|
||||||
|
|
||||||
|
PATH=$VTPATH_OLD
|
201
IMG/cpio/ventoy/loop/fydeos/ventoy-hook.sh
Normal file
201
IMG/cpio/ventoy/loop/fydeos/ventoy-hook.sh
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
#!/ventoy/busybox/sh
|
||||||
|
#************************************************************************************
|
||||||
|
# Copyright (c) 2021, longpanda <admin@ventoy.net>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#************************************************************************************
|
||||||
|
|
||||||
|
. /ventoy/hook/ventoy-hook-lib.sh
|
||||||
|
|
||||||
|
vtlog "####### $0 $* ########"
|
||||||
|
|
||||||
|
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||||
|
|
||||||
|
mkdir /sys
|
||||||
|
mount -t sysfs sys /sys
|
||||||
|
mdev -s
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
while [ -n "Y" ]; do
|
||||||
|
usb_disk=$(get_ventoy_disk_name)
|
||||||
|
|
||||||
|
if echo $usb_disk | egrep -q "nvme|mmc|nbd"; then
|
||||||
|
vtpart2=${usb_disk}p2
|
||||||
|
else
|
||||||
|
vtpart2=${usb_disk}2
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e "${vtpart2}" ]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
sleep 2
|
||||||
|
mdev -s
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
vtdiskname=$(get_ventoy_disk_name)
|
||||||
|
if [ "$vtdiskname" = "unknown" ]; then
|
||||||
|
vtlog "ventoy disk not found"
|
||||||
|
PATH=$VTPATH_OLD
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||||
|
|
||||||
|
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
|
||||||
|
vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||||
|
echo -n $vtDM > /ventoy/vtDM
|
||||||
|
|
||||||
|
ventoy_create_chromeos_ventoy_part 3
|
||||||
|
mdev -s
|
||||||
|
|
||||||
|
vtlog "copy out the e2fsck program ..."
|
||||||
|
|
||||||
|
copy_lib() {
|
||||||
|
cp -a /ventoy_rdroot/usr/lib64/$1 /usr/lib64/
|
||||||
|
cp -a /ventoy_rdroot/lib64/$1 /lib64/
|
||||||
|
}
|
||||||
|
|
||||||
|
mkdir /ventoy_rdroot
|
||||||
|
mkdir -p /lib /lib64 /usr/lib64 /sbin
|
||||||
|
|
||||||
|
mount -o ro /dev/ventoy3 /ventoy_rdroot >>$VTLOG 2>&1
|
||||||
|
cp -a /ventoy_rdroot/sbin/e2fsck /sbin/
|
||||||
|
cp -a /ventoy_rdroot/sbin/dmsetup /sbin/
|
||||||
|
|
||||||
|
copy_lib libext2fs*
|
||||||
|
copy_lib libcom_err*
|
||||||
|
copy_lib libe2p*
|
||||||
|
copy_lib libblk*
|
||||||
|
copy_lib libuuid*
|
||||||
|
copy_lib libdl.*
|
||||||
|
copy_lib libdl-*
|
||||||
|
copy_lib libc.*
|
||||||
|
copy_lib libc-*
|
||||||
|
copy_lib libpthread*
|
||||||
|
copy_lib ld-*
|
||||||
|
copy_lib libdevmapper*
|
||||||
|
copy_lib libudev*
|
||||||
|
copy_lib libm.*
|
||||||
|
copy_lib libm-*
|
||||||
|
copy_lib librt*
|
||||||
|
copy_lib libpopt*
|
||||||
|
copy_lib libgpg-error*
|
||||||
|
copy_lib libselinux*
|
||||||
|
copy_lib libsepol*
|
||||||
|
copy_lib libpcre*
|
||||||
|
copy_lib libcap*
|
||||||
|
copy_lib libdw*
|
||||||
|
copy_lib libgcc_s*
|
||||||
|
copy_lib libattr*
|
||||||
|
copy_lib libelf*
|
||||||
|
copy_lib libz.*
|
||||||
|
copy_lib libbz2*
|
||||||
|
copy_lib libgcrypt*
|
||||||
|
copy_lib liblvm*
|
||||||
|
|
||||||
|
ln -s /lib64/libdevmapper.so.1.02 /lib64/libdevmapper.so.1.02.1
|
||||||
|
|
||||||
|
umount /ventoy_rdroot
|
||||||
|
|
||||||
|
vtlog "========================================="
|
||||||
|
vtlog "===== e2fsck -y -v /dev/ventoy1 ====="
|
||||||
|
e2fsck -y -v /dev/ventoy1 >>$VTLOG 2>&1
|
||||||
|
#vtlog "===== e2fsck -y -v /dev/ventoy3 ====="
|
||||||
|
#e2fsck -y -v /dev/ventoy3 >>$VTLOG 2>&1
|
||||||
|
vtlog "===== e2fsck -y -v /dev/ventoy8 ====="
|
||||||
|
e2fsck -y -v /dev/ventoy8 >>$VTLOG 2>&1
|
||||||
|
vtlog "========================================="
|
||||||
|
|
||||||
|
/sbin/dmsetup --version >>$VTLOG 2>&1
|
||||||
|
veritysetup --version >>$VTLOG 2>&1
|
||||||
|
|
||||||
|
vtlog "proc devtmpfs ..."
|
||||||
|
mkdir /newdev
|
||||||
|
mount -t devtmpfs dev /newdev
|
||||||
|
|
||||||
|
cp -a /dev/mapper/ventoy* /newdev/mapper/
|
||||||
|
cp -a /dev/ventoy* /newdev/
|
||||||
|
|
||||||
|
|
||||||
|
vtshortname="${vtdiskname#/dev/}"
|
||||||
|
mv /newdev/${vtshortname} /newdev/backup_${vtshortname}
|
||||||
|
cp -a /dev/ventoy /newdev/${vtshortname}
|
||||||
|
|
||||||
|
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
|
||||||
|
if [ -e /dev/ventoy${i} ]; then
|
||||||
|
if echo $vtdiskname | egrep -q "nvme|mmc|nbd"; then
|
||||||
|
vtpart=p$i
|
||||||
|
else
|
||||||
|
vtpart=$i
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e /newdev/${vtshortname}${vtpart} ]; then
|
||||||
|
mv /newdev/${vtshortname}${vtpart} /newdev/backup_${vtshortname}${vtpart}
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp -a /dev/ventoy${i} /newdev/${vtshortname}${vtpart}
|
||||||
|
|
||||||
|
if [ $i -eq 3 ]; then
|
||||||
|
[ -e /dev/${vtshortname}${vtpart} ] && rm -f /dev/${vtshortname}${vtpart}
|
||||||
|
cp -a /dev/ventoy${i} /dev/${vtshortname}${vtpart}
|
||||||
|
vt_root_dev="/dev/${vtshortname}${vtpart}"
|
||||||
|
vtlog "vt_root_dev=$vt_root_dev"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
# if grep -q 'DM=' /proc/cmdline; then
|
||||||
|
# vtlog "Boot verified image ..."
|
||||||
|
|
||||||
|
# dmP1=$(sed "s/.*\(0 [0-9]* verity\).*/\1/" /proc/cmdline)
|
||||||
|
# alg=$(sed "s/.*alg=\([^ ]*\).*/\1/" /proc/cmdline)
|
||||||
|
# hexdigest=$(sed "s/.*root_hexdigest=\([0-9a-fA-F][0-9a-fA-F]*\).*/\1/" /proc/cmdline)
|
||||||
|
# salt=$(sed "s/.*salt=\([0-9a-fA-F][0-9a-fA-F]*\).*/\1/" /proc/cmdline)
|
||||||
|
# hashstart=$(sed "s/.*hashstart=\([0-9][0-9]*\).*/\1/" /proc/cmdline)
|
||||||
|
|
||||||
|
#512 to 4096
|
||||||
|
# blocknum=$(expr $hashstart / 8)
|
||||||
|
# hashoffset=$(expr $hashstart \* 512)
|
||||||
|
|
||||||
|
# vtlog "veritysetup create vroot $vt_root_dev $vt_root_dev $hexdigest --data-block-size=4096 --hash-block-size=4096 --data-blocks=$blocknum --hash-offset=$hashoffset --salt=$salt --hash=$alg --no-superblock --format=0"
|
||||||
|
# veritysetup create vroot $vt_root_dev $vt_root_dev $hexdigest --data-block-size=4096 --hash-block-size=4096 --data-blocks=$blocknum --hash-offset=$hashoffset --salt=$salt --hash=$alg --no-superblock --format=0
|
||||||
|
# sleep 1
|
||||||
|
# mdev -s
|
||||||
|
|
||||||
|
# blkdev_num=$(dmsetup ls | grep vroot | sed 's/.*(\([0-9][0-9]*\),[^0-9]*\([0-9][0-9]*\).*/\1:\2/')
|
||||||
|
# vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||||
|
# vtlog "blkdev_num=$blkdev_num vtDM=$vtDM"
|
||||||
|
|
||||||
|
# if [ -b /dev/$vtDM ]; then
|
||||||
|
# veritysetup status vroot >> $VTLOG 2>&1
|
||||||
|
# mount -o ro /dev/$vtDM /ventoy_rdroot
|
||||||
|
# else
|
||||||
|
# mount -o ro $vt_root_dev /ventoy_rdroot
|
||||||
|
# fi
|
||||||
|
# else
|
||||||
|
# vtlog "Boot normal image ..."
|
||||||
|
# mount -o ro $vt_root_dev /ventoy_rdroot
|
||||||
|
# fi
|
||||||
|
|
||||||
|
vtlog "Boot normal image ..."
|
||||||
|
mount -o ro $vt_root_dev /ventoy_rdroot
|
||||||
|
|
||||||
|
cp -a $VTLOG /newdev/ventoy.log
|
||||||
|
umount /newdev
|
||||||
|
mount -t devtmpfs dev /ventoy_rdroot/dev
|
||||||
|
|
||||||
|
PATH=$VTPATH_OLD
|
@@ -58,6 +58,12 @@ ventoy_get_os_type() {
|
|||||||
|
|
||||||
# rhel6/CentOS6 and all other distributions based on them
|
# rhel6/CentOS6 and all other distributions based on them
|
||||||
elif $GREP -q 'el6' /proc/version; then
|
elif $GREP -q 'el6' /proc/version; then
|
||||||
|
if [ -f /sbin/detectcd ]; then
|
||||||
|
if $GREP -q -i 'LENOVO-EasyStartup' /sbin/detectcd; then
|
||||||
|
echo 'easystartup'; return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
echo 'rhel6'; return
|
echo 'rhel6'; return
|
||||||
|
|
||||||
# rhel7/CentOS7/rhel8/CentOS8 and all other distributions based on them
|
# rhel7/CentOS7/rhel8/CentOS8 and all other distributions based on them
|
||||||
|
@@ -81,6 +81,13 @@ else
|
|||||||
echo "use unsquashfs_32" >>$VTLOG
|
echo "use unsquashfs_32" >>$VTLOG
|
||||||
$BUSYBOX_PATH/cp -a $VTOY_PATH/tool/unsquashfs_32 $VTOY_PATH/tool/vtoy_unsquashfs
|
$BUSYBOX_PATH/cp -a $VTOY_PATH/tool/unsquashfs_32 $VTOY_PATH/tool/vtoy_unsquashfs
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if $GREP -q 64 $VTOY_PATH/ventoy_arch; then
|
||||||
|
echo "use veritysetup64" >>$VTLOG
|
||||||
|
$BUSYBOX_PATH/cp -a $VTOY_PATH/tool/veritysetup64 $VTOY_PATH/tool/veritysetup
|
||||||
|
else
|
||||||
|
echo "use veritysetup32" >>$VTLOG
|
||||||
|
$BUSYBOX_PATH/cp -a $VTOY_PATH/tool/veritysetup32 $VTOY_PATH/tool/veritysetup
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@ elif uname -m | egrep -q 'mips64'; then
|
|||||||
else
|
else
|
||||||
export TOOLDIR=i386
|
export TOOLDIR=i386
|
||||||
fi
|
fi
|
||||||
export PATH=./tool/$TOOLDIR:$PATH
|
export PATH="./tool/$TOOLDIR:$PATH"
|
||||||
|
|
||||||
|
|
||||||
echo ''
|
echo ''
|
||||||
|
@@ -164,7 +164,11 @@ function distro_specify_wim_patch {
|
|||||||
vt_windows_collect_wim_patch wim /BOOT/H3_7PE.WIM
|
vt_windows_collect_wim_patch wim /BOOT/H3_7PE.WIM
|
||||||
vt_windows_collect_wim_patch wim /BOOT/H3_8PE.WIM
|
vt_windows_collect_wim_patch wim /BOOT/H3_8PE.WIM
|
||||||
vt_windows_collect_wim_patch wim /BOOT/H3_81PE.WIM
|
vt_windows_collect_wim_patch wim /BOOT/H3_81PE.WIM
|
||||||
fi
|
elif [ -d (loop)/2k10/winpe ]; then
|
||||||
|
vt_windows_collect_wim_patch wim /2k10/winpe/w1086pe.wim
|
||||||
|
vt_windows_collect_wim_patch wim /2k10/winpe/w8x86pe.wim
|
||||||
|
vt_windows_collect_wim_patch wim /2k10/winpe/w7x86pe.wim
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function distro_specify_wim_patch_phase2 {
|
function distro_specify_wim_patch_phase2 {
|
||||||
@@ -757,6 +761,8 @@ function ventoy_reset_nojoliet {
|
|||||||
else
|
else
|
||||||
vt_iso9660_nojoliet 0
|
vt_iso9660_nojoliet 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
vt_append_extra_sector 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function uefi_iso_menu_func {
|
function uefi_iso_menu_func {
|
||||||
@@ -783,6 +789,12 @@ function uefi_iso_menu_func {
|
|||||||
else
|
else
|
||||||
set ventoy_fs_probe=iso9660
|
set ventoy_fs_probe=iso9660
|
||||||
ventoy_reset_nojoliet
|
ventoy_reset_nojoliet
|
||||||
|
|
||||||
|
# Lenovo EasyStartup need an addional sector for boundary check
|
||||||
|
if vt_str_begin "$vt_volume_id" "EasyStartup"; then
|
||||||
|
vt_skip_svd "${vtoy_iso_part}${vt_chosen_path}"
|
||||||
|
vt_append_extra_sector 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
loopback loop "${1}${chosen_path}"
|
loopback loop "${1}${chosen_path}"
|
||||||
@@ -1487,6 +1499,11 @@ function vtoy_unsupport_menuentry {
|
|||||||
#============================================================#
|
#============================================================#
|
||||||
#
|
#
|
||||||
|
|
||||||
|
function only_uefi_tip {
|
||||||
|
echo -e "\n This IMG file is only supported in UEFI mode. \n"
|
||||||
|
echo -e "\n press ENTER to exit ..."
|
||||||
|
read vtInputKey
|
||||||
|
}
|
||||||
|
|
||||||
function ventoy_img_easyos {
|
function ventoy_img_easyos {
|
||||||
vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
|
vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
|
||||||
@@ -1730,6 +1747,74 @@ function ventoy_img_tails {
|
|||||||
vt_unset_boot_opt
|
vt_unset_boot_opt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ventoy_img_fydeos {
|
||||||
|
if [ "$grub_platform" = "pc" ]; then
|
||||||
|
only_uefi_tip
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=64"
|
||||||
|
vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
|
||||||
|
|
||||||
|
ventoy_debug_pause
|
||||||
|
|
||||||
|
#boot image file
|
||||||
|
vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=fydeos
|
||||||
|
vt_img_hook_root
|
||||||
|
|
||||||
|
set grubdisk=vtimghd
|
||||||
|
set grubpartA=(vtimghd,3)
|
||||||
|
set grubpartB=(vtimghd,5)
|
||||||
|
set linuxpartA=(sda,3)
|
||||||
|
set linuxpartB=(sda,5)
|
||||||
|
|
||||||
|
set root=(vtimghd,12)
|
||||||
|
configfile (vtimghd,12)/efi/boot/grub.cfg
|
||||||
|
|
||||||
|
vt_img_unhook_root
|
||||||
|
vt_unset_boot_opt
|
||||||
|
|
||||||
|
unset grubdisk
|
||||||
|
unset grubpartA
|
||||||
|
unset grubpartB
|
||||||
|
unset linuxpartA
|
||||||
|
unset linuxpartB
|
||||||
|
}
|
||||||
|
|
||||||
|
function ventoy_img_cloudready {
|
||||||
|
if [ "$grub_platform" = "pc" ]; then
|
||||||
|
only_uefi_tip
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=64"
|
||||||
|
vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
|
||||||
|
|
||||||
|
ventoy_debug_pause
|
||||||
|
|
||||||
|
#boot image file
|
||||||
|
vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=cloudready
|
||||||
|
vt_img_hook_root
|
||||||
|
|
||||||
|
set grubdisk=vtimghd
|
||||||
|
set grubpartA=(vtimghd,3)
|
||||||
|
set grubpartB=(vtimghd,5)
|
||||||
|
set linuxpartA=(sda,3)
|
||||||
|
set linuxpartB=(sda,5)
|
||||||
|
|
||||||
|
set root=(vtimghd,12)
|
||||||
|
configfile (vtimghd,12)/efi/boot/grub.cfg
|
||||||
|
|
||||||
|
vt_img_unhook_root
|
||||||
|
vt_unset_boot_opt
|
||||||
|
|
||||||
|
unset grubdisk
|
||||||
|
unset grubpartA
|
||||||
|
unset grubpartB
|
||||||
|
unset linuxpartA
|
||||||
|
unset linuxpartB
|
||||||
|
}
|
||||||
|
|
||||||
function ventoy_img_memtest86 {
|
function ventoy_img_memtest86 {
|
||||||
chainloader (vtimghd,1)/efi/boot/BOOTX64.efi
|
chainloader (vtimghd,1)/efi/boot/BOOTX64.efi
|
||||||
boot
|
boot
|
||||||
@@ -1754,6 +1839,7 @@ function legacy_img_memdisk {
|
|||||||
function img_common_menuentry {
|
function img_common_menuentry {
|
||||||
set ventoy_compatible=YES
|
set ventoy_compatible=YES
|
||||||
set ventoy_busybox_ver=32
|
set ventoy_busybox_ver=32
|
||||||
|
unset LoadIsoEfiDriver
|
||||||
|
|
||||||
vt_chosen_img_path vt_chosen_path vt_chosen_size
|
vt_chosen_img_path vt_chosen_path vt_chosen_size
|
||||||
|
|
||||||
@@ -1787,19 +1873,26 @@ function img_common_menuentry {
|
|||||||
|
|
||||||
|
|
||||||
vt_get_fs_label (vtimghd,1) vtImgHd1Label
|
vt_get_fs_label (vtimghd,1) vtImgHd1Label
|
||||||
if [ -d (vtimghd,2)/lib ]; then
|
|
||||||
|
if [ "$vtImgHd1Label" = "STATE" ]; then
|
||||||
|
vt_get_fs_label (vtimghd,3) vtImgHd3Label
|
||||||
|
elif [ -d (vtimghd,2)/lib ]; then
|
||||||
vt_get_fs_label (vtimghd,2) vtImgHd2Label
|
vt_get_fs_label (vtimghd,2) vtImgHd2Label
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e (vtimghd,1)/etc/hostname ]; then
|
if [ -e (vtimghd,1)/etc/hostname ]; then
|
||||||
vt_1st_line (vtimghd,1)/etc/hostname vtImgHostname
|
vt_1st_line (vtimghd,1)/etc/hostname vtImgHostname
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if vt_str_begin "$vtImgHd3Label" "ROOT-"; then
|
||||||
if [ -e (vtimghd,1)/easy.sfs ]; then
|
if [ -f (vtimghd,3)/etc/os-release.d/ID ]; then
|
||||||
ventoy_img_easyos
|
vt_1st_line (vtimghd,3)/etc/os-release.d/ID vt_release_line1
|
||||||
elif [ -e (vtimghd,1)/volumio.initrd ]; then
|
if [ vt_str_begin "$vt_release_line1" "FydeOS" ]; then
|
||||||
ventoy_img_volumio
|
ventoy_img_fydeos
|
||||||
|
fi
|
||||||
|
elif [ -f (vtimghd,3)/etc/cloudready-release ]; then
|
||||||
|
ventoy_img_cloudready
|
||||||
|
fi
|
||||||
elif vt_str_begin "$vtImgHd1Label" "LAKKA"; then
|
elif vt_str_begin "$vtImgHd1Label" "LAKKA"; then
|
||||||
ventoy_img_openelec lakka
|
ventoy_img_openelec lakka
|
||||||
elif vt_str_begin "$vtImgHd1Label" "LIBREELEC"; then
|
elif vt_str_begin "$vtImgHd1Label" "LIBREELEC"; then
|
||||||
@@ -1814,6 +1907,10 @@ function img_common_menuentry {
|
|||||||
ventoy_img_tails
|
ventoy_img_tails
|
||||||
elif [ "$vtImgHd2Label" = "RECALBOX" ]; then
|
elif [ "$vtImgHd2Label" = "RECALBOX" ]; then
|
||||||
ventoy_img_recalbox
|
ventoy_img_recalbox
|
||||||
|
elif [ -e (vtimghd,1)/easy.sfs ]; then
|
||||||
|
ventoy_img_easyos
|
||||||
|
elif [ -e (vtimghd,1)/volumio.initrd ]; then
|
||||||
|
ventoy_img_volumio
|
||||||
elif [ -f (vtimghd,2)/loader/entries/ubos.conf ]; then
|
elif [ -f (vtimghd,2)/loader/entries/ubos.conf ]; then
|
||||||
ventoy_img_ubos
|
ventoy_img_ubos
|
||||||
elif [ -f (vtimghd,2)/etc/openwrt_version ]; then
|
elif [ -f (vtimghd,2)/etc/openwrt_version ]; then
|
||||||
@@ -1823,7 +1920,7 @@ function img_common_menuentry {
|
|||||||
img_unsupport_tip
|
img_unsupport_tip
|
||||||
else
|
else
|
||||||
ventoy_img_memtest86
|
ventoy_img_memtest86
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
vt_linux_chain_data "${vtoy_iso_part}${vt_chosen_path}"
|
vt_linux_chain_data "${vtoy_iso_part}${vt_chosen_path}"
|
||||||
ventoy_acpi_param ${vtoy_chain_mem_addr} 512
|
ventoy_acpi_param ${vtoy_chain_mem_addr} 512
|
||||||
@@ -1857,7 +1954,7 @@ function img_unsupport_menuentry {
|
|||||||
#############################################################
|
#############################################################
|
||||||
#############################################################
|
#############################################################
|
||||||
|
|
||||||
set VENTOY_VERSION="1.0.50"
|
set VENTOY_VERSION="1.0.51"
|
||||||
|
|
||||||
#ACPI not compatible with Window7/8, so disable by default
|
#ACPI not compatible with Window7/8, so disable by default
|
||||||
set VTOY_PARAM_NO_ACPI=1
|
set VTOY_PARAM_NO_ACPI=1
|
||||||
@@ -1935,9 +2032,11 @@ vt_load_part_table $vtoydev
|
|||||||
|
|
||||||
#Load Plugin
|
#Load Plugin
|
||||||
if [ -f $vtoy_iso_part/ventoy/ventoy.json ]; then
|
if [ -f $vtoy_iso_part/ventoy/ventoy.json ]; then
|
||||||
clear
|
clear
|
||||||
vt_load_plugin $vtoy_iso_part
|
vt_load_plugin $vtoy_iso_part
|
||||||
clear
|
clear
|
||||||
|
else
|
||||||
|
vt_check_json_path_case $vtoy_iso_part
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$VTOY_MENU_TIMEOUT" ]; then
|
if [ -n "$VTOY_MENU_TIMEOUT" ]; then
|
||||||
@@ -2004,6 +2103,15 @@ if [ -n "$VTOY_DEFAULT_KBD_LAYOUT" ]; then
|
|||||||
set_keyboard_layout "$VTOY_DEFAULT_KBD_LAYOUT"
|
set_keyboard_layout "$VTOY_DEFAULT_KBD_LAYOUT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "$VTOY_PLUGIN_PATH_CASE_MISMATCH" ]; then
|
||||||
|
clear
|
||||||
|
echo "$VTOY_PLUGIN_PATH_CASE_MISMATCH"
|
||||||
|
echo -e "\n\nPath case does not match! ventoy directory and ventoy.json MUST be all lowercase!"
|
||||||
|
echo -e "\n路径大小写不匹配!ventoy 目录和 ventoy.json 文件的名字必须是全部小写,请修正!"
|
||||||
|
echo -e "\n\npress ENTER to continue (请按回车键继续) ..."
|
||||||
|
read vtInputKey
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "$VTOY_PLUGIN_SYNTAX_ERROR" ]; then
|
if [ -n "$VTOY_PLUGIN_SYNTAX_ERROR" ]; then
|
||||||
clear
|
clear
|
||||||
echo -e "\n Syntax error detected in ventoy.json, please check! \n"
|
echo -e "\n Syntax error detected in ventoy.json, please check! \n"
|
||||||
|
@@ -105,6 +105,23 @@ else
|
|||||||
echo "BOOTIA32.EFI NOT found ..."
|
echo "BOOTIA32.EFI NOT found ..."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menuentry 'Search and boot xorboot' --class=boot_xorboot --class=F4boot {
|
||||||
|
set VTOY_SEARCH_NO_VTOYEFI=1
|
||||||
|
if search -n -s -f /efi/xorboot/xorboot32.xor; then
|
||||||
|
unset VTOY_SEARCH_NO_VTOYEFI
|
||||||
|
terminal_output console
|
||||||
|
if [ -f /efi/xorboot/bootia32.efi ]; then
|
||||||
|
chainloader /efi/xorboot/bootia32.efi
|
||||||
|
elif [ -f /efi/xorboot/xorboot.efi ]; then
|
||||||
|
chainloader /efi/xorboot/xorboot.efi
|
||||||
|
fi
|
||||||
|
boot
|
||||||
|
else
|
||||||
|
unset VTOY_SEARCH_NO_VTOYEFI
|
||||||
|
echo "xorboot NOT found ..."
|
||||||
|
fi
|
||||||
|
}
|
||||||
elif [ "$grub_cpu" = "arm64" ]; then
|
elif [ "$grub_cpu" = "arm64" ]; then
|
||||||
menuentry 'Search and boot BOOTAA64.EFI' --class=boot_uefi --class=F4boot {
|
menuentry 'Search and boot BOOTAA64.EFI' --class=boot_uefi --class=F4boot {
|
||||||
set VTOY_SEARCH_NO_VTOYEFI=1
|
set VTOY_SEARCH_NO_VTOYEFI=1
|
||||||
@@ -131,9 +148,25 @@ else
|
|||||||
echo "BOOTX64.EFI NOT found ..."
|
echo "BOOTX64.EFI NOT found ..."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menuentry 'Search and boot xorboot' --class=boot_xorboot --class=F4boot {
|
||||||
|
set VTOY_SEARCH_NO_VTOYEFI=1
|
||||||
|
if search -n -s -f /efi/xorboot/xorboot.xor; then
|
||||||
|
unset VTOY_SEARCH_NO_VTOYEFI
|
||||||
|
terminal_output console
|
||||||
|
if [ -f /efi/xorboot/bootx64.efi ]; then
|
||||||
|
chainloader /efi/xorboot/bootx64.efi
|
||||||
|
elif [ -f /efi/xorboot/xorboot.efi ]; then
|
||||||
|
chainloader /efi/xorboot/xorboot.efi
|
||||||
|
fi
|
||||||
|
boot
|
||||||
|
else
|
||||||
|
unset VTOY_SEARCH_NO_VTOYEFI
|
||||||
|
echo "xorboot NOT found ..."
|
||||||
|
fi
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@@ -320,7 +320,7 @@ EOF
|
|||||||
for i in 0 1 2 3 4 5 6 7 8 9; do
|
for i in 0 1 2 3 4 5 6 7 8 9; do
|
||||||
check_umount_disk "$PART2"
|
check_umount_disk "$PART2"
|
||||||
|
|
||||||
if mkfs.vfat -F 16 -n VTOYEFI $PART2; then
|
if mkfs.vfat -F 16 -n VTOYEFI -s 1 $PART2; then
|
||||||
echo 'success'
|
echo 'success'
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
|
Binary file not shown.
Binary file not shown.
@@ -77,9 +77,13 @@ cp $OPT ./tool/ENROLL_THIS_KEY_IN_MOKMANAGER.cer $tmpmnt/
|
|||||||
|
|
||||||
|
|
||||||
mkdir -p $tmpmnt/tool
|
mkdir -p $tmpmnt/tool
|
||||||
cp $OPT ./tool/i386/mount.exfat-fuse $tmpmnt/tool/mount.exfat-fuse_i386
|
# cp $OPT ./tool/i386/mount.exfat-fuse $tmpmnt/tool/mount.exfat-fuse_i386
|
||||||
cp $OPT ./tool/x86_64/mount.exfat-fuse $tmpmnt/tool/mount.exfat-fuse_x86_64
|
# cp $OPT ./tool/x86_64/mount.exfat-fuse $tmpmnt/tool/mount.exfat-fuse_x86_64
|
||||||
cp $OPT ./tool/aarch64/mount.exfat-fuse $tmpmnt/tool/mount.exfat-fuse_aarch64
|
# cp $OPT ./tool/aarch64/mount.exfat-fuse $tmpmnt/tool/mount.exfat-fuse_aarch64
|
||||||
|
# to save space
|
||||||
|
cp $OPT ./tool/i386/vtoygpt $tmpmnt/tool/mount.exfat-fuse_i386
|
||||||
|
cp $OPT ./tool/x86_64/vtoygpt $tmpmnt/tool/mount.exfat-fuse_x86_64
|
||||||
|
cp $OPT ./tool/aarch64/vtoygpt $tmpmnt/tool/mount.exfat-fuse_aarch64
|
||||||
|
|
||||||
|
|
||||||
rm -f $tmpmnt/grub/i386-pc/*.img
|
rm -f $tmpmnt/grub/i386-pc/*.img
|
||||||
|
@@ -16,7 +16,7 @@ You can copy many image files at a time and ventoy will give you a boot menu to
|
|||||||
x86 Legacy BIOS, IA32 UEFI, x86_64 UEFI, ARM64 UEFI and MIPS64EL UEFI are supported in the same way.<br/>
|
x86 Legacy BIOS, IA32 UEFI, x86_64 UEFI, ARM64 UEFI and MIPS64EL UEFI are supported in the same way.<br/>
|
||||||
Both MBR and GPT partition style are supported in the same way.<br/>
|
Both MBR and GPT partition style are supported in the same way.<br/>
|
||||||
Most type of OS supported(Windows/WinPE/Linux/Unix/Vmware/Xen...) <br/>
|
Most type of OS supported(Windows/WinPE/Linux/Unix/Vmware/Xen...) <br/>
|
||||||
720+ ISO files are tested (<a href="https://www.ventoy.net/en/isolist.html">List</a>). 90%+ distros in <a href="https://distrowatch.com/">distrowatch.com</a> supported. <br/>
|
730+ ISO files are tested (<a href="https://www.ventoy.net/en/isolist.html">List</a>). 90%+ distros in <a href="https://distrowatch.com/">distrowatch.com</a> supported. <br/>
|
||||||
<br/>Official Website: <a href=https://www.ventoy.net>https://www.ventoy.net</a>
|
<br/>Official Website: <a href=https://www.ventoy.net>https://www.ventoy.net</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ Most type of OS supported(Windows/WinPE/Linux/Unix/Vmware/Xen...) <br/>
|
|||||||
* FAT32/exFAT/NTFS/UDF/XFS/Ext2(3)(4) supported for main partition
|
* FAT32/exFAT/NTFS/UDF/XFS/Ext2(3)(4) supported for main partition
|
||||||
* ISO files larger than 4GB supported
|
* ISO files larger than 4GB supported
|
||||||
* Native boot menu style for Legacy & UEFI
|
* Native boot menu style for Legacy & UEFI
|
||||||
* Most type of OS supported, 720+ iso files tested
|
* Most type of OS supported, 730+ iso files tested
|
||||||
* Linux vDisk boot supported
|
* Linux vDisk boot supported
|
||||||
* Not only boot but also complete installation process
|
* Not only boot but also complete installation process
|
||||||
* Menu dynamically switchable between List/TreeView mode
|
* Menu dynamically switchable between List/TreeView mode
|
||||||
|
@@ -698,12 +698,45 @@ static int VentoyFatDiskRead(uint32 Sector, uint8 *Buffer, uint32 SectorCount)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL Is2K10PE(void)
|
||||||
|
{
|
||||||
|
BOOL bRet = FALSE;
|
||||||
|
FILE *fp = NULL;
|
||||||
|
CHAR szLine[1024];
|
||||||
|
|
||||||
|
fopen_s(&fp, "X:\\Windows\\System32\\PECMD.INI", "r");
|
||||||
|
if (!fp)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(szLine, 0, sizeof(szLine));
|
||||||
|
while (fgets(szLine, sizeof(szLine) - 1, fp))
|
||||||
|
{
|
||||||
|
if (strstr(szLine, "2k10\\"))
|
||||||
|
{
|
||||||
|
bRet = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
|
||||||
static CHAR GetMountLogicalDrive(void)
|
static CHAR GetMountLogicalDrive(void)
|
||||||
{
|
{
|
||||||
CHAR Letter = 'Y';
|
CHAR Letter = 'Y';
|
||||||
DWORD Drives;
|
DWORD Drives;
|
||||||
DWORD Mask = 0x1000000;
|
DWORD Mask = 0x1000000;
|
||||||
|
|
||||||
|
// fixed use M as mountpoint for 2K10 PE
|
||||||
|
if (Is2K10PE())
|
||||||
|
{
|
||||||
|
Log("Use M: for 2K10 PE");
|
||||||
|
return 'M';
|
||||||
|
}
|
||||||
|
|
||||||
Drives = GetLogicalDrives();
|
Drives = GetLogicalDrives();
|
||||||
Log("Drives=0x%x", Drives);
|
Log("Drives=0x%x", Drives);
|
||||||
|
|
||||||
@@ -770,20 +803,68 @@ UINT64 GetVentoyEfiPartStartSector(HANDLE hDrive)
|
|||||||
return StartSector;
|
return StartSector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int VentoyRunImdisk(const char *IsoPath, const char *imdiskexe)
|
||||||
|
{
|
||||||
|
CHAR Letter;
|
||||||
|
CHAR Cmdline[512];
|
||||||
|
WCHAR CmdlineW[512];
|
||||||
|
PROCESS_INFORMATION Pi;
|
||||||
|
|
||||||
|
Log("VentoyRunImdisk <%s> <%s>", IsoPath, imdiskexe);
|
||||||
|
|
||||||
|
Letter = GetMountLogicalDrive();
|
||||||
|
sprintf_s(Cmdline, sizeof(Cmdline), "%s -a -o ro -f \"%s\" -m %C:", imdiskexe, IsoPath, Letter);
|
||||||
|
Log("mount iso to %C: use imdisk cmd <%s>", Letter, Cmdline);
|
||||||
|
|
||||||
|
if (IsUTF8Encode(IsoPath))
|
||||||
|
{
|
||||||
|
STARTUPINFOW Si;
|
||||||
|
GetStartupInfoW(&Si);
|
||||||
|
Si.dwFlags |= STARTF_USESHOWWINDOW;
|
||||||
|
Si.wShowWindow = SW_HIDE;
|
||||||
|
|
||||||
|
Utf8ToUtf16(Cmdline, CmdlineW);
|
||||||
|
CreateProcessW(NULL, CmdlineW, NULL, NULL, FALSE, 0, NULL, NULL, &Si, &Pi);
|
||||||
|
|
||||||
|
Log("This is UTF8 encoding");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
STARTUPINFOA Si;
|
||||||
|
GetStartupInfoA(&Si);
|
||||||
|
Si.dwFlags |= STARTF_USESHOWWINDOW;
|
||||||
|
Si.wShowWindow = SW_HIDE;
|
||||||
|
|
||||||
|
CreateProcessA(NULL, Cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &Si, &Pi);
|
||||||
|
|
||||||
|
Log("This is ANSI encoding");
|
||||||
|
}
|
||||||
|
|
||||||
|
Log("Wait for imdisk process ...");
|
||||||
|
WaitForSingleObject(Pi.hProcess, INFINITE);
|
||||||
|
Log("imdisk process finished");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int VentoyMountISOByImdisk(const char *IsoPath, DWORD PhyDrive)
|
int VentoyMountISOByImdisk(const char *IsoPath, DWORD PhyDrive)
|
||||||
{
|
{
|
||||||
int rc = 1;
|
int rc = 1;
|
||||||
BOOL bRet;
|
BOOL bRet;
|
||||||
CHAR Letter;
|
|
||||||
DWORD dwBytes;
|
DWORD dwBytes;
|
||||||
HANDLE hDrive;
|
HANDLE hDrive;
|
||||||
CHAR PhyPath[MAX_PATH];
|
CHAR PhyPath[MAX_PATH];
|
||||||
WCHAR PhyPathW[MAX_PATH];
|
|
||||||
PROCESS_INFORMATION Pi;
|
|
||||||
GET_LENGTH_INFORMATION LengthInfo;
|
GET_LENGTH_INFORMATION LengthInfo;
|
||||||
|
|
||||||
Log("VentoyMountISOByImdisk %s", IsoPath);
|
Log("VentoyMountISOByImdisk %s", IsoPath);
|
||||||
|
|
||||||
|
if (IsFileExist("X:\\Windows\\System32\\imdisk.exe"))
|
||||||
|
{
|
||||||
|
Log("imdisk.exe exist, use it directly...");
|
||||||
|
VentoyRunImdisk(IsoPath, "imdisk.exe");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
sprintf_s(PhyPath, sizeof(PhyPath), "\\\\.\\PhysicalDrive%d", PhyDrive);
|
sprintf_s(PhyPath, sizeof(PhyPath), "\\\\.\\PhysicalDrive%d", PhyDrive);
|
||||||
hDrive = CreateFileA(PhyPath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
|
hDrive = CreateFileA(PhyPath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
|
||||||
if (hDrive == INVALID_HANDLE_VALUE)
|
if (hDrive == INVALID_HANDLE_VALUE)
|
||||||
@@ -826,37 +907,8 @@ int VentoyMountISOByImdisk(const char *IsoPath, DWORD PhyDrive)
|
|||||||
|
|
||||||
if (LoadNtDriver(PhyPath) == 0)
|
if (LoadNtDriver(PhyPath) == 0)
|
||||||
{
|
{
|
||||||
|
VentoyRunImdisk(IsoPath, "ventoy\\imdisk.exe");
|
||||||
rc = 0;
|
rc = 0;
|
||||||
|
|
||||||
Letter = GetMountLogicalDrive();
|
|
||||||
sprintf_s(PhyPath, sizeof(PhyPath), "ventoy\\imdisk.exe -a -o ro -f \"%s\" -m %C:", IsoPath, Letter);
|
|
||||||
Log("mount iso to %C: use imdisk cmd <%s>", Letter, PhyPath);
|
|
||||||
|
|
||||||
if (IsUTF8Encode(IsoPath))
|
|
||||||
{
|
|
||||||
STARTUPINFOW Si;
|
|
||||||
GetStartupInfoW(&Si);
|
|
||||||
Si.dwFlags |= STARTF_USESHOWWINDOW;
|
|
||||||
Si.wShowWindow = SW_HIDE;
|
|
||||||
|
|
||||||
Utf8ToUtf16(PhyPath, PhyPathW);
|
|
||||||
CreateProcessW(NULL, PhyPathW, NULL, NULL, FALSE, 0, NULL, NULL, &Si, &Pi);
|
|
||||||
|
|
||||||
Log("This is UTF8 encoding");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
STARTUPINFOA Si;
|
|
||||||
GetStartupInfoA(&Si);
|
|
||||||
Si.dwFlags |= STARTF_USESHOWWINDOW;
|
|
||||||
Si.wShowWindow = SW_HIDE;
|
|
||||||
|
|
||||||
CreateProcessA(NULL, PhyPath, NULL, NULL, FALSE, 0, NULL, NULL, &Si, &Pi);
|
|
||||||
|
|
||||||
Log("This is ANSI encoding");
|
|
||||||
}
|
|
||||||
|
|
||||||
WaitForSingleObject(Pi.hProcess, INFINITE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fl_shutdown();
|
fl_shutdown();
|
||||||
|
Reference in New Issue
Block a user