From: Michael Lelli toadking@toadking.com
Fix umounting filesystems mounted on paths with spaces.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57391 --- dlls/ntdll/unix/file.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c index 44adc4f4626..e1d3e3979b5 100644 --- a/dlls/ntdll/unix/file.c +++ b/dlls/ntdll/unix/file.c @@ -3975,23 +3975,25 @@ static NTSTATUS unmount_device( HANDLE handle ) { if ((mount_point = get_device_mount_point( st.st_rdev ))) { + LARGE_INTEGER time; #ifdef __APPLE__ - static const char umount[] = "diskutil unmount >/dev/null 2>&1 "; + static char diskutil[] = "diskutil"; + static char unmount[] = "unmount"; + char *argv[4] = {diskutil, unmount, mount_point, NULL}; #else - static const char umount[] = "umount >/dev/null 2>&1 "; + static char umount[] = "umount"; + char *argv[3] = {umount, mount_point, NULL}; #endif - char *cmd; - if (asprintf( &cmd, "%s%s", umount, mount_point ) != -1) - { - system( cmd ); - free( cmd ); + __wine_unix_spawnvp( argv, TRUE ); #ifdef linux - /* umount will fail to release the loop device since we still have - a handle to it, so we release it here */ - if (major(st.st_rdev) == LOOP_MAJOR) ioctl( unix_fd, 0x4c01 /*LOOP_CLR_FD*/, 0 ); + /* umount will fail to release the loop device since we still have + a handle to it, so we release it here */ + if (major(st.st_rdev) == LOOP_MAJOR) ioctl( unix_fd, 0x4c01 /*LOOP_CLR_FD*/, 0 ); #endif - } - free( mount_point ); + /* Add in a small delay. Without this subsequent tasks + like IOCTL_STORAGE_EJECT_MEDIA might fail. */ + time.QuadPart = -100 * (ULONGLONG)10000; + NtDelayExecution( FALSE, &time ); } } if (needs_close) close( unix_fd );