mirror of
https://github.com/ventoy/Ventoy.git
synced 2026-07-24 10:48:12 +00:00
Fix the boot issue for latest GhostBSD (#3664)
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* ventoy_unix.c
|
* ventoy_unix.c
|
||||||
*
|
*
|
||||||
* Copyright (c) 2020, longpanda <admin@ventoy.net>
|
* Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||||
*
|
*
|
||||||
@@ -7,12 +7,12 @@
|
|||||||
* modify it under the terms of the GNU General Public License as
|
* modify it under the terms of the GNU General Public License as
|
||||||
* published by the Free Software Foundation; either version 3 of the
|
* published by the Free Software Foundation; either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but
|
* This program is distributed in the hope that it will be useful, but
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* General Public License for more details.
|
* General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
@@ -69,9 +69,9 @@ static int ventoy_get_file_override(const char *filename, grub_uint64_t *offset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
*offset = grub_iso9660_get_last_file_dirent_pos(file) + 2;
|
*offset = grub_iso9660_get_last_file_dirent_pos(file) + 2;
|
||||||
|
|
||||||
grub_file_close(file);
|
grub_file_close(file);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,12 +83,12 @@ static grub_uint32_t ventoy_unix_get_override_chunk_count(void)
|
|||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_mod_new_len > 0)
|
if (g_mod_new_len > 0)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_ko_fillmap_len > 0)
|
if (g_ko_fillmap_len > 0)
|
||||||
{
|
{
|
||||||
count += (g_ko_fillmap_len / 512);
|
count += (g_ko_fillmap_len / 512);
|
||||||
@@ -109,7 +109,7 @@ static grub_uint32_t ventoy_unix_get_virt_chunk_count(void)
|
|||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_mod_new_len > 0)
|
if (g_mod_new_len > 0)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
@@ -127,7 +127,7 @@ static grub_uint32_t ventoy_unix_get_virt_chunk_size(void)
|
|||||||
{
|
{
|
||||||
size += ventoy_align_2k(g_conf_new_len);
|
size += ventoy_align_2k(g_conf_new_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_mod_new_len > 0)
|
if (g_mod_new_len > 0)
|
||||||
{
|
{
|
||||||
size += ventoy_align_2k(g_mod_new_len);
|
size += ventoy_align_2k(g_mod_new_len);
|
||||||
@@ -141,9 +141,9 @@ static void ventoy_unix_fill_map_data(ventoy_chain_head *chain, struct g_ventoy_
|
|||||||
grub_uint32_t i;
|
grub_uint32_t i;
|
||||||
ventoy_img_chunk *chunk = NULL;
|
ventoy_img_chunk *chunk = NULL;
|
||||||
|
|
||||||
debug("Fill unix map data: <%llu> <%u> %p\n",
|
debug("Fill unix map data: <%llu> <%u> %p\n",
|
||||||
(unsigned long long)chain->os_param.vtoy_disk_size, g_img_chunk_list.cur_chunk, map);
|
(unsigned long long)chain->os_param.vtoy_disk_size, g_img_chunk_list.cur_chunk, map);
|
||||||
|
|
||||||
map->magic1[0] = map->magic2[0] = VENTOY_UNIX_SEG_MAGIC0;
|
map->magic1[0] = map->magic2[0] = VENTOY_UNIX_SEG_MAGIC0;
|
||||||
map->magic1[1] = map->magic2[1] = VENTOY_UNIX_SEG_MAGIC1;
|
map->magic1[1] = map->magic2[1] = VENTOY_UNIX_SEG_MAGIC1;
|
||||||
map->magic1[2] = map->magic2[2] = VENTOY_UNIX_SEG_MAGIC2;
|
map->magic1[2] = map->magic2[2] = VENTOY_UNIX_SEG_MAGIC2;
|
||||||
@@ -158,12 +158,12 @@ static void ventoy_unix_fill_map_data(ventoy_chain_head *chain, struct g_ventoy_
|
|||||||
debug("####[FAIL] Too many segments for the ISO file %u\n", g_img_chunk_list.cur_chunk);
|
debug("####[FAIL] Too many segments for the ISO file %u\n", g_img_chunk_list.cur_chunk);
|
||||||
map->segnum = VENTOY_UNIX_MAX_SEGNUM;
|
map->segnum = VENTOY_UNIX_MAX_SEGNUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < (grub_uint32_t)(map->segnum); i++)
|
for (i = 0; i < (grub_uint32_t)(map->segnum); i++)
|
||||||
{
|
{
|
||||||
chunk = g_img_chunk_list.chunk + i;
|
chunk = g_img_chunk_list.chunk + i;
|
||||||
map->seglist[i].seg_start_bytes = chunk->disk_start_sector * 512ULL;
|
map->seglist[i].seg_start_bytes = chunk->disk_start_sector * 512ULL;
|
||||||
map->seglist[i].seg_end_bytes = (chunk->disk_end_sector + 1) * 512ULL;
|
map->seglist[i].seg_end_bytes = (chunk->disk_end_sector + 1) * 512ULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ static void ventoy_unix_fill_override_data( grub_uint64_t isosize, ventoy_cha
|
|||||||
grub_uint64_t sector;
|
grub_uint64_t sector;
|
||||||
ventoy_override_chunk *cur;
|
ventoy_override_chunk *cur;
|
||||||
ventoy_iso9660_override *dirent;
|
ventoy_iso9660_override *dirent;
|
||||||
|
|
||||||
sector = (isosize + 2047) / 2048;
|
sector = (isosize + 2047) / 2048;
|
||||||
|
|
||||||
cur = (ventoy_override_chunk *)((char *)chain + chain->override_chunk_offset);
|
cur = (ventoy_override_chunk *)((char *)chain + chain->override_chunk_offset);
|
||||||
@@ -215,7 +215,7 @@ static void ventoy_unix_fill_override_data( grub_uint64_t isosize, ventoy_cha
|
|||||||
offset = g_mod_override_offset;
|
offset = g_mod_override_offset;
|
||||||
|
|
||||||
ventoy_unix_fill_map_data(chain, (struct g_ventoy_map *)data);
|
ventoy_unix_fill_map_data(chain, (struct g_ventoy_map *)data);
|
||||||
|
|
||||||
for (i = 0; i < g_ko_fillmap_len / 512; i++)
|
for (i = 0; i < g_ko_fillmap_len / 512; i++)
|
||||||
{
|
{
|
||||||
cur->img_offset = offset;
|
cur->img_offset = offset;
|
||||||
@@ -252,7 +252,7 @@ static void ventoy_unix_fill_virt_data( grub_uint64_t isosize, ventoy_chain_h
|
|||||||
|
|
||||||
override = (char *)chain + chain->virt_chunk_offset;
|
override = (char *)chain + chain->virt_chunk_offset;
|
||||||
cur = (ventoy_virt_chunk *)override;
|
cur = (ventoy_virt_chunk *)override;
|
||||||
|
|
||||||
sector = (isosize + 2047) / 2048;
|
sector = (isosize + 2047) / 2048;
|
||||||
offset = 2 * sizeof(ventoy_virt_chunk);
|
offset = 2 * sizeof(ventoy_virt_chunk);
|
||||||
|
|
||||||
@@ -267,10 +267,10 @@ static void ventoy_unix_fill_virt_data( grub_uint64_t isosize, ventoy_chain_h
|
|||||||
{
|
{
|
||||||
ventoy_unix_fill_map_data(chain, (struct g_ventoy_map *)(g_mod_new_data + g_mod_search_magic));
|
ventoy_unix_fill_map_data(chain, (struct g_ventoy_map *)(g_mod_new_data + g_mod_search_magic));
|
||||||
}
|
}
|
||||||
|
|
||||||
ventoy_unix_fill_virt(g_mod_new_data, g_mod_new_len);
|
ventoy_unix_fill_virt(g_mod_new_data, g_mod_new_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +287,7 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath, const char
|
|||||||
grub_uint8_t disk_guid[16];
|
grub_uint8_t disk_guid[16];
|
||||||
|
|
||||||
debug("ventoy_freebsd_append_conf %s\n", isopath);
|
debug("ventoy_freebsd_append_conf %s\n", isopath);
|
||||||
|
|
||||||
isofile = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", isopath);
|
isofile = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", isopath);
|
||||||
if (!isofile)
|
if (!isofile)
|
||||||
{
|
{
|
||||||
@@ -296,7 +296,7 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath, const char
|
|||||||
|
|
||||||
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)
|
if (alias)
|
||||||
{
|
{
|
||||||
vtoy_ssprintf(buf, pos, "hint.ventoy.0.alias=\"%s\"\n", alias);
|
vtoy_ssprintf(buf, pos, "hint.ventoy.0.alias=\"%s\"\n", alias);
|
||||||
@@ -320,7 +320,7 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath, const char
|
|||||||
}
|
}
|
||||||
|
|
||||||
debug("Fill hint.ventoy info\n");
|
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);
|
||||||
@@ -338,7 +338,7 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath, const char
|
|||||||
for (i = 0; i < g_img_chunk_list.cur_chunk; i++)
|
for (i = 0; i < g_img_chunk_list.cur_chunk; i++)
|
||||||
{
|
{
|
||||||
chunk = g_img_chunk_list.chunk + i;
|
chunk = g_img_chunk_list.chunk + i;
|
||||||
vtoy_ssprintf(buf, pos, "hint.ventoy.%u.seg=\"0x%llx@0x%llx\"\n",
|
vtoy_ssprintf(buf, pos, "hint.ventoy.%u.seg=\"0x%llx@0x%llx\"\n",
|
||||||
i, (ulonglong)(chunk->disk_start_sector * 512),
|
i, (ulonglong)(chunk->disk_start_sector * 512),
|
||||||
(ulonglong)((chunk->disk_end_sector + 1) * 512));
|
(ulonglong)((chunk->disk_end_sector + 1) * 512));
|
||||||
}
|
}
|
||||||
@@ -368,7 +368,7 @@ grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **ar
|
|||||||
(void)ctxt;
|
(void)ctxt;
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)args;
|
(void)args;
|
||||||
|
|
||||||
g_unix_vlnk_boot = 0;
|
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;
|
||||||
@@ -411,7 +411,7 @@ grub_err_t ventoy_cmd_parse_freenas_ver(grub_extcmd_context_t ctxt, int argc, ch
|
|||||||
const char *ver = NULL;
|
const char *ver = NULL;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
VTOY_JSON *json = NULL;
|
VTOY_JSON *json = NULL;
|
||||||
|
|
||||||
(void)ctxt;
|
(void)ctxt;
|
||||||
(void)argc;
|
(void)argc;
|
||||||
|
|
||||||
@@ -472,7 +472,7 @@ grub_err_t ventoy_cmd_unix_freebsd_ver(grub_extcmd_context_t ctxt, int argc, cha
|
|||||||
char *buf;
|
char *buf;
|
||||||
char *start = NULL;
|
char *start = NULL;
|
||||||
char *nextline = NULL;
|
char *nextline = NULL;
|
||||||
|
|
||||||
(void)ctxt;
|
(void)ctxt;
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)args;
|
(void)args;
|
||||||
@@ -502,7 +502,7 @@ grub_err_t ventoy_cmd_unix_freebsd_ver(grub_extcmd_context_t ctxt, int argc, cha
|
|||||||
nextline++;
|
nextline++;
|
||||||
}
|
}
|
||||||
|
|
||||||
*nextline = 0;
|
*nextline = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
nextline = ventoy_get_line(start);
|
nextline = ventoy_get_line(start);
|
||||||
@@ -521,25 +521,162 @@ grub_err_t ventoy_cmd_unix_freebsd_ver(grub_extcmd_context_t ctxt, int argc, cha
|
|||||||
|
|
||||||
grub_free(buf);
|
grub_free(buf);
|
||||||
grub_file_close(file);
|
grub_file_close(file);
|
||||||
|
|
||||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ventoy_freebsd_ver_elf(int bit64, grub_elf_t elf, const char *section, const char *env, char *data)
|
||||||
|
{
|
||||||
|
int j = 0;
|
||||||
|
int k = 0;
|
||||||
|
int ret = 1;
|
||||||
|
char *str = NULL;
|
||||||
|
void *hdr = NULL;
|
||||||
|
grub_off_t offset = 0;
|
||||||
|
grub_uint32_t len = 0;
|
||||||
|
char ver[64] = {0};
|
||||||
|
|
||||||
|
if (bit64)
|
||||||
|
{
|
||||||
|
Elf64_Ehdr *e = &(elf->ehdr.ehdr64);
|
||||||
|
Elf64_Shdr *h;
|
||||||
|
Elf64_Shdr *s;
|
||||||
|
Elf64_Shdr *t;
|
||||||
|
Elf64_Half i;
|
||||||
|
|
||||||
|
h = hdr = grub_zalloc(e->e_shnum * e->e_shentsize);
|
||||||
|
if (!h)
|
||||||
|
{
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
debug("read section header %u %u %u\n", e->e_shnum, e->e_shentsize, e->e_shstrndx);
|
||||||
|
grub_file_seek(elf->file, e->e_shoff);
|
||||||
|
grub_file_read(elf->file, h, e->e_shnum * e->e_shentsize);
|
||||||
|
|
||||||
|
s = (Elf64_Shdr *)((char *)h + e->e_shstrndx * e->e_shentsize);
|
||||||
|
str = grub_malloc(s->sh_size + 1);
|
||||||
|
if (!str)
|
||||||
|
{
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
str[s->sh_size] = 0;
|
||||||
|
|
||||||
|
debug("read string table %u %u\n", (grub_uint32_t)s->sh_offset, (grub_uint32_t)s->sh_size);
|
||||||
|
grub_file_seek(elf->file, s->sh_offset);
|
||||||
|
grub_file_read(elf->file, str, s->sh_size);
|
||||||
|
|
||||||
|
for (t = h, i = 0; i < e->e_shnum; i++)
|
||||||
|
{
|
||||||
|
if (grub_strcmp(str + t->sh_name, section) == 0)
|
||||||
|
{
|
||||||
|
offset = t->sh_offset;
|
||||||
|
len = t->sh_size;
|
||||||
|
debug("find %s section at %u %u\n", section, (grub_uint32_t)offset, len);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
t = (Elf64_Shdr *)((char *)t + e->e_shentsize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Elf32_Ehdr *e = &(elf->ehdr.ehdr32);
|
||||||
|
Elf32_Shdr *h;
|
||||||
|
Elf32_Shdr *s;
|
||||||
|
Elf32_Shdr *t;
|
||||||
|
Elf32_Half i;
|
||||||
|
|
||||||
|
h = hdr = grub_zalloc(e->e_shnum * e->e_shentsize);
|
||||||
|
if (!h)
|
||||||
|
{
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
debug("read section header %u %u %u\n", e->e_shnum, e->e_shentsize, e->e_shstrndx);
|
||||||
|
grub_file_seek(elf->file, e->e_shoff);
|
||||||
|
grub_file_read(elf->file, h, e->e_shnum * e->e_shentsize);
|
||||||
|
|
||||||
|
s = (Elf32_Shdr *)((char *)h + e->e_shstrndx * e->e_shentsize);
|
||||||
|
str = grub_malloc(s->sh_size + 1);
|
||||||
|
if (!str)
|
||||||
|
{
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
str[s->sh_size] = 0;
|
||||||
|
|
||||||
|
debug("read string table %u %u\n", (grub_uint32_t)s->sh_offset, (grub_uint32_t)s->sh_size);
|
||||||
|
grub_file_seek(elf->file, s->sh_offset);
|
||||||
|
grub_file_read(elf->file, str, s->sh_size);
|
||||||
|
|
||||||
|
for (t = h, i = 0; i < e->e_shnum; i++)
|
||||||
|
{
|
||||||
|
if (grub_strcmp(str + t->sh_name, section) == 0)
|
||||||
|
{
|
||||||
|
offset = t->sh_offset;
|
||||||
|
len = t->sh_size;
|
||||||
|
debug("find %s section at %u %u\n", section, (grub_uint32_t)offset, len);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
t = (Elf32_Shdr *)((char *)t + e->e_shentsize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (offset == 0 || len == 0)
|
||||||
|
{
|
||||||
|
debug("%s section not found\n", section);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_file_seek(elf->file, offset + len - 8192);
|
||||||
|
grub_file_read(elf->file, data, 8192);
|
||||||
|
|
||||||
|
for (j = 0; j < 8192 - 12; j++)
|
||||||
|
{
|
||||||
|
if (grub_strncmp(data + j, "@(#)FreeBSD ", 12) == 0)
|
||||||
|
{
|
||||||
|
for (k = j + 12; k < 8192; k++)
|
||||||
|
{
|
||||||
|
if (0 == grub_isdigit(data[k]) && data[k] != '.')
|
||||||
|
{
|
||||||
|
data[k] = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_snprintf(ver, sizeof(ver), "%s", data + j + 12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (ver[0])
|
||||||
|
{
|
||||||
|
k = (int)grub_strtoul(ver, NULL, 10);
|
||||||
|
debug("%s freebsd version:<%s> <%d.x>\n", section, ver, k);
|
||||||
|
grub_snprintf(ver, sizeof(ver), "%d.x", k);
|
||||||
|
ventoy_set_env(env, ver);
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
debug("%s freebsd version:<%s>\n", section, "NOT FOUND");
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
grub_check_free(str);
|
||||||
|
grub_check_free(hdr);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
grub_err_t ventoy_cmd_unix_freebsd_ver_elf(grub_extcmd_context_t ctxt, int argc, char **args)
|
grub_err_t ventoy_cmd_unix_freebsd_ver_elf(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
{
|
{
|
||||||
int j;
|
int ret = 0;
|
||||||
int k;
|
int bit64 = 0;
|
||||||
grub_elf_t elf = NULL;
|
|
||||||
grub_off_t offset = 0;
|
|
||||||
grub_uint32_t len = 0;
|
|
||||||
char *str = NULL;
|
|
||||||
char *data = NULL;
|
char *data = NULL;
|
||||||
void *hdr = NULL;
|
grub_elf_t elf = NULL;
|
||||||
char ver[64] = {0};
|
|
||||||
|
|
||||||
(void)ctxt;
|
(void)ctxt;
|
||||||
(void)argc;
|
|
||||||
(void)args;
|
|
||||||
|
|
||||||
if (argc != 3)
|
if (argc != 3)
|
||||||
{
|
{
|
||||||
@@ -560,136 +697,18 @@ grub_err_t ventoy_cmd_unix_freebsd_ver_elf(grub_extcmd_context_t ctxt, int argc,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[1][0] == '6')
|
bit64 = (args[1][0] == '6') ? 1 : 0;
|
||||||
|
|
||||||
|
ret = ventoy_freebsd_ver_elf(bit64, elf, ".data", args[2], data);
|
||||||
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
Elf64_Ehdr *e = &(elf->ehdr.ehdr64);
|
ret = ventoy_freebsd_ver_elf(bit64, elf, ".rodata", args[2], data);
|
||||||
Elf64_Shdr *h;
|
|
||||||
Elf64_Shdr *s;
|
|
||||||
Elf64_Shdr *t;
|
|
||||||
Elf64_Half i;
|
|
||||||
|
|
||||||
h = hdr = grub_zalloc(e->e_shnum * e->e_shentsize);
|
|
||||||
if (!h)
|
|
||||||
{
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
debug("read section header %u %u %u\n", e->e_shnum, e->e_shentsize, e->e_shstrndx);
|
|
||||||
grub_file_seek(elf->file, e->e_shoff);
|
|
||||||
grub_file_read(elf->file, h, e->e_shnum * e->e_shentsize);
|
|
||||||
|
|
||||||
s = (Elf64_Shdr *)((char *)h + e->e_shstrndx * e->e_shentsize);
|
|
||||||
str = grub_malloc(s->sh_size + 1);
|
|
||||||
if (!str)
|
|
||||||
{
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
str[s->sh_size] = 0;
|
|
||||||
|
|
||||||
debug("read string table %u %u\n", (grub_uint32_t)s->sh_offset, (grub_uint32_t)s->sh_size);
|
|
||||||
grub_file_seek(elf->file, s->sh_offset);
|
|
||||||
grub_file_read(elf->file, str, s->sh_size);
|
|
||||||
|
|
||||||
for (t = h, i = 0; i < e->e_shnum; i++)
|
|
||||||
{
|
|
||||||
if (grub_strcmp(str + t->sh_name, ".data") == 0)
|
|
||||||
{
|
|
||||||
offset = t->sh_offset;
|
|
||||||
len = t->sh_size;
|
|
||||||
debug("find .data section at %u %u\n", (grub_uint32_t)offset, len);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
t = (Elf64_Shdr *)((char *)t + e->e_shentsize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Elf32_Ehdr *e = &(elf->ehdr.ehdr32);
|
|
||||||
Elf32_Shdr *h;
|
|
||||||
Elf32_Shdr *s;
|
|
||||||
Elf32_Shdr *t;
|
|
||||||
Elf32_Half i;
|
|
||||||
|
|
||||||
h = hdr = grub_zalloc(e->e_shnum * e->e_shentsize);
|
|
||||||
if (!h)
|
|
||||||
{
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
debug("read section header %u %u %u\n", e->e_shnum, e->e_shentsize, e->e_shstrndx);
|
|
||||||
grub_file_seek(elf->file, e->e_shoff);
|
|
||||||
grub_file_read(elf->file, h, e->e_shnum * e->e_shentsize);
|
|
||||||
|
|
||||||
s = (Elf32_Shdr *)((char *)h + e->e_shstrndx * e->e_shentsize);
|
|
||||||
str = grub_malloc(s->sh_size + 1);
|
|
||||||
if (!str)
|
|
||||||
{
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
str[s->sh_size] = 0;
|
|
||||||
|
|
||||||
debug("read string table %u %u\n", (grub_uint32_t)s->sh_offset, (grub_uint32_t)s->sh_size);
|
|
||||||
grub_file_seek(elf->file, s->sh_offset);
|
|
||||||
grub_file_read(elf->file, str, s->sh_size);
|
|
||||||
|
|
||||||
for (t = h, i = 0; i < e->e_shnum; i++)
|
|
||||||
{
|
|
||||||
if (grub_strcmp(str + t->sh_name, ".data") == 0)
|
|
||||||
{
|
|
||||||
offset = t->sh_offset;
|
|
||||||
len = t->sh_size;
|
|
||||||
debug("find .data section at %u %u\n", (grub_uint32_t)offset, len);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
t = (Elf32_Shdr *)((char *)t + e->e_shentsize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (offset == 0 || len == 0)
|
|
||||||
{
|
|
||||||
debug(".data section not found %s\n", args[0]);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_file_seek(elf->file, offset + len - 8192);
|
|
||||||
grub_file_read(elf->file, data, 8192);
|
|
||||||
|
|
||||||
for (j = 0; j < 8192 - 12; j++)
|
|
||||||
{
|
|
||||||
if (grub_strncmp(data + j, "@(#)FreeBSD ", 12) == 0)
|
|
||||||
{
|
|
||||||
for (k = j + 12; k < 8192; k++)
|
|
||||||
{
|
|
||||||
if (0 == grub_isdigit(data[k]) && data[k] != '.')
|
|
||||||
{
|
|
||||||
data[k] = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_snprintf(ver, sizeof(ver), "%s", data + j + 12);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ver[0])
|
|
||||||
{
|
|
||||||
k = (int)grub_strtoul(ver, NULL, 10);
|
|
||||||
debug("freebsd version:<%s> <%d.x>\n", ver, k);
|
|
||||||
grub_snprintf(ver, sizeof(ver), "%d.x", k);
|
|
||||||
ventoy_set_env(args[2], ver);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
debug("freebsd version:<%s>\n", "NOT FOUND");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
grub_check_free(str);
|
|
||||||
grub_check_free(hdr);
|
|
||||||
grub_check_free(data);
|
grub_check_free(data);
|
||||||
check_free(elf, grub_elf_close);
|
check_free(elf, grub_elf_close);
|
||||||
|
|
||||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -704,7 +723,7 @@ grub_err_t ventoy_cmd_unix_replace_grub_conf(grub_extcmd_context_t ctxt, int arg
|
|||||||
grub_file_t file;
|
grub_file_t file;
|
||||||
char extcfg[512];
|
char extcfg[512];
|
||||||
const char *confile = NULL;
|
const char *confile = NULL;
|
||||||
const char * loader_conf[] =
|
const char * loader_conf[] =
|
||||||
{
|
{
|
||||||
"/boot/grub/grub.cfg",
|
"/boot/grub/grub.cfg",
|
||||||
};
|
};
|
||||||
@@ -716,7 +735,7 @@ grub_err_t ventoy_cmd_unix_replace_grub_conf(grub_extcmd_context_t ctxt, int arg
|
|||||||
debug("Replace conf invalid argc %d\n", argc);
|
debug("Replace conf invalid argc %d\n", argc);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < sizeof(loader_conf) / sizeof(loader_conf[0]); i++)
|
for (i = 0; i < sizeof(loader_conf) / sizeof(loader_conf[0]); i++)
|
||||||
{
|
{
|
||||||
if (ventoy_get_file_override(loader_conf[i], &offset) == 0)
|
if (ventoy_get_file_override(loader_conf[i], &offset) == 0)
|
||||||
@@ -728,7 +747,7 @@ grub_err_t ventoy_cmd_unix_replace_grub_conf(grub_extcmd_context_t ctxt, int arg
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (confile == NULL)
|
if (confile == NULL)
|
||||||
{
|
{
|
||||||
debug("Can't find grub.cfg file from %u locations\n", i);
|
debug("Can't find grub.cfg file from %u locations\n", i);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -745,13 +764,13 @@ grub_err_t ventoy_cmd_unix_replace_grub_conf(grub_extcmd_context_t ctxt, int arg
|
|||||||
data = grub_malloc(VTOY_MAX_SCRIPT_BUF);
|
data = grub_malloc(VTOY_MAX_SCRIPT_BUF);
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
grub_file_close(file);
|
grub_file_close(file);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_file_read(file, data, file->size);
|
grub_file_read(file, data, file->size);
|
||||||
grub_file_close(file);
|
grub_file_close(file);
|
||||||
|
|
||||||
g_conf_new_data = data;
|
g_conf_new_data = data;
|
||||||
g_conf_new_len = (int)file->size;
|
g_conf_new_len = (int)file->size;
|
||||||
|
|
||||||
@@ -783,7 +802,7 @@ grub_err_t ventoy_cmd_unix_replace_grub_conf(grub_extcmd_context_t ctxt, int arg
|
|||||||
{
|
{
|
||||||
vtoy_ssprintf(extcfg, len, ";set kFreeBSD.hint.ventoy.0.remount=%d", 1);
|
vtoy_ssprintf(extcfg, len, ";set kFreeBSD.hint.ventoy.0.remount=%d", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_memmove(pos + len, pos, (int)(file->size - (pos - data)));
|
grub_memmove(pos + len, pos, (int)(file->size - (pos - data)));
|
||||||
grub_memcpy(pos, extcfg, len);
|
grub_memcpy(pos, extcfg, len);
|
||||||
g_conf_new_len += len;
|
g_conf_new_len += len;
|
||||||
@@ -792,7 +811,7 @@ grub_err_t ventoy_cmd_unix_replace_grub_conf(grub_extcmd_context_t ctxt, int arg
|
|||||||
{
|
{
|
||||||
debug("no kfreebsd found\n");
|
debug("no kfreebsd found\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -803,7 +822,7 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
|
|||||||
grub_uint64_t offset;
|
grub_uint64_t offset;
|
||||||
grub_file_t file;
|
grub_file_t file;
|
||||||
const char *confile = NULL;
|
const char *confile = NULL;
|
||||||
const char * loader_conf[] =
|
const char * loader_conf[] =
|
||||||
{
|
{
|
||||||
"/boot/loader.conf",
|
"/boot/loader.conf",
|
||||||
"/boot/defaults/loader.conf",
|
"/boot/defaults/loader.conf",
|
||||||
@@ -816,7 +835,7 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
|
|||||||
debug("Replace conf invalid argc %d\n", argc);
|
debug("Replace conf invalid argc %d\n", argc);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < sizeof(loader_conf) / sizeof(loader_conf[0]); i++)
|
for (i = 0; i < sizeof(loader_conf) / sizeof(loader_conf[0]); i++)
|
||||||
{
|
{
|
||||||
if (ventoy_get_file_override(loader_conf[i], &offset) == 0)
|
if (ventoy_get_file_override(loader_conf[i], &offset) == 0)
|
||||||
@@ -828,7 +847,7 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (confile == NULL)
|
if (confile == NULL)
|
||||||
{
|
{
|
||||||
debug("Can't find loader.conf file from %u locations\n", i);
|
debug("Can't find loader.conf file from %u locations\n", i);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -845,13 +864,13 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
|
|||||||
data = grub_malloc(VTOY_MAX_SCRIPT_BUF);
|
data = grub_malloc(VTOY_MAX_SCRIPT_BUF);
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
grub_file_close(file);
|
grub_file_close(file);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_file_read(file, data, file->size);
|
grub_file_read(file, data, file->size);
|
||||||
grub_file_close(file);
|
grub_file_close(file);
|
||||||
|
|
||||||
g_conf_new_data = data;
|
g_conf_new_data = data;
|
||||||
g_conf_new_len = (int)file->size;
|
g_conf_new_len = (int)file->size;
|
||||||
|
|
||||||
@@ -863,19 +882,19 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
|
|||||||
{
|
{
|
||||||
g_conf_new_len += ventoy_dragonfly_append_conf(data + file->size, args[1]);
|
g_conf_new_len += ventoy_dragonfly_append_conf(data + file->size, args[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ventoy_unix_search_magic(char *data, int len)
|
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 += 4096)
|
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 >> 12));
|
debug("unix find search magic at 0x%x loop:%d\n", i, (i >> 12));
|
||||||
@@ -910,7 +929,7 @@ grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char
|
|||||||
g_mod_override_offset = offset;
|
g_mod_override_offset = offset;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
debug("Can't find replace ko file from %s\n", args[0]);
|
debug("Can't find replace ko file from %s\n", args[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -928,18 +947,18 @@ grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char
|
|||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
debug("Failed to alloc memory for new ko %d\n", (int)file->size);
|
debug("Failed to alloc memory for new ko %d\n", (int)file->size);
|
||||||
grub_file_close(file);
|
grub_file_close(file);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_file_read(file, data, file->size);
|
grub_file_read(file, data, file->size);
|
||||||
grub_file_close(file);
|
grub_file_close(file);
|
||||||
|
|
||||||
g_mod_new_data = data;
|
g_mod_new_data = data;
|
||||||
g_mod_new_len = (int)file->size;
|
g_mod_new_len = (int)file->size;
|
||||||
|
|
||||||
ventoy_unix_search_magic(g_mod_new_data, g_mod_new_len);
|
ventoy_unix_search_magic(g_mod_new_data, g_mod_new_len);
|
||||||
|
|
||||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -967,7 +986,7 @@ grub_err_t ventoy_cmd_unix_ko_fillmap(grub_extcmd_context_t ctxt, int argc, char
|
|||||||
g_mod_override_offset = grub_iso9660_get_last_read_pos(file);
|
g_mod_override_offset = grub_iso9660_get_last_read_pos(file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
debug("Can't find replace ko file from %s\n", args[0]);
|
debug("Can't find replace ko file from %s\n", args[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -977,8 +996,8 @@ grub_err_t ventoy_cmd_unix_ko_fillmap(grub_extcmd_context_t ctxt, int argc, char
|
|||||||
magic[0] = 0;
|
magic[0] = 0;
|
||||||
grub_file_seek(file, i);
|
grub_file_seek(file, i);
|
||||||
grub_file_read(file, magic, sizeof(magic));
|
grub_file_read(file, magic, sizeof(magic));
|
||||||
|
|
||||||
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 >> 16));
|
||||||
@@ -987,7 +1006,7 @@ grub_err_t ventoy_cmd_unix_ko_fillmap(grub_extcmd_context_t ctxt, int argc, char
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
len = (grub_uint32_t)OFFSET_OF(struct g_ventoy_map, seglist) +
|
len = (grub_uint32_t)OFFSET_OF(struct g_ventoy_map, seglist) +
|
||||||
(sizeof(struct g_ventoy_seg) * g_img_chunk_list.cur_chunk);
|
(sizeof(struct g_ventoy_seg) * g_img_chunk_list.cur_chunk);
|
||||||
|
|
||||||
g_ko_fillmap_len = (int)len;
|
g_ko_fillmap_len = (int)len;
|
||||||
@@ -1034,7 +1053,7 @@ grub_err_t ventoy_cmd_unix_fill_image_desc(grub_extcmd_context_t ctxt, int argc,
|
|||||||
if (grub_memcmp(flag, byte + i, 32) == 0)
|
if (grub_memcmp(flag, byte + i, 32) == 0)
|
||||||
{
|
{
|
||||||
debug("Find position flag at %d(0x%x)\n", i, i);
|
debug("Find position flag at %d(0x%x)\n", i, i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1118,7 +1137,7 @@ grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char
|
|||||||
const char *pLastChain = NULL;
|
const char *pLastChain = NULL;
|
||||||
const char *compatible;
|
const char *compatible;
|
||||||
ventoy_chain_head *chain;
|
ventoy_chain_head *chain;
|
||||||
|
|
||||||
(void)ctxt;
|
(void)ctxt;
|
||||||
(void)argc;
|
(void)argc;
|
||||||
|
|
||||||
@@ -1161,9 +1180,9 @@ grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char
|
|||||||
return grub_error(GRUB_ERR_BAD_ARGUMENT, "File %s is not bootable", args[0]);
|
return grub_error(GRUB_ERR_BAD_ARGUMENT, "File %s is not bootable", args[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
img_chunk_size = g_img_chunk_list.cur_chunk * sizeof(ventoy_img_chunk);
|
img_chunk_size = g_img_chunk_list.cur_chunk * sizeof(ventoy_img_chunk);
|
||||||
|
|
||||||
if (ventoy_compatible)
|
if (ventoy_compatible)
|
||||||
{
|
{
|
||||||
size = sizeof(ventoy_chain_head) + img_chunk_size;
|
size = sizeof(ventoy_chain_head) + img_chunk_size;
|
||||||
@@ -1172,11 +1191,11 @@ grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char
|
|||||||
{
|
{
|
||||||
override_count = ventoy_unix_get_override_chunk_count();
|
override_count = ventoy_unix_get_override_chunk_count();
|
||||||
override_size = override_count * sizeof(ventoy_override_chunk);
|
override_size = override_count * sizeof(ventoy_override_chunk);
|
||||||
|
|
||||||
virt_chunk_size = ventoy_unix_get_virt_chunk_size();
|
virt_chunk_size = ventoy_unix_get_virt_chunk_size();
|
||||||
size = sizeof(ventoy_chain_head) + img_chunk_size + override_size + virt_chunk_size;
|
size = sizeof(ventoy_chain_head) + img_chunk_size + override_size + virt_chunk_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
pLastChain = grub_env_get("vtoy_chain_mem_addr");
|
pLastChain = grub_env_get("vtoy_chain_mem_addr");
|
||||||
if (pLastChain)
|
if (pLastChain)
|
||||||
{
|
{
|
||||||
@@ -1239,7 +1258,7 @@ grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char
|
|||||||
ventoy_unix_fill_virt_data(isosize, chain);
|
ventoy_unix_fill_virt_data(isosize, chain);
|
||||||
|
|
||||||
grub_file_close(file);
|
grub_file_close(file);
|
||||||
|
|
||||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -489,20 +489,20 @@ function ventoy_freebsd_proc {
|
|||||||
ventoy_get_truenas_ver "$1" "${chosen_path}"
|
ventoy_get_truenas_ver "$1" "${chosen_path}"
|
||||||
elif vt_strstr "$vt_volume_id" "FURYBSD"; then
|
elif vt_strstr "$vt_volume_id" "FURYBSD"; then
|
||||||
ventoy_get_furybsd_ver "$1" "${chosen_path}"
|
ventoy_get_furybsd_ver "$1" "${chosen_path}"
|
||||||
elif regexp --set 1:vtBsdVerNum "^(15|14|13|12|11|10|9)_[0-9]" "$vt_volume_id"; then
|
elif regexp --set 1:vtBsdVerNum "^(1[0-9]|9)_[0-9]" "$vt_volume_id"; then
|
||||||
set vt_freebsd_ver=${vtBsdVerNum}.x
|
set vt_freebsd_ver=${vtBsdVerNum}.x
|
||||||
elif [ -d (loop)/usr/midnightbsd-dist ]; then
|
elif [ -d (loop)/usr/midnightbsd-dist ]; then
|
||||||
ventoy_get_midnightbsd_ver "$1" "${chosen_path}"
|
ventoy_get_midnightbsd_ver "$1" "${chosen_path}"
|
||||||
set vtFreeBsdDistro=MidnightBSD
|
set vtFreeBsdDistro=MidnightBSD
|
||||||
elif [ -e (loop)/bin/freebsd-version ]; then
|
elif [ -e (loop)/bin/freebsd-version ]; then
|
||||||
vt_unix_parse_freebsd_ver (loop)/bin/freebsd-version vt_userland_ver
|
vt_unix_parse_freebsd_ver (loop)/bin/freebsd-version vt_userland_ver
|
||||||
if regexp --set 1:vtBsdVerNum "\"(15|14|13|12|11|10|9)\.[0-9]-" "$vt_userland_ver"; then
|
if regexp --set 1:vtBsdVerNum "\"(1[0-9]|9)\.[0-9]-" "$vt_userland_ver"; then
|
||||||
set vt_freebsd_ver=${vtBsdVerNum}.x
|
set vt_freebsd_ver=${vtBsdVerNum}.x
|
||||||
fi
|
fi
|
||||||
elif [ -e (loop)/README.TXT ]; then
|
elif [ -e (loop)/README.TXT ]; then
|
||||||
vt_1st_line (loop)/README.TXT vt_freebsd_line1
|
vt_1st_line (loop)/README.TXT vt_freebsd_line1
|
||||||
if regexp --set 1:vtBsdVerNum "FreeBSD (15|14|13|12|11|10|9)\.[0-9]-" "$vt_freebsd_line1"; then
|
if regexp --set 1:vtBsdVerNum "FreeBSD (1[0-9]|9)\.[0-9]-" "$vt_freebsd_line1"; then
|
||||||
set vt_freebsd_ver=${vtBsdVerNum}.x
|
set vt_freebsd_ver=${vtBsdVerNum}.x
|
||||||
fi
|
fi
|
||||||
elif vt_strstr "${chosen_path}" "MidnightBSD"; then
|
elif vt_strstr "${chosen_path}" "MidnightBSD"; then
|
||||||
set vt_freebsd_ver=9.x
|
set vt_freebsd_ver=9.x
|
||||||
@@ -531,7 +531,7 @@ function ventoy_freebsd_proc {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$vt_freebsd_ver" = "xx" ]; then
|
if [ "$vt_freebsd_ver" = "xx" ]; then
|
||||||
set vt_freebsd_ver=14.x
|
set vt_freebsd_ver=15.x
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user