Jump to content
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
HP.com home

Transition Impacts

Tru64 UNIX Software Transition Kit


» HP STK home
» Home
» Overview
» Tools
» Documentation
» Transition impacts
» Identifier types
» Impact list
» Porting to HP-UX
» Glossary
» Help
» Send us feedback
Site maps
» Tru64 UNIX STK
Content starts here

critical impact:

sysinfo - not available; use the uname and setuname functions (CrUn176)

SEC Impacts

Problem description

The sysinfo function exists on Tru64 UNIX, but not on HP-UX. However, you can use the uname and setuname functions to achieve similar results.

The sysinfo function manages system information strings. It retrieves and sets information relating to the operating system by sending special commands to the kernel.


C/C++ Functionssysinfo        

Old behavior

The sysinfo function is defined for Tru64 UNIX as follows:

long sysinfo(
            int command, 
            char *buf, 
            long count);

where command specifies the commands that manage the system information strings, buf is the buffer used for storage of system information, and count is the size of the buffer pointed to by the buf parameter. Following is a sample use of the sysinfo function:

int foo
char buf[BUF_SIZE];
long ret;
int len = sizeof(buf);
ret = sysinfo(SI_HOSTNAME, buf, len);

This code fragment copies into the buffer the name of the present host machine, typically the hostname or nodename that the machine is recognized by locally. All calls to sysinfo are written in the same manner.

See also

Solution description

Use the uname and setuname functions to achieve similar results.

The correct way for applications to manipulate system information is through calls to uname and setuname. Note that uname and setuname may not behave exactly the same as sysinfo. In particular, a direct replacement is not available for the SI_ARCHITECTURE and SI_SET_SYSNAME command strings.

You must also keep in mind the limit for setuname for a nodename is smaller on HP-UX than SI_HOSTNAME on Tru64 UNIX (see sys/utsname.h). Review your code and applicable manpages for more information on these functions.

Although there is an undocumented sysinfo function on HP-UX, to achieve functionality similar to that on Tru64 UNIX you need to use the HP-UX uname function.

New behavior

There is only one call to issue on HP-UX to retrieve all values. Accessing members of the utsname structure will yield similar results to sysinfo.

void foo
  int ret;
  char namebuf[UTSLEN];
  struct utsname name;

  ret = uname (&name);


Tru64 UNIX sysinfo      HP-UX uname/setuname
SI_HOSTNAME             name.nodename
SI_SYSNAME              name.sysname
SI_MACHINE              name.machine
SI_RELEASE              name.relase
SI_ARCHITECTURE         name.machine
SI_SET_HOSTNAME         setuname(namebuf, sizeof(namebuf)-1); 

See also

Problem summary

classifications source types OS release severity type
SEC C, C++ any HP-UX 11i version critical unavailable
Printable version
Privacy statement Using this site means you accept its terms Feedback to DSPP
© 2007 Hewlett-Packard Development Company, L.P.