[Wine-patches] [eterhack] mountmgr: Fix registering USBSTOR device when UDisks2 is used (eterbug #6508).
Alexander Morozov
amorozov на etersoft.ru
Пт Июн 22 19:41:23 MSK 2012
---
dlls/mountmgr.sys/dbus.c | 57 +++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 54 insertions(+), 3 deletions(-)
diff --git a/dlls/mountmgr.sys/dbus.c b/dlls/mountmgr.sys/dbus.c
index 38f3cd7..9b9856c 100644
--- a/dlls/mountmgr.sys/dbus.c
+++ b/dlls/mountmgr.sys/dbus.c
@@ -426,10 +426,14 @@ static const char *udisks2_string_from_array( DBusMessageIter *iter )
/* find the drive entry in the dictionary and get its parameters */
static void udisks2_get_drive_info( const char *drive_name, DBusMessageIter *dict,
- enum device_type *drive_type, int *removable )
+ enum device_type *drive_type, int *removable,
+ STORAGE_BUS_TYPE *bus_type, const char **vendor,
+ const char **product, const char **revision,
+ const char **serial )
{
DBusMessageIter iter, drive, variant;
const char *name;
+ const char *bus = NULL;
p_dbus_message_iter_recurse( dict, &iter );
while ((name = udisks_next_dict_entry( &iter, &drive )))
@@ -444,11 +448,45 @@ static void udisks2_get_drive_info( const char *drive_name, DBusMessageIter *dic
p_dbus_message_iter_get_basic( &variant, removable );
else if (!strcmp( name, "MediaCompatibility" ))
*drive_type = udisks_parse_media_compatibility( &variant );
+ else if (!strcmp( name, "Vendor" ))
+ p_dbus_message_iter_get_basic( &variant, vendor );
+ else if (!strcmp( name, "Model" ))
+ p_dbus_message_iter_get_basic( &variant, product );
+ else if (!strcmp( name, "Revision" ))
+ p_dbus_message_iter_get_basic( &variant, revision );
+ else if (!strcmp( name, "Serial" ))
+ p_dbus_message_iter_get_basic( &variant, serial );
+ else if (!strcmp( name, "ConnectionBus" ))
+ {
+ p_dbus_message_iter_get_basic( &variant, &bus );
+ if (bus && !strcmp( bus, "usb" ))
+ *bus_type = BusTypeUsb;
+ }
}
}
}
}
+static void get_usbdev_nums_from_devname( const char *devname, int *bus_num, int *dev_num )
+{
+ static const char sys_block[] = "/sys/class/block";
+ const char *dev;
+ char *sys_path;
+
+ dev = strrchr( devname, '/' );
+ if (dev)
+ {
+ sys_path = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(sys_block) + strlen(dev) );
+ if (sys_path)
+ {
+ strcpy( sys_path, sys_block );
+ strcat( sys_path, dev );
+ get_usbdev_nums( sys_path, bus_num, dev_num );
+ RtlFreeHeap( GetProcessHeap(), 0, sys_path );
+ }
+ }
+}
+
static void udisks2_add_device( const char *udi, DBusMessageIter *dict, DBusMessageIter *block )
{
DBusMessageIter iter, variant, paths, string;
@@ -460,6 +498,12 @@ static void udisks2_add_device( const char *udi, DBusMessageIter *dict, DBusMess
const char *iface, *name;
int removable = FALSE;
enum device_type drive_type = DEVICE_UNKNOWN;
+ const char *vendor = NULL;
+ const char *product = NULL;
+ const char *revision = NULL;
+ const char *serial = NULL;
+ STORAGE_BUS_TYPE bus_type = BusTypeUnknown;
+ int usb_bus = 0, usb_addr = 0;
if (automount_disabled())
return;
@@ -486,13 +530,17 @@ static void udisks2_add_device( const char *udi, DBusMessageIter *dict, DBusMess
while ((name = udisks_next_dict_entry( &iter, &variant )))
{
if (!strcmp( name, "Device" ))
+ {
device = udisks2_string_from_array( &variant );
+ get_usbdev_nums_from_devname( device, &usb_bus, &usb_addr );
+ }
else if (!strcmp( name, "IdType" ))
p_dbus_message_iter_get_basic( &variant, &type );
else if (!strcmp( name, "Drive" ))
{
p_dbus_message_iter_get_basic( &variant, &drive );
- udisks2_get_drive_info( drive, dict, &drive_type, &removable );
+ udisks2_get_drive_info( drive, dict, &drive_type, &removable, &bus_type,
+ &vendor, &product, &revision, &serial );
}
else if (!strcmp( name, "IdUUID" ))
{
@@ -521,10 +569,13 @@ static void udisks2_add_device( const char *udi, DBusMessageIter *dict, DBusMess
drive_type = DEVICE_DVD;
}
}
+ if (bus_type == BusTypeUsb && drive_type == DEVICE_UNKNOWN)
+ drive_type = DEVICE_HARDDISK;
if (device)
{
if (removable) add_dos_device( -1, udi, device, mount_point, drive_type, guid_ptr,
- BusTypeUnknown, NULL, NULL, NULL, NULL, 0, 0 );
+ bus_type, vendor, product, revision, serial,
+ usb_bus, usb_addr );
else if (guid_ptr) add_volume( udi, device, mount_point, DEVICE_HARDDISK_VOL, guid_ptr );
}
}
--
1.7.10.5
Подробная информация о списке рассылки Wine-patches