return 0;
}
-static int ventoy_vhd_read_parttbl(const char *filename, ventoy_gpt_info *gpt, int *index)
+static int ventoy_vhd_read_parttbl(const char *filename, ventoy_gpt_info *gpt, int *index, grub_uint64_t *poffset)
{
int i;
+ int find = 0;
int ret = 1;
grub_uint64_t start;
grub_file_t file = NULL;
if (start == gpt->PartTbl[i].StartLBA)
{
*index = i;
+ find = 1;
break;
}
}
if ((grub_uint32_t)start == gpt->MBR.PartTbl[i].StartSectorId)
{
*index = i;
+ find = 1;
break;
}
}
}
+ if (find == 0) // MBR Logical partition
+ {
+ if (file->device->disk->partition->number > 0)
+ {
+ *index = file->device->disk->partition->number;
+ debug("Fall back part number: %d\n", *index);
+ }
+ }
+
+ *poffset = start;
ret = 0;
end:
else
{
gpt = grub_zalloc(sizeof(ventoy_gpt_info));
- ventoy_vhd_read_parttbl(vhdpath, gpt, &partIndex);
+ ventoy_vhd_read_parttbl(vhdpath, gpt, &partIndex, &offset);
debug("This is HDD partIndex %d %s\n", partIndex, vhdpath);
}
}
else
{
- offset = gpt->MBR.PartTbl[partIndex].StartSectorId;
offset *= 512;
-
debug("MBR disk signature: %02x%02x%02x%02x Part(%d) offset:%llu\n",
gpt->MBR.BootCode[0x1b8 + 0], gpt->MBR.BootCode[0x1b8 + 1],
gpt->MBR.BootCode[0x1b8 + 2], gpt->MBR.BootCode[0x1b8 + 3],