cancel
Showing results for 
Search instead for 
Did you mean: 

HPUX 11.31 uname issue

shirish11
Advisor

HPUX 11.31 uname issue

I set the uname -S pc123456789 as name and whe i see uname -n

it just shows pc123456 only so my application which uses uname function it also fail?

any workaround on this .

Waiting for reply.
Thanks
10 REPLIES
kemo
Trusted Contributor

Re: HPUX 11.31 uname issue

node name has limitation in lenght, only the 1st 8 characters will be taken.
shirish11
Advisor

Re: HPUX 11.31 uname issue

Hi ,I dont get any where in the doc like node name is of 8 characters.
can you please give me the doc id of HP UX
Thanks
kemo
Trusted Contributor

Re: HPUX 11.31 uname issue

Hello Dear

From the MAN pages of uname(1):

Change the node name (system name) to nodename.
nodename is restricted to UTSLEN-1 characters (see uname(2)). See WARNINGS. Only users with appropriate privileges can use the -S option.

from the MAN pages of uname(2):

The utsname structure, defined in , is set up as
follows:

#define UTSLEN 9
#define SNLEN 15

char sysname[UTSLEN];
char nodename[UTSLEN];

_______________________________________



> setuname()
The setuname() system call sets the node name (system name), as returned in the nodename field of the utsname structure, to name, which has a length of namelen characters. This is usually executed by /sbin/init.d/hostname at system boot time. Names are limited to UTSLEN - 1 characters; UTSLEN is defined in .

thanks
Pete Randall
Outstanding Contributor

Re: HPUX 11.31 uname issue

See this thread for an extended, and detailed discussion of nodename/hostname/uname and the associated rules:

http://h30499.www3.hp.com/t5/System-Administration/hostname-and-nodename/m-p/3788510#M264534

Pete


Pete
kemo
Trusted Contributor

Re: HPUX 11.31 uname issue

Note:

in HPUX v3

# define UTSLEN _SYS_NMLN

And UMLN value

#define __SYS_NMLN_V1 9

the nodename length = UTSLEN-1 = 8.
Dennis Handly
Acclaimed Contributor

Re: HPUX 11.31 uname issue

>I set the uname -S pc123456789 as name and when I see uname -n, it just shows pc123456 only so my application which uses uname function it also fail?

Yes, you'll get EOVERFLOW if longer than 8. Unless you compile it with the special options.
shirish11
Advisor

Re: HPUX 11.31 uname issue

Hi ,
my utsname.h file is like this .....
/*
* BEGIN_DESC
*
* Copyright (c) 1996-2004 Hewlett-Packard Development Company, LP
*
* File:
* @(#)B.11.31_LR common/sys/utsname.h $Revision: $
*
* Purpose:
* Definitions for uname(2) and setuname(2)
*
* Classification: Release to Release Consistency Req:
* public binary & source
*
* BE header: yes
*
* Shipped: yes
* /usr/include/sys/utsname.h
* /usr/conf/sys/utsname.h
*
* END_DESC
*/

#ifndef _SYS_UTSNAME_INCLUDED
#define _SYS_UTSNAME_INCLUDED

#include

#define __SYS_NMLN_V2 257
#define __SYS_NMLN_V1 9
#define __SNLEN_V2 257
#define __SNLEN_V1 15

#define __UTSNAME_VERSION_V2_ATTR _HPUX_API_VERS_20040821_ATTR

#define _UTSNAME_COMMON_FIELDS(_nmln, _snlen) \
char sysname[_nmln]; \
char nodename[_nmln]; \
char release[_nmln]; \
char version[_nmln]; \
char machine[_nmln]; \
char __idnumber[_snlen];

#define _UTSNAME_EXTENDED_FIELDS(_nmln) \
char __domainname[_nmln]; \
char __reserved1[_nmln];

#ifdef _INCLUDE_HPUX_SOURCE

struct utsname_hpux_v1 {
_UTSNAME_COMMON_FIELDS(__SYS_NMLN_V1, __SNLEN_V1)
};
#endif /* _INCLUDE_HPUX_SOURCE */

#if (_INCLUDE_HPUX_API_LEVEL < 20040821)

#define _SYS_NMLN __SYS_NMLN_V1
#define _SNLEN __SNLEN_V1
#define __UNAME_VERSION_ATTR

struct utsname {
_UTSNAME_COMMON_FIELDS(__SYS_NMLN_V1, __SNLEN_V1)
};

#else /* _INCLUDE_HPUX_API_LEVEL >= 20040821 */

#define _SYS_NMLN __SYS_NMLN_V2
#define _SNLEN __SNLEN_V2
#define __UNAME_VERSION_ATTR __UTSNAME_VERSION_V2_ATTR

struct __UTSNAME_VERSION_V2_ATTR utsname {
_UTSNAME_COMMON_FIELDS(__SYS_NMLN_V2, __SNLEN_V2)
_UTSNAME_EXTENDED_FIELDS(__SYS_NMLN_V2)
};

#endif /* _INCLUDE_HPUX_API_LEVEL >= 20040821 */

#ifdef _INCLUDE_HPUX_SOURCE
# define SYS_NMLN _SYS_NMLN
# define UTSLEN _SYS_NMLN
# define SNLEN _SNLEN
# define idnumber __idnumber
# define domainname __domainname
#endif /* _INCLUDE_HPUX_SOURCE */

#ifndef _NO_USER_PROTOS
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */




By default _INCLUDE_HPUX_SOURCE is only defined and if we have to change it then how to change it? i am seeing the __SYS_NMLN_V2 257 also so how to use this one..

my uname -a
uname -a
HP-UX pumass00 B.11.31 U ia64 1883224899 unlimited-user license


Dennis Handly
Acclaimed Contributor

Re: HPUX 11.31 uname issue

>if we have to change it then how to change it? I am seeing the __SYS_NMLN_V2 257 also so how to use this one.

You should not be looking at utsname.h to figure out how to program. You should be looking at the thread and documentation that Pete mentioned. Are you prepared to recompile every application that calls uname(2)?

See expanded_node_host_names(5):
http://h20000.www2.hp.com/bc/docs/support/SupportManual/c02254938/c02254938.pdf

>HP-UX pumass00 B.11.31 U ia64 1883224899

If your nodename is > 8, uname(1) doesn't check for errors.
shirish11
Advisor

Re: HPUX 11.31 uname issue

Thank you
Manix
Honored Contributor

Re: HPUX 11.31 uname issue