+static int ventoy_mbr_need_update(ventoy_disk *disk, MBR_HEAD *mbr)
+{
+ int update = 0;
+ int partition_style;
+ MBR_HEAD LocalMBR;
+
+ partition_style = disk->vtoydata.partition_style;
+ memcpy(mbr, &(disk->vtoydata.gptinfo.MBR), 512);
+
+ VentoyGetLocalBootImg(&LocalMBR);
+ memcpy(LocalMBR.BootCode + 0x180, mbr->BootCode + 0x180, 16);
+ if (partition_style)
+ {
+ LocalMBR.BootCode[92] = 0x22;
+ }
+
+ if (memcmp(LocalMBR.BootCode, mbr->BootCode, 440))
+ {
+ memcpy(mbr->BootCode, LocalMBR.BootCode, 440);
+ vlog("MBR boot code different, must update it.\n");
+ update = 1;
+ }
+
+ if (partition_style == 0 && mbr->PartTbl[0].Active == 0)
+ {
+ mbr->PartTbl[0].Active = 0x80;
+ mbr->PartTbl[1].Active = 0;
+ mbr->PartTbl[2].Active = 0;
+ mbr->PartTbl[3].Active = 0;
+ vlog("set MBR partition 1 active flag enabled\n");
+ update = 1;
+ }
+
+ return update;
+}
+