locked
How to Match Drive Letter to SCSI ID RRS feed

  • Question

  • We have converted a c++ application that accesses scsi jukebox and scsi optical drives with ASPI to use SPTI.  The application uses the SetupDi calls to find all of the scsi devices and their IDs.  It also calls GetLogicalDriveStrings and GetDriveType to get and display the drive letters assigned by the OS.  What I have not figured out is how to link the drive letters to the scsi ids.  I would like to do this automatically to prevent users from entering mismatched information into the application.

    Thursday, December 2, 2010 3:57 PM

All replies

  • Hi MesaCorp,

    Once you get DevicePathId (that could be scsi style path id), use GetVolumeNameForVolumeMountPoint to find out the volume name, and once you get the volume name you'll be able to get mounting points.

    Wednesday, December 15, 2010 1:50 AM
  • Thanks for your response but I believe I still have a problem.

    Maybe I'm missing something but GetVolumeNameForVolumeMountPoint wants a drive letter, e:\, string for input.  So I fed it the drive letters I've identified as belonging to a removable drive and it returns a volume GUID.  I still don't see how to link the volume GUID to the target id that I have already determined belong to a SCSI optical drive.

    Maybe this will be helpful.  I've listed below the primary calls that I am making and examples of the information that I have gathered from these calls.

    CM_Get_Device_ID
     Get the device instance id
     PCI\VEN_9005&DEV_8017&SUBSYS_00459005&REV_10\5&18FD9575&0&2000E5

    SetupDiGetDeviceRegistryProperty
     Get the adapter id
     PCI\VEN_9005&DEV_8017&SUBSYS_00459005&REV_10

    SetupDiGetClassDevs
     Get the device id
     PCI\VEN_9005&DEV_8017&SUBSYS_00459005&REV_10\5&18FD9575&0&2000E5

    SetupDiGetDeviceInterfaceDetail
     Get the device path
     \\?\pci#ven_9005&dev_8017&subsys_00459005&rev_10#5&18fd9575&0&2000e5#{2accfe60-c130-11d2-b082-00a0c91efb8b}

    DeviceIoControl( hDevice, IOCTL_STORAGE_QUERY_PROPERTY
     Get bus type, max transfer length, max physical pages, and alignment mask

    DeviceIoControl( hDevice, IOCTL_SCSI_GET_INQUIRY_DATA
     Get the initiator bus id, path id, target id, lun, and device claimed

    GetLogicalDriveStrings
    GetDriveType
     determine the removable drive letters

    GetVolumeNameForVolumeMountPoint
     \\?\Volume{f37684ba-f33f-11df-99dd-806e6f6e6963}\

    What I need to be able to do is link the target id, lun, and path id I have from the inquiry call to a specific removable drive letter.

    It appears that the first target id I find will link to the first drive letter I find but I'm leery of assuming that this will always be true.  I'm hoping there is a more concrete way to link target id to drive letter.

     

    Thursday, December 16, 2010 10:29 PM
  • It is possible to use device path id in GetVolumeNameForVolumeMountPoint method. In that case you'll get volume name for your CDROM device. Also please try with/without trailing backslash for the device path id.

    With Regards,
    Mikhail

    Monday, December 20, 2010 8:28 PM