Commit 236a1bc8 authored by Alexandre Julliard's avatar Alexandre Julliard

mountmgr: Move the DiskArbitration support to the Unix library.

parent 95615a4a
...@@ -827,9 +827,4 @@ void run_dbus_loop(void) ...@@ -827,9 +827,4 @@ void run_dbus_loop(void)
TRACE( "Skipping, DBUS support not compiled in\n" ); TRACE( "Skipping, DBUS support not compiled in\n" );
} }
NTSTATUS dhcp_request( void *args )
{
return STATUS_NOT_SUPPORTED;
}
#endif /* SONAME_LIBDBUS_1 */ #endif /* SONAME_LIBDBUS_1 */
...@@ -18,8 +18,11 @@ ...@@ -18,8 +18,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#if 0
#pragma makedep unix
#endif
#include "config.h" #include "config.h"
#include "wine/port.h"
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
...@@ -43,6 +46,8 @@ ...@@ -43,6 +46,8 @@
#include "winsock2.h" #include "winsock2.h"
#include "ws2ipdef.h" #include "ws2ipdef.h"
#include "dhcpcsdk.h" #include "dhcpcsdk.h"
#include "unixlib.h"
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(mountmgr); WINE_DEFAULT_DEBUG_CHANNEL(mountmgr);
...@@ -163,9 +168,9 @@ static void appeared_callback( DADiskRef disk, void *context ) ...@@ -163,9 +168,9 @@ static void appeared_callback( DADiskRef disk, void *context )
} }
if (removable) if (removable)
add_dos_device( -1, device, device, mount_point, type, guid_ptr, &scsi_info ); queue_device_op( ADD_DOS_DEVICE, device, device, mount_point, type, guid_ptr, NULL, &scsi_info );
else else
if (guid_ptr) add_volume( device, device, mount_point, DEVICE_HARDDISK_VOL, guid_ptr, NULL, &scsi_info ); if (guid_ptr) queue_device_op( ADD_VOLUME, device, device, mount_point, DEVICE_HARDDISK_VOL, guid_ptr, NULL, &scsi_info );
done: done:
CFRelease( dict ); CFRelease( dict );
...@@ -191,20 +196,17 @@ static void disappeared_callback( DADiskRef disk, void *context ) ...@@ -191,20 +196,17 @@ static void disappeared_callback( DADiskRef disk, void *context )
TRACE( "got unmount notification for '%s'\n", device ); TRACE( "got unmount notification for '%s'\n", device );
if ((ref = CFDictionaryGetValue( dict, CFSTR("DAMediaRemovable") )) && CFBooleanGetValue( ref )) queue_device_op( REMOVE_DEVICE, device, NULL, NULL, 0, NULL, NULL, NULL );
remove_dos_device( -1, device );
else
remove_volume( device );
done: done:
CFRelease( dict ); CFRelease( dict );
} }
static DWORD WINAPI runloop_thread( void *arg ) void run_diskarbitration_loop(void)
{ {
DASessionRef session = DASessionCreate( NULL ); DASessionRef session = DASessionCreate( NULL );
if (!session) return 1; if (!session) return;
DASessionScheduleWithRunLoop( session, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode ); DASessionScheduleWithRunLoop( session, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode );
DARegisterDiskAppearedCallback( session, kDADiskDescriptionMatchVolumeMountable, DARegisterDiskAppearedCallback( session, kDADiskDescriptionMatchVolumeMountable,
...@@ -216,20 +218,11 @@ static DWORD WINAPI runloop_thread( void *arg ) ...@@ -216,20 +218,11 @@ static DWORD WINAPI runloop_thread( void *arg )
CFRunLoopRun(); CFRunLoopRun();
DASessionUnscheduleFromRunLoop( session, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode ); DASessionUnscheduleFromRunLoop( session, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode );
CFRelease( session ); CFRelease( session );
return 0;
}
void initialize_diskarbitration(void)
{
HANDLE handle;
if (!(handle = CreateThread( NULL, 0, runloop_thread, NULL, 0, NULL ))) return;
CloseHandle( handle );
} }
#else /* HAVE_DISKARBITRATION_DISKARBITRATION_H */ #else /* HAVE_DISKARBITRATION_DISKARBITRATION_H */
void initialize_diskarbitration(void) void run_diskarbitration_loop(void)
{ {
TRACE( "Skipping, Disk Arbitration support not compiled in\n" ); TRACE( "Skipping, Disk Arbitration support not compiled in\n" );
} }
...@@ -291,17 +284,17 @@ done: ...@@ -291,17 +284,17 @@ done:
return ret; return ret;
} }
ULONG get_dhcp_request_param( const char *unix_name, struct mountmgr_dhcp_request_param *param, char *buf, ULONG offset, NTSTATUS dhcp_request( void *args )
ULONG size )
{ {
CFStringRef service_id = find_service_id( unix_name ); const struct dhcp_request_params *params = args;
CFStringRef service_id = find_service_id( params->unix_name );
CFDictionaryRef dict; CFDictionaryRef dict;
CFDataRef value; CFDataRef value;
DWORD ret = 0; DWORD ret = 0;
CFIndex len; CFIndex len;
param->offset = 0; params->req->offset = 0;
param->size = 0; params->req->size = 0;
if (!service_id) return 0; if (!service_id) return 0;
if (!(dict = SCDynamicStoreCopyDHCPInfo( NULL, service_id ))) if (!(dict = SCDynamicStoreCopyDHCPInfo( NULL, service_id )))
...@@ -310,25 +303,25 @@ ULONG get_dhcp_request_param( const char *unix_name, struct mountmgr_dhcp_reques ...@@ -310,25 +303,25 @@ ULONG get_dhcp_request_param( const char *unix_name, struct mountmgr_dhcp_reques
return 0; return 0;
} }
CFRelease( service_id ); CFRelease( service_id );
if (!(value = DHCPInfoGetOptionData( dict, map_option(param->id) ))) if (!(value = DHCPInfoGetOptionData( dict, map_option(params->req->id) )))
{ {
CFRelease( dict ); CFRelease( dict );
return 0; return 0;
} }
len = CFDataGetLength( value ); len = CFDataGetLength( value );
switch (param->id) switch (params->req->id)
{ {
case OPTION_SUBNET_MASK: case OPTION_SUBNET_MASK:
case OPTION_ROUTER_ADDRESS: case OPTION_ROUTER_ADDRESS:
case OPTION_BROADCAST_ADDRESS: case OPTION_BROADCAST_ADDRESS:
{ {
DWORD *ptr = (DWORD *)(buf + offset); DWORD *ptr = (DWORD *)(params->buffer + params->offset);
if (len == sizeof(*ptr) && size >= sizeof(*ptr)) if (len == sizeof(*ptr) && params->size >= sizeof(*ptr))
{ {
CFDataGetBytes( value, CFRangeMake(0, len), (UInt8 *)ptr ); CFDataGetBytes( value, CFRangeMake(0, len), (UInt8 *)ptr );
param->offset = offset; params->req->offset = params->offset;
param->size = sizeof(*ptr); params->req->size = sizeof(*ptr);
TRACE( "returning %08x\n", *ptr ); TRACE( "returning %08x\n", *ptr );
} }
ret = sizeof(*ptr); ret = sizeof(*ptr);
...@@ -338,33 +331,32 @@ ULONG get_dhcp_request_param( const char *unix_name, struct mountmgr_dhcp_reques ...@@ -338,33 +331,32 @@ ULONG get_dhcp_request_param( const char *unix_name, struct mountmgr_dhcp_reques
case OPTION_DOMAIN_NAME: case OPTION_DOMAIN_NAME:
case OPTION_MSFT_IE_PROXY: case OPTION_MSFT_IE_PROXY:
{ {
char *ptr = buf + offset; char *ptr = params->buffer + params->offset;
if (size >= len) if (params->size >= len)
{ {
CFDataGetBytes( value, CFRangeMake(0, len), (UInt8 *)ptr ); CFDataGetBytes( value, CFRangeMake(0, len), (UInt8 *)ptr );
param->offset = offset; params->req->offset = params->offset;
param->size = len; params->req->size = len;
TRACE( "returning %s\n", debugstr_an(ptr, len) ); TRACE( "returning %s\n", debugstr_an(ptr, len) );
} }
ret = len; ret = len;
break; break;
} }
default: default:
FIXME( "option %u not supported\n", param->id ); FIXME( "option %u not supported\n", params->req->id );
break; break;
} }
CFRelease( dict ); CFRelease( dict );
return ret; *params->ret_size = ret;
return STATUS_SUCCESS;
} }
#elif !defined(SONAME_LIBDBUS_1) #elif !defined(SONAME_LIBDBUS_1)
ULONG get_dhcp_request_param( const char *unix_name, struct mountmgr_dhcp_request_param *param, char *buf, ULONG offset, NTSTATUS dhcp_request( void *args )
ULONG size )
{ {
FIXME( "support not compiled in\n" ); return STATUS_NOT_SUPPORTED;
return 0;
} }
#endif #endif
...@@ -408,15 +408,11 @@ static void WINAPI query_dhcp_request_params( TP_CALLBACK_INSTANCE *instance, vo ...@@ -408,15 +408,11 @@ static void WINAPI query_dhcp_request_params( TP_CALLBACK_INSTANCE *instance, vo
offset = FIELD_OFFSET(struct mountmgr_dhcp_request_params, params[query->count]); offset = FIELD_OFFSET(struct mountmgr_dhcp_request_params, params[query->count]);
for (i = 0; i < query->count; i++) for (i = 0; i < query->count; i++)
{ {
#ifdef __APPLE__
offset += get_dhcp_request_param( query->unix_name, &query->params[i], (char *)query, offset, outsize - offset );
#else
ULONG ret_size; ULONG ret_size;
struct dhcp_request_params params = { query->unix_name, &query->params[i], struct dhcp_request_params params = { query->unix_name, &query->params[i],
(char *)query, offset, outsize - offset, &ret_size }; (char *)query, offset, outsize - offset, &ret_size };
MOUNTMGR_CALL( dhcp_request, &params ); MOUNTMGR_CALL( dhcp_request, &params );
offset += ret_size; offset += ret_size;
#endif
if (offset > outsize) if (offset > outsize)
{ {
if (offset >= sizeof(query->size)) query->size = offset; if (offset >= sizeof(query->size)) query->size = offset;
...@@ -685,8 +681,6 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) ...@@ -685,8 +681,6 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
params.op_apc = device_op; params.op_apc = device_op;
CloseHandle( CreateThread( NULL, 0, run_loop_thread, &params, 0, NULL )); CloseHandle( CreateThread( NULL, 0, run_loop_thread, &params, 0, NULL ));
initialize_diskarbitration();
#ifdef _WIN64 #ifdef _WIN64
/* create a symlink so that the Wine port overrides key can be edited with 32-bit reg or regedit */ /* create a symlink so that the Wine port overrides key can be edited with 32-bit reg or regedit */
RegCreateKeyExW( HKEY_LOCAL_MACHINE, wow64_ports_keyW, 0, NULL, REG_OPTION_CREATE_LINK, RegCreateKeyExW( HKEY_LOCAL_MACHINE, wow64_ports_keyW, 0, NULL, REG_OPTION_CREATE_LINK,
......
...@@ -36,8 +36,6 @@ ...@@ -36,8 +36,6 @@
#define WINE_MOUNTMGR_EXTENSIONS #define WINE_MOUNTMGR_EXTENSIONS
#include "ddk/mountmgr.h" #include "ddk/mountmgr.h"
extern void initialize_diskarbitration(void) DECLSPEC_HIDDEN;
extern WCHAR *strdupW( const WCHAR * ) DECLSPEC_HIDDEN; extern WCHAR *strdupW( const WCHAR * ) DECLSPEC_HIDDEN;
/* device functions */ /* device functions */
...@@ -114,8 +112,4 @@ extern struct mount_point *add_volume_mount_point( DEVICE_OBJECT *device, UNICOD ...@@ -114,8 +112,4 @@ extern struct mount_point *add_volume_mount_point( DEVICE_OBJECT *device, UNICOD
extern void delete_mount_point( struct mount_point *mount ) DECLSPEC_HIDDEN; extern void delete_mount_point( struct mount_point *mount ) DECLSPEC_HIDDEN;
extern void set_mount_point_id( struct mount_point *mount, const void *id, unsigned int id_len ) DECLSPEC_HIDDEN; extern void set_mount_point_id( struct mount_point *mount, const void *id, unsigned int id_len ) DECLSPEC_HIDDEN;
#ifdef __APPLE__
extern ULONG get_dhcp_request_param( const char *unix_name, struct mountmgr_dhcp_request_param *param,
char *buf, ULONG offset, ULONG size ) DECLSPEC_HIDDEN;
#endif
#endif /* __WINE_MOUNTMGR_H */ #endif /* __WINE_MOUNTMGR_H */
...@@ -128,6 +128,7 @@ static NTSTATUS run_loop( void *args ) ...@@ -128,6 +128,7 @@ static NTSTATUS run_loop( void *args )
const struct run_loop_params *params = args; const struct run_loop_params *params = args;
run_loop_params = *params; run_loop_params = *params;
run_diskarbitration_loop();
run_dbus_loop(); run_dbus_loop();
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
......
...@@ -152,6 +152,7 @@ extern void queue_device_op( enum device_op op, const char *udi, const char *dev ...@@ -152,6 +152,7 @@ extern void queue_device_op( enum device_op op, const char *udi, const char *dev
const char *mount_point, enum device_type type, const GUID *guid, const char *mount_point, enum device_type type, const GUID *guid,
const char *disk_serial, const struct scsi_info *info ) DECLSPEC_HIDDEN; const char *disk_serial, const struct scsi_info *info ) DECLSPEC_HIDDEN;
extern void run_dbus_loop(void) DECLSPEC_HIDDEN; extern void run_dbus_loop(void) DECLSPEC_HIDDEN;
extern void run_diskarbitration_loop(void) DECLSPEC_HIDDEN;
extern NTSTATUS dhcp_request( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS dhcp_request( void *args ) DECLSPEC_HIDDEN;
extern NTSTATUS query_symbol_file( void *buff, ULONG insize, ULONG outsize, ULONG *info ) DECLSPEC_HIDDEN; extern NTSTATUS query_symbol_file( void *buff, ULONG insize, ULONG outsize, ULONG *info ) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment