Alexandre Julliard : ntdll: Preserve the startup Unix directory unless it's on a removable device.
Alexandre Julliard
julliard at winehq.org
Mon Dec 27 16:15:03 CST 2021
Module: wine
Branch: master
Commit: 3e73437ae8f04a12200bf537758d22e5f9723637
URL: https://source.winehq.org/git/wine.git/?a=commit;h=3e73437ae8f04a12200bf537758d22e5f9723637
Author: Alexandre Julliard <julliard at winehq.org>
Date: Mon Dec 27 18:51:16 2021 +0100
ntdll: Preserve the startup Unix directory unless it's on a removable device.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52256
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/unix/file.c | 2 +-
dlls/ntdll/unix/server.c | 23 ++++++++++++-----------
dlls/ntdll/unix/unix_private.h | 3 +++
3 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c
index 07bfa6c22c4..a29b5cbb980 100644
--- a/dlls/ntdll/unix/file.c
+++ b/dlls/ntdll/unix/file.c
@@ -6223,7 +6223,7 @@ static inline BOOL is_device_placeholder( int fd )
return !memcmp( buffer, wine_placeholder, sizeof(wine_placeholder) - 1 );
}
-static NTSTATUS get_device_info( int fd, FILE_FS_DEVICE_INFORMATION *info )
+NTSTATUS get_device_info( int fd, FILE_FS_DEVICE_INFORMATION *info )
{
struct stat st;
diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c
index a388247beb2..b8c7ce715e6 100644
--- a/dlls/ntdll/unix/server.c
+++ b/dlls/ntdll/unix/server.c
@@ -75,6 +75,7 @@
#define WIN32_NO_STATUS
#include "windef.h"
#include "winnt.h"
+#include "winioctl.h"
#include "wine/server.h"
#include "wine/debug.h"
#include "unix_private.h"
@@ -1172,6 +1173,16 @@ 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;
@@ -1215,7 +1226,6 @@ static void server_connect_error( const char *serverdir )
* server_connect
*
* Attempt to connect to an existing server socket.
- * We need to be in the server directory already.
*/
static int server_connect(void)
{
@@ -1544,16 +1554,7 @@ void server_init_process_done(void)
{
void *entry, *teb;
NTSTATUS status;
- int suspend, needs_close, unixdir;
-
- if (peb->ProcessParameters->CurrentDirectory.Handle &&
- !server_get_unix_fd( peb->ProcessParameters->CurrentDirectory.Handle,
- FILE_TRAVERSE, &unixdir, &needs_close, NULL, NULL ))
- {
- fchdir( unixdir );
- if (needs_close) close( unixdir );
- }
- else chdir( "/" ); /* avoid locking removable devices */
+ int suspend;
#ifdef __APPLE__
send_server_task_port();
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h
index d9ce8300fa9..42b03cab8f6 100644
--- a/dlls/ntdll/unix/unix_private.h
+++ b/dlls/ntdll/unix/unix_private.h
@@ -105,6 +105,8 @@ extern LONGLONG CDECL fast_RtlGetSystemTimePrecise(void) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL unwind_builtin_dll( ULONG type, struct _DISPATCHER_CONTEXT *dispatch,
CONTEXT *context ) DECLSPEC_HIDDEN;
+struct _FILE_FS_DEVICE_INFORMATION;
+
extern const char wine_build[] DECLSPEC_HIDDEN;
extern const char *home_dir DECLSPEC_HIDDEN;
@@ -267,6 +269,7 @@ extern NTSTATUS get_full_path( const WCHAR *name, const WCHAR *curdir, WCHAR **p
extern NTSTATUS open_unix_file( HANDLE *handle, const char *unix_name, ACCESS_MASK access,
OBJECT_ATTRIBUTES *attr, ULONG attributes, ULONG sharing, ULONG disposition,
ULONG options, void *ea_buffer, ULONG ea_length ) DECLSPEC_HIDDEN;
+extern NTSTATUS get_device_info( int fd, struct _FILE_FS_DEVICE_INFORMATION *info ) DECLSPEC_HIDDEN;
extern void init_files(void) DECLSPEC_HIDDEN;
extern void init_cpu_info(void) DECLSPEC_HIDDEN;
extern void add_completion( HANDLE handle, ULONG_PTR value, NTSTATUS status, ULONG info, BOOL async ) DECLSPEC_HIDDEN;
More information about the wine-cvs
mailing list