Alexandre Julliard : ntdll: Fix current directory initialization on removable devices.
Alexandre Julliard
julliard at winehq.org
Sun Jan 2 15:29:03 CST 2022
Module: wine
Branch: master
Commit: 15101bae7b9a10d73b8edc05e0ea58590378db29
URL: https://source.winehq.org/git/wine.git/?a=commit;h=15101bae7b9a10d73b8edc05e0ea58590378db29
Author: Alexandre Julliard <julliard at winehq.org>
Date: Sun Jan 2 13:45:40 2022 +0100
ntdll: Fix current directory initialization on removable devices.
Fix a regression caused by 3e73437ae8f04a12200bf537758d22e5f9723637.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52311
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/unix/server.c | 27 +++++++++------------------
1 file changed, 9 insertions(+), 18 deletions(-)
diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c
index b8c7ce715e6..6a3224d8385 100644
--- a/dlls/ntdll/unix/server.c
+++ b/dlls/ntdll/unix/server.c
@@ -104,6 +104,7 @@ timeout_t server_start_time = 0; /* time of server startup */
sigset_t server_block_set; /* signals to block during server calls */
static int fd_socket = -1; /* socket to exchange file descriptors with the server */
+static int initial_cwd = -1;
static pid_t server_pid;
static pthread_mutex_t fd_cache_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -1173,16 +1174,6 @@ static int setup_config_dir(void)
}
else if (errno != EEXIST) fatal_perror( "cannot create %s/dosdevices", config_dir );
- if (fd_cwd != -1)
- {
- FILE_FS_DEVICE_INFORMATION info;
- if (!get_device_info( fd_cwd, &info ) && (info.Characteristics & FILE_REMOVABLE_MEDIA))
- {
- close( fd_cwd );
- fd_cwd = -1;
- }
- }
-
if (fd_cwd == -1) fd_cwd = open( "dosdevices/c:", O_RDONLY );
fcntl( fd_cwd, F_SETFD, FD_CLOEXEC );
return fd_cwd;
@@ -1231,9 +1222,9 @@ static int server_connect(void)
{
struct sockaddr_un addr;
struct stat st;
- int s, slen, retry, fd_cwd;
+ int s, slen, retry;
- fd_cwd = setup_config_dir();
+ initial_cwd = setup_config_dir();
/* chdir to the server directory */
if (chdir( server_dir ) == -1)
@@ -1287,12 +1278,7 @@ static int server_connect(void)
#endif
if (connect( s, (struct sockaddr *)&addr, slen ) != -1)
{
- /* switch back to the starting directory */
- if (fd_cwd != -1)
- {
- fchdir( fd_cwd );
- close( fd_cwd );
- }
+ fchdir( initial_cwd ); /* switch back to the starting directory */
fcntl( s, F_SETFD, FD_CLOEXEC );
return s;
}
@@ -1555,6 +1541,11 @@ void server_init_process_done(void)
void *entry, *teb;
NTSTATUS status;
int suspend;
+ FILE_FS_DEVICE_INFORMATION info;
+
+ if (!get_device_info( initial_cwd, &info ) && (info.Characteristics & FILE_REMOVABLE_MEDIA))
+ chdir( "/" );
+ close( initial_cwd );
#ifdef __APPLE__
send_server_task_port();
More information about the wine-cvs
mailing list