Compare commits

...

26 Commits

Author SHA1 Message Date
longpanda
ed1aa3d5be 1.0.72 release 2022-03-26 17:33:46 +08:00
longpanda
8e66110374 Update README.md 2022-03-26 16:07:51 +08:00
Kerollos Magdy
f5f65aa868 add GitHub actions state to README (#419)
* add GitHub actions state to README

* Update README.md

* remove link in README

Co-authored-by: Dylan M. Taylor <dylan@dylanmtaylor.com>
2022-03-26 10:51:26 +08:00
geeseven
4e5fcf211b add IMG to no iso tip (#480) 2022-03-26 10:48:45 +08:00
Celine Lee
9789069c0d Modify casting in protection against underflow (#1514)
Dear Ventoy community –
 
Our team is working with your code and we noticed this if logical expression:
 
                if (len - 1 - (int)(long)(pos - pwdstr) != 32)
 
We studied the surrounding code. We believe we understand the intention of the type casts in the above if statement. It seems they were meant to ensure an underflow doesn’t occur by the subtraction between to char pointers, which is a great catch (!). However, we believe the way the type casts are structured, the code is not actually protecting against such underflow because pwdstr isn’t cast into a signed long until after the subtraction occurs. To properly protect this code against underflow, we believe it should be changed to something like the following:

if (len - 1 - ((long)pos – (long)pwdstr) != 32)

Or, to enhance readability for junior engineers who may not know that the “long” type cast is implicitly of a signed integer type, we could include the `signed` keyword for added verbosity:
 
if (len - 1 - ((signed long)pos – (signed long)pwdstr) != 32)
 
Thank you!
2022-03-26 10:29:18 +08:00
longpanda
1cf45ac0c5 update 2022-03-26 10:07:22 +08:00
adrian5
40fe21f909 Fix wording, normalize capitalization (#762)
Co-authored-by: longpanda <59477474+ventoy@users.noreply.github.com>
2022-03-26 10:05:18 +08:00
George
e6bdf075ca Changes to english language (#1140)
Changes detail to details and replug to reinsert. Which makes words flow with the sentance better.
2022-03-26 09:47:28 +08:00
Chrystian Rafael Rubio de Melo
7c76e57bf4 fixing grammar mistakes (#1482) 2022-03-26 09:46:35 +08:00
longpanda
7fe038b697 Merge branch 'master' of https://github.com/ventoy/Ventoy 2022-03-24 23:48:01 +08:00
longpanda
c01c69db3b Add missing execute bit when packing (#1530) 2022-03-24 23:47:43 +08:00
Celine Lee
0e996e74c9 Update error message to align with int16 range (#1513)
I think this might be a minor typo-- since the conditional checks for `priority` to be in the signed int16 range, the error message should line up with that expected range.
2022-03-22 19:15:25 +08:00
longpanda
1371159f0b update OS detection 2022-03-22 19:14:51 +08:00
longpanda
44b38dce74 Add support for venomlinux (#1526) 2022-03-22 17:52:56 +08:00
longpanda
392d8ef4fa 1.0.71 release 2022-03-11 21:36:42 +08:00
VenusGirl❤
d1900c75cd Create ko_KR.txt (#1462)
Korean Help
2022-03-11 21:25:01 +08:00
fa7e1d5fa0 keep up with 1.0.67 (#1464)
Modify Japanese Translation for Grub Help Text to Keep up with 1.0.67 Release
2022-03-11 21:23:51 +08:00
longpanda
6ae8bf840d Suppress the Fn hotkey when VTOY_DEFAULT_IMAGE is already Fn>xxx 2022-03-08 19:26:04 +08:00
longpanda
ce862da402 1. Fix the bug when booing Easy Recovery Essentional for Windows10.
2. Fix the bug when booting FreeBSD 13.0 by F2 browser mode.
2022-03-08 18:27:07 +08:00
longpanda
6d4f5ff00b Update FUNDING.yml 2022-03-07 00:14:40 +08:00
longpanda
ab0f25d097 Fixe the issue when booting PrimeOS 2.0.1 2022-03-06 21:04:36 +08:00
longpanda
ff14c07c4e Support Easy Recovery Essentials (#1481) 2022-03-06 19:31:18 +08:00
longpanda
f7fac26c91 Auto use memdisk mode for KolibriOS.iso 2022-02-23 23:35:57 +08:00
longpanda
ebae102f41 Fix the issue when set F2> as the default menu item. 2022-02-23 17:05:33 +08:00
longpanda
c3718d6001 Auto use memdisk mode for Memtest86+ iso file. 2022-02-22 22:23:33 +08:00
longpanda
d0744513a6 You can set { "VTOY_DEFAULT_IMAGE": "F2>" } to set F2 browser as the default menu entry. 2022-02-22 20:20:59 +08:00
38 changed files with 1064 additions and 213 deletions

2
.github/FUNDING.yml vendored
View File

@@ -6,7 +6,7 @@ open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username liberapay: Ventoy
issuehunt: # Replace with a single IssueHunt username issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username otechie: # Replace with a single Otechie username
custom: ['https://www.paypal.me/ventoy', 'https://www.ventoy.net/en/donation.html'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] custom: ['https://www.paypal.me/ventoy', 'https://www.ventoy.net/en/donation.html'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

View File

@@ -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.70 placeholder: 1.0.72
validations: validations:
required: true required: true
- type: dropdown - type: dropdown

View File

@@ -108,10 +108,10 @@
cd /home/Ventoy-master/VtoyTool cd /home/Ventoy-master/VtoyTool
sh build.sh sh build.sh
4.8 == Build vtoyfat == 4.8 == Build vtoycli ==
cd /home/Ventoy-master/vtoyfat/fat_io_lib cd /home/Ventoy-master/vtoycli/fat_io_lib
sh buildlib.sh sh buildlib.sh
cd /home/Ventoy-master/vtoyfat cd /home/Ventoy-master/vtoycli
sh build.sh sh build.sh
4.9 == Build exfat-util == 4.9 == Build exfat-util ==

View File

@@ -137,6 +137,10 @@ static grub_uint64_t g_enumerate_start_time_ms;
static grub_uint64_t g_enumerate_finish_time_ms; static grub_uint64_t g_enumerate_finish_time_ms;
int g_vtoy_file_flt[VTOY_FILE_FLT_BUTT] = {0}; int g_vtoy_file_flt[VTOY_FILE_FLT_BUTT] = {0};
static char g_iso_vd_id_publisher[130];
static char g_iso_vd_id_prepare[130];
static char g_iso_vd_id_application[130];
static int g_pager_flag = 0; static int g_pager_flag = 0;
static char g_old_pager[32]; static char g_old_pager[32];
@@ -5469,6 +5473,98 @@ out:
return ret; return ret;
} }
static grub_err_t ventoy_iso_vd_id_clear(grub_extcmd_context_t ctxt, int argc, char **args)
{
(void)ctxt;
(void)argc;
(void)args;
g_iso_vd_id_publisher[0] = 0;
g_iso_vd_id_prepare[0] = 0;
g_iso_vd_id_application[0] = 0;
return 0;
}
static grub_err_t ventoy_cmd_iso_vd_id_parse(grub_extcmd_context_t ctxt, int argc, char **args)
{
int ret = 1;
int offset = 318;
grub_file_t file = NULL;
(void)ctxt;
(void)argc;
file = grub_file_open(args[0], VENTOY_FILE_TYPE);
if (!file)
{
grub_printf("Failed to open %s\n", args[0]);
goto out;
}
grub_file_seek(file, 16 * 2048 + offset);
grub_file_read(file, g_iso_vd_id_publisher, 128);
offset += 128;
grub_file_seek(file, 16 * 2048 + offset);
grub_file_read(file, g_iso_vd_id_prepare, 128);
offset += 128;
grub_file_seek(file, 16 * 2048 + offset);
grub_file_read(file, g_iso_vd_id_application, 128);
out:
check_free(file, grub_file_close);
grub_errno = GRUB_ERR_NONE;
return ret;
}
static grub_err_t ventoy_cmd_iso_vd_id_begin(grub_extcmd_context_t ctxt, int argc, char **args)
{
int ret = 1;
char *id = g_iso_vd_id_publisher;
(void)ctxt;
(void)argc;
if (args[0][0] == '1')
{
id = g_iso_vd_id_prepare;
}
else if (args[0][0] == '2')
{
id = g_iso_vd_id_application;
}
if (args[1][0] == '0' && grub_strncasecmp(id, args[2], grub_strlen(args[2])) == 0)
{
ret = 0;
}
if (args[1][0] == '1' && grub_strncmp(id, args[2], grub_strlen(args[2])) == 0)
{
ret = 0;
}
grub_errno = GRUB_ERR_NONE;
return ret;
}
static grub_err_t ventoy_cmd_fn_mutex_lock(grub_extcmd_context_t ctxt, int argc, char **args)
{
(void)ctxt;
(void)argc;
g_ventoy_fn_mutex = 0;
if (argc == 1 && args[0][0] == '1' && args[0][1] == 0)
{
g_ventoy_fn_mutex = 1;
}
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
int ventoy_env_init(void) int ventoy_env_init(void)
{ {
char buf[64]; char buf[64];
@@ -5630,7 +5726,9 @@ static cmd_para ventoy_cmds[] =
{ "vt_unix_parse_freebsd_ver", ventoy_cmd_unix_freebsd_ver, 0, NULL, "", "", NULL }, { "vt_unix_parse_freebsd_ver", ventoy_cmd_unix_freebsd_ver, 0, NULL, "", "", NULL },
{ "vt_unix_parse_freebsd_ver_elf", ventoy_cmd_unix_freebsd_ver_elf, 0, NULL, "", "", NULL }, { "vt_unix_parse_freebsd_ver_elf", ventoy_cmd_unix_freebsd_ver_elf, 0, NULL, "", "", NULL },
{ "vt_unix_reset", ventoy_cmd_unix_reset, 0, NULL, "", "", NULL }, { "vt_unix_reset", ventoy_cmd_unix_reset, 0, NULL, "", "", NULL },
{ "vt_unix_check_vlnk", ventoy_cmd_unix_check_vlnk, 0, NULL, "", "", NULL },
{ "vt_unix_replace_conf", ventoy_cmd_unix_replace_conf, 0, NULL, "", "", NULL }, { "vt_unix_replace_conf", ventoy_cmd_unix_replace_conf, 0, NULL, "", "", NULL },
{ "vt_unix_replace_grub_conf", ventoy_cmd_unix_replace_grub_conf, 0, NULL, "", "", NULL },
{ "vt_unix_replace_ko", ventoy_cmd_unix_replace_ko, 0, NULL, "", "", NULL }, { "vt_unix_replace_ko", ventoy_cmd_unix_replace_ko, 0, NULL, "", "", NULL },
{ "vt_unix_ko_fillmap", ventoy_cmd_unix_ko_fillmap, 0, NULL, "", "", NULL }, { "vt_unix_ko_fillmap", ventoy_cmd_unix_ko_fillmap, 0, NULL, "", "", NULL },
{ "vt_unix_fill_image_desc", ventoy_cmd_unix_fill_image_desc, 0, NULL, "", "", NULL }, { "vt_unix_fill_image_desc", ventoy_cmd_unix_fill_image_desc, 0, NULL, "", "", NULL },
@@ -5664,6 +5762,10 @@ static cmd_para ventoy_cmds[] =
{ "vt_get_vlnk_dst", grub_cmd_get_vlnk_dst, 0, NULL, "", "", NULL }, { "vt_get_vlnk_dst", grub_cmd_get_vlnk_dst, 0, NULL, "", "", NULL },
{ "vt_set_fake_vlnk", ventoy_cmd_set_fake_vlnk, 0, NULL, "", "", NULL }, { "vt_set_fake_vlnk", ventoy_cmd_set_fake_vlnk, 0, NULL, "", "", NULL },
{ "vt_reset_fake_vlnk", ventoy_cmd_reset_fake_vlnk, 0, NULL, "", "", NULL }, { "vt_reset_fake_vlnk", ventoy_cmd_reset_fake_vlnk, 0, NULL, "", "", NULL },
{ "vt_iso_vd_id_parse", ventoy_cmd_iso_vd_id_parse, 0, NULL, "", "", NULL },
{ "vt_iso_vd_id_clear", ventoy_iso_vd_id_clear, 0, NULL, "", "", NULL },
{ "vt_iso_vd_id_begin", ventoy_cmd_iso_vd_id_begin, 0, NULL, "", "", NULL },
{ "vt_fn_mutex_lock", ventoy_cmd_fn_mutex_lock, 0, NULL, "", "", NULL },
}; };
int ventoy_register_all_cmd(void) int ventoy_register_all_cmd(void)

View File

@@ -1019,6 +1019,7 @@ extern int g_ventoy_grub2_mode;
extern int g_ventoy_wimboot_mode; extern int g_ventoy_wimboot_mode;
extern int g_ventoy_iso_uefi_drv; extern int g_ventoy_iso_uefi_drv;
extern int g_ventoy_case_insensitive; extern int g_ventoy_case_insensitive;
extern int g_ventoy_fn_mutex;
extern grub_uint8_t g_ventoy_chain_type; extern grub_uint8_t g_ventoy_chain_type;
extern int g_vhdboot_enable; extern int g_vhdboot_enable;
@@ -1093,7 +1094,9 @@ grub_err_t ventoy_cmd_locate_wim_patch(grub_extcmd_context_t ctxt, int argc, cha
grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
int ventoy_get_disk_guid(const char *filename, grub_uint8_t *guid, grub_uint8_t *signature); int ventoy_get_disk_guid(const char *filename, grub_uint8_t *guid, grub_uint8_t *signature);
grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_check_vlnk(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_replace_grub_conf(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_ko_fillmap(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_unix_ko_fillmap(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_fill_image_desc(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_unix_fill_image_desc(grub_extcmd_context_t ctxt, int argc, char **args);

View File

@@ -960,7 +960,7 @@ static int ventoy_plugin_parse_pwdstr(char *pwdstr, vtoy_password *pwd)
return 1; return 1;
} }
if (len - 1 - (int)(long)(pos - pwdstr) != 32) if (len - 1 - ((long)pos - (long)pwdstr) != 32)
{ {
if (NULL == pwd) grub_printf("Invalid md5 salt password format %s\n", pwdstr); if (NULL == pwd) grub_printf("Invalid md5 salt password format %s\n", pwdstr);
return 1; return 1;

View File

@@ -48,6 +48,7 @@ int g_mod_new_len = 0;
char *g_mod_new_data = NULL; char *g_mod_new_data = NULL;
int g_mod_search_magic = 0; int g_mod_search_magic = 0;
int g_unix_vlnk_boot = 0;
int g_ko_fillmap_len = 0; int g_ko_fillmap_len = 0;
char *g_ko_fillmap_data = NULL; char *g_ko_fillmap_data = NULL;
@@ -273,13 +274,14 @@ static void ventoy_unix_fill_virt_data( grub_uint64_t isosize, ventoy_chain_h
return; return;
} }
static int ventoy_freebsd_append_conf(char *buf, const char *isopath) static int ventoy_freebsd_append_conf(char *buf, const char *isopath, const char *alias)
{ {
int pos = 0; int pos = 0;
grub_uint32_t i; grub_uint32_t i;
grub_disk_t disk; grub_disk_t disk;
grub_file_t isofile; grub_file_t isofile;
char uuid[64] = {0}; char uuid[64] = {0};
const char *val = NULL;
ventoy_img_chunk *chunk; ventoy_img_chunk *chunk;
grub_uint8_t disk_sig[4]; grub_uint8_t disk_sig[4];
grub_uint8_t disk_guid[16]; grub_uint8_t disk_guid[16];
@@ -295,12 +297,30 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath)
vtoy_ssprintf(buf, pos, "ventoy_load=\"%s\"\n", "YES"); vtoy_ssprintf(buf, pos, "ventoy_load=\"%s\"\n", "YES");
vtoy_ssprintf(buf, pos, "ventoy_name=\"%s\"\n", g_ko_mod_path); vtoy_ssprintf(buf, pos, "ventoy_name=\"%s\"\n", g_ko_mod_path);
if (alias)
{
vtoy_ssprintf(buf, pos, "hint.ventoy.0.alias=\"%s\"\n", alias);
}
if (g_unix_vlnk_boot)
{
vtoy_ssprintf(buf, pos, "hint.ventoy.0.vlnk=%d\n", 1);
}
val = ventoy_get_env("VTOY_UNIX_REMOUNT");
if (val && val[0] == '1' && val[1] == 0)
{
vtoy_ssprintf(buf, pos, "hint.ventoy.0.remount=%d\n", 1);
}
if (g_mod_search_magic) if (g_mod_search_magic)
{ {
debug("hint.ventoy NO need\n"); debug("hint.ventoy NO need\n");
goto out; goto out;
} }
debug("Fill hint.ventoy info\n");
disk = isofile->device->disk; disk = isofile->device->disk;
ventoy_get_disk_guid(isofile->name, disk_guid, disk_sig); ventoy_get_disk_guid(isofile->name, disk_guid, disk_sig);
@@ -349,6 +369,7 @@ grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **ar
(void)argc; (void)argc;
(void)args; (void)args;
g_unix_vlnk_boot = 0;
g_mod_search_magic = 0; g_mod_search_magic = 0;
g_conf_new_len = 0; g_conf_new_len = 0;
g_mod_new_len = 0; g_mod_new_len = 0;
@@ -363,6 +384,27 @@ grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **ar
VENTOY_CMD_RETURN(GRUB_ERR_NONE); VENTOY_CMD_RETURN(GRUB_ERR_NONE);
} }
grub_err_t ventoy_cmd_unix_check_vlnk(grub_extcmd_context_t ctxt, int argc, char **args)
{
grub_file_t file;
(void)ctxt;
if (argc != 1)
{
return 1;
}
file = grub_file_open(args[0], VENTOY_FILE_TYPE);
if (file)
{
g_unix_vlnk_boot = file->vlnk;
grub_file_close(file);
}
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_parse_freenas_ver(grub_extcmd_context_t ctxt, int argc, char **args) grub_err_t ventoy_cmd_parse_freenas_ver(grub_extcmd_context_t ctxt, int argc, char **args)
{ {
grub_file_t file; grub_file_t file;
@@ -647,6 +689,109 @@ out:
VENTOY_CMD_RETURN(GRUB_ERR_NONE); VENTOY_CMD_RETURN(GRUB_ERR_NONE);
} }
grub_err_t ventoy_cmd_unix_replace_grub_conf(grub_extcmd_context_t ctxt, int argc, char **args)
{
int len = 0;
grub_uint32_t i;
char *data;
char *pos;
const char *val = NULL;
grub_uint64_t offset;
grub_file_t file;
char extcfg[512];
const char *confile = NULL;
const char * loader_conf[] =
{
"/boot/grub/grub.cfg",
};
(void)ctxt;
if (argc != 1 && argc != 2)
{
debug("Replace conf invalid argc %d\n", argc);
return 1;
}
for (i = 0; i < sizeof(loader_conf) / sizeof(loader_conf[0]); i++)
{
if (ventoy_get_file_override(loader_conf[i], &offset) == 0)
{
confile = loader_conf[i];
g_conf_override_offset = offset;
break;
}
}
if (confile == NULL)
{
debug("Can't find grub.cfg file from %u locations\n", i);
return 1;
}
file = ventoy_grub_file_open(GRUB_FILE_TYPE_LINUX_INITRD, "(loop)/%s", confile);
if (!file)
{
debug("Failed to open %s \n", confile);
return 1;
}
debug("old grub2 conf file size:%d\n", (int)file->size);
data = grub_malloc(VTOY_MAX_SCRIPT_BUF);
if (!data)
{
grub_file_close(file);
return 1;
}
grub_file_read(file, data, file->size);
grub_file_close(file);
g_conf_new_data = data;
g_conf_new_len = (int)file->size;
pos = grub_strstr(data, "kfreebsd /boot/kernel/kernel");
if (pos)
{
pos += grub_strlen("kfreebsd /boot/kernel/kernel");
if (grub_strncmp(pos, ".gz", 3) == 0)
{
pos += 3;
}
if (argc == 2)
{
vtoy_ssprintf(extcfg, len, ";kfreebsd_module_elf %s; set kFreeBSD.hint.ventoy.0.alias=\"%s\"", args[0], args[1]);
}
else
{
vtoy_ssprintf(extcfg, len, ";kfreebsd_module_elf %s", args[0]);
}
if (g_unix_vlnk_boot)
{
vtoy_ssprintf(extcfg, len, ";set kFreeBSD.hint.ventoy.0.vlnk=%d", 1);
}
val = ventoy_get_env("VTOY_UNIX_REMOUNT");
if (val && val[0] == '1' && val[1] == 0)
{
vtoy_ssprintf(extcfg, len, ";set kFreeBSD.hint.ventoy.0.remount=%d", 1);
}
grub_memmove(pos + len, pos, (int)(file->size - (pos - data)));
grub_memcpy(pos, extcfg, len);
g_conf_new_len += len;
}
else
{
debug("no kfreebsd found\n");
}
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, char **args) grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, char **args)
{ {
grub_uint32_t i; grub_uint32_t i;
@@ -662,7 +807,7 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
(void)ctxt; (void)ctxt;
if (argc != 2) if (argc != 2 && argc != 3)
{ {
debug("Replace conf invalid argc %d\n", argc); debug("Replace conf invalid argc %d\n", argc);
return 1; return 1;
@@ -691,7 +836,7 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
return 1; return 1;
} }
debug("old conf file size:%d\n", (int)file->size); debug("old conf file <%s> size:%d\n", confile, (int)file->size);
data = grub_malloc(VTOY_MAX_SCRIPT_BUF); data = grub_malloc(VTOY_MAX_SCRIPT_BUF);
if (!data) if (!data)
@@ -708,7 +853,7 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
if (grub_strcmp(args[0], "FreeBSD") == 0) if (grub_strcmp(args[0], "FreeBSD") == 0)
{ {
g_conf_new_len += ventoy_freebsd_append_conf(data + file->size, args[1]); g_conf_new_len += ventoy_freebsd_append_conf(data + file->size, args[1], (argc > 2) ? args[2] : NULL);
} }
else if (grub_strcmp(args[0], "DragonFly") == 0) else if (grub_strcmp(args[0], "DragonFly") == 0)
{ {
@@ -723,13 +868,13 @@ static int ventoy_unix_search_magic(char *data, int len)
int i; int i;
grub_uint32_t *magic = NULL; grub_uint32_t *magic = NULL;
for (i = 0; i < len; i += 65536) for (i = 0; i < len; i += 4096)
{ {
magic = (grub_uint32_t *)(data + i); magic = (grub_uint32_t *)(data + i);
if (magic[0] == VENTOY_UNIX_SEG_MAGIC0 && magic[1] == VENTOY_UNIX_SEG_MAGIC1 && if (magic[0] == VENTOY_UNIX_SEG_MAGIC0 && magic[1] == VENTOY_UNIX_SEG_MAGIC1 &&
magic[2] == VENTOY_UNIX_SEG_MAGIC2 && magic[3] == VENTOY_UNIX_SEG_MAGIC3) magic[2] == VENTOY_UNIX_SEG_MAGIC2 && magic[3] == VENTOY_UNIX_SEG_MAGIC3)
{ {
debug("unix find search magic at 0x%x loop:%d\n", i, (i >> 16)); debug("unix find search magic at 0x%x loop:%d\n", i, (i >> 12));
g_mod_search_magic = i; g_mod_search_magic = i;
return 0; return 0;
} }

View File

@@ -20,7 +20,7 @@
. $VTOY_PATH/hook/ventoy-os-lib.sh . $VTOY_PATH/hook/ventoy-os-lib.sh
if $GREP -q '^"$mount_handler"' /init; then if $GREP -q '^"$mount_handler"' /init; then
echo 'use mount_handler ...' >> $VTLOG echo 'use mount_handler1 ...' >> $VTLOG
vthookfile=/hooks/archiso vthookfile=/hooks/archiso
@@ -37,6 +37,9 @@ if $GREP -q '^"$mount_handler"' /init; then
if [ -f $vthookfile ]; then 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 $SED '/while ! poll_device "${dev}"/a\ if /ventoy/busybox/sh /ventoy/hook/arch/ventoy-timeout.sh ${dev}; then break; fi' -i $vthookfile
fi fi
elif $GREP -q '^$mount_handler' /init; then
echo 'use mount_handler2 ...' >> $VTLOG
$SED "/^\$mount_handler/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/arch/ventoy-disk.sh" -i /init
elif $GREP -q '^KEEP_SEARCHING' /init; then elif $GREP -q '^KEEP_SEARCHING' /init; then
echo 'KEEP_SEARCHING found ...' >> $VTLOG echo 'KEEP_SEARCHING found ...' >> $VTLOG

View File

@@ -52,8 +52,12 @@ ventoy_get_os_type() {
fi fi
fi fi
# PrimeOS :
if $GREP -q 'PrimeOS' /proc/version; then
echo 'primeos'; return
# Debian : # Debian :
if $GREP -q '[Dd]ebian' /proc/version; then elif $GREP -q '[Dd]ebian' /proc/version; then
echo 'debian'; return echo 'debian'; return
# Ubuntu : do the same process with debian # Ubuntu : do the same process with debian
@@ -338,6 +342,24 @@ ventoy_get_os_type() {
echo "openEuler"; return echo "openEuler"; return
fi fi
#special arch based iso file check
if [ -f /init ]; then
if $GREP -q 'mount_handler' /init; then
if [ -d /hooks ]; then
if $BUSYBOX_PATH/ls -1 /hooks/ | $GREP -q '.*iso$'; then
echo "arch"; return
fi
elif [ -d /hook ]; then
if $BUSYBOX_PATH/ls -1 /hook/ | $GREP -q '.*iso$'; then
echo "arch"; return
fi
fi
fi
fi
echo "default" echo "default"
} }

View File

@@ -500,6 +500,8 @@ function ventoy_freebsd_proc {
if [ "$vt_freebsd_ver" = "xx" ]; then if [ "$vt_freebsd_ver" = "xx" ]; then
if [ -e (loop)/boot/kernel/kernel ]; then if [ -e (loop)/boot/kernel/kernel ]; then
vt_unix_parse_freebsd_ver_elf (loop)/boot/kernel/kernel $vt_freebsd_bit vt_freebsd_ver vt_unix_parse_freebsd_ver_elf (loop)/boot/kernel/kernel $vt_freebsd_bit vt_freebsd_ver
elif [ -e (loop)/boot/kernel/kernel.gz ]; then
vt_unix_parse_freebsd_ver_elf (loop)/boot/kernel/kernel.gz $vt_freebsd_bit vt_freebsd_ver
fi fi
if [ "$vt_freebsd_ver" = "xx" ]; then if [ "$vt_freebsd_ver" = "xx" ]; then
@@ -519,8 +521,17 @@ function ventoy_freebsd_proc {
fi fi
done done
vt_unix_replace_ko $vt_unix_mod_path (vtunix)/ventoy_unix/$vtFreeBsdDistro/geom_ventoy_ko/$vt_freebsd_ver/$vt_freebsd_bit/geom_ventoy.ko.xz if [ -n "$vt_unix_mod_path" ]; then
vt_unix_replace_conf FreeBSD "${1}${chosen_path}" vt_unix_replace_ko $vt_unix_mod_path (vtunix)/ventoy_unix/$vtFreeBsdDistro/geom_ventoy_ko/$vt_freebsd_ver/$vt_freebsd_bit/geom_ventoy.ko.xz
vt_unix_replace_conf FreeBSD "${1}${chosen_path}"
elif [ -e (loop)/easyre.ufs.uzip ]; then
vt_unix_replace_ko "/boot/grub/i386-pc/linux.mod" (vtunix)/ventoy_unix/$vtFreeBsdDistro/geom_ventoy_ko/$vt_freebsd_ver/$vt_freebsd_bit/geom_ventoy.ko.xz
if [ "$grub_platform" = "pc" ]; then
vt_unix_replace_grub_conf "/boot/grub/i386-pc/linux.mod" "cd9"
else
vt_unix_replace_conf FreeBSD "${1}${chosen_path}" "cd9"
fi
fi
} }
function ventoy_dragonfly_proc { function ventoy_dragonfly_proc {
@@ -542,6 +553,8 @@ function ventoy_dragonfly_proc {
function ventoy_unix_comm_proc { function ventoy_unix_comm_proc {
vt_unix_reset vt_unix_reset
vt_unix_check_vlnk "${1}${chosen_path}"
if [ "$ventoy_compatible" = "NO" ]; then if [ "$ventoy_compatible" = "NO" ]; then
loopback vtunix $vtoy_efi_part/ventoy/ventoy_unix.cpio loopback vtunix $vtoy_efi_part/ventoy/ventoy_unix.cpio
@@ -1303,14 +1316,32 @@ function iso_common_menuentry {
set vtcompat=1 set vtcompat=1
fi fi
# auto memdisk mode for some special ISO files
vt_iso_vd_id_parse "${vtoy_iso_part}${vt_chosen_path}"
unset vtMemDiskBoot
if vt_check_mode 0; then
set vtMemDiskBoot=1
else
if [ "$grub_platform" = "pc" ]; then
if vt_iso_vd_id_begin 1 0 "Memtest86+"; then
set vtMemDiskBoot=1
elif vt_iso_vd_id_begin 0 1 "KolibriOS"; then
set vtMemDiskBoot=1
fi
fi
fi
vt_iso_vd_id_clear
if [ "$grub_platform" = "pc" ]; then if [ "$grub_platform" = "pc" ]; then
if vt_check_mode 0; then if [ -n "$vtMemDiskBoot" ]; then
legacy_iso_memdisk $vtoy_iso_part "$vt_chosen_path" legacy_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
else else
legacy_iso_menu_func $vtoy_iso_part "$vt_chosen_path" legacy_iso_menu_func $vtoy_iso_part "$vt_chosen_path"
fi fi
else else
if vt_check_mode 0; then if [ -n "$vtMemDiskBoot" ]; then
uefi_iso_memdisk $vtoy_iso_part "$vt_chosen_path" uefi_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
else else
uefi_iso_menu_func $vtoy_iso_part "$vt_chosen_path" uefi_iso_menu_func $vtoy_iso_part "$vt_chosen_path"
@@ -2082,7 +2113,7 @@ function img_unsupport_menuentry {
############################################################# #############################################################
############################################################# #############################################################
set VENTOY_VERSION="1.0.70" set VENTOY_VERSION="1.0.72"
#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
@@ -2305,6 +2336,32 @@ export VTOY_HELP_TXT_LANGUAGE
export VTOY_CHKSUM_FILE_PATH export VTOY_CHKSUM_FILE_PATH
#colect all image files (iso files)
set ventoy_img_count=0
vt_list_img $vtoy_iso_part ventoy_img_count
#Main menu
if [ $ventoy_img_count -gt 0 ]; then
if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
vt_dynamic_menu 0 0
else
vt_dynamic_menu 0 1
fi
else
if [ -n "$VTOY_NO_ISO_TIP" ]; then
NO_ISO_MENU="No ISO or supported IMG files found, $VTOY_NO_ISO_TIP"
elif [ -n "$VTOY_DEFAULT_SEARCH_ROOT" ]; then
NO_ISO_MENU="No ISO or supported IMG files found, please check VTOY_DEFAULT_SEARCH_ROOT"
else
NO_ISO_MENU="No ISO or supported IMG files found"
fi
menuentry "$NO_ISO_MENU (Press enter to reboot ...)" {
echo -e "\n Rebooting ... "
reboot
}
fi
#special VTOY_DEFAULT_IMAGE process #special VTOY_DEFAULT_IMAGE process
if [ -n "$VTOY_DEFAULT_IMAGE" ]; then if [ -n "$VTOY_DEFAULT_IMAGE" ]; then
if regexp --set 1:vtHotkey --set 2:vtDefault "(F[2-9])>(.*)" "$VTOY_DEFAULT_IMAGE"; then if regexp --set 1:vtHotkey --set 2:vtDefault "(F[2-9])>(.*)" "$VTOY_DEFAULT_IMAGE"; then
@@ -2319,7 +2376,12 @@ if [ -n "$VTOY_DEFAULT_IMAGE" ]; then
export timeout export timeout
export default export default
if [ "$vtHotkey" = "F4" ]; then vt_fn_mutex_lock 1
if [ "$vtHotkey" = "F2" ]; then
unset timeout
vt_browser_disk
elif [ "$vtHotkey" = "F4" ]; then
ventoy_localboot ventoy_localboot
elif [ "$vtHotkey" = "F5" ]; then elif [ "$vtHotkey" = "F5" ]; then
ventoy_diagnosis ventoy_diagnosis
@@ -2327,32 +2389,10 @@ if [ -n "$VTOY_DEFAULT_IMAGE" ]; then
ventoy_ext_menu ventoy_ext_menu
fi fi
vt_fn_mutex_lock 0
unset timeout unset timeout
unset default unset default
fi fi
fi fi
#colect all image files (iso files)
set ventoy_img_count=0
vt_list_img $vtoy_iso_part ventoy_img_count
#Main menu
if [ $ventoy_img_count -gt 0 ]; then
if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
vt_dynamic_menu 0 0
else
vt_dynamic_menu 0 1
fi
else
if [ -n "$VTOY_NO_ISO_TIP" ]; then
NO_ISO_MENU="No ISO files found, $VTOY_NO_ISO_TIP"
elif [ -n "$VTOY_DEFAULT_SEARCH_ROOT" ]; then
NO_ISO_MENU="No ISO files found, please check VTOY_DEFAULT_SEARCH_ROOT"
else
NO_ISO_MENU="No ISO files found"
fi
menuentry "$NO_ISO_MENU (Press enter to reboot ...)" {
echo -e "\n Rebooting ... "
reboot
}
fi

View File

@@ -1,8 +1,8 @@
h - この画面を表示する h - この画面を表示する
F1 - 主記憶装置上に記憶域を作成する容量の小さなWinPE・LiveCD専用 F1 - 主記憶装置上に記憶域を作成する容量の小さなWinPE・LiveCD専用
F2 - Browse and boot files in local disk F2 - 手元の記憶装置にある起動ファイルを選択して実行する
F3 - 表示形式を切り替える(一覧 ↔ 階層) F3 - 表示形式を切り替える(一覧 ↔ 階層)
F4 - 手元の記憶装置にあるOSを起動する F4 - 手元の記憶装置にあるWindowsまたはLinuxを起動する
F5 - 諸機能 F5 - 諸機能
F6 - Grub2の構成を読み込む F6 - Grub2の構成を読み込む
F7 - 操作形式を切り替えるGUI ↔ CUI F7 - 操作形式を切り替えるGUI ↔ CUI
@@ -15,4 +15,4 @@ Ctrl+u - ISO efiドライバーを読み取る開発用非公式
この画面を閉じるにはESCを押してください この画面を閉じるにはESCを押してください ......

View File

@@ -0,0 +1,18 @@
h - 이 도움말 정보 표시
F1 - Memdisk 모드 (작은 WinPE/LiveCD ISO/IMG 전용)
F2 - 로컬 디스크에서 파일 찾아보기 및 부팅
F3 - 트리보기 <-> 목록보기 간에 메뉴 모드 전환
F4 - 로컬 디스크에서 Windows/Linux 부팅
F5 - 유틸리티
F6 - 사용자 지정 Grub2 메뉴 로드
F7 - GUI 모드 <-> TEXT 모드 간에 전환
m - 체크섬 이미지 파일 (md5/sha1/sha256/sha512)
Ctrl+w - WIMBOOT 모드 (표준 Windows ISO 전용)
Ctrl+r - Grub2 모드 (일부 Linux 배포판에만 해당)
Ctrl+i - 호환 모드 (디버그 전용)
Ctrl+u - ISO eFi 드라이버 로드 (디버그 전용, 공식적으로 사용할 수 없음)
돌아가려면 ESC를 누르십시오 ......

View File

@@ -7,7 +7,7 @@ print_usage() {
echo 'Usage: Ventoy2Disk.sh CMD [ OPTION ] /dev/sdX' echo 'Usage: Ventoy2Disk.sh CMD [ OPTION ] /dev/sdX'
echo ' CMD:' echo ' CMD:'
echo ' -i install Ventoy to sdX (fails if disk already installed with Ventoy)' echo ' -i install Ventoy to sdX (fails if disk already installed with Ventoy)'
echo ' -I force install Ventoy to sdX (no matter installed or not)' echo ' -I force install Ventoy to sdX (no matter if installed or not)'
echo ' -u update Ventoy in sdX' echo ' -u update Ventoy in sdX'
echo ' -l list Ventoy information in sdX' echo ' -l list Ventoy information in sdX'
echo '' echo ''
@@ -165,7 +165,7 @@ if [ -d ./tmp_mnt ]; then
umount ./tmp_mnt >/dev/null 2>&1 umount ./tmp_mnt >/dev/null 2>&1
rm -rf ./tmp_mnt rm -rf ./tmp_mnt
if [ -d ./tmp_mnt ]; then if [ -d ./tmp_mnt ]; then
vterr "tmp_mnt directory exits, please delete it first." vterr "tmp_mnt directory exists, please delete it first."
exit 1 exit 1
fi fi
fi fi
@@ -345,6 +345,7 @@ if [ "$MODE" = "install" -a -z "$NONDESTRUCTIVE" ]; then
sync sync
vtinfo "esp partition processing ..." vtinfo "esp partition processing ..."
if [ "$SECUREBOOT" != "YES" ]; then if [ "$SECUREBOOT" != "YES" ]; then
sleep 2 sleep 2
check_umount_disk "$DISK" check_umount_disk "$DISK"
@@ -551,7 +552,7 @@ else
vtinfo "Upgrade operation is safe, all the data in the 1st partition (iso files and other) will be unchanged!" vtinfo "Upgrade operation is safe, all the data in the 1st partition (iso files and other) will be unchanged!"
echo "" echo ""
read -p "Update Ventoy $oldver ===> $curver Continue? (y/n)" Answer read -p "Update Ventoy $oldver ===> $curver Continue? (y/n) " Answer
if [ "$Answer" != "y" ]; then if [ "$Answer" != "y" ]; then
if [ "$Answer" != "Y" ]; then if [ "$Answer" != "Y" ]; then
exit 0 exit 0

Binary file not shown.

View File

@@ -176,6 +176,13 @@ chmod +x $tmpdir/VentoyWeb.sh
chmod +x $tmpdir/VentoyPlugson.sh chmod +x $tmpdir/VentoyPlugson.sh
chmod +x $tmpdir/VentoyVlnk.sh chmod +x $tmpdir/VentoyVlnk.sh
chmod +x $tmpdir/VentoyGUI* chmod +x $tmpdir/VentoyGUI*
chmod +x $tmpdir/tool/*.sh
for d in i386 x86_64 aarch64 mips64el; do
chmod +x $tmpdir/tool/$d/xzcat
chmod +x $tmpdir/tool/$d/Ventoy2Disk.*
done
cp $OPT $LANG_DIR/languages.json $tmpdir/tool/ cp $OPT $LANG_DIR/languages.json $tmpdir/tool/

View File

@@ -248,9 +248,9 @@
"STR_INSTALL_TIP":"The device will be formatted and all the data will be lost.#@Continue?", "STR_INSTALL_TIP":"The device will be formatted and all the data will be lost.#@Continue?",
"STR_INSTALL_TIP2":"The device will be formatted and all the data will be lost.#@Continue? (Double Check)", "STR_INSTALL_TIP2":"The device will be formatted and all the data will be lost.#@Continue? (Double Check)",
"STR_INSTALL_SUCCESS":"Congratulations!#@Ventoy has been successfully installed to the device.", "STR_INSTALL_SUCCESS":"Congratulations!#@Ventoy has been successfully installed to the device.",
"STR_INSTALL_FAILED":"An error occurred during the installation. You can replug the USB device and try again. Check log.txt for detail. If it always fail, please refer the FAQ in the official website.", "STR_INSTALL_FAILED":"An error occurred during the installation. You can reinsert the USB device and try again. Check log.txt for details. If it always fails, please refer the FAQ on the official website.",
"STR_UPDATE_SUCCESS":"Congratulations!#@Ventoy has been successfully updated to the device.", "STR_UPDATE_SUCCESS":"Congratulations!#@Ventoy has been successfully updated on the device.",
"STR_UPDATE_FAILED":"An error occurred during the update. You can replug the USB device and try again. Check log.txt for detail. If it always fail, please refer the FAQ in the official website.", "STR_UPDATE_FAILED":"An error occurred during the update. You can reinsert the USB device and try again. Check log.txt for details. If it always fails, please refer the FAQ on the official website.",
"STR_WAIT_PROCESS":"A thread is running, please wait...", "STR_WAIT_PROCESS":"A thread is running, please wait...",
"STR_MENU_OPTION":"Option", "STR_MENU_OPTION":"Option",
"STR_MENU_SECURE_BOOT":"Secure Boot Support", "STR_MENU_SECURE_BOOT":"Secure Boot Support",
@@ -261,7 +261,7 @@
"STR_SPACE_VAL_INVALID":"Invalid value for reserved space", "STR_SPACE_VAL_INVALID":"Invalid value for reserved space",
"STR_MENU_CLEAR":"Clear Ventoy", "STR_MENU_CLEAR":"Clear Ventoy",
"STR_CLEAR_SUCCESS":"Ventoy has been successfully removed from the device.", "STR_CLEAR_SUCCESS":"Ventoy has been successfully removed from the device.",
"STR_CLEAR_FAILED":"An error occurred when clearing Ventoy from disk. You can replug the USB device and try again. Check log.txt for details.", "STR_CLEAR_FAILED":"An error occurred when removing Ventoy from disk. You can reinsert the USB device and try again. Check log.txt for details.",
"STR_MENU_PART_STYLE":"Partition Style", "STR_MENU_PART_STYLE":"Partition Style",
"STR_DISK_2TB_MBR_ERROR":"Please select GPT for devices over 2TB", "STR_DISK_2TB_MBR_ERROR":"Please select GPT for devices over 2TB",
"STR_SHOW_ALL_DEV":"Show All Devices", "STR_SHOW_ALL_DEV":"Show All Devices",
@@ -402,7 +402,7 @@
"name":"Portuguese Brazilian (Português do Brasil)", "name":"Portuguese Brazilian (Português do Brasil)",
"FontFamily":"Courier New", "FontFamily":"Courier New",
"FontSize":16, "FontSize":16,
"Author":"EstevaoCostaG3, David BrazSan, Hildo Guillardi Júnior", "Author":"EstevaoCostaG3, David BrazSan, Hildo Guillardi Júnior, Chrystian Rubio",
"STR_ERROR":"Erro", "STR_ERROR":"Erro",
"STR_WARNING":"Atenção", "STR_WARNING":"Atenção",
@@ -429,7 +429,7 @@
"STR_BTN_OK":"OK", "STR_BTN_OK":"OK",
"STR_BTN_CANCEL":"Cancelar", "STR_BTN_CANCEL":"Cancelar",
"STR_PRESERVE_SPACE":"Preservar algum espaço no final do disco", "STR_PRESERVE_SPACE":"Preservar algum espaço no final do disco",
"STR_SPACE_VAL_INVALID":"Valor invalido para o espaço reservado", "STR_SPACE_VAL_INVALID":"Valor inválido para o espaço reservado",
"STR_MENU_CLEAR":"Remover o Ventoy", "STR_MENU_CLEAR":"Remover o Ventoy",
"STR_CLEAR_SUCCESS":"O Ventoy foi removido deste dispositivo com sucesso.", "STR_CLEAR_SUCCESS":"O Ventoy foi removido deste dispositivo com sucesso.",
"STR_CLEAR_FAILED":"Um erro ocorreu ao remover o Ventoy do disco. Você pode reconectar o dispositivo USB e tentar novamente. Verifique o Arquivo log.txt para mais detalhes.", "STR_CLEAR_FAILED":"Um erro ocorreu ao remover o Ventoy do disco. Você pode reconectar o dispositivo USB e tentar novamente. Verifique o Arquivo log.txt para mais detalhes.",
@@ -439,18 +439,18 @@
"STR_PART_ALIGN_4KB":"Alinhar partições com 4KB", "STR_PART_ALIGN_4KB":"Alinhar partições com 4KB",
"STR_WEB_COMMUNICATION_ERR":"Erro de comunicação:", "STR_WEB_COMMUNICATION_ERR":"Erro de comunicação:",
"STR_WEB_REMOTE_ABNORMAL":"Erro de comunicação: remoto anormal", "STR_WEB_REMOTE_ABNORMAL":"Erro de comunicação: remoto anormal",
"STR_WEB_REQUEST_TIMEOUT":"Erro de comunicação: Solicitação cronometrado", "STR_WEB_REQUEST_TIMEOUT":"Erro de comunicação: Solicitação cronometrada",
"STR_WEB_SERVICE_UNAVAILABLE":"Erro de comunicação: Serviço indisponível", "STR_WEB_SERVICE_UNAVAILABLE":"Erro de comunicação: Serviço indisponível",
"STR_WEB_TOKEN_MISMATCH":"Status daemon atualizado, por favor, tente novamente mais tarde.", "STR_WEB_TOKEN_MISMATCH":"Status daemon atualizado, por favor, tente novamente mais tarde.",
"STR_WEB_SERVICE_BUSY":"O serviço está ocupado, por favor, tente novamente mais tarde.", "STR_WEB_SERVICE_BUSY":"O serviço está ocupado, por favor, tente novamente mais tarde.",
"STR_MENU_VTSI_CREATE":"Gerar arquivo VTSI", "STR_MENU_VTSI_CREATE":"Gerar arquivo VTSI",
"STR_VTSI_CREATE_TIP":"Não será gravado no dispositivo, desta vez, apenas derado um VTSI file#@Continuar?", "STR_VTSI_CREATE_TIP":"Não será gravado no dispositivo, desta vez, apenas gerado um arquivo VTSI.#@Continuar?",
"STR_VTSI_CREATE_SUCCESS":"Arquivo VTSI criado com sucesso!#@Você pode usar Rufus(3.15+) para gravá-lo no dispositivo e completar a instalação do Ventoy.", "STR_VTSI_CREATE_SUCCESS":"Arquivo VTSI criado com sucesso!#@Você pode usar Rufus(3.15+) para gravá-lo no dispositivo e completar a instalação do Ventoy.",
"STR_VTSI_CREATE_FAILED":"Criaçao do arquivo VTSI falhada.", "STR_VTSI_CREATE_FAILED":"Criação do arquivo VTSI falhada.",
"STR_MENU_PART_RESIZE":"Instalação não destrutiva", "STR_MENU_PART_RESIZE":"Instalação não destrutiva",
"STR_PART_RESIZE_TIP":"Ventoy tentará uma instalação não destrutiva, se possível.#@Continuar?", "STR_PART_RESIZE_TIP":"Ventoy tentará uma instalação não destrutiva, se possível.#@Continuar?",
"STR_PART_RESIZE_SUCCESS":"Parabéns!#@Instalação não destrutiva do Ventoy concluída com sucesso.", "STR_PART_RESIZE_SUCCESS":"Parabéns!#@Instalação não destrutiva do Ventoy concluída com sucesso.",
"STR_PART_RESIZE_FAILED":"Falha na installação não destrutiva, cheque o arquivo log.txt para entender.", "STR_PART_RESIZE_FAILED":"Falha na instalação não destrutiva, cheque o arquivo log.txt para entender.",
"STR_PART_RESIZE_UNSUPPORTED":"Instalação não destrutiva do Ventoy interrompida devido fato desconhecido. Cheque o arquivo log.txt para detalhes.", "STR_PART_RESIZE_UNSUPPORTED":"Instalação não destrutiva do Ventoy interrompida devido fato desconhecido. Cheque o arquivo log.txt para detalhes.",
"STRXXX":"" "STRXXX":""

View File

@@ -1 +1 @@
de_DEen_USfr_FRhr_HRid_IDja_JPpt_PTsr_RStr_TRzh_CN de_DEen_USfr_FRhr_HRid_IDja_JPko_KRpt_PTsr_RStr_TRzh_CN

View File

@@ -723,7 +723,7 @@
<footer class="main-footer"> <footer class="main-footer">
<div class="pull-right hidden-xs"> <div class="pull-right hidden-xs">
<b id="plugson_build_date">20220204 16:31:23</b> <b id="plugson_build_date">20220311 21:24:51</b>
</div> </div>
<strong><a href="https://www.ventoy.net" target="_blank">https://www.ventoy.net</a></strong> <strong><a href="https://www.ventoy.net" target="_blank">https://www.ventoy.net</a></strong>
</footer> </footer>
@@ -818,11 +818,6 @@
(function ventoy_handshake() { (function ventoy_handshake() {
if (m_syntax_error === 1) {
}
callVtoyCatchErr({ callVtoyCatchErr({
method : 'handshake' method : 'handshake'
}, },
@@ -844,6 +839,13 @@
m_invalid_config = 0; m_invalid_config = 0;
} }
if (data.save_error === 1) {
var title = g_current_language == 'en' ? g_vtoy_cur_language_en.STR_INFO : g_vtoy_cur_language_cn.STR_INFO;
var msg = g_current_language == 'en' ? g_vtoy_cur_language_en.STR_CONFIG_SAVE_ERROR_TIP : g_vtoy_cur_language_cn.STR_CONFIG_SAVE_ERROR_TIP;
Modal.alert({title:title,msg:msg}).on(function(e) {
});
}
setTimeout(function() { setTimeout(function() {
ventoy_handshake(); ventoy_handshake();
}, 1000); }, 1000);

View File

@@ -7,6 +7,7 @@
<img src="https://img.shields.io/github/license/ventoy/Ventoy?style=for-the-badge"> <img src="https://img.shields.io/github/license/ventoy/Ventoy?style=for-the-badge">
<img src="https://img.shields.io/github/stars/ventoy/Ventoy?style=for-the-badge"> <img src="https://img.shields.io/github/stars/ventoy/Ventoy?style=for-the-badge">
<img src="https://img.shields.io/github/downloads/ventoy/Ventoy/total.svg?style=for-the-badge"> <img src="https://img.shields.io/github/downloads/ventoy/Ventoy/total.svg?style=for-the-badge">
<img src="https://img.shields.io/github/workflow/status/ventoy/Ventoy/Ventoy%20CI?label=actions&logo=github&style=for-the-badge">
</p> </p>
<h4 align="left"> <h4 align="left">
@@ -17,7 +18,7 @@ You can also browse ISO/WIM/IMG/VHD(x)/EFI files in local disk and boot them.<br
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/ChromeOS/Vmware/Xen...) <br/> Most type of OS supported(Windows/WinPE/Linux/Unix/ChromeOS/Vmware/Xen...) <br/>
810+ 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 (<a href="https://www.ventoy.net/en/distrowatch.html">Details</a>). <br/> 830+ 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 (<a href="https://www.ventoy.net/en/distrowatch.html">Details</a>). <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>
@@ -37,11 +38,17 @@ FydeOS, CloudReady
**Other** **Other**
VMware ESXi, Citrix XenServer, Xen XCP-ng VMware ESXi, Citrix XenServer, Xen XCP-ng
# Subscription Service
Ventoy is an open source software under GPLv3 license.
But Ventoy project need to pay for the server hosting, domain name, bandwidth, many USB sticks for test, large capacity of HDD (for downloading ISO files) and so on.
For the better and sustainable development of Ventoy, I provide the [【subscription service】](https://www.ventoy.net/en/doc_subscription.html).
# Tested Image Report # Tested Image Report
[【How to report a successfully tested image file】](https://github.com/ventoy/Ventoy/issues/1195) [【How to report a successfully tested image file】](https://github.com/ventoy/Ventoy/issues/1195)
# Ventoy Browser # Ventoy Browser
With Ventoy you can also browse ISO/WIM/IMG/VHD(x)/EFI files in local disk and boot them. [Notes](https://www.ventoy.net/en/doc_browser.html) With Ventoy, you can also browse ISO/WIM/IMG/VHD(x)/EFI files in local disk and boot them. [Notes](https://www.ventoy.net/en/doc_browser.html)
# VentoyPlugson # VentoyPlugson
A GUI Ventoy plugin configurator. [VentoyPlugson](https://www.ventoy.net/en/plugin_plugson.html) A GUI Ventoy plugin configurator. [VentoyPlugson](https://www.ventoy.net/en/plugin_plugson.html)
@@ -63,7 +70,7 @@ A GUI Ventoy plugin configurator. [VentoyPlugson](https://www.ventoy.net/en/plug
* 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, 810+ iso files tested * Most types of OS supported, 830+ 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
@@ -122,7 +129,7 @@ See [https://www.ventoy.net/en/faq.html](https://www.ventoy.net/en/faq.html) for
# Donation # Donation
It would be much appreciated if you want to make a small donation to support my work! It would be much appreciated if you want to make a small donation to support my work!
Alipay, WeChat Pay, PayPal and Bitcoin are avaliable for donation. You can chose any of them. Alipay, WeChat Pay, PayPal and Bitcoin are available for donation. You can choose any of them.
Alipay | WeChat Pay Alipay | WeChat Pay
-|- -|-

View File

@@ -297,7 +297,7 @@ int read_sort_file(char *filename, int source, char *source_path[])
} else if((errno == ERANGE) || } else if((errno == ERANGE) ||
(priority < -32768 || priority > 32767)) { (priority < -32768 || priority > 32767)) {
ERROR("Sort file \"%s\", entry \"%s\" has priority " ERROR("Sort file \"%s\", entry \"%s\" has priority "
"outside range of -32767:32768.\n", filename, "outside range of -32768:32767.\n", filename,
line_buffer); line_buffer);
goto failed; goto failed;
} }

View File

@@ -65,11 +65,22 @@ static g_taste_t g_ventoy_taste;
static g_ctl_req_t g_ventoy_config; static g_ctl_req_t g_ventoy_config;
static g_dumpconf_t g_ventoy_dumpconf; static g_dumpconf_t g_ventoy_dumpconf;
static const char *g_ventoy_disk_uuid = NULL; static char g_ventoy_disk_uuid[64];
static bool g_ventoy_tasted = false; static bool g_ventoy_tasted = false;
static off_t g_ventoy_disk_size = 0; static off_t g_ventoy_disk_size = 0;
static off_t g_disk_map_start = 0; static off_t g_disk_map_start = 0;
static off_t g_disk_map_end = 0; static off_t g_disk_map_end = 0;
static int g_ventoy_remount = 0;
struct g_ventoy_map g_ventoy_map_data __attribute__((aligned (4096))) =
{
{ VENTOY_UNIX_SEG_MAGIC0, VENTOY_UNIX_SEG_MAGIC1, VENTOY_UNIX_SEG_MAGIC2, VENTOY_UNIX_SEG_MAGIC3 },
{ 0, 0, 0, 0 },
0, 0,
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ { 0, 0 } },
{ VENTOY_UNIX_SEG_MAGIC0, VENTOY_UNIX_SEG_MAGIC1, VENTOY_UNIX_SEG_MAGIC2, VENTOY_UNIX_SEG_MAGIC3 }
};
struct g_class g_ventoy_class = { struct g_class g_ventoy_class = {
.name = G_VENTOY_CLASS_NAME, .name = G_VENTOY_CLASS_NAME,
@@ -191,12 +202,19 @@ g_ventoy_access(struct g_provider *pp, int dr, int dw, int de)
g_topology_assert(); g_topology_assert();
gp = pp->geom; gp = pp->geom;
/* On first open, grab an extra "exclusive" bit */ if (g_ventoy_remount)
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0) {
de++; de = 0;
/* ... and let go of it on last close */ }
if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0) else
de--; {
/* On first open, grab an extra "exclusive" bit */
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0)
de++;
/* ... and let go of it on last close */
if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0)
de--;
}
LIST_FOREACH_SAFE(cp1, &gp->consumer, consumer, tmp) { LIST_FOREACH_SAFE(cp1, &gp->consumer, consumer, tmp) {
error = g_access(cp1, dr, dw, de); error = g_access(cp1, dr, dw, de);
@@ -642,24 +660,52 @@ g_ventoy_destroy_geom(struct gctl_req *req __unused,
static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp) static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
{ {
int i; int i;
int vlnk = 0;
bool ret = true;
uint8_t *buf; uint8_t *buf;
char uuid[64]; char uuid[64];
const char *value; const char *value;
struct g_consumer *cp; struct g_consumer *cp;
struct g_geom *gp; struct g_geom *gp;
uint8_t mbrdata[] = {
0xEB, 0x63, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x56, 0x54, 0x00, 0x47, 0x65, 0x00, 0x48, 0x44, 0x00, 0x52, 0x64, 0x00, 0x20, 0x45, 0x72, 0x0D,
};
if (g_ventoy_disk_size == 0) if (g_ventoy_disk_size == 0)
{ {
if (resource_string_value("ventoy", 0, "disksize", &value) == 0) if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{ {
G_DEBUG("ventoy.disksize: %s\n", value); G_DEBUG("ventoy map data is valid. [OK]\n");
g_ventoy_disk_size = strtouq(value, NULL, 0);
}
if (resource_string_value("ventoy", 0, "diskuuid", &g_ventoy_disk_uuid) == 0) for (i = 0; i < 16; i++)
{ {
sprintf(uuid + i * 2, "%02x", g_ventoy_map_data.diskuuid[i]);
}
snprintf(g_ventoy_disk_uuid, sizeof(g_ventoy_disk_uuid), "%s", uuid);
g_ventoy_disk_size = g_ventoy_map_data.disksize;
G_DEBUG("ventoy.disksize: %llu\n", (unsigned long long)g_ventoy_disk_size);
G_DEBUG("ventoy.diskuuid: <%s>\n", g_ventoy_disk_uuid); G_DEBUG("ventoy.diskuuid: <%s>\n", g_ventoy_disk_uuid);
} }
else
{
G_DEBUG("ventoy map data is invalid, get from resource\n");
if (resource_string_value("ventoy", 0, "disksize", &value) == 0)
{
G_DEBUG("ventoy.disksize: %s\n", value);
g_ventoy_disk_size = strtouq(value, NULL, 0);
}
if (resource_string_value("ventoy", 0, "diskuuid", &value) == 0)
{
snprintf(g_ventoy_disk_uuid, sizeof(g_ventoy_disk_uuid), "%s", value);
G_DEBUG("ventoy.diskuuid: <%s>\n", value);
}
}
} }
if (g_ventoy_disk_size != pp->mediasize) if (g_ventoy_disk_size != pp->mediasize)
@@ -700,14 +746,28 @@ static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
{ {
sprintf(uuid + i * 2, "%02x", buf[0x180 + i]); sprintf(uuid + i * 2, "%02x", buf[0x180 + i]);
} }
g_free(buf);
if (strncmp(g_ventoy_disk_uuid, uuid, 32) == 0) if (strncmp(g_ventoy_disk_uuid, uuid, 32))
{ {
return true; ret = false;
} }
return false; if (resource_int_value("ventoy", 0, "vlnk", &vlnk) || (vlnk != 1))
{
if (memcmp(mbrdata, buf, 0x30) || memcmp(mbrdata + 0x30, buf + 0x190, 16))
{
ret = false;
}
}
g_free(buf);
if (ret)
{
G_DEBUG("ventoy disk check OK\n");
}
return ret;
} }
static struct g_geom * static struct g_geom *
@@ -716,8 +776,10 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
int i; int i;
int error; int error;
int disknum; int disknum;
int remount = 0;
char *endpos; char *endpos;
const char *value; const char *value;
const char *alias = NULL;
struct g_geom *gp; struct g_geom *gp;
struct g_ventoy_metadata md; struct g_ventoy_metadata md;
struct g_ventoy_softc *sc; struct g_ventoy_softc *sc;
@@ -741,9 +803,32 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_ventoy_tasted = true; g_ventoy_tasted = true;
G_DEBUG("######### ventoy disk <%s> #############\n", pp->name); G_DEBUG("###### ventoy disk <%s> ######\n", pp->name);
resource_int_value("ventoy", 0, "segnum", &disknum); /* hint.ventoy.0.remount=1 */
if (resource_int_value("ventoy", 0, "remount", &remount) == 0 && remount == 1)
{
g_ventoy_remount = 1;
G_DEBUG("###### ventoy remount enabled ######\n");
}
/* hint.ventoy.0.alias=xxx */
if (resource_string_value("ventoy", 0, "alias", &alias) == 0 && alias)
{
G_DEBUG("###### ventoy alias <%s> ######\n", alias);
setenv("kern.devalias.ventoy/IMAGE", alias);
}
if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{
disknum = (int)g_ventoy_map_data.segnum;
G_DEBUG("segnum from map data is:<%d>\n", disknum);
}
else
{
resource_int_value("ventoy", 0, "segnum", &disknum);
G_DEBUG("segnum from resource is:<%d>\n", disknum);
}
strlcpy(md.md_magic, G_VENTOY_MAGIC, sizeof(md.md_magic)); strlcpy(md.md_magic, G_VENTOY_MAGIC, sizeof(md.md_magic));
md.md_version = G_VENTOY_VERSION; md.md_version = G_VENTOY_VERSION;
@@ -765,19 +850,30 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
for (i = 0; i < disknum; i ++) for (i = 0; i < disknum; i ++)
{ {
if (resource_string_value("ventoy", i, "seg", &value) == 0) if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{ {
g_disk_map_start = strtouq(value, &endpos, 0); G_DEBUG("[map] ventoy segment%d: 0x%llx@0x%llx\n", i,
g_disk_map_end = strtouq(endpos + 1, NULL, 0); (long long)g_ventoy_map_data.seglist[i].seg_start_bytes,
(long long)g_ventoy_map_data.seglist[i].seg_end_bytes);
g_disk_map_start = (off_t)g_ventoy_map_data.seglist[i].seg_start_bytes;
g_disk_map_end = (off_t)g_ventoy_map_data.seglist[i].seg_end_bytes;
} }
else else
{ {
printf("Failed to parse ventoy seg %d\n", i); if (resource_string_value("ventoy", i, "seg", &value) == 0)
continue; {
g_disk_map_start = strtouq(value, &endpos, 0);
g_disk_map_end = strtouq(endpos + 1, NULL, 0);
}
else
{
printf("Failed to parse ventoy seg %d\n", i);
continue;
}
G_DEBUG("[resource] ventoy segment%d: %s\n", i, value);
} }
G_DEBUG("ventoy segment%d: %s\n", i, value);
G_VENTOY_DEBUG(1, "Adding disk %s to %s.", pp->name, gp->name); G_VENTOY_DEBUG(1, "Adding disk %s to %s.", pp->name, gp->name);
error = g_ventoy_add_disk(sc, pp, i); error = g_ventoy_add_disk(sc, pp, i);
if (error != 0) { if (error != 0) {
@@ -792,7 +888,7 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_disk_map_end = 0; g_disk_map_end = 0;
} }
return (gp); return (gp);
} }
static void static void

View File

@@ -76,6 +76,33 @@ struct g_ventoy_softc {
struct mtx sc_lock; struct mtx sc_lock;
}; };
#define sc_name sc_geom->name #define sc_name sc_geom->name
#pragma pack(1)
#define VENTOY_UNIX_SEG_MAGIC0 0x11223344
#define VENTOY_UNIX_SEG_MAGIC1 0x55667788
#define VENTOY_UNIX_SEG_MAGIC2 0x99aabbcc
#define VENTOY_UNIX_SEG_MAGIC3 0xddeeff00
#define VENTOY_UNIX_MAX_SEGNUM 40960
struct g_ventoy_seg {
uint64_t seg_start_bytes;
uint64_t seg_end_bytes;
};
struct g_ventoy_map{
uint32_t magic1[4];
uint32_t magic2[4];
uint64_t segnum;
uint64_t disksize;
uint8_t diskuuid[16];
struct g_ventoy_seg seglist[VENTOY_UNIX_MAX_SEGNUM];
uint32_t magic3[4];
};
#pragma pack()
#define VENTOY_MAP_VALID(magic2) \
(magic2[0] == VENTOY_UNIX_SEG_MAGIC0 && magic2[1] == VENTOY_UNIX_SEG_MAGIC1 && magic2[2] == VENTOY_UNIX_SEG_MAGIC2 && magic2[3] == VENTOY_UNIX_SEG_MAGIC3)
#endif /* _KERNEL */ #endif /* _KERNEL */
struct g_ventoy_metadata { struct g_ventoy_metadata {

View File

@@ -65,11 +65,22 @@ static g_taste_t g_ventoy_taste;
static g_ctl_req_t g_ventoy_config; static g_ctl_req_t g_ventoy_config;
static g_dumpconf_t g_ventoy_dumpconf; static g_dumpconf_t g_ventoy_dumpconf;
static const char *g_ventoy_disk_uuid = NULL; static char g_ventoy_disk_uuid[64];
static bool g_ventoy_tasted = false; static bool g_ventoy_tasted = false;
static off_t g_ventoy_disk_size = 0; static off_t g_ventoy_disk_size = 0;
static off_t g_disk_map_start = 0; static off_t g_disk_map_start = 0;
static off_t g_disk_map_end = 0; static off_t g_disk_map_end = 0;
static int g_ventoy_remount = 0;
struct g_ventoy_map g_ventoy_map_data __attribute__((aligned (4096))) =
{
{ VENTOY_UNIX_SEG_MAGIC0, VENTOY_UNIX_SEG_MAGIC1, VENTOY_UNIX_SEG_MAGIC2, VENTOY_UNIX_SEG_MAGIC3 },
{ 0, 0, 0, 0 },
0, 0,
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ { 0, 0 } },
{ VENTOY_UNIX_SEG_MAGIC0, VENTOY_UNIX_SEG_MAGIC1, VENTOY_UNIX_SEG_MAGIC2, VENTOY_UNIX_SEG_MAGIC3 }
};
struct g_class g_ventoy_class = { struct g_class g_ventoy_class = {
.name = G_VENTOY_CLASS_NAME, .name = G_VENTOY_CLASS_NAME,
@@ -191,12 +202,19 @@ g_ventoy_access(struct g_provider *pp, int dr, int dw, int de)
g_topology_assert(); g_topology_assert();
gp = pp->geom; gp = pp->geom;
/* On first open, grab an extra "exclusive" bit */ if (g_ventoy_remount)
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0) {
de++; de = 0;
/* ... and let go of it on last close */ }
if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0) else
de--; {
/* On first open, grab an extra "exclusive" bit */
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0)
de++;
/* ... and let go of it on last close */
if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0)
de--;
}
LIST_FOREACH_SAFE(cp1, &gp->consumer, consumer, tmp) { LIST_FOREACH_SAFE(cp1, &gp->consumer, consumer, tmp) {
error = g_access(cp1, dr, dw, de); error = g_access(cp1, dr, dw, de);
@@ -678,24 +696,52 @@ g_ventoy_destroy_geom(struct gctl_req *req __unused,
static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp) static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
{ {
int i; int i;
int vlnk = 0;
bool ret = true;
uint8_t *buf; uint8_t *buf;
char uuid[64]; char uuid[64];
const char *value; const char *value;
struct g_consumer *cp; struct g_consumer *cp;
struct g_geom *gp; struct g_geom *gp;
uint8_t mbrdata[] = {
0xEB, 0x63, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x56, 0x54, 0x00, 0x47, 0x65, 0x00, 0x48, 0x44, 0x00, 0x52, 0x64, 0x00, 0x20, 0x45, 0x72, 0x0D,
};
if (g_ventoy_disk_size == 0) if (g_ventoy_disk_size == 0)
{ {
if (resource_string_value("ventoy", 0, "disksize", &value) == 0) if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{ {
G_DEBUG("ventoy.disksize: %s\n", value); G_DEBUG("ventoy map data is valid. [OK]\n");
g_ventoy_disk_size = strtouq(value, NULL, 0);
}
if (resource_string_value("ventoy", 0, "diskuuid", &g_ventoy_disk_uuid) == 0) for (i = 0; i < 16; i++)
{ {
sprintf(uuid + i * 2, "%02x", g_ventoy_map_data.diskuuid[i]);
}
snprintf(g_ventoy_disk_uuid, sizeof(g_ventoy_disk_uuid), "%s", uuid);
g_ventoy_disk_size = g_ventoy_map_data.disksize;
G_DEBUG("ventoy.disksize: %llu\n", (unsigned long long)g_ventoy_disk_size);
G_DEBUG("ventoy.diskuuid: <%s>\n", g_ventoy_disk_uuid); G_DEBUG("ventoy.diskuuid: <%s>\n", g_ventoy_disk_uuid);
} }
else
{
G_DEBUG("ventoy map data is invalid, get from resource\n");
if (resource_string_value("ventoy", 0, "disksize", &value) == 0)
{
G_DEBUG("ventoy.disksize: %s\n", value);
g_ventoy_disk_size = strtouq(value, NULL, 0);
}
if (resource_string_value("ventoy", 0, "diskuuid", &value) == 0)
{
snprintf(g_ventoy_disk_uuid, sizeof(g_ventoy_disk_uuid), "%s", value);
G_DEBUG("ventoy.diskuuid: <%s>\n", value);
}
}
} }
if (g_ventoy_disk_size != pp->mediasize) if (g_ventoy_disk_size != pp->mediasize)
@@ -736,14 +782,93 @@ static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
{ {
sprintf(uuid + i * 2, "%02x", buf[0x180 + i]); sprintf(uuid + i * 2, "%02x", buf[0x180 + i]);
} }
g_free(buf);
if (strncmp(g_ventoy_disk_uuid, uuid, 32) == 0) if (strncmp(g_ventoy_disk_uuid, uuid, 32))
{ {
return true; ret = false;
} }
return false; if (resource_int_value("ventoy", 0, "vlnk", &vlnk) || (vlnk != 1))
{
if (memcmp(mbrdata, buf, 0x30) || memcmp(mbrdata + 0x30, buf + 0x190, 16))
{
ret = false;
}
}
g_free(buf);
if (ret)
{
G_DEBUG("ventoy disk check OK\n");
}
return ret;
}
struct g_dev_softc {
struct mtx sc_mtx;
struct cdev *sc_dev;
struct cdev *sc_alias;
int sc_open;
int sc_active;
};
static int g_ventoy_devalias(struct g_provider *pp)
{
static int firstflag = 0;
const static char *ventoy_alias = NULL;
static struct g_provider *ventoy_pp = NULL;
struct g_consumer *cp;
struct cdev *adev;
struct g_dev_softc *sc;
if (firstflag == 0)
{
/* hint.ventoy.0.alias=xxx */
if (resource_string_value("ventoy", 0, "alias", &ventoy_alias) == 0)
{
G_DEBUG("###### ventoy alias <%s> ######\n", ventoy_alias);
}
else
{
ventoy_alias = NULL;
}
firstflag = 1;
}
if (!ventoy_alias)
{
return 0;
}
if (!ventoy_pp)
{
if (strcmp(pp->name, "ventoy/IMAGE") == 0)
{
ventoy_pp = pp;
}
return 0;
}
LIST_FOREACH(cp, &ventoy_pp->consumers, consumers) {
if (cp->geom && cp->geom->class && cp->geom->class->name)
{
printf("111 cp->geom->class->name=<%s>\n", cp->geom->class->name);
if (strcmp(cp->geom->class->name, "DEV") == 0)
{
sc = cp->private;
make_dev_alias_p(MAKEDEV_CHECKNAME | MAKEDEV_WAITOK, &adev, sc->sc_dev, "%s", ventoy_alias);
G_DEBUG("Create devalias for ventoy <%s>\n", ventoy_alias);
ventoy_alias = NULL;
break;
}
}
}
return 0;
} }
static struct g_geom * static struct g_geom *
@@ -752,12 +877,15 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
int i; int i;
int error; int error;
int disknum; int disknum;
int remount = 0;
char *endpos; char *endpos;
const char *value; const char *value;
struct g_geom *gp; struct g_geom *gp;
struct g_ventoy_metadata md; struct g_ventoy_metadata md;
struct g_ventoy_softc *sc; struct g_ventoy_softc *sc;
g_ventoy_devalias(pp);
if (g_ventoy_tasted) if (g_ventoy_tasted)
{ {
return NULL; return NULL;
@@ -777,9 +905,25 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_ventoy_tasted = true; g_ventoy_tasted = true;
G_DEBUG("######### ventoy disk <%s> #############\n", pp->name); G_DEBUG("###### ventoy disk <%s> ######\n", pp->name);
resource_int_value("ventoy", 0, "segnum", &disknum); /* hint.ventoy.0.remount=1 */
if (resource_int_value("ventoy", 0, "remount", &remount) == 0 && remount == 1)
{
g_ventoy_remount = 1;
G_DEBUG("###### ventoy remount enabled ######\n");
}
if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{
disknum = (int)g_ventoy_map_data.segnum;
G_DEBUG("segnum from map data is:<%d>\n", disknum);
}
else
{
resource_int_value("ventoy", 0, "segnum", &disknum);
G_DEBUG("segnum from resource is:<%d>\n", disknum);
}
strlcpy(md.md_magic, G_VENTOY_MAGIC, sizeof(md.md_magic)); strlcpy(md.md_magic, G_VENTOY_MAGIC, sizeof(md.md_magic));
md.md_version = G_VENTOY_VERSION; md.md_version = G_VENTOY_VERSION;
@@ -801,19 +945,30 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
for (i = 0; i < disknum; i ++) for (i = 0; i < disknum; i ++)
{ {
if (resource_string_value("ventoy", i, "seg", &value) == 0) if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{ {
g_disk_map_start = strtouq(value, &endpos, 0); G_DEBUG("[map] ventoy segment%d: 0x%llx@0x%llx\n", i,
g_disk_map_end = strtouq(endpos + 1, NULL, 0); (long long)g_ventoy_map_data.seglist[i].seg_start_bytes,
(long long)g_ventoy_map_data.seglist[i].seg_end_bytes);
g_disk_map_start = (off_t)g_ventoy_map_data.seglist[i].seg_start_bytes;
g_disk_map_end = (off_t)g_ventoy_map_data.seglist[i].seg_end_bytes;
} }
else else
{ {
printf("Failed to parse ventoy seg %d\n", i); if (resource_string_value("ventoy", i, "seg", &value) == 0)
continue; {
g_disk_map_start = strtouq(value, &endpos, 0);
g_disk_map_end = strtouq(endpos + 1, NULL, 0);
}
else
{
printf("Failed to parse ventoy seg %d\n", i);
continue;
}
G_DEBUG("[resource] ventoy segment%d: %s\n", i, value);
} }
G_DEBUG("ventoy segment%d: %s\n", i, value);
G_VENTOY_DEBUG(1, "Adding disk %s to %s.", pp->name, gp->name); G_VENTOY_DEBUG(1, "Adding disk %s to %s.", pp->name, gp->name);
error = g_ventoy_add_disk(sc, pp, i); error = g_ventoy_add_disk(sc, pp, i);
if (error != 0) { if (error != 0) {
@@ -828,7 +983,7 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_disk_map_end = 0; g_disk_map_end = 0;
} }
return (gp); return (gp);
} }
static void static void
@@ -1066,3 +1221,4 @@ g_ventoy_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
} }
DECLARE_GEOM_CLASS(g_ventoy_class, g_ventoy); DECLARE_GEOM_CLASS(g_ventoy_class, g_ventoy);
//MODULE_VERSION(geom_ventoy, 0);

View File

@@ -76,6 +76,33 @@ struct g_ventoy_softc {
struct mtx sc_lock; struct mtx sc_lock;
}; };
#define sc_name sc_geom->name #define sc_name sc_geom->name
#pragma pack(1)
#define VENTOY_UNIX_SEG_MAGIC0 0x11223344
#define VENTOY_UNIX_SEG_MAGIC1 0x55667788
#define VENTOY_UNIX_SEG_MAGIC2 0x99aabbcc
#define VENTOY_UNIX_SEG_MAGIC3 0xddeeff00
#define VENTOY_UNIX_MAX_SEGNUM 40960
struct g_ventoy_seg {
uint64_t seg_start_bytes;
uint64_t seg_end_bytes;
};
struct g_ventoy_map{
uint32_t magic1[4];
uint32_t magic2[4];
uint64_t segnum;
uint64_t disksize;
uint8_t diskuuid[16];
struct g_ventoy_seg seglist[VENTOY_UNIX_MAX_SEGNUM];
uint32_t magic3[4];
};
#pragma pack()
#define VENTOY_MAP_VALID(magic2) \
(magic2[0] == VENTOY_UNIX_SEG_MAGIC0 && magic2[1] == VENTOY_UNIX_SEG_MAGIC1 && magic2[2] == VENTOY_UNIX_SEG_MAGIC2 && magic2[3] == VENTOY_UNIX_SEG_MAGIC3)
#endif /* _KERNEL */ #endif /* _KERNEL */
struct g_ventoy_metadata { struct g_ventoy_metadata {

View File

@@ -70,8 +70,9 @@ static bool g_ventoy_tasted = false;
static off_t g_ventoy_disk_size = 0; static off_t g_ventoy_disk_size = 0;
static off_t g_disk_map_start = 0; static off_t g_disk_map_start = 0;
static off_t g_disk_map_end = 0; static off_t g_disk_map_end = 0;
static int g_ventoy_remount = 0;
struct g_ventoy_map g_ventoy_map_data __attribute__((aligned (65536))) = struct g_ventoy_map g_ventoy_map_data __attribute__((aligned (4096))) =
{ {
{ VENTOY_UNIX_SEG_MAGIC0, VENTOY_UNIX_SEG_MAGIC1, VENTOY_UNIX_SEG_MAGIC2, VENTOY_UNIX_SEG_MAGIC3 }, { VENTOY_UNIX_SEG_MAGIC0, VENTOY_UNIX_SEG_MAGIC1, VENTOY_UNIX_SEG_MAGIC2, VENTOY_UNIX_SEG_MAGIC3 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 },
@@ -200,12 +201,19 @@ g_ventoy_access(struct g_provider *pp, int dr, int dw, int de)
g_topology_assert(); g_topology_assert();
gp = pp->geom; gp = pp->geom;
/* On first open, grab an extra "exclusive" bit */ if (g_ventoy_remount)
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0) {
de++; de = 0;
/* ... and let go of it on last close */ }
if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0) else
de--; {
/* On first open, grab an extra "exclusive" bit */
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0)
de++;
/* ... and let go of it on last close */
if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0)
de--;
}
LIST_FOREACH_SAFE(cp1, &gp->consumer, consumer, tmp) { LIST_FOREACH_SAFE(cp1, &gp->consumer, consumer, tmp) {
error = g_access(cp1, dr, dw, de); error = g_access(cp1, dr, dw, de);
@@ -687,6 +695,7 @@ g_ventoy_destroy_geom(struct gctl_req *req __unused,
static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp) static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
{ {
int i; int i;
int vlnk = 0;
bool ret = true; bool ret = true;
uint8_t *buf; uint8_t *buf;
char uuid[64]; char uuid[64];
@@ -778,9 +787,12 @@ static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
ret = false; ret = false;
} }
if (memcmp(mbrdata, buf, 0x30) || memcmp(mbrdata + 0x30, buf + 0x190, 16)) if (resource_int_value("ventoy", 0, "vlnk", &vlnk) || (vlnk != 1))
{ {
ret = false; if (memcmp(mbrdata, buf, 0x30) || memcmp(mbrdata + 0x30, buf + 0x190, 16))
{
ret = false;
}
} }
g_free(buf); g_free(buf);
@@ -799,8 +811,10 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
int i; int i;
int error; int error;
int disknum; int disknum;
int remount = 0;
char *endpos; char *endpos;
const char *value; const char *value;
const char *alias = NULL;
struct g_geom *gp; struct g_geom *gp;
struct g_ventoy_metadata md; struct g_ventoy_metadata md;
struct g_ventoy_softc *sc; struct g_ventoy_softc *sc;
@@ -824,7 +838,24 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_ventoy_tasted = true; g_ventoy_tasted = true;
G_DEBUG("######### ventoy disk <%s> #############\n", pp->name); G_DEBUG("###### ventoy disk <%s> ######\n", pp->name);
/* hint.ventoy.0.remount=1 */
if (resource_int_value("ventoy", 0, "remount", &remount) == 0 && remount == 1)
{
g_ventoy_remount = 1;
G_DEBUG("###### ventoy remount enabled ######\n");
}
/* hint.ventoy.0.alias=xxx */
if (resource_string_value("ventoy", 0, "alias", &alias) == 0)
{
G_DEBUG("###### ventoy alias <%s> ######\n", alias);
}
else
{
alias = NULL;
}
if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2)) if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{ {
@@ -895,7 +926,12 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_disk_map_end = 0; g_disk_map_end = 0;
} }
return (gp); if (alias)
{
g_geom_add_alias(gp, alias);
}
return (gp);
} }
static void static void

View File

@@ -70,8 +70,9 @@ static bool g_ventoy_tasted = false;
static off_t g_ventoy_disk_size = 0; static off_t g_ventoy_disk_size = 0;
static off_t g_disk_map_start = 0; static off_t g_disk_map_start = 0;
static off_t g_disk_map_end = 0; static off_t g_disk_map_end = 0;
static int g_ventoy_remount = 0;
struct g_ventoy_map g_ventoy_map_data __attribute__((aligned (65536))) = struct g_ventoy_map g_ventoy_map_data __attribute__((aligned (4096))) =
{ {
{ VENTOY_UNIX_SEG_MAGIC0, VENTOY_UNIX_SEG_MAGIC1, VENTOY_UNIX_SEG_MAGIC2, VENTOY_UNIX_SEG_MAGIC3 }, { VENTOY_UNIX_SEG_MAGIC0, VENTOY_UNIX_SEG_MAGIC1, VENTOY_UNIX_SEG_MAGIC2, VENTOY_UNIX_SEG_MAGIC3 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 },
@@ -200,12 +201,19 @@ g_ventoy_access(struct g_provider *pp, int dr, int dw, int de)
g_topology_assert(); g_topology_assert();
gp = pp->geom; gp = pp->geom;
/* On first open, grab an extra "exclusive" bit */ if (g_ventoy_remount)
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0) {
de++; de = 0;
/* ... and let go of it on last close */ }
if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0) else
de--; {
/* On first open, grab an extra "exclusive" bit */
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0)
de++;
/* ... and let go of it on last close */
if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0)
de--;
}
LIST_FOREACH_SAFE(cp1, &gp->consumer, consumer, tmp) { LIST_FOREACH_SAFE(cp1, &gp->consumer, consumer, tmp) {
error = g_access(cp1, dr, dw, de); error = g_access(cp1, dr, dw, de);
@@ -721,6 +729,7 @@ g_ventoy_destroy_geom(struct gctl_req *req __unused,
static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp) static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
{ {
int i; int i;
int vlnk = 0;
bool ret = true; bool ret = true;
uint8_t *buf; uint8_t *buf;
char uuid[64]; char uuid[64];
@@ -812,9 +821,12 @@ static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
ret = false; ret = false;
} }
if (memcmp(mbrdata, buf, 0x30) || memcmp(mbrdata + 0x30, buf + 0x190, 16)) if (resource_int_value("ventoy", 0, "vlnk", &vlnk) || (vlnk != 1))
{ {
ret = false; if (memcmp(mbrdata, buf, 0x30) || memcmp(mbrdata + 0x30, buf + 0x190, 16))
{
ret = false;
}
} }
g_free(buf); g_free(buf);
@@ -833,8 +845,10 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
int i; int i;
int error; int error;
int disknum; int disknum;
int remount = 0;
char *endpos; char *endpos;
const char *value; const char *value;
const char *alias = NULL;
struct g_geom *gp; struct g_geom *gp;
struct g_ventoy_metadata md; struct g_ventoy_metadata md;
struct g_ventoy_softc *sc; struct g_ventoy_softc *sc;
@@ -858,7 +872,24 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_ventoy_tasted = true; g_ventoy_tasted = true;
G_DEBUG("######### ventoy disk <%s> #############\n", pp->name); G_DEBUG("###### ventoy disk <%s> ######\n", pp->name);
/* hint.ventoy.0.remount=1 */
if (resource_int_value("ventoy", 0, "remount", &remount) == 0 && remount == 1)
{
g_ventoy_remount = 1;
G_DEBUG("###### ventoy remount enabled ######\n");
}
/* hint.ventoy.0.alias=xxx */
if (resource_string_value("ventoy", 0, "alias", &alias) == 0)
{
G_DEBUG("###### ventoy alias <%s> ######\n", alias);
}
else
{
alias = NULL;
}
if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2)) if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{ {
@@ -929,7 +960,12 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_disk_map_end = 0; g_disk_map_end = 0;
} }
return (gp); if (alias && sc && sc->sc_provider)
{
g_provider_add_alias(sc->sc_provider, "%s", alias);
}
return (gp);
} }
static void static void

View File

@@ -65,11 +65,22 @@ static g_taste_t g_ventoy_taste;
static g_ctl_req_t g_ventoy_config; static g_ctl_req_t g_ventoy_config;
static g_dumpconf_t g_ventoy_dumpconf; static g_dumpconf_t g_ventoy_dumpconf;
static const char *g_ventoy_disk_uuid = NULL; static char g_ventoy_disk_uuid[64];
static bool g_ventoy_tasted = false; static bool g_ventoy_tasted = false;
static off_t g_ventoy_disk_size = 0; static off_t g_ventoy_disk_size = 0;
static off_t g_disk_map_start = 0; static off_t g_disk_map_start = 0;
static off_t g_disk_map_end = 0; static off_t g_disk_map_end = 0;
static int g_ventoy_remount = 0;
struct g_ventoy_map g_ventoy_map_data __attribute__((aligned (4096))) =
{
{ VENTOY_UNIX_SEG_MAGIC0, VENTOY_UNIX_SEG_MAGIC1, VENTOY_UNIX_SEG_MAGIC2, VENTOY_UNIX_SEG_MAGIC3 },
{ 0, 0, 0, 0 },
0, 0,
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ { 0, 0 } },
{ VENTOY_UNIX_SEG_MAGIC0, VENTOY_UNIX_SEG_MAGIC1, VENTOY_UNIX_SEG_MAGIC2, VENTOY_UNIX_SEG_MAGIC3 }
};
struct g_class g_ventoy_class = { struct g_class g_ventoy_class = {
.name = G_VENTOY_CLASS_NAME, .name = G_VENTOY_CLASS_NAME,
@@ -191,12 +202,19 @@ g_ventoy_access(struct g_provider *pp, int dr, int dw, int de)
g_topology_assert(); g_topology_assert();
gp = pp->geom; gp = pp->geom;
/* On first open, grab an extra "exclusive" bit */ if (g_ventoy_remount)
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0) {
de++; de = 0;
/* ... and let go of it on last close */ }
if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0) else
de--; {
/* On first open, grab an extra "exclusive" bit */
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0)
de++;
/* ... and let go of it on last close */
if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0)
de--;
}
LIST_FOREACH_SAFE(cp1, &gp->consumer, consumer, tmp) { LIST_FOREACH_SAFE(cp1, &gp->consumer, consumer, tmp) {
error = g_access(cp1, dr, dw, de); error = g_access(cp1, dr, dw, de);
@@ -642,24 +660,52 @@ g_ventoy_destroy_geom(struct gctl_req *req __unused,
static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp) static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
{ {
int i; int i;
int vlnk = 0;
bool ret = true;
uint8_t *buf; uint8_t *buf;
char uuid[64]; char uuid[64];
const char *value; const char *value;
struct g_consumer *cp; struct g_consumer *cp;
struct g_geom *gp; struct g_geom *gp;
uint8_t mbrdata[] = {
0xEB, 0x63, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x56, 0x54, 0x00, 0x47, 0x65, 0x00, 0x48, 0x44, 0x00, 0x52, 0x64, 0x00, 0x20, 0x45, 0x72, 0x0D,
};
if (g_ventoy_disk_size == 0) if (g_ventoy_disk_size == 0)
{ {
if (resource_string_value("ventoy", 0, "disksize", &value) == 0) if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{ {
G_DEBUG("ventoy.disksize: %s\n", value); G_DEBUG("ventoy map data is valid. [OK]\n");
g_ventoy_disk_size = strtouq(value, NULL, 0);
}
if (resource_string_value("ventoy", 0, "diskuuid", &g_ventoy_disk_uuid) == 0) for (i = 0; i < 16; i++)
{ {
sprintf(uuid + i * 2, "%02x", g_ventoy_map_data.diskuuid[i]);
}
snprintf(g_ventoy_disk_uuid, sizeof(g_ventoy_disk_uuid), "%s", uuid);
g_ventoy_disk_size = g_ventoy_map_data.disksize;
G_DEBUG("ventoy.disksize: %llu\n", (unsigned long long)g_ventoy_disk_size);
G_DEBUG("ventoy.diskuuid: <%s>\n", g_ventoy_disk_uuid); G_DEBUG("ventoy.diskuuid: <%s>\n", g_ventoy_disk_uuid);
} }
else
{
G_DEBUG("ventoy map data is invalid, get from resource\n");
if (resource_string_value("ventoy", 0, "disksize", &value) == 0)
{
G_DEBUG("ventoy.disksize: %s\n", value);
g_ventoy_disk_size = strtouq(value, NULL, 0);
}
if (resource_string_value("ventoy", 0, "diskuuid", &value) == 0)
{
snprintf(g_ventoy_disk_uuid, sizeof(g_ventoy_disk_uuid), "%s", value);
G_DEBUG("ventoy.diskuuid: <%s>\n", value);
}
}
} }
if (g_ventoy_disk_size != pp->mediasize) if (g_ventoy_disk_size != pp->mediasize)
@@ -700,14 +746,28 @@ static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
{ {
sprintf(uuid + i * 2, "%02x", buf[0x180 + i]); sprintf(uuid + i * 2, "%02x", buf[0x180 + i]);
} }
g_free(buf);
if (strncmp(g_ventoy_disk_uuid, uuid, 32) == 0) if (strncmp(g_ventoy_disk_uuid, uuid, 32))
{ {
return true; ret = false;
} }
return false; if (resource_int_value("ventoy", 0, "vlnk", &vlnk) || (vlnk != 1))
{
if (memcmp(mbrdata, buf, 0x30) || memcmp(mbrdata + 0x30, buf + 0x190, 16))
{
ret = false;
}
}
g_free(buf);
if (ret)
{
G_DEBUG("ventoy disk check OK\n");
}
return ret;
} }
static struct g_geom * static struct g_geom *
@@ -716,8 +776,10 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
int i; int i;
int error; int error;
int disknum; int disknum;
int remount = 0;
char *endpos; char *endpos;
const char *value; const char *value;
const char *alias = NULL;
struct g_geom *gp; struct g_geom *gp;
struct g_ventoy_metadata md; struct g_ventoy_metadata md;
struct g_ventoy_softc *sc; struct g_ventoy_softc *sc;
@@ -741,9 +803,32 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_ventoy_tasted = true; g_ventoy_tasted = true;
G_DEBUG("######### ventoy disk <%s> #############\n", pp->name); G_DEBUG("###### ventoy disk <%s> ######\n", pp->name);
resource_int_value("ventoy", 0, "segnum", &disknum); /* hint.ventoy.0.remount=1 */
if (resource_int_value("ventoy", 0, "remount", &remount) == 0 && remount == 1)
{
g_ventoy_remount = 1;
G_DEBUG("###### ventoy remount enabled ######\n");
}
/* hint.ventoy.0.alias=xxx */
if (resource_string_value("ventoy", 0, "alias", &alias) == 0 && alias)
{
G_DEBUG("###### ventoy alias <%s> ######\n", alias);
setenv("kern.devalias.ventoy/IMAGE", alias);
}
if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{
disknum = (int)g_ventoy_map_data.segnum;
G_DEBUG("segnum from map data is:<%d>\n", disknum);
}
else
{
resource_int_value("ventoy", 0, "segnum", &disknum);
G_DEBUG("segnum from resource is:<%d>\n", disknum);
}
strlcpy(md.md_magic, G_VENTOY_MAGIC, sizeof(md.md_magic)); strlcpy(md.md_magic, G_VENTOY_MAGIC, sizeof(md.md_magic));
md.md_version = G_VENTOY_VERSION; md.md_version = G_VENTOY_VERSION;
@@ -765,19 +850,30 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
for (i = 0; i < disknum; i ++) for (i = 0; i < disknum; i ++)
{ {
if (resource_string_value("ventoy", i, "seg", &value) == 0) if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{ {
g_disk_map_start = strtouq(value, &endpos, 0); G_DEBUG("[map] ventoy segment%d: 0x%llx@0x%llx\n", i,
g_disk_map_end = strtouq(endpos + 1, NULL, 0); (long long)g_ventoy_map_data.seglist[i].seg_start_bytes,
(long long)g_ventoy_map_data.seglist[i].seg_end_bytes);
g_disk_map_start = (off_t)g_ventoy_map_data.seglist[i].seg_start_bytes;
g_disk_map_end = (off_t)g_ventoy_map_data.seglist[i].seg_end_bytes;
} }
else else
{ {
printf("Failed to parse ventoy seg %d\n", i); if (resource_string_value("ventoy", i, "seg", &value) == 0)
continue; {
g_disk_map_start = strtouq(value, &endpos, 0);
g_disk_map_end = strtouq(endpos + 1, NULL, 0);
}
else
{
printf("Failed to parse ventoy seg %d\n", i);
continue;
}
G_DEBUG("[resource] ventoy segment%d: %s\n", i, value);
} }
G_DEBUG("ventoy segment%d: %s\n", i, value);
G_VENTOY_DEBUG(1, "Adding disk %s to %s.", pp->name, gp->name); G_VENTOY_DEBUG(1, "Adding disk %s to %s.", pp->name, gp->name);
error = g_ventoy_add_disk(sc, pp, i); error = g_ventoy_add_disk(sc, pp, i);
if (error != 0) { if (error != 0) {
@@ -792,7 +888,7 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_disk_map_end = 0; g_disk_map_end = 0;
} }
return (gp); return (gp);
} }
static void static void

View File

@@ -76,6 +76,33 @@ struct g_ventoy_softc {
struct mtx sc_lock; struct mtx sc_lock;
}; };
#define sc_name sc_geom->name #define sc_name sc_geom->name
#pragma pack(1)
#define VENTOY_UNIX_SEG_MAGIC0 0x11223344
#define VENTOY_UNIX_SEG_MAGIC1 0x55667788
#define VENTOY_UNIX_SEG_MAGIC2 0x99aabbcc
#define VENTOY_UNIX_SEG_MAGIC3 0xddeeff00
#define VENTOY_UNIX_MAX_SEGNUM 40960
struct g_ventoy_seg {
uint64_t seg_start_bytes;
uint64_t seg_end_bytes;
};
struct g_ventoy_map{
uint32_t magic1[4];
uint32_t magic2[4];
uint64_t segnum;
uint64_t disksize;
uint8_t diskuuid[16];
struct g_ventoy_seg seglist[VENTOY_UNIX_MAX_SEGNUM];
uint32_t magic3[4];
};
#pragma pack()
#define VENTOY_MAP_VALID(magic2) \
(magic2[0] == VENTOY_UNIX_SEG_MAGIC0 && magic2[1] == VENTOY_UNIX_SEG_MAGIC1 && magic2[2] == VENTOY_UNIX_SEG_MAGIC2 && magic2[3] == VENTOY_UNIX_SEG_MAGIC3)
#endif /* _KERNEL */ #endif /* _KERNEL */
struct g_ventoy_metadata { struct g_ventoy_metadata {