[Wine-patches] [3/5] mountmgr: Add a partial implementation of IOCTL_STORAGE_QUERY_PROPERTY.
Alexander Morozov
=?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Ср Ноя 12 12:45:47 MSK 2008
Ветка eterhack, баг 2581
----------- следующая часть -----------
From f648777fcf16ecc51b561bc131e3e007d9e721ed Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Wed, 12 Nov 2008 11:06:18 +0300
Subject: [PATCH] mountmgr: Add a partial implementation of IOCTL_STORAGE_QUERY_PROPERTY.
---
dlls/mountmgr.sys/device.c | 46 +++++++++++++++++++++++++++++++++++++++--
dlls/mountmgr.sys/diskarb.c | 2 +-
dlls/mountmgr.sys/hal.c | 18 +++++++++++++++-
dlls/mountmgr.sys/mountmgr.c | 3 +-
dlls/mountmgr.sys/mountmgr.h | 2 +-
5 files changed, 64 insertions(+), 7 deletions(-)
diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c
index a448f56..df22caf 100644
--- a/dlls/mountmgr.sys/device.c
+++ b/dlls/mountmgr.sys/device.c
@@ -72,6 +72,7 @@ struct dos_drive
struct mount_point *volume; /* Volume{xxx} mount point */
char *unix_device; /* unix device path */
char *unix_mount; /* unix mount point path */
+ STORAGE_BUS_TYPE bus_type; /* bus type */
};
static struct list drives_list = LIST_INIT(drives_list);
@@ -202,6 +203,7 @@ static NTSTATUS create_disk_device( const char *udi, DWORD type, struct dos_driv
drive->unix_device = NULL;
drive->unix_mount = NULL;
drive->symlink.Buffer = NULL;
+ drive->bus_type = BusTypeUnknown;
if (udi)
{
if (!(drive->udi = HeapAlloc( GetProcessHeap(), 0, strlen(udi)+1 )))
@@ -475,7 +477,7 @@ static void create_drive_devices(void)
/* create a new dos drive */
NTSTATUS add_dos_device( int letter, const char *udi, const char *device,
- const char *mount_point, DWORD type )
+ const char *mount_point, DWORD type, STORAGE_BUS_TYPE bus )
{
struct dos_drive *drive, *next;
@@ -510,6 +512,7 @@ NTSTATUS add_dos_device( int letter, const char *udi, const char *device,
found:
RtlFreeHeap( GetProcessHeap(), 0, drive->unix_device );
drive->unix_device = strdupA( device );
+ drive->bus_type = bus;
set_drive_letter( drive, letter );
set_unix_mount_point( drive, mount_point );
@@ -517,9 +520,9 @@ found:
{
HKEY hkey;
- TRACE( "added device %c: udi %s for %s on %s type %u\n",
+ TRACE( "added device %c: udi %s for %s on %s type %u bus %u\n",
'a' + drive->drive, wine_dbgstr_a(udi), wine_dbgstr_a(device),
- wine_dbgstr_a(mount_point), type );
+ wine_dbgstr_a(mount_point), type, bus );
/* hack: force the drive type in the registry */
if (!RegCreateKeyW( HKEY_LOCAL_MACHINE, drives_keyW, &hkey ))
@@ -633,6 +636,43 @@ static NTSTATUS WINAPI harddisk_ioctl( DEVICE_OBJECT *device, IRP *irp )
case IOCTL_CDROM_READ_TOC:
irp->IoStatus.u.Status = STATUS_INVALID_DEVICE_REQUEST;
break;
+ case IOCTL_STORAGE_QUERY_PROPERTY:
+ {
+ STORAGE_PROPERTY_QUERY *spq;
+ STORAGE_DEVICE_DESCRIPTOR sdd;
+ size_t sdd_size = sizeof(STORAGE_DEVICE_DESCRIPTOR);
+ DWORD len = min( sdd_size, irpsp->Parameters.DeviceIoControl.OutputBufferLength );
+
+ switch (drive->type)
+ {
+ case DRIVE_FIXED:
+ case DRIVE_CDROM:
+ case DRIVE_REMOVABLE_DISK:
+ if (irpsp->Parameters.DeviceIoControl.InputBufferLength
+ < sizeof(STORAGE_PROPERTY_QUERY))
+ {
+ irp->IoStatus.u.Status = STATUS_INVALID_PARAMETER;
+ break;
+ }
+ spq = irp->AssociatedIrp.SystemBuffer;
+ if (spq->PropertyId != StorageDeviceProperty ||
+ spq->QueryType != PropertyStandardQuery)
+ {
+ irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED;
+ break;
+ }
+ RtlZeroMemory( &sdd, sdd_size );
+ sdd.Size = sdd_size;
+ sdd.BusType = drive->bus_type;
+ memcpy( irp->AssociatedIrp.SystemBuffer, &sdd, len );
+ irp->IoStatus.Information = len;
+ irp->IoStatus.u.Status = STATUS_SUCCESS;
+ break;
+ default:
+ irp->IoStatus.u.Status = STATUS_INVALID_DEVICE_REQUEST;
+ }
+ break;
+ }
default:
FIXME( "unsupported ioctl %x\n", irpsp->Parameters.DeviceIoControl.IoControlCode );
irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED;
diff --git a/dlls/mountmgr.sys/diskarb.c b/dlls/mountmgr.sys/diskarb.c
index a469ee6..b89ade9 100644
--- a/dlls/mountmgr.sys/diskarb.c
+++ b/dlls/mountmgr.sys/diskarb.c
@@ -69,7 +69,7 @@ static void appeared_callback( DADiskRef disk, void *context )
TRACE( "got mount notification for '%s' on '%s'\n", device, mount_point );
- add_dos_device( -1, device, device, mount_point, type );
+ add_dos_device( -1, device, device, mount_point, type, BusTypeUnknown );
done:
CFRelease( dict );
}
diff --git a/dlls/mountmgr.sys/hal.c b/dlls/mountmgr.sys/hal.c
index d26f52d..03c21dc 100644
--- a/dlls/mountmgr.sys/hal.c
+++ b/dlls/mountmgr.sys/hal.c
@@ -113,7 +113,9 @@ static void new_device( LibHalContext *ctx, const char *udi )
char *mount_point = NULL;
char *device = NULL;
char *type = NULL;
+ char *bus = NULL;
DWORD drive_type;
+ STORAGE_BUS_TYPE bus_type = BusTypeUnknown;
p_dbus_error_init( &error );
@@ -129,6 +131,19 @@ static void new_device( LibHalContext *ctx, const char *udi )
if (!p_libhal_device_get_property_bool( ctx, parent, "storage.removable", &error ))
goto done;
+ if (!(bus = p_libhal_device_get_property_string( ctx, parent, "storage.bus", &error )))
+ p_dbus_error_free( &error );
+
+ if (bus)
+ {
+ if (!strcmp( bus, "ide" )) bus_type = BusTypeAta;
+ if (!strcmp( bus, "usb" )) bus_type = BusTypeUsb;
+ if (!strcmp( bus, "ieee1394" )) bus_type = BusType1394;
+ if (!strcmp( bus, "scsi" )) bus_type = BusTypeScsi;
+ if (!strcmp( bus, "sata" )) bus_type = BusTypeAta;
+ if (!strcmp( bus, "linux_raid" )) bus_type = BusTypeRAID;
+ }
+
if (!(type = p_libhal_device_get_property_string( ctx, parent, "storage.drive_type", &error )))
p_dbus_error_free( &error ); /* ignore error */
@@ -136,7 +151,7 @@ static void new_device( LibHalContext *ctx, const char *udi )
else if (!strcmp( type, "floppy" )) drive_type = DRIVE_REMOVABLE;
else drive_type = DRIVE_REMOVABLE_DISK; /* FIXME: default to removable */
- add_dos_device( -1, udi, device, mount_point, drive_type );
+ add_dos_device( -1, udi, device, mount_point, drive_type, bus_type );
/* add property watch for mount point */
p_libhal_device_add_property_watch( ctx, udi, &error );
@@ -146,6 +161,7 @@ done:
if (parent) p_libhal_free_string( parent );
if (device) p_libhal_free_string( device );
if (mount_point) p_libhal_free_string( mount_point );
+ if (bus) p_libhal_free_string( bus );
p_dbus_error_free( &error );
}
diff --git a/dlls/mountmgr.sys/mountmgr.c b/dlls/mountmgr.sys/mountmgr.c
index ab9363d..45ca690 100644
--- a/dlls/mountmgr.sys/mountmgr.c
+++ b/dlls/mountmgr.sys/mountmgr.c
@@ -256,7 +256,8 @@ static NTSTATUS define_unix_drive( const void *in_buff, SIZE_T insize )
{
TRACE( "defining %c: dev %s mount %s type %u\n",
letter, debugstr_a(device), debugstr_a(mount_point), input->type );
- return add_dos_device( letter - 'a', NULL, device, mount_point, input->type );
+ return add_dos_device( letter - 'a', NULL, device, mount_point,
+ input->type, BusTypeUnknown );
}
else
{
diff --git a/dlls/mountmgr.sys/mountmgr.h b/dlls/mountmgr.sys/mountmgr.h
index 63e9b75..24e7aa9 100644
--- a/dlls/mountmgr.sys/mountmgr.h
+++ b/dlls/mountmgr.sys/mountmgr.h
@@ -41,7 +41,7 @@ extern void initialize_diskarbitration(void);
/* device functions */
extern NTSTATUS add_dos_device( int letter, const char *udi, const char *device,
- const char *mount_point, DWORD type );
+ const char *mount_point, DWORD type, STORAGE_BUS_TYPE bus );
extern NTSTATUS remove_dos_device( int letter, const char *udi );
extern NTSTATUS query_dos_device( int letter, DWORD *type, const char **device, const char **mount_point );
extern NTSTATUS WINAPI harddisk_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path );
--
1.5.6.5.GIT
Подробная информация о списке рассылки Wine-patches