Operating System - HP-UX
1837035 Members
3080 Online
110111 Solutions
New Discussion

Re: How do I programmatically get the hardware address for a SCSI device?

 
Philip A. Reyniers
Occasional Advisor

How do I programmatically get the hardware address for a SCSI device?

I have a C++ program that obtains information about all the SCSI devices installed on a given 11.x server. However, I need to obtain the physical hardware address for a given device using C/C++. Now, I am not referring to using CSTM or ioscan, I am looking for a method of getting the physical hardware address ( i.e. 10/0/14/0.0.0 ) from the device name ( i.e. /dev/rdsk/c0t0d0 ).

Thanks in advance to all that reply.

Philip A. Reyniers

 

P.S. This thread has been moved from Disk to HP-UX > languages. -HP Forum Moderator

If it is not broken leave it alone, if you have time try to improve it, and if you do not care then get another job.
6 REPLIES 6
David Ruska
Honored Contributor

Re: How do I programmatically get the hardware address for a SCSI device?


What's wrong with using the output of ioscan?

e.g.

# ioscan -Cdisk -fnk
Class I H/W Path Driver S/W State H/W Type Description
======================================================================
disk 0 10/0.5.0 sdisk CLAIMED DEVICE Quantum XP34361WD
/dev/dsk/c0t5d0 /dev/rdsk/c0t5d0
disk 1 10/0.6.0 sdisk CLAIMED DEVICE Quantum XP34361WD
/dev/dsk/c0t6d0 /dev/rdsk/c0t6d0
disk 2 10/12/5.2.0 sdisk CLAIMED DEVICE TOSHIBA CD-ROM XM-5401TA
/dev/dsk/c4t2d0 /dev/rdsk/c4t2d0
#
#
The journey IS the reward.
Philip A. Reyniers
Occasional Advisor

Re: How do I programmatically get the hardware address for a SCSI device?

First, it is a C++ program not a shell program, where I would want to run additional system processes at the additional cost and overhead. Second, I am at a point in the code that I have been able to programmatically replicate the functionality of diskinfo with added information. A recent benchmark I was able to process 65 scsi device files in 2.2 seconds. Try that with diskinfo. Finally, the code MUST be standardized, clean, have low impact, and run in the shortest amount of time.
If it is not broken leave it alone, if you have time try to improve it, and if you do not care then get another job.
Julian Perez_1
Valued Contributor

Re: How do I programmatically get the hardware address for a SCSI device?

Hello,

I think is not possible to perform this task, because c0t0d0 comes from last 3 numbers in hard path. I mean that 10/0/14/3.2.4 = c3t2d4. It's only an example.

10/0/14 depends on server bus architecture, SCSI or FC card slot, partition number if hard partitions are used, and another tips that are not showed in disk device file.

I know is not the best solution, but you can have a fast ioscan with

# ioscan -kfnC disk (info from kernel)

Maybe you can include a litle script at boot time, including:

# ioscan -kfnCdisk > diskinfo.txt

And then you can work with this text file from your application.

It's only an idea.

Have nice day and best regards,

Julian


Keep the faith
John Hall
Frequent Advisor

Re: How do I programmatically get the hardware address for a SCSI device?

Use "lssf /dev/rdsk/c0t0d0"
Philip Kernohan
Advisor

Re: How do I programmatically get the hardware address for a SCSI device?

Philip,

apologies for not having direct experience of using this command but can 'ioconfig' assist you?

Check 'man ioconfig' for more details. Please let us know if this helps otherwise John's idea of lssf looks good.

Regards,
PK
It's nice to be important but it's more important to be nice
Pruthviraj HP
Occasional Advisor

Re: How do I programmatically get the hardware address for a SCSI device?

Hi,

The simplest thing for you to do would be (provided your C++ program sits above the file system) use the ioconfig file and read the records using the "union ioconfig_record", the "ioconfig_t" member of this has hw_path_t hw_path and "dyn_major_t" member has driver major numbers.