HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

What is the difference between CS_MACHINE_SERIAL and MACHINE_SERIAL ?

 
masoodsy
Member

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
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