From 5bd513640b52b62f379f2d15dc49cffbb899d191 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 12 Jan 2007 14:42:43 +0100 Subject: [PATCH] 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 98b83b72b0..999687a193 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -1438,9 +1438,6 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file, 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 a7ef8df7e8..3444998e09 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -111,7 +111,6 @@ extern NTSTATUS DIR_get_unix_cwd( char **cwd ); /* 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 fe3356621e..2ad3cfb561 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -1291,22 +1291,6 @@ NTSTATUS VIRTUAL_HandleFault( LPCVOID addr ) 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 d20360a5fd..389c6a749f 100644 --- a/server/fd.c +++ b/server/fd.c @@ -1668,6 +1668,12 @@ int is_same_file_fd( struct fd *fd1, struct fd *fd2 ) 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 66471387db..050f72382c 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 6edb59f160..836d438a08 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 process *process, obj_handle_t handle, 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 001afcbed9..1c53f49cf2 100644 --- a/server/process.c +++ b/server/process.c @@ -492,7 +492,7 @@ static struct process_dll *process_load_dll( struct process *process, struct fil 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; -- 2.32.0.93.g670b81a890