ntdll: Fix current directory initialization on removable devices.

Fix a regression caused by 3e73437ae8.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52311
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2022-01-02 13:45:40 +01:00
parent 8eacd3e507
commit 15101bae7b
1 changed files with 9 additions and 18 deletions

View File

@ -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();