1830979 Members
2015 Online
110018 Solutions
New Discussion

Re: CS_PARTITION_IDENT

 
tatry
Occasional Contributor

CS_PARTITION_IDENT

Hello,

I tried to find the structure of the field CS_PARTITION_IDENT used in getconf but I found nothing.
The only thing I have is that CS_PARTITION_IDENT is an opaque string of printable ascii characters not to exceed 64 bytes including the string terminator.

Somebody know the maximum lenght of this field ?

Regards,
Lionel
2 REPLIES 2
TwoProc
Honored Contributor

Re: CS_PARTITION_IDENT

Well, I don't know where you got that information above (opaque string of printable ascii characters not to exceed 64 bytes including the string terminator), but if you read it - it means that it is a character string 64 bytes long, with a null terminator at the end. This means you have up to 63 bytes you can put into it, and you must make sure that an 8 bit value of zero is the very last thing at the end of your string. Funny though, I don't find that CS_PARTITION_IDENT is a string. Grep'ing through the /usr/conf/sys/*.h files, I found the following definition:
# define _CS_PARTITION_IDENT 10004 /* Partition Identifier */

This is in the unistd.h file, under a section titled:
/* Symbolic constants for confstr() defined by HP-UX: 10000-19999 */

Going a little further with this, a man on confstr() yields:
DESCRIPTION
confstr() provides a method for applications to get configuration-
defined string values. Its use and purpose are similar to sysconf()
(see sysconf(2)), except that it is used where string values rather
than numeric values are returned.

The function prototype to confstr is:
size_t confstr(int name, char *buf, size_t len);

The first argument "name" is actually an integer, and that's where you would pass the value "_CS_PARTITION_IDENT" which will be replaced with the value 10004 (by the precompiler). The next argument will return to YOU a pointer to buffer already malloc'd for you, and the last argument (len) will return you a length of how long the string is.

I hope I went the right direction with this information, and don't get your off track, but I can find no other information on "CS_PARTITION_IDENT", which looks to me like a constant integer, not a fixed length string variable.
We are the people our parents warned us about --Jimmy Buffett
Dietmar Konermann
Honored Contributor

Re: CS_PARTITION_IDENT

Lionel,

the man page contains an example how to work with confstr()... it is recommended to first ask for the buffer size before actually retrieving the value. This is more flexible, instead of using 64 bytes fixed.

e.g.:

#include
#include

size_t bufsize;
char *buffer;

bufsize=confstr(_CS_PARTITION_IDENT,NULL,(size_t)0);
buffer=(char *)malloc(bufsize);
confstr(_CS_PARTITION_IDENT,buffer,bufsize);


BTW, _you_ need to allocate the buffer and tell confstr() how large the buffer is.

Best regards...
Dietmar.
"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)