ntdll: Moved the check for removable file in load_dll to the server.

This commit is contained in:
Alexandre Julliard 2007-01-12 14:42:43 +01:00
parent c255bf4676
commit 5bd513640b
7 changed files with 16 additions and 22 deletions

View File

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

View File

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

View File

@ -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

View File

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

View File

@ -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 )
{

View File

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

View File

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