diff options
Diffstat (limited to 'src/hardware/dmidecode.c')
-rw-r--r-- | src/hardware/dmidecode.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/hardware/dmidecode.c b/src/hardware/dmidecode.c index 04988a9..348c7a2 100644 --- a/src/hardware/dmidecode.c +++ b/src/hardware/dmidecode.c @@ -49,6 +49,9 @@ void init_dmiprocessor_struct(DmiProcessor *cpu) cpu->l1_cache_handle = NULL; cpu->l2_cache_handle = NULL; cpu->l3_cache_handle = NULL; + cpu->manufacturer = NULL; + cpu->serial_number = NULL; + cpu->part_number = NULL; } /* @@ -120,6 +123,24 @@ short check_dmiprocessor_attributes(DmiProcessor *cpu) goto done; } } + if (!cpu->manufacturer) { + if (!(cpu->manufacturer = strdup(""))) { + ret = -12; + goto done; + } + } + if (!cpu->serial_number) { + if (!(cpu->serial_number = strdup(""))) { + ret = -13; + goto done; + } + } + if (!cpu->part_number) { + if (!(cpu->part_number = strdup(""))) { + ret = -14; + goto done; + } + } ret = 0; @@ -193,6 +214,13 @@ short dmi_get_processors(DmiProcessor **cpus, unsigned *cpus_nb) buf = NULL; continue; } + /* Manufacturer */ + buf = copy_string_part_after_delim(buffer[i], "Manufacturer: "); + if (buf) { + (*cpus)[curr_cpu].manufacturer = buf; + buf = NULL; + continue; + } /* Status */ buf = copy_string_part_after_delim(buffer[i], "Status: Populated, "); if (buf) { @@ -297,6 +325,20 @@ short dmi_get_processors(DmiProcessor **cpus, unsigned *cpus_nb) buf = NULL; continue; } + /* Serial Number */ + buf = copy_string_part_after_delim(buffer[i], "Serial Number: "); + if (buf) { + (*cpus)[curr_cpu].serial_number = buf; + buf = NULL; + continue; + } + /* Part Number */ + buf = copy_string_part_after_delim(buffer[i], "Part Number: "); + if (buf) { + (*cpus)[curr_cpu].part_number = buf; + buf = NULL; + continue; + } /* CPU Characteristics */ if (strstr(buffer[i], "Characteristics:") && !strstr(buffer[i], "Characteristics: ")) { @@ -390,6 +432,12 @@ void dmi_free_processors(DmiProcessor **cpus, unsigned *cpus_nb) (*cpus)[i].l2_cache_handle = NULL; free((*cpus)[i].l3_cache_handle); (*cpus)[i].l3_cache_handle = NULL; + free((*cpus)[i].manufacturer); + (*cpus)[i].manufacturer = NULL; + free((*cpus)[i].serial_number); + (*cpus)[i].serial_number = NULL; + free((*cpus)[i].part_number); + (*cpus)[i].part_number = NULL; } free (*cpus); } |