X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/Ventoy.git/blobdiff_plain/dd2411d7d47fd72be78802cb28d6f0ef73785e9e..3ac17aa8250c55ca51afc13ee3c856cd7e67b917:/LinuxGUI/Ventoy2Disk/Web/ventoy_http.c diff --git a/LinuxGUI/Ventoy2Disk/Web/ventoy_http.c b/LinuxGUI/Ventoy2Disk/Web/ventoy_http.c index 77fcebf..ac9920f 100644 --- a/LinuxGUI/Ventoy2Disk/Web/ventoy_http.c +++ b/LinuxGUI/Ventoy2Disk/Web/ventoy_http.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -160,9 +161,10 @@ static int ventoy_http_save_cfg(void) { FILE *fp; - fp = fopen("./Ventoy2Disk.ini", "w"); + fp = fopen(g_ini_file, "w"); if (!fp) { + vlog("Failed to open %s code:%d\n", g_ini_file, errno); return 0; } @@ -180,7 +182,7 @@ static int ventoy_http_load_cfg(void) char line[256]; FILE *fp; - fp = fopen("./Ventoy2Disk.ini", "r"); + fp = fopen(g_ini_file, "r"); if (!fp) { return 0; @@ -493,6 +495,7 @@ static int VentoyProcSecureBoot(int SecureBoot) fl_remove("/EFI/BOOT/grubx64.efi"); fl_remove("/EFI/BOOT/grubx64_real.efi"); fl_remove("/EFI/BOOT/MokManager.efi"); + fl_remove("/EFI/BOOT/mmx64.efi"); fl_remove("/ENROLL_THIS_KEY_IN_MOKMANAGER.cer"); file = fl_fopen("/EFI/BOOT/BOOTX64.EFI", "wb"); @@ -683,6 +686,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; @@ -740,17 +744,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; @@ -1499,7 +1518,7 @@ int ventoy_http_start(const char *ip, const char *port) { "listening_ports", "24680", "document_root", "WebUI", - "error_log_file", VTOY_LOG_FILE, + "error_log_file", g_log_file, "request_timeout_ms", "10000", NULL };