Skip to content

Commit

Permalink
Fix a bug for Linux GUI program when update from old release. (ventoy…
Browse files Browse the repository at this point in the history
  • Loading branch information
ventoy committed Apr 26, 2022
1 parent 480afee commit 9e2e4ec
Show file tree
Hide file tree
Showing 15 changed files with 18 additions and 2 deletions.
Binary file modified INSTALL/tool/aarch64/V2DServer
Binary file not shown.
Binary file modified INSTALL/tool/aarch64/Ventoy2Disk.gtk3
Binary file not shown.
Binary file modified INSTALL/tool/aarch64/Ventoy2Disk.qt5
Binary file not shown.
Binary file modified INSTALL/tool/i386/V2DServer
Binary file not shown.
Binary file modified INSTALL/tool/i386/Ventoy2Disk.gtk2
Binary file not shown.
Binary file modified INSTALL/tool/i386/Ventoy2Disk.gtk3
Binary file not shown.
Binary file modified INSTALL/tool/i386/Ventoy2Disk.qt5
Binary file not shown.
Binary file modified INSTALL/tool/mips64el/V2DServer
Binary file not shown.
Binary file modified INSTALL/tool/mips64el/Ventoy2Disk.gtk3
Binary file not shown.
Binary file modified INSTALL/tool/mips64el/Ventoy2Disk.qt5
Binary file not shown.
Binary file modified INSTALL/tool/x86_64/V2DServer
Binary file not shown.
Binary file modified INSTALL/tool/x86_64/Ventoy2Disk.gtk2
Binary file not shown.
Binary file modified INSTALL/tool/x86_64/Ventoy2Disk.gtk3
Binary file not shown.
Binary file modified INSTALL/tool/x86_64/Ventoy2Disk.qt5
Binary file not shown.
20 changes: 18 additions & 2 deletions LinuxGUI/Ventoy2Disk/Web/ventoy_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ static int ventoy_write_gpt_part_table(int fd, uint64_t disksize, VTOY_GPT_INFO
static void * ventoy_update_thread(void *data)
{
int fd;
int updateMBR;
ssize_t len;
off_t offset;
MBR_HEAD MBR;
Expand Down Expand Up @@ -742,17 +743,32 @@ static void * ventoy_update_thread(void *data)
len = write(fd, disk->vtoydata.rsvdata, sizeof(disk->vtoydata.rsvdata));
vlog("Writing reserve data offset:%llu len:%llu ...\n", (_ull)offset, (_ull)len);

updateMBR = 0;
memcpy(&MBR, &(disk->vtoydata.gptinfo.MBR), 512);

if (disk->vtoydata.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;

updateMBR = 1;
vlog("set MBR partition 1 active flag enabled\n");
}

if (MBR.BootCode[0x190] != 0x56 || MBR.BootCode[0x191] != 0x54)
{
vlog("set VT data %02x %02x\n", MBR.BootCode[0x190], MBR.BootCode[0x191]);
MBR.BootCode[0x190] = 0x56;
MBR.BootCode[0x191] = 0x54;
updateMBR = 1;
}

if (updateMBR)
{
offset = lseek(fd, 0, SEEK_SET);
len = write(fd, &MBR, 512);
vlog("set MBR partition 1 active flag enabled offset:%llu len:%llu\n", (_ull)offset, (_ull)len);
vlog("update MBR offset:%llu len:%llu\n", (_ull)offset, (_ull)len);
}

g_current_progress = PT_SYNC_DATA1;
Expand Down

0 comments on commit 9e2e4ec

Please sign in to comment.