Module: wine Branch: master Commit: a28a387615256f7831249f55895290837f17d8e8 URL: http://source.winehq.org/git/wine.git/?a=commit;h=a28a387615256f7831249f5589...
Author: Alexandre Julliard julliard@winehq.org Date: Wed Oct 15 20:12:27 2008 +0200
mountmgr: Specify the drive type as a DWORD instead of a string.
---
dlls/mountmgr.sys/device.c | 37 +++++++++++++++++++++++++++---------- dlls/mountmgr.sys/diskarb.c | 4 ++-- dlls/mountmgr.sys/hal.c | 6 +++++- dlls/mountmgr.sys/mountmgr.h | 2 +- 4 files changed, 35 insertions(+), 14 deletions(-)
diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c index 0435f35..0260b5f 100644 --- a/dlls/mountmgr.sys/device.c +++ b/dlls/mountmgr.sys/device.c @@ -35,10 +35,22 @@
#include "wine/library.h" #include "wine/list.h" +#include "wine/unicode.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(mountmgr);
+static const WCHAR drive_types[][8] = +{ + { 0 }, /* DRIVE_UNKNOWN */ + { 0 }, /* DRIVE_NO_ROOT_DIR */ + {'f','l','o','p','p','y',0}, /* DRIVE_REMOVABLE */ + {'h','d',0}, /* DRIVE_FIXED */ + {'n','e','t','w','o','r','k',0}, /* DRIVE_REMOTE */ + {'c','d','r','o','m',0}, /* DRIVE_CDROM */ + {'r','a','m','d','i','s','k',0} /* DRIVE_RAMDISK */ +}; + struct dos_drive { struct list entry; @@ -87,7 +99,7 @@ static inline int is_valid_device( struct stat *st ) }
/* find or create a DOS drive for the corresponding device */ -static int add_drive( const char *device, const char *type ) +static int add_drive( const char *device, DWORD type ) { char *path, *p; char in_use[26]; @@ -103,7 +115,7 @@ static int add_drive( const char *device, const char *type )
first = 2; last = 26; - if (type && !strcmp( type, "floppy" )) + if (type == DRIVE_REMOVABLE) { first = 0; last = 2; @@ -186,7 +198,7 @@ static BOOL set_mount_point( struct dos_drive *drive, const char *mount_point ) }
BOOL add_dos_device( const char *udi, const char *device, - const char *mount_point, const char *type ) + const char *mount_point, DWORD type ) { struct dos_drive *drive;
@@ -213,17 +225,22 @@ found:
set_mount_point( drive, mount_point );
- TRACE( "added device %c: udi %s for %s on %s type %s\n", + TRACE( "added device %c: udi %s for %s on %s type %u\n", '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), type );
/* hack: force the drive type in the registry */ if (!RegCreateKeyA( HKEY_LOCAL_MACHINE, "Software\Wine\Drives", &hkey )) { - char name[3] = "a:"; + const WCHAR *type_name = drive_types[type]; + WCHAR name[3] = {'a',':',0}; + name[0] += drive->drive; - if (!type || strcmp( type, "cdrom" )) type = "floppy"; /* FIXME: default to floppy */ - RegSetValueExA( hkey, name, 0, REG_SZ, (const BYTE *)type, strlen(type) + 1 ); + if (type_name[0]) + RegSetValueExW( hkey, name, 0, REG_SZ, (const BYTE *)type_name, + (strlenW(type_name) + 1) * sizeof(WCHAR) ); + else + RegDeleteValueW( hkey, name ); RegCloseKey( hkey ); }
@@ -248,9 +265,9 @@ BOOL remove_dos_device( const char *udi ) /* clear the registry key too */ if (!RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\Wine\Drives", &hkey )) { - char name[3] = "a:"; + WCHAR name[3] = {'a',':',0}; name[0] += drive->drive; - RegDeleteValueA( hkey, name ); + RegDeleteValueW( hkey, name ); RegCloseKey( hkey ); }
diff --git a/dlls/mountmgr.sys/diskarb.c b/dlls/mountmgr.sys/diskarb.c index d5f3d61..4f18d52 100644 --- a/dlls/mountmgr.sys/diskarb.c +++ b/dlls/mountmgr.sys/diskarb.c @@ -47,7 +47,7 @@ static void appeared_callback( DADiskRef disk, void *context ) const void *ref; char device[64]; char mount_point[PATH_MAX]; - const char *type = NULL; + DWORD type = DRIVE_UNKNOWN;
if (!dict) return;
@@ -69,7 +69,7 @@ static void appeared_callback( DADiskRef disk, void *context ) { if (!CFStringCompare( ref, CFSTR("cd9660"), 0 ) || !CFStringCompare( ref, CFSTR("udf"), 0 )) - type = "cdrom"; + type = DRIVE_CDROM; }
TRACE( "got mount notification for '%s' on '%s'\n", device, mount_point ); diff --git a/dlls/mountmgr.sys/hal.c b/dlls/mountmgr.sys/hal.c index 615edf0..c1d6e70 100644 --- a/dlls/mountmgr.sys/hal.c +++ b/dlls/mountmgr.sys/hal.c @@ -117,6 +117,7 @@ static void new_device( LibHalContext *ctx, const char *udi ) char *mount_point = NULL; char *device = NULL; char *type = NULL; + DWORD drive_type;
p_dbus_error_init( &error );
@@ -135,7 +136,10 @@ static void new_device( LibHalContext *ctx, const char *udi ) if (!(type = p_libhal_device_get_property_string( ctx, parent, "storage.drive_type", &error ))) p_dbus_error_free( &error ); /* ignore error */
- add_dos_device( udi, device, mount_point, type ); + if (type && !strcmp( type, "cdrom" )) drive_type = DRIVE_CDROM; + else drive_type = DRIVE_REMOVABLE; /* FIXME: default to removable */ + + add_dos_device( udi, device, mount_point, drive_type );
/* add property watch for mount point */ p_libhal_device_add_property_watch( ctx, udi, &error ); diff --git a/dlls/mountmgr.sys/mountmgr.h b/dlls/mountmgr.sys/mountmgr.h index 1e1ce85..2d34624 100644 --- a/dlls/mountmgr.sys/mountmgr.h +++ b/dlls/mountmgr.sys/mountmgr.h @@ -21,5 +21,5 @@ 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 ); + const char *mount_point, DWORD type ); extern BOOL remove_dos_device( const char *udi );