explorer/mountmgr.sys: Move device hotplug code over to mount manager.

This commit is contained in:
Maarten Lankhorst 2008-03-03 22:58:32 -08:00 committed by Alexandre Julliard
parent 6e59cd2c34
commit 9c02e01dcb
8 changed files with 53 additions and 25 deletions

View File

@ -4,9 +4,15 @@ SRCDIR = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
MODULE = mountmgr.sys MODULE = mountmgr.sys
IMPORTS = advapi32 ntoskrnl.exe kernel32 ntdll IMPORTS = advapi32 ntoskrnl.exe kernel32 ntdll
DELAYIMPORTS = user32
EXTRADLLFLAGS = -Wb,--subsystem,native EXTRADLLFLAGS = -Wb,--subsystem,native
EXTRADEFS = @HALINCL@
EXTRALIBS = @DISKARBITRATIONLIB@ -luuid
C_SRCS = \ C_SRCS = \
device.c \
diskarb.c \
hal.c \
mountmgr.c mountmgr.c
@MAKE_DLL_RULES@ @MAKE_DLL_RULES@

View File

@ -37,7 +37,7 @@
#include "wine/list.h" #include "wine/list.h"
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(explorer); WINE_DEFAULT_DEBUG_CHANNEL(mountmgr);
struct dos_drive struct dos_drive
{ {
@ -72,8 +72,8 @@ static void send_notify( int drive, int code )
info.dbcv_reserved = 0; info.dbcv_reserved = 0;
info.dbcv_unitmask = 1 << drive; info.dbcv_unitmask = 1 << drive;
info.dbcv_flags = DBTF_MEDIA; info.dbcv_flags = DBTF_MEDIA;
SendMessageTimeoutW( HWND_BROADCAST, WM_DEVICECHANGE, code, (LPARAM)&info, result = BroadcastSystemMessageW( BSF_FORCEIFHUNG|BSF_QUERY, NULL,
SMTO_ABORTIFHUNG, 0, &result ); WM_DEVICECHANGE, code, (LPARAM)&info );
} }
static inline int is_valid_device( struct stat *st ) static inline int is_valid_device( struct stat *st )
@ -213,7 +213,7 @@ found:
set_mount_point( drive, mount_point ); set_mount_point( drive, mount_point );
WINE_TRACE( "added device %c: udi %s for %s on %s type %s\n", TRACE( "added device %c: udi %s for %s on %s type %s\n",
'a' + drive->drive, wine_dbgstr_a(udi), wine_dbgstr_a(device), 'a' + drive->drive, wine_dbgstr_a(udi), wine_dbgstr_a(device),
wine_dbgstr_a(mount_point), wine_dbgstr_a(type) ); wine_dbgstr_a(mount_point), wine_dbgstr_a(type) );

View File

@ -33,9 +33,9 @@
#include "winuser.h" #include "winuser.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "explorer_private.h" #include "mountmgr.h"
WINE_DEFAULT_DEBUG_CHANNEL(explorer); WINE_DEFAULT_DEBUG_CHANNEL(mountmgr);
#ifdef HAVE_DISKARBITRATION_DISKARBITRATION_H #ifdef HAVE_DISKARBITRATION_DISKARBITRATION_H
@ -72,7 +72,7 @@ static void appeared_callback( DADiskRef disk, void *context )
type = "cdrom"; type = "cdrom";
} }
WINE_TRACE( "got mount notification for '%s' on '%s'\n", device, mount_point ); TRACE( "got mount notification for '%s' on '%s'\n", device, mount_point );
add_dos_device( device, device, mount_point, type ); add_dos_device( device, device, mount_point, type );
done: done:
@ -101,7 +101,7 @@ static void disappeared_callback( DADiskRef disk, void *context )
strcpy( device, "/dev/r" ); strcpy( device, "/dev/r" );
CFStringGetCString( ref, device + 6, sizeof(device) - 6, kCFStringEncodingASCII ); CFStringGetCString( ref, device + 6, sizeof(device) - 6, kCFStringEncodingASCII );
WINE_TRACE( "got unmount notification for '%s'\n", device ); TRACE( "got unmount notification for '%s'\n", device );
remove_dos_device( device ); remove_dos_device( device );
done: done:
@ -139,7 +139,7 @@ void initialize_diskarbitration(void)
void initialize_diskarbitration(void) void initialize_diskarbitration(void)
{ {
WINE_TRACE( "Skipping, Disk Arbitration support not compiled in\n" ); TRACE( "Skipping, Disk Arbitration support not compiled in\n" );
} }
#endif /* HAVE_DISKARBITRATION_DISKARBITRATION_H */ #endif /* HAVE_DISKARBITRATION_DISKARBITRATION_H */

View File

@ -36,9 +36,9 @@
#include "wine/library.h" #include "wine/library.h"
#include "wine/exception.h" #include "wine/exception.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "explorer_private.h" #include "mountmgr.h"
WINE_DEFAULT_DEBUG_CHANNEL(explorer); WINE_DEFAULT_DEBUG_CHANNEL(mountmgr);
#ifdef SONAME_LIBHAL #ifdef SONAME_LIBHAL
@ -98,7 +98,7 @@ static BOOL load_functions(void)
return TRUE; return TRUE;
failed: failed:
WINE_WARN( "failed to load HAL support: %s\n", error ); WARN( "failed to load HAL support: %s\n", error );
return FALSE; return FALSE;
} }
@ -153,7 +153,7 @@ static void removed_device( LibHalContext *ctx, const char *udi )
{ {
DBusError error; DBusError error;
WINE_TRACE( "removed %s\n", wine_dbgstr_a(udi) ); TRACE( "removed %s\n", wine_dbgstr_a(udi) );
if (remove_dos_device( udi )) if (remove_dos_device( udi ))
{ {
@ -167,7 +167,7 @@ static void removed_device( LibHalContext *ctx, const char *udi )
static void property_modified (LibHalContext *ctx, const char *udi, static void property_modified (LibHalContext *ctx, const char *udi,
const char *key, dbus_bool_t is_removed, dbus_bool_t is_added) const char *key, dbus_bool_t is_removed, dbus_bool_t is_added)
{ {
WINE_TRACE( "udi %s key %s %s\n", wine_dbgstr_a(udi), wine_dbgstr_a(key), TRACE( "udi %s key %s %s\n", wine_dbgstr_a(udi), wine_dbgstr_a(key),
is_added ? "added" : is_removed ? "removed" : "modified" ); is_added ? "added" : is_removed ? "removed" : "modified" );
if (!strcmp( key, "volume.mount_point" )) new_device( ctx, udi ); if (!strcmp( key, "volume.mount_point" )) new_device( ctx, udi );
@ -187,7 +187,7 @@ static DWORD WINAPI hal_thread( void *arg )
p_dbus_error_init( &error ); p_dbus_error_init( &error );
if (!(dbc = p_dbus_bus_get( DBUS_BUS_SYSTEM, &error ))) if (!(dbc = p_dbus_bus_get( DBUS_BUS_SYSTEM, &error )))
{ {
WINE_WARN( "failed to get system dbus connection: %s\n", error.message ); WARN( "failed to get system dbus connection: %s\n", error.message );
p_dbus_error_free( &error ); p_dbus_error_free( &error );
return 1; return 1;
} }
@ -199,7 +199,7 @@ static DWORD WINAPI hal_thread( void *arg )
if (!p_libhal_ctx_init( ctx, &error )) if (!p_libhal_ctx_init( ctx, &error ))
{ {
WINE_WARN( "HAL context init failed: %s\n", error.message ); WARN( "HAL context init failed: %s\n", error.message );
p_dbus_error_free( &error ); p_dbus_error_free( &error );
return 1; return 1;
} }
@ -218,7 +218,7 @@ static DWORD WINAPI hal_thread( void *arg )
} }
__EXCEPT( assert_fault ) __EXCEPT( assert_fault )
{ {
WINE_WARN( "dbus assertion failure, disabling HAL support\n" ); WARN( "dbus assertion failure, disabling HAL support\n" );
return 1; return 1;
} }
__ENDTRY; __ENDTRY;
@ -243,7 +243,7 @@ void initialize_hal(void)
void initialize_hal(void) void initialize_hal(void)
{ {
WINE_TRACE( "Skipping, HAL support not compiled in\n" ); TRACE( "Skipping, HAL support not compiled in\n" );
} }
#endif /* SONAME_LIBHAL */ #endif /* SONAME_LIBHAL */

View File

@ -38,6 +38,7 @@
#include "wine/library.h" #include "wine/library.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "mountmgr.h"
WINE_DEFAULT_DEBUG_CHANNEL(mountmgr); WINE_DEFAULT_DEBUG_CHANNEL(mountmgr);
@ -493,6 +494,9 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
return status; return status;
} }
initialize_hal();
initialize_diskarbitration();
RtlInitUnicodeString( &nameW, harddiskW ); RtlInitUnicodeString( &nameW, harddiskW );
status = IoCreateDriver( &nameW, harddisk_driver_entry ); status = IoCreateDriver( &nameW, harddisk_driver_entry );

View File

@ -0,0 +1,25 @@
/*
* Mountmanager private header
*
* Copyright 2008 Maarten Lankhorst
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
extern void initialize_hal(void);
extern void initialize_diskarbitration(void);
extern BOOL add_dos_device( const char *udi, const char *device,
const char *mount_point, const char *type );
extern BOOL remove_dos_device( const char *udi );

View File

@ -6,15 +6,10 @@ MODULE = explorer.exe
APPMODE = -mwindows APPMODE = -mwindows
IMPORTS = rpcrt4 user32 gdi32 advapi32 kernel32 ntdll IMPORTS = rpcrt4 user32 gdi32 advapi32 kernel32 ntdll
DELAYIMPORTS = comctl32 DELAYIMPORTS = comctl32
EXTRADEFS = @HALINCL@
EXTRALIBS = @DISKARBITRATIONLIB@
C_SRCS = \ C_SRCS = \
desktop.c \ desktop.c \
device.c \
diskarb.c \
explorer.c \ explorer.c \
hal.c \
systray.c systray.c
@MAKE_PROG_RULES@ @MAKE_PROG_RULES@

View File

@ -234,8 +234,6 @@ void manage_desktop( char *arg )
SystemParametersInfoA( SPI_SETDESKPATTERN, -1, NULL, FALSE ); SystemParametersInfoA( SPI_SETDESKPATTERN, -1, NULL, FALSE );
SetDeskWallPaper( (LPSTR)-1 ); SetDeskWallPaper( (LPSTR)-1 );
initialize_display_settings( hwnd ); initialize_display_settings( hwnd );
initialize_diskarbitration();
initialize_hal();
initialize_systray(); initialize_systray();
} }
else else