Commit a28a3876 authored by Alexandre Julliard's avatar Alexandre Julliard

mountmgr: Specify the drive type as a DWORD instead of a string.

parent f1511803
......@@ -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 );
}
......
......@@ -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 );
......
......@@ -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 );
......
......@@ -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 );
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