Operating System - HP-UX
1833777 Members
2356 Online
110063 Solutions
New Discussion

Re: How can I obtain a disk address programmatically (c) knowing only a device file?

 
Wayne R. Clesi
Advisor

How can I obtain a disk address programmatically (c) knowing only a device file?

I have a need to get a disk (or tape or whatever) address knowing only the device file. Currently, I do the brute force (version 2.0) method. I scan each entry in the pstat structure pst_diskinfo table building the "device file" from the information contained in it. If that matches the device file name that I have, then I can get the address.

Problem is alternate links (NIKEs, VA7400's, etc.) are not in the pst_diskinfo table. Since I know the card instance number, etc. from the device file, is there a way to build the address by looking at kernel tables (other then the pst_diskinfo)?

I'm running HPUX 11.0 (don't laugh...).

Any suggestions would be appreciated!

Thanks,

Wayne
To ask for help is not a sign of ignorance or incapability; it is a sign of wisdom, maturity, and competence. -Dave Packard
7 REPLIES 7
Victor Fridyev
Honored Contributor

Re: How can I obtain a disk address programmatically (c) knowing only a device file?

Hi,

Try to look on
ioscan -kfnCdisk
output. You can find the requested information there.

HTH
Entities are not to be multiplied beyond necessity - RTFM
Wayne R. Clesi
Advisor

Re: How can I obtain a disk address programmatically (c) knowing only a device file?

Thanks for the reply, but I was trying to avoid parsing the output from a command.

I was looking for insight as to what C code could be written to scan the tables, etc.

Wayne
To ask for help is not a sign of ignorance or incapability; it is a sign of wisdom, maturity, and competence. -Dave Packard
Geoff Wild
Honored Contributor

Re: How can I obtain a disk address programmatically (c) knowing only a device file?

Well, here's the reverse way:

How to decode those device numbers

e.g 0x1f0d0700

The first 2 hex digits (1fhex - 31decimal) indicate the major device number. Do an lsdev and look for "31". You will find that major block device 31 is SCSI disk. Thus this is a /dev/dsk device node.

The next 2 hex digits (0dhex - 13 decimal) indicate the bus "instance" number or controller number; "c13" in this case.

The next hex digit (0) indicates the SCSI ID or target. "t0" in this case.

The next hex digit (7) indicates the LUN (d7) in this case.

The remaining 2 hex digits are device driver specific.

In summary, 0x1f0d0700 decodes to
/dev/dsk/c13t0d7.

Don't know if that will help or not...

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Wayne R. Clesi
Advisor

Re: How can I obtain a disk address programmatically (c) knowing only a device file?

Yes, I actually knew that. In fact, I have a PERL script that breaks that down for me (I use it when I get LVM error messages).

Thanks for the reply!

Wayne
To ask for help is not a sign of ignorance or incapability; it is a sign of wisdom, maturity, and competence. -Dave Packard
Bill Hassell
Honored Contributor

Re: How can I obtain a disk address programmatically (c) knowing only a device file?

If you need the actual hardware path (such as 8/0.2.1), you'll need to use the lssf command. The reason is that an instance is mapped to a physical address when the device file is created and only the kernel knows the physical mapping.


Bill Hassell, sysadmin
Wayne R. Clesi
Advisor

Re: How can I obtain a disk address programmatically (c) knowing only a device file?

...and there is no way to get to those kernel structures?

Wayne
To ask for help is not a sign of ignorance or incapability; it is a sign of wisdom, maturity, and competence. -Dave Packard
Wayne R. Clesi
Advisor

Re: How can I obtain a disk address programmatically (c) knowing only a device file?

I have found, what I think, is a solution. As I mentioned before, I scan the pstat pst_diskinfo tables. The problem was that not all device files were included (probably because they weren't used in a while...just a guess). Anyway, I discovered that if I open the device file BEFORE I scan the pst_diskinfo table, then the device file is added.

Thanks to all who answered. Points have been assigned to all who answered in recognition of your effort.

Bill, I wasn't being obnoxious with my last reply. I come from a mainframe world where everything in the system is available to authorized users. The control blocks (structures) are not always documented, but, having access to the code solves that problem. It's a little difficult adjusting, even after 10 years, to a world where the sys admin is supposed to just "trust" the OS.

Take care and thanks again!

Wayne
To ask for help is not a sign of ignorance or incapability; it is a sign of wisdom, maturity, and competence. -Dave Packard