Commit 15101bae authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Fix current directory initialization on removable devices.

parent 8eacd3e5
...@@ -104,6 +104,7 @@ timeout_t server_start_time = 0; /* time of server startup */ ...@@ -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 */ 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 fd_socket = -1; /* socket to exchange file descriptors with the server */
static int initial_cwd = -1;
static pid_t server_pid; static pid_t server_pid;
static pthread_mutex_t fd_cache_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t fd_cache_mutex = PTHREAD_MUTEX_INITIALIZER;
...@@ -1173,16 +1174,6 @@ static int setup_config_dir(void) ...@@ -1173,16 +1174,6 @@ static int setup_config_dir(void)
} }
else if (errno != EEXIST) fatal_perror( "cannot create %s/dosdevices", config_dir ); 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 ); if (fd_cwd == -1) fd_cwd = open( "dosdevices/c:", O_RDONLY );
fcntl( fd_cwd, F_SETFD, FD_CLOEXEC ); fcntl( fd_cwd, F_SETFD, FD_CLOEXEC );
return fd_cwd; return fd_cwd;
...@@ -1231,9 +1222,9 @@ static int server_connect(void) ...@@ -1231,9 +1222,9 @@ static int server_connect(void)
{ {
struct sockaddr_un addr; struct sockaddr_un addr;
struct stat st; 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 */ /* chdir to the server directory */
if (chdir( server_dir ) == -1) if (chdir( server_dir ) == -1)
...@@ -1287,12 +1278,7 @@ static int server_connect(void) ...@@ -1287,12 +1278,7 @@ static int server_connect(void)
#endif #endif
if (connect( s, (struct sockaddr *)&addr, slen ) != -1) if (connect( s, (struct sockaddr *)&addr, slen ) != -1)
{ {
/* switch back to the starting directory */ fchdir( initial_cwd ); /* switch back to the starting directory */
if (fd_cwd != -1)
{
fchdir( fd_cwd );
close( fd_cwd );
}
fcntl( s, F_SETFD, FD_CLOEXEC ); fcntl( s, F_SETFD, FD_CLOEXEC );
return s; return s;
} }
...@@ -1555,6 +1541,11 @@ void server_init_process_done(void) ...@@ -1555,6 +1541,11 @@ void server_init_process_done(void)
void *entry, *teb; void *entry, *teb;
NTSTATUS status; NTSTATUS status;
int suspend; 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__ #ifdef __APPLE__
send_server_task_port(); send_server_task_port();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment