[PATCH 2/2] mountmgr: Populate HKLM\HARDWARE\DEVICEMAP\Scsi on Mac OS.

Charles Davis cdavis at mymail.mines.edu
Fri Apr 22 08:52:56 CDT 2011


---
 dlls/mountmgr.sys/diskarb.c |   58 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/dlls/mountmgr.sys/diskarb.c b/dlls/mountmgr.sys/diskarb.c
index d3912ca..2068c46 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,29 @@ 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;
+    int fd;
 
     if (!dict) return;
 
@@ -67,14 +85,54 @@ 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 );
+
+    
+    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, device );
+        }
+        close( fd );
+    }
+
     TRACE( "got mount notification for '%s' on '%s' uuid %s\n",
            device, mount_point, wine_dbgstr_guid(guid_ptr) );
 
-- 
1.7.5.rc1




More information about the wine-patches mailing list