Enumerating and mapping SCSI targets

I'm pretty sure I'm missing something obvious, so if this is a doofus
question, please excuse the doofusness.

I want to enumerate all of the SCSI devices installed in a system, then open
a handle to some of them. It seems easy enough to enum the devices, devcon
provides a good example of using the SetupDiX API to do this. So how do I
open the same handle I would get if I CreatFile("\\.\PhysicalDrive2"),
given that I get back:
SCSI\DISK&VEN_SEAGATE&PROD_ST19171W&REV_0024\5&5745DE6&0&000
from the SetupDiX functions?

Secondly, from either of these identifiers, is there a simple way to map the
SCSI bus, TID, & LUN? It appears that the blob to the right of the last &
in the hardware ID returned from the SetupDiX API encodes this, is there a
better way than that?

Thanks,

Phil

Philip D. Barila
Seagate Technology, LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.

You'd want to open the disk device interface on the devnode that you've
found. That should get you the same handle that you'd get with
\.\physicaldriveN

You can send IOCTL_SCSI_GET_ADDRESS if you want ot get the device
address. You should treat the hardware IDs and device interface names
as opaque and not try to interpret them.

-p

-----Original Message-----
From: Phil Barila [mailto:xxxxx@Seagate.com]
Sent: Wednesday, January 08, 2003 1:11 PM
To: NT Developers Interest List

I'm pretty sure I'm missing something obvious, so if this is a doofus
question, please excuse the doofusness.

I want to enumerate all of the SCSI devices installed in a system, then
open a handle to some of them. It seems easy enough to enum the
devices, devcon provides a good example of using the SetupDiX API to do
this. So how do I open the same handle I would get if I
CreatFile("\\.\PhysicalDrive2"),
given that I get back:
SCSI\DISK&VEN_SEAGATE&PROD_ST19171W&REV_0024\5&5745DE6&0&000
from the SetupDiX functions?

Secondly, from either of these identifiers, is there a simple way to map
the SCSI bus, TID, & LUN? It appears that the blob to the right of the
last & in the hardware ID returned from the SetupDiX API encodes this,
is there a better way than that?

Thanks,

Phil

Philip D. Barila
Seagate Technology, LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.


You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

Peter,

Thanks for the response. Do you mean SetupDiGetDeviceInterfaceDetail and
CreateFile on the returned DevicePath? I thought I was missing something
obvious. It wasn't immediately obvious to me, even after you pointed me at
it, but is that what you had in mind?

Oh yes. I knew that IOCTL. Glad I could put my failing memory on display
for entertainment purposes. Thanks for the reminder.

Phil

Philip D. Barila
Seagate Technology, LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.

"Peter Wieland" wrote in message
news:xxxxx@ntdev...

You'd want to open the disk device interface on the devnode that you've
found. That should get you the same handle that you'd get with
\.\physicaldriveN

You can send IOCTL_SCSI_GET_ADDRESS if you want ot get the device
address. You should treat the hardware IDs and device interface names
as opaque and not try to interpret them.

-p

-----Original Message-----
From: Phil Barila [mailto:xxxxx@Seagate.com]
Sent: Wednesday, January 08, 2003 1:11 PM
To: NT Developers Interest List

I'm pretty sure I'm missing something obvious, so if this is a doofus
question, please excuse the doofusness.

I want to enumerate all of the SCSI devices installed in a system, then
open a handle to some of them. It seems easy enough to enum the
devices, devcon provides a good example of using the SetupDiX API to do
this. So how do I open the same handle I would get if I
CreatFile("\\.\PhysicalDrive2"),
given that I get back:
SCSI\DISK&VEN_SEAGATE&PROD_ST19171W&REV_0024\5&5745DE6&0&000
from the SetupDiX functions?

Secondly, from either of these identifiers, is there a simple way to map
the SCSI bus, TID, & LUN? It appears that the blob to the right of the
last & in the hardware ID returned from the SetupDiX API encodes this,
is there a better way than that?

Thanks,

Phil
--
Philip D. Barila
Seagate Technology, LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.

---
You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

Yep - the device path in the sp_device_interface_detail_data is what I
had in mind.

-p

-----Original Message-----
From: Phil Barila [mailto:xxxxx@Seagate.com]
Sent: Wednesday, January 08, 2003 2:43 PM
To: NT Developers Interest List

Peter,

Thanks for the response. Do you mean SetupDiGetDeviceInterfaceDetail
and CreateFile on the returned DevicePath? I thought I was missing
something obvious. It wasn't immediately obvious to me, even after you
pointed me at it, but is that what you had in mind?

Oh yes. I knew that IOCTL. Glad I could put my failing memory on
display for entertainment purposes. Thanks for the reminder.

Phil

Philip D. Barila
Seagate Technology, LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.

"Peter Wieland" wrote in message
news:xxxxx@ntdev...

You'd want to open the disk device interface on the devnode that you've
found. That should get you the same handle that you'd get with
\.\physicaldriveN

You can send IOCTL_SCSI_GET_ADDRESS if you want ot get the device
address. You should treat the hardware IDs and device interface names
as opaque and not try to interpret them.

-p

-----Original Message-----
From: Phil Barila [mailto:xxxxx@Seagate.com]
Sent: Wednesday, January 08, 2003 1:11 PM
To: NT Developers Interest List

I'm pretty sure I'm missing something obvious, so if this is a doofus
question, please excuse the doofusness.

I want to enumerate all of the SCSI devices installed in a system, then
open a handle to some of them. It seems easy enough to enum the
devices, devcon provides a good example of using the SetupDiX API to do
this. So how do I open the same handle I would get if I
CreatFile("\\.\PhysicalDrive2"),
given that I get back:
SCSI\DISK&VEN_SEAGATE&PROD_ST19171W&REV_0024\5&5745DE6&0&000
from the SetupDiX functions?

Secondly, from either of these identifiers, is there a simple way to map
the SCSI bus, TID, & LUN? It appears that the blob to the right of the
last & in the hardware ID returned from the SetupDiX API encodes this,
is there a better way than that?

Thanks,

Phil
--
Philip D. Barila
Seagate Technology, LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.

---
You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

---
You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

Many thanks,

Phil

“Peter Wieland” wrote in message
news:xxxxx@ntdev…

Yep - the device path in the sp_device_interface_detail_data is what I
had in mind.

-p

> Secondly, from either of these identifiers, is there a simple way to
map the

SCSI bus, TID, & LUN? It appears that the blob to the right of the
last &

Open and send IOCTL_STORAGE_QUERY_PROPERTY.

Max