Operating System - HP-UX
1820475 Members
2847 Online
109624 Solutions
New Discussion юеВ

How to get hardware configuration info from inside a C program?

 
Andre Ladeira
New Member

How to get hardware configuration info from inside a C program?

Hi,

I need to get info about the hardware configuration (just like the data returned from ioscan )from inside a C/C++ program.I can't use system commands from inside the program as it can cause blocking issues. I think that there are two ways to get this infomation, one using some ioctl() call on the device drivers in /dev and other reading the data directly from some kernel table (called iotree i guess), but I can't find any documentation about this at all.

Does anyone know how I can get this info? Any info or ideas on this would be much appreciated.

Thanks,
Andr?
2 REPLIES 2
A. Clay Stephenson
Acclaimed Contributor

Re: How to get hardware configuration info from inside a C program?

Hi Andre:

Rather than doing ioctls for all of the various devices and thus having to branch on each major device, I suggest that you indeed do an ioscan from within a pipe but include an alarm signal handler using setjmp and longjump to jump out out the ioscan call. You can also get some pretty good ideas if you look at /usr/sam/lib/ioparser.sh. I attached a sample piece of code that includes the setjmp stuff. I already had a standard function that was very close.

Clay
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: How to get hardware configuration info from inside a C program?

Hi Andre:

Rather than doing ioctls for all of the various devices and thus having to branch on each major device, I suggest that you indeed do an ioscan from within a pipe but include an alarm signal handler using setjmp and longjump to jump out out the ioscan call. You can also get some pretty good ideas if you look at /usr/sam/lib/ioparser.sh. I attached a sample piece of code that includes the setjmp stuff. I already had a standard function that was very close.

Clay
If it ain't broke, I can fix that.