mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-02-14 23:22:32 -05:00
Fix the "Unsupported vtoy type unknown" error when boot a VDI file created by VirtualBox 7.x
This commit is contained in:
parent
ee994a0569
commit
f7e6bbc70c
@ -861,7 +861,8 @@ typedef struct vhd_footer_t
|
|||||||
grub_uint8_t savedst; // Saved state
|
grub_uint8_t savedst; // Saved state
|
||||||
}vhd_footer_t;
|
}vhd_footer_t;
|
||||||
|
|
||||||
#define VDI_IMAGE_FILE_INFO "<<< Oracle VM VirtualBox Disk Image >>>\n"
|
#define VDI_IMAGE_FILE_INFO "<<< Oracle VM VirtualBox Disk Image >>>\n"
|
||||||
|
#define VDI_IMAGE_FILE_INFO2 "<<< Oracle VirtualBox Disk Image >>>\n"
|
||||||
|
|
||||||
/** Image signature. */
|
/** Image signature. */
|
||||||
#define VDI_IMAGE_SIGNATURE (0xbeda107f)
|
#define VDI_IMAGE_SIGNATURE (0xbeda107f)
|
||||||
|
@ -536,12 +536,25 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
|
|||||||
{
|
{
|
||||||
grub_file_seek(file, 0);
|
grub_file_seek(file, 0);
|
||||||
grub_file_read(file, &vdihdr, sizeof(vdihdr));
|
grub_file_read(file, &vdihdr, sizeof(vdihdr));
|
||||||
if (vdihdr.u32Signature == VDI_IMAGE_SIGNATURE &&
|
if (vdihdr.u32Signature == VDI_IMAGE_SIGNATURE)
|
||||||
grub_strncmp(vdihdr.szFileInfo, VDI_IMAGE_FILE_INFO, grub_strlen(VDI_IMAGE_FILE_INFO)) == 0)
|
|
||||||
{
|
{
|
||||||
offset = 2 * 1048576;
|
|
||||||
g_img_trim_head_secnum = offset / 512;
|
|
||||||
grub_snprintf(type, sizeof(type), "vdi");
|
grub_snprintf(type, sizeof(type), "vdi");
|
||||||
|
if (grub_strncmp(vdihdr.szFileInfo, VDI_IMAGE_FILE_INFO, grub_strlen(VDI_IMAGE_FILE_INFO)) == 0)
|
||||||
|
{
|
||||||
|
offset = 2 * 1048576;
|
||||||
|
g_img_trim_head_secnum = offset / 512;
|
||||||
|
debug("VDI V1\n");
|
||||||
|
}
|
||||||
|
else if (grub_strncmp(vdihdr.szFileInfo, VDI_IMAGE_FILE_INFO2, grub_strlen(VDI_IMAGE_FILE_INFO2)) == 0)
|
||||||
|
{
|
||||||
|
offset = 2 * 1048576;
|
||||||
|
g_img_trim_head_secnum = offset / 512;
|
||||||
|
debug("VDI V2\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
debug("invalid file info <%s>\n", vdihdr.szFileInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -568,7 +581,7 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
|
|||||||
if (gpt->MBR.Byte55 != 0x55 || gpt->MBR.ByteAA != 0xAA)
|
if (gpt->MBR.Byte55 != 0x55 || gpt->MBR.ByteAA != 0xAA)
|
||||||
{
|
{
|
||||||
grub_env_set(args[1], "unknown");
|
grub_env_set(args[1], "unknown");
|
||||||
debug("invalid mbr signature: 0x%x 0x%x\n", gpt->MBR.Byte55, gpt->MBR.ByteAA);
|
debug("invalid mbr signature: 0x%x 0x%x offset=%d\n", gpt->MBR.Byte55, gpt->MBR.ByteAA, offset);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user