From: longpanda Date: Wed, 27 Apr 2022 02:25:44 +0000 (+0800) Subject: Fix a bug when install Ventoy if the USB already mounted at a path that contains... X-Git-Tag: v1.0.74~3 X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/Ventoy.git/commitdiff_plain/fd0d335eb69950ceaed69adeac72064987cd79b9 Fix a bug when install Ventoy if the USB already mounted at a path that contains space. --- diff --git a/INSTALL/tool/aarch64/V2DServer b/INSTALL/tool/aarch64/V2DServer index 03ce643..0cb6480 100644 Binary files a/INSTALL/tool/aarch64/V2DServer and b/INSTALL/tool/aarch64/V2DServer differ diff --git a/INSTALL/tool/aarch64/Ventoy2Disk.gtk3 b/INSTALL/tool/aarch64/Ventoy2Disk.gtk3 index e42d624..842c524 100644 Binary files a/INSTALL/tool/aarch64/Ventoy2Disk.gtk3 and b/INSTALL/tool/aarch64/Ventoy2Disk.gtk3 differ diff --git a/INSTALL/tool/aarch64/Ventoy2Disk.qt5 b/INSTALL/tool/aarch64/Ventoy2Disk.qt5 index 009a187..0e1a49d 100644 Binary files a/INSTALL/tool/aarch64/Ventoy2Disk.qt5 and b/INSTALL/tool/aarch64/Ventoy2Disk.qt5 differ diff --git a/INSTALL/tool/i386/V2DServer b/INSTALL/tool/i386/V2DServer index deb1033..a3a58fc 100644 Binary files a/INSTALL/tool/i386/V2DServer and b/INSTALL/tool/i386/V2DServer differ diff --git a/INSTALL/tool/i386/Ventoy2Disk.gtk2 b/INSTALL/tool/i386/Ventoy2Disk.gtk2 index 774f5d3..ca248df 100644 Binary files a/INSTALL/tool/i386/Ventoy2Disk.gtk2 and b/INSTALL/tool/i386/Ventoy2Disk.gtk2 differ diff --git a/INSTALL/tool/i386/Ventoy2Disk.gtk3 b/INSTALL/tool/i386/Ventoy2Disk.gtk3 index 6116798..c2c84f7 100644 Binary files a/INSTALL/tool/i386/Ventoy2Disk.gtk3 and b/INSTALL/tool/i386/Ventoy2Disk.gtk3 differ diff --git a/INSTALL/tool/i386/Ventoy2Disk.qt5 b/INSTALL/tool/i386/Ventoy2Disk.qt5 index b1c226d..1aa6f86 100644 Binary files a/INSTALL/tool/i386/Ventoy2Disk.qt5 and b/INSTALL/tool/i386/Ventoy2Disk.qt5 differ diff --git a/INSTALL/tool/mips64el/V2DServer b/INSTALL/tool/mips64el/V2DServer index 38eca27..fdbdda5 100644 Binary files a/INSTALL/tool/mips64el/V2DServer and b/INSTALL/tool/mips64el/V2DServer differ diff --git a/INSTALL/tool/mips64el/Ventoy2Disk.gtk3 b/INSTALL/tool/mips64el/Ventoy2Disk.gtk3 index 83ced17..68b6895 100644 Binary files a/INSTALL/tool/mips64el/Ventoy2Disk.gtk3 and b/INSTALL/tool/mips64el/Ventoy2Disk.gtk3 differ diff --git a/INSTALL/tool/mips64el/Ventoy2Disk.qt5 b/INSTALL/tool/mips64el/Ventoy2Disk.qt5 index d3c827e..4ccca4f 100644 Binary files a/INSTALL/tool/mips64el/Ventoy2Disk.qt5 and b/INSTALL/tool/mips64el/Ventoy2Disk.qt5 differ diff --git a/INSTALL/tool/x86_64/V2DServer b/INSTALL/tool/x86_64/V2DServer index 0bd0a4e..c5079cc 100644 Binary files a/INSTALL/tool/x86_64/V2DServer and b/INSTALL/tool/x86_64/V2DServer differ diff --git a/INSTALL/tool/x86_64/Ventoy2Disk.gtk2 b/INSTALL/tool/x86_64/Ventoy2Disk.gtk2 index 20ca6b3..d473a6b 100644 Binary files a/INSTALL/tool/x86_64/Ventoy2Disk.gtk2 and b/INSTALL/tool/x86_64/Ventoy2Disk.gtk2 differ diff --git a/INSTALL/tool/x86_64/Ventoy2Disk.gtk3 b/INSTALL/tool/x86_64/Ventoy2Disk.gtk3 index 4d41ef2..562ecaf 100644 Binary files a/INSTALL/tool/x86_64/Ventoy2Disk.gtk3 and b/INSTALL/tool/x86_64/Ventoy2Disk.gtk3 differ diff --git a/INSTALL/tool/x86_64/Ventoy2Disk.qt5 b/INSTALL/tool/x86_64/Ventoy2Disk.qt5 index 40beccc..df9d6aa 100644 Binary files a/INSTALL/tool/x86_64/Ventoy2Disk.qt5 and b/INSTALL/tool/x86_64/Ventoy2Disk.qt5 differ diff --git a/LinuxGUI/Ventoy2Disk/Core/ventoy_util.c b/LinuxGUI/Ventoy2Disk/Core/ventoy_util.c index 27c015f..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;