lang: funcs: Add sys.smbios.oem_strings()#936
Conversation
This reads the SMBIOS Type 11 data and returns a []str of the contents.
|
Quick draft comment: you named it sys.smbios... you probably meant to have a subpackage, like sys/smbios if there are planning to be a lot of smbios.whatever() functions. If not then you probably want sys.smbios_whatever() |
|
I figured it should move into a subpackage, but for the draft I was trying to save energy figuring out how to do the subpackage and get the prototype working instead I'll move it to a subpackage and then move this to ready-to-review |
|
You can look at the other lang/core/ dirs for sub package examples. However we need a rough design (even if not implemented) about what else should go in there before we make it a subpackage. If we don't have more than say 3-4+ functions, let's just do sys.smbios_whatever() |
|
Also as part of this review: keep in mind (1) on some machines that file doesn't exist and (2) we must write safe code that can never panic. Yours is a big unsafe with looking into list indexes without length checking first for example. |
b7ee313 to
cb70565
Compare
This reads the SMBIOS Type 11 data and returns a []str of the contents.
Example usage:
I booted qemu with the following flags:
-smbios type=11,path=config.json(This includes the contents of 'config.json' as a type 11 string, neat!)-smbios type=11,value=this is the second one(A second type 11 entry to make sure multiple entries works)MCL:
The mgmt output:
I'd like to write tests for this just to keep it safe.
Implementation details:
There may already be existing golang smbios libraries, but the data structure is pretty simple (and extremely well documented), so I felt it was best to read and decode it directly.
Reference: https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.9.0.pdf