Operating System - HP-UX
1752758 Members
5000 Online
108789 Solutions
New Discussion

What is the difference between CS_MACHINE_SERIAL and MACHINE_SERIAL ?

 
masoodsy
Occasional Contributor

What is the difference between CS_MACHINE_SERIAL and MACHINE_SERIAL ?

What is the difference between CS_MACHINE_SERIAL and MACHINE_SERIAL ?

i get this question whenever i need to check the serial, what is the difference after all ?

 

 

1 REPLY 1
Matti_Kurkela
Honored Contributor

Re: What is the difference between CS_MACHINE_SERIAL and MACHINE_SERIAL ?

One is longer to type than the other?

According to getconf(1) man page, the getconf uses confstr(), pathconf() or sysconf() system calls/library routines to get the information it returns. Of these, only confstr() offers access to the serial number, because it's a string value. And the confstr(3C) man page indicates that the serial number could be queried programmatically like this:

#include <unistd.h>

#define SERNUM_BUFFER_LEN 20
size_t result;
char serial_num[SERNUM_BUFFER_LEN];

result = confstr(_CS_MACHINE_SERIAL, serial_num, SERNUM_BUFFER_LEN);

The /usr/include/unistd.h and /usr/include/sys/unistd.h only define the _CS_MACHINE_SERIAL constant: there is no corresponding constant without the CS_ prefix.

So, both "getconf CS_MACHINE_SERIAL" and "getconf MACHINE_SERIAL" might both be aliases to the same code.

I just ran "tusc -o no_cs.log getconf MACHINE_SERIAL" and "tusc -o with_cs.log getconf CS_MACHINE_SERIAL" and can confirm this: there is no difference between "getconf MACHINE_SERIAL" and "getconf CS_MACHINE_SERIAL" at the system call level. The only difference in tusc outputs was on the first line, which includes the command line parameters given to getconf (which are obviously different).

So CS_;MACHINE_SERIAL is probably offered by getconf to match the programmatic interface, and MACHINE_SERIAL as an alias to it because it's easier to type.

(This is what happens when I'm bored at work in a summer vacation season...)

MK