Alexandre Julliard : ntdll:
Moved the check for removable file in load_dll to the server.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Jan 12 13:55:13 CST 2007
Module: wine
Branch: master
Commit: 5bd513640b52b62f379f2d15dc49cffbb899d191
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5bd513640b52b62f379f2d15dc49cffbb899d191
Author: Alexandre Julliard <julliard at winehq.org>
Date: Fri Jan 12 14:42:43 2007 +0100
ntdll: Moved the check for removable file in load_dll to the server.
---
dlls/ntdll/loader.c | 3 ---
dlls/ntdll/ntdll_misc.h | 1 -
dlls/ntdll/virtual.c | 16 ----------------
server/fd.c | 8 +++++++-
server/file.c | 6 ++++++
server/file.h | 2 ++
server/process.c | 2 +-
7 files changed, 16 insertions(+), 22 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 98b83b7..999687a 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -1438,9 +1438,6 @@ static NTSTATUS load_native_dll( LPCWSTR
nt = RtlImageNtHeader( module );
- /* don't keep the file open if the mapping is from removable media */
- if (!VIRTUAL_HasMapping( module )) file = 0;
-
SERVER_START_REQ( load_dll )
{
req->handle = file;
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index a7ef8df..3444998 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -111,7 +111,6 @@ extern NTSTATUS DIR_get_unix_cwd( char *
/* virtual memory */
extern NTSTATUS VIRTUAL_HandleFault(LPCVOID addr);
-extern BOOL VIRTUAL_HasMapping( LPCVOID addr );
extern void VIRTUAL_SetForceExec( BOOL enable );
extern void VIRTUAL_UseLargeAddressSpace(void);
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index fe33566..2ad3cfb 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -1291,22 +1291,6 @@ NTSTATUS VIRTUAL_HandleFault( LPCVOID ad
return ret;
}
-/***********************************************************************
- * VIRTUAL_HasMapping
- *
- * Check if the specified view has an associated file mapping.
- */
-BOOL VIRTUAL_HasMapping( LPCVOID addr )
-{
- FILE_VIEW *view;
- BOOL ret = FALSE;
-
- RtlEnterCriticalSection( &csVirtual );
- if ((view = VIRTUAL_FindView( addr ))) ret = (view->mapping != 0);
- RtlLeaveCriticalSection( &csVirtual );
- return ret;
-}
-
/***********************************************************************
* VIRTUAL_SetForceExec
diff --git a/server/fd.c b/server/fd.c
index d20360a..389c6a7 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -1668,6 +1668,12 @@ int is_same_file_fd( struct fd *fd1, str
return fd1->inode == fd2->inode;
}
+/* check if fd is on a removable device */
+int is_fd_removable( struct fd *fd )
+{
+ return (fd->inode && fd->inode->device->removable);
+}
+
/* handler for close_handle that refuses to close fd-associated handles in other processes */
int fd_close_handle( struct object *obj, struct process *process, obj_handle_t handle )
{
@@ -1966,7 +1972,7 @@ DECL_HANDLER(get_handle_fd)
reply->type = fd->fd_ops->get_file_info( fd, &reply->flags );
if (reply->type != FD_TYPE_INVALID)
{
- if (fd->inode && fd->inode->device->removable) reply->flags |= FD_FLAG_REMOVABLE;
+ if (is_fd_removable(fd)) reply->flags |= FD_FLAG_REMOVABLE;
if (!req->cached)
{
int unix_fd = get_unix_fd( fd );
diff --git a/server/file.c b/server/file.c
index 6647138..050f723 100644
--- a/server/file.c
+++ b/server/file.c
@@ -319,6 +319,12 @@ int get_file_unix_fd( struct file *file
return get_unix_fd( file->fd );
}
+struct file *grab_file_unless_removable( struct file *file )
+{
+ if (is_fd_removable( file->fd )) return NULL;
+ return (struct file *)grab_object( file );
+}
+
/* extend a file beyond the current end of file */
static int extend_file( struct file *file, file_pos_t new_size )
{
diff --git a/server/file.h b/server/file.h
index 6edb59f..836d438 100644
--- a/server/file.h
+++ b/server/file.h
@@ -55,6 +55,7 @@ extern void *get_fd_user( struct fd *fd
extern void set_fd_user( struct fd *fd, const struct fd_ops *ops, struct object *user );
extern int get_unix_fd( struct fd *fd );
extern int is_same_file_fd( struct fd *fd1, struct fd *fd2 );
+extern int is_fd_removable( struct fd *fd );
extern int fd_close_handle( struct object *obj, struct process *process, obj_handle_t handle );
extern void fd_poll_event( struct fd *fd, int event );
extern int check_fd_events( struct fd *fd, int events );
@@ -104,6 +105,7 @@ extern struct file *get_file_obj( struct
unsigned int access );
extern int get_file_unix_fd( struct file *file );
extern int is_same_file( struct file *file1, struct file *file2 );
+extern struct file *grab_file_unless_removable( struct file *file );
extern int grow_file( struct file *file, file_pos_t size );
extern struct file *create_temp_file( int access );
extern void file_set_error(void);
diff --git a/server/process.c b/server/process.c
index 001afcb..1c53f49 100644
--- a/server/process.c
+++ b/server/process.c
@@ -492,7 +492,7 @@ static struct process_dll *process_load_
free( dll );
return NULL;
}
- if (file) dll->file = (struct file *)grab_object( file );
+ if (file) dll->file = grab_file_unless_removable( file );
list_add_tail( &process->dlls, &dll->entry );
}
return dll;
More information about the wine-cvs
mailing list