Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1317
  • Last Modified:

how to get the port number of the SCSI Host based adapter on my system?


I have two SAS host based adapters on my system. i want to fire an IOCTL on the miniport driver for these adapters to find out some hardware specific details.

To be able to fire an IOCTL, i need to create a handle for these scsi adapters using createFile function. While doing this, i need to prepare the file name is \\.\scsiN, where N stands for the  number of the SCSI adapter.

Is there anyway to determine N (the number of the SCSI adapter) directly here instead of starting with 0 iterating until my IOCTL on the minport succeeds?

I have a way to do it when i have some SCSI drives connected to the HBAs. I will fire an IOCTL with the control code IOCTL_SCSI_GET_ADDRESS on to one of the drives connected to the HBA and in return i will get a SCSI_ADDRESS structure for the SCSI disk. This structure contains the port number of the disk, which is same as the controller number.

But i don't want to do this because i want to be able to fire the IOCTL on the miniport even when the disks are not connected.

Please let me know if anybody can help.
1 Solution
I've always actually scanned. If you don't, then you won't be able to detect devices that aren't attached (i.e, have no drive letter associated with them, or they aren't part of a software RAID set; or you haven't run a diskpart rescan yet)

So 1)  do a loop opening \\.\SCSIn  (I go from 0-15)
Then 2) use the IOCTL as you described.

* Don't make the assumption that every attached device is going to be a SCSI device type 0.  

* Also be aware of SATA disks attached to SAS controllers.  While the standard SCSI pass-through IOCTLS will work, you will get an emulated target and you have to use vendor/product specific code to do even basic things like get the correct make/model/serial number of the target device.  That is because in SCSI world, the Vendor / Product IDs are 8/16 bytes respectively, and the serial number can be on EVPD page 80, or 83, or sometimes somewhere else.

But on SATA devices, you have a fixed 40-byte MAKE/MODEL field, and I think 20 bytes for serial number.  Something always gets lost in the translation.

* Unless you have control over the hardware, then also be aware of iSCSI target devices, and hardware RAID devices.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now