X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/Ventoy.git/blobdiff_plain/cbbd57eee5980acc6879e119fe6b8913285f2af6..0135bf19342ee9e95e5adfb902fc5657a8a90c32:/LinuxGUI/Ventoy2Disk/Core/ventoy_util.c diff --git a/LinuxGUI/Ventoy2Disk/Core/ventoy_util.c b/LinuxGUI/Ventoy2Disk/Core/ventoy_util.c index d15a419..cc3e5e1 100644 --- a/LinuxGUI/Ventoy2Disk/Core/ventoy_util.c +++ b/LinuxGUI/Ventoy2Disk/Core/ventoy_util.c @@ -164,11 +164,40 @@ end: return mount; } +static int ventoy_mount_path_escape(char *src, char *dst, int len) +{ + int i = 0; + int n = 0; + + dst[len - 1] = 0; + + for (i = 0; i < len - 1; i++) + { + if (src[i] == '\\' && src[i + 1] == '0' && src[i + 2] == '4' && src[i + 3] == '0') + { + dst[n++] = ' '; + i += 3; + } + else + { + dst[n++] = src[i]; + } + + if (src[i] == 0) + { + break; + } + } + + return 0; +} + int ventoy_try_umount_disk(const char *devpath) { int rc; int len; - char line[512]; + char line[1024]; + char mntpt[1024]; char *pos1 = NULL; char *pos2 = NULL; FILE *fp = NULL; @@ -193,14 +222,15 @@ int ventoy_try_umount_disk(const char *devpath) *pos2 = 0; } - rc = umount(pos1 + 1); + ventoy_mount_path_escape(pos1 + 1, mntpt, sizeof(mntpt)); + rc = umount(mntpt); if (rc) { - vdebug("umount %s %s [ failed ] error:%d\n", devpath, pos1 + 1, errno); + vdebug("umount <%s> <%s> [ failed ] error:%d\n", devpath, mntpt, errno); } else { - vdebug("umount %s %s [ success ]\n", devpath, pos1 + 1); + vdebug("umount <%s> <%s> [ success ]\n", devpath, mntpt); } } } @@ -210,7 +240,6 @@ int ventoy_try_umount_disk(const char *devpath) return 0; } - int ventoy_read_file_to_buf(const char *FileName, int ExtLen, void **Bufer, int *BufLen) { int FileSize; @@ -299,6 +328,7 @@ static int VentoyFillProtectMBR(uint64_t DiskSizeBytes, MBR_HEAD *pMBR) vdebug("Disk signature: 0x%08x\n", DiskSignature); memcpy(pMBR->BootCode + 0x1B8, &DiskSignature, 4); + memcpy(pMBR->BootCode + 0x180, &Guid, 16); DiskSectorCount = DiskSizeBytes / 512 - 1; if (DiskSectorCount > 0xFFFFFFFF) @@ -412,7 +442,7 @@ int ventoy_fill_gpt(uint64_t size, uint64_t reserve, int align4k, VTOY_GPT_INFO ventoy_gen_preudo_uuid(&(Table[1].PartGuid)); Table[1].StartLBA = Table[0].LastLBA + 1; Table[1].LastLBA = Table[1].StartLBA + VTOYEFI_PART_BYTES / 512 - 1; - Table[1].Attr = 0x8000000000000001ULL; + Table[1].Attr = 0xC000000000000001ULL; ventoy_fill_gpt_partname(Table[1].Name, "VTOYEFI"); #if 0 @@ -490,6 +520,7 @@ int ventoy_fill_mbr(uint64_t size, uint64_t reserve, int align4k, MBR_HEAD *pMBR vdebug("Disk signature: 0x%08x\n", DiskSignature); memcpy(pMBR->BootCode + 0x1B8, &DiskSignature, 4); + memcpy(pMBR->BootCode + 0x180, &Guid, 16); if (size / 512 > 0xFFFFFFFF) {