[PATCH 2/2] mountmgr: Populate HKLM\HARDWARE\DEVICEMAP\Scsi on Mac OS. (try 2)
Charles Davis
cdavis at mymail.mines.edu
Mon May 9 08:42:36 CDT 2011
Try 2: Get the device name from mountmgr instead of making one up.
---
dlls/mountmgr.sys/diskarb.c | 61 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 60 insertions(+), 1 deletions(-)
diff --git a/dlls/mountmgr.sys/diskarb.c b/dlls/mountmgr.sys/diskarb.c
index 9e3cd28..e381797 100644
--- a/dlls/mountmgr.sys/diskarb.c
+++ b/dlls/mountmgr.sys/diskarb.c
@@ -26,6 +26,9 @@
#include <stdarg.h>
#include <stdio.h>
#include <sys/time.h>
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
#include "mountmgr.h"
#include "wine/debug.h"
@@ -36,14 +39,30 @@ WINE_DEFAULT_DEBUG_CHANNEL(mountmgr);
#include <DiskArbitration/DiskArbitration.h>
+typedef struct
+{
+ uint64_t bus;
+ uint64_t port;
+ uint64_t target;
+ uint64_t lun;
+} dk_scsi_identify_t;
+
+#define DKIOCSCSIIDENTIFY _IOR('d', 254, dk_scsi_identify_t)
+
static void appeared_callback( DADiskRef disk, void *context )
{
CFDictionaryRef dict = DADiskCopyDescription( disk );
const void *ref;
char device[64];
char mount_point[PATH_MAX];
+ char model[64];
+ size_t model_len = 0;
GUID guid, *guid_ptr = NULL;
enum device_type type = DEVICE_UNKNOWN;
+ UINT pdtype = 0;
+ SCSI_ADDRESS scsi_addr;
+ UNICODE_STRING devname;
+ int fd;
if (!dict) return;
@@ -67,22 +86,62 @@ static void appeared_callback( DADiskRef disk, void *context )
if ((ref = CFDictionaryGetValue( dict, CFSTR("DAMediaKind") )))
{
if (!CFStringCompare( ref, CFSTR("IOCDMedia"), 0 ))
+ {
type = DEVICE_CDROM;
+ pdtype = 5;
+ }
if (!CFStringCompare( ref, CFSTR("IODVDMedia"), 0 ) ||
!CFStringCompare( ref, CFSTR("IOBDMedia"), 0 ))
+ {
type = DEVICE_DVD;
+ pdtype = 5;
+ }
if (!CFStringCompare( ref, CFSTR("IOMedia"), 0 ))
type = DEVICE_HARDDISK;
}
+ if ((ref = CFDictionaryGetValue( dict, CFSTR("DADeviceVendor") )))
+ {
+ CFStringGetCString( ref, model, sizeof(model), kCFStringEncodingASCII );
+ model_len += CFStringGetLength( ref );
+ model[model_len++] = ' ';
+ }
+ if ((ref = CFDictionaryGetValue( dict, CFSTR("DADeviceModel") )))
+ {
+ CFStringGetCString( ref, model+model_len, sizeof(model)-model_len, kCFStringEncodingASCII );
+ model_len += CFStringGetLength( ref );
+ model[model_len++] = ' ';
+ }
+ if ((ref = CFDictionaryGetValue( dict, CFSTR("DADeviceRevision") )))
+ CFStringGetCString( ref, model+model_len, sizeof(model)-model_len, kCFStringEncodingASCII );
+
TRACE( "got mount notification for '%s' on '%s' uuid %s\n",
device, mount_point, wine_dbgstr_guid(guid_ptr) );
+ devname.Buffer = NULL;
if ((ref = CFDictionaryGetValue( dict, CFSTR("DAMediaRemovable") )) && CFBooleanGetValue( ref ))
- add_dos_device( -1, device, device, mount_point, type, guid_ptr, NULL );
+ add_dos_device( -1, device, device, mount_point, type, guid_ptr, &devname );
else
if (guid_ptr) add_volume( device, device, mount_point, DEVICE_HARDDISK_VOL, guid_ptr );
+ if ((fd = open( device, O_RDONLY )) >= 0)
+ {
+ dk_scsi_identify_t dsi;
+
+ if (ioctl( fd, DKIOCSCSIIDENTIFY, &dsi ) >= 0)
+ {
+ scsi_addr.PortNumber = dsi.bus;
+ scsi_addr.PathId = dsi.port;
+ scsi_addr.TargetId = dsi.target;
+ scsi_addr.Lun = dsi.lun;
+
+ /* FIXME: get real controller Id for SCSI */
+ /* FIXME: get real driver name */
+ create_scsi_entry( &scsi_addr, 255, "WINE SCSI", pdtype, model, &devname, device );
+ }
+ close( fd );
+ }
+
done:
CFRelease( dict );
}
--
1.7.3.4
More information about the wine-patches
mailing list