Results 1 to 7 of 7
Hello all,
This is the story... I used an execl call to dmidecode and parsed it using sed to get serial numbers
so a business friend could make a (mostly) ...
- 11-23-2010 #1Just Joined!
- Join Date
- Nov 2010
- Posts
- 5
c/c++ Getting Serials
Hello all,
This is the story... I used an execl call to dmidecode and parsed it using sed to get serial numbers
so a business friend could make a (mostly) unique serial when his cross platform software is installed on different machines.
I know this is falling outside the spirit of Linux being a profit thing, but the request has been to now do the same thing without using Linux commands. Which sounds like a chore since I would be re-inventing something that already exist namely dmidecode.
Is the source available for dmidecode?
I have no idea where to start to look for the info like dmidecode provides.
Any pointers would be appreciated.
- 11-24-2010 #2
Source links are on the project page at Savannah:
dmidecode
But there's no guarantee that a serial number will not be duplicated across manufacturers. If uniqueness is the criterion, consider the generate_uuid function.
- 11-24-2010 #3Just Joined!
- Join Date
- Nov 2010
- Posts
- 5
Awesome link thanks a bunch.
The technique I used before was just to use sed to eliminate all letters and then string all the serials together. Unfortunatley, since many seemed undefined, it would produce numbers of different sizes which may not be acceptable.
Many thanks for the suggestion and link!
- 11-26-2010 #4Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Yes. You definitely want to have a guaranteed unique identifier (GUID in the parlance). That is what the generate_uuid function is for, though there are other methods. I had to create a GUID generating function for some enterprise software about 15 years ago - each object in the database (there are often millions) had to have a GUID to identify it, and from that GUID you needed to be able to determine the following:
1. The class (type) of object.
2. The system it was created on (IPv4 network address).
3. The date+time it was created.
4. The process that created it.
5. A sequence number so that when all the above are the same, the guid is still unique. Possible when a system can generate multiple objects in a second.
This guid was a maximum of 46 characters in length. Each field but the last was an 8-digit hexadecimal number. The last (the sequence number) was an unsigned 32-bit integer which takes up to 10 characters in decimal format. Each field was separated by a dot. These days I'd probably use the network MAC address (48 bits) or a CPU ID instead for the machine identifier. That would widen the field a bit, but not much.
So, finally, there's nothing wrong with making $$ with open source software. Just perform due dilligence regarding the licenses all of the components you are using, otherwise you leave yourself open to legal action. Just because something os open source and under a GPL, it is still material governed by copyright and the licenses you have (explicitly or implicitly) agreed to by using them. Some may require a separate license for commercial use (pay for the privilege). Some may require you disclose source code. Others don't care. In any case, visit www.fossbazaar.org for more information about all this.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 11-26-2010 #5Just Joined!
- Join Date
- Nov 2010
- Posts
- 5
Thanks for a cryptic message Rubberman! Lol,Just kidding that was very through.
Be warned though, might have another question or two about what seems an interesting technique.
For example, I produced the data items you mentions easily enough ( bye the way this is in the language mono), and sent them to a text file.
Now would I read from that alphanumeric file and use some fixed function to produce a wholly original GUID by assigning a number to the fixed types of characters/digits in that file (hope this makes sense)?
Would that be, in essence, encrypted?
TY for any further guidance.
- 11-26-2010 #6Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Yes. If you want, you can use some sort of 32 bit hash function to scramble the strings to make them a number you can format as hex (fixed width). With most such functions, such as crc32, you have some possibility of a collision, but it would be unlikely for all of them in any set of guids to be identical, so you end up with what should be (99.999+% probability) unique ID's.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 11-26-2010 #7
Uh, Rub, I guess if you're rolling your own means of construction, the "G" can mean whatever you want it to mean (Glory! said Humpty). But most of us think GUID stands for Globally Unique IDentifier, per RFC4122, which is a good place to start if you must write the code yourself. But there are good C functions available for the purpose, and you don't have to settle for five nines.


Reply With Quote