mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-04-15 16:48:41 -04:00
Optimization for FreeBSD
This commit is contained in:
parent
164c8d6505
commit
e4ccd5115e
@ -140,12 +140,13 @@ 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>\n", (unsigned long long)chain->os_param.vtoy_disk_size, g_img_chunk_list.cur_chunk);
|
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);
|
||||||
|
|
||||||
map->magic1[0] = map->magic2[0] = map->magic3[0] = VENTOY_UNIX_SEG_MAGIC0;
|
map->magic1[0] = map->magic2[0] = VENTOY_UNIX_SEG_MAGIC0;
|
||||||
map->magic1[1] = map->magic2[1] = map->magic3[1] = VENTOY_UNIX_SEG_MAGIC1;
|
map->magic1[1] = map->magic2[1] = VENTOY_UNIX_SEG_MAGIC1;
|
||||||
map->magic1[2] = map->magic2[2] = map->magic3[2] = VENTOY_UNIX_SEG_MAGIC2;
|
map->magic1[2] = map->magic2[2] = VENTOY_UNIX_SEG_MAGIC2;
|
||||||
map->magic1[3] = map->magic2[3] = map->magic3[3] = VENTOY_UNIX_SEG_MAGIC3;
|
map->magic1[3] = map->magic2[3] = VENTOY_UNIX_SEG_MAGIC3;
|
||||||
|
|
||||||
map->disksize = chain->os_param.vtoy_disk_size;
|
map->disksize = chain->os_param.vtoy_disk_size;
|
||||||
grub_memcpy(map->diskuuid, chain->os_param.vtoy_disk_guid, 16);
|
grub_memcpy(map->diskuuid, chain->os_param.vtoy_disk_guid, 16);
|
||||||
@ -190,12 +191,12 @@ static void ventoy_unix_fill_override_data( grub_uint64_t isosize, ventoy_cha
|
|||||||
dirent->first_sector_be = grub_swap_bytes32(dirent->first_sector);
|
dirent->first_sector_be = grub_swap_bytes32(dirent->first_sector);
|
||||||
dirent->size_be = grub_swap_bytes32(dirent->size);
|
dirent->size_be = grub_swap_bytes32(dirent->size);
|
||||||
sector += (dirent->size + 2047) / 2048;
|
sector += (dirent->size + 2047) / 2048;
|
||||||
|
cur++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_mod_new_len > 0)
|
if (g_mod_new_len > 0)
|
||||||
{
|
{
|
||||||
/* mod.ko */
|
/* mod.ko */
|
||||||
cur++;
|
|
||||||
cur->img_offset = g_mod_override_offset;
|
cur->img_offset = g_mod_override_offset;
|
||||||
cur->override_size = sizeof(ventoy_iso9660_override);
|
cur->override_size = sizeof(ventoy_iso9660_override);
|
||||||
dirent = (ventoy_iso9660_override *)cur->override_data;
|
dirent = (ventoy_iso9660_override *)cur->override_data;
|
||||||
@ -204,6 +205,7 @@ static void ventoy_unix_fill_override_data( grub_uint64_t isosize, ventoy_cha
|
|||||||
dirent->first_sector_be = grub_swap_bytes32(dirent->first_sector);
|
dirent->first_sector_be = grub_swap_bytes32(dirent->first_sector);
|
||||||
dirent->size_be = grub_swap_bytes32(dirent->size);
|
dirent->size_be = grub_swap_bytes32(dirent->size);
|
||||||
sector += (dirent->size + 2047) / 2048;
|
sector += (dirent->size + 2047) / 2048;
|
||||||
|
cur++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_ko_fillmap_len > 0)
|
if (g_ko_fillmap_len > 0)
|
||||||
@ -215,23 +217,24 @@ static void ventoy_unix_fill_override_data( grub_uint64_t isosize, ventoy_cha
|
|||||||
|
|
||||||
for (i = 0; i < g_ko_fillmap_len / 512; i++)
|
for (i = 0; i < g_ko_fillmap_len / 512; i++)
|
||||||
{
|
{
|
||||||
cur++;
|
|
||||||
cur->img_offset = offset;
|
cur->img_offset = offset;
|
||||||
cur->override_size = 512;
|
cur->override_size = 512;
|
||||||
grub_memcpy(cur->override_data, data, 512);
|
grub_memcpy(cur->override_data, data, 512);
|
||||||
|
|
||||||
offset += 512;
|
offset += 512;
|
||||||
data += 512;
|
data += 512;
|
||||||
|
cur++;
|
||||||
}
|
}
|
||||||
|
|
||||||
left = (g_ko_fillmap_len % 512);
|
left = (g_ko_fillmap_len % 512);
|
||||||
if (left > 0)
|
if (left > 0)
|
||||||
{
|
{
|
||||||
cur++;
|
|
||||||
cur->img_offset = offset;
|
cur->img_offset = offset;
|
||||||
cur->override_size = left;
|
cur->override_size = left;
|
||||||
grub_memcpy(cur->override_data, data, left);
|
grub_memcpy(cur->override_data, data, left);
|
||||||
|
|
||||||
offset += left;
|
offset += left;
|
||||||
|
cur++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -811,6 +814,7 @@ grub_err_t ventoy_cmd_unix_ko_fillmap(grub_extcmd_context_t ctxt, int argc, char
|
|||||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "(loop)%s", args[0]);
|
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "(loop)%s", args[0]);
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
|
grub_file_read(file, magic, 4); /* read for trigger */
|
||||||
g_mod_override_offset = grub_iso9660_get_last_read_pos(file);
|
g_mod_override_offset = grub_iso9660_get_last_read_pos(file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -845,7 +849,7 @@ grub_err_t ventoy_cmd_unix_ko_fillmap(grub_extcmd_context_t ctxt, int argc, char
|
|||||||
debug("Failed to malloc fillmap data\n");
|
debug("Failed to malloc fillmap data\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
debug("Fillmap ko segnum:%u, override len:%d", g_img_chunk_list.cur_chunk, g_ko_fillmap_len);
|
debug("Fillmap ko segnum:%u, override len:%u data:%p\n", g_img_chunk_list.cur_chunk, len, g_ko_fillmap_data);
|
||||||
|
|
||||||
grub_file_close(file);
|
grub_file_close(file);
|
||||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||||
|
@ -421,6 +421,11 @@ function ventoy_freebsd_proc {
|
|||||||
set vtFreeBsdDistro=FreeBSD
|
set vtFreeBsdDistro=FreeBSD
|
||||||
set vt_freebsd_ver=xx
|
set vt_freebsd_ver=xx
|
||||||
|
|
||||||
|
if [ -e (loop)/boot/kernel/geom_ventoy.ko ]; then
|
||||||
|
vt_unix_ko_fillmap /boot/kernel/geom_ventoy.ko
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
if vt_strstr "$vt_volume_id" "GHOSTBSD"; then
|
if vt_strstr "$vt_volume_id" "GHOSTBSD"; then
|
||||||
ventoy_get_ghostbsd_ver "$1" "${chosen_path}"
|
ventoy_get_ghostbsd_ver "$1" "${chosen_path}"
|
||||||
elif vt_strstr "$vt_volume_id" "FREENAS"; then
|
elif vt_strstr "$vt_volume_id" "FREENAS"; then
|
||||||
@ -472,10 +477,6 @@ function ventoy_freebsd_proc {
|
|||||||
set vt_freebsd_ver=9.x
|
set vt_freebsd_ver=9.x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e (loop)/boot/kernel/geom_ventoy.ko ]; then
|
|
||||||
vt_unix_ko_fillmap /boot/kernel/geom_ventoy.ko
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -e (loop)/usr/freebsd-dist/cloninst.sh ]; then
|
if [ -e (loop)/usr/freebsd-dist/cloninst.sh ]; then
|
||||||
set vtFreeBsdDistro=ClonOS
|
set vtFreeBsdDistro=ClonOS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user