CPU (Linux): try detecting CPU name using lscpu

Fix #567
This commit is contained in:
李通洲 2023-09-27 15:03:28 +08:00 committed by 李通洲
parent 88c12486bf
commit 7caa8d4618
No known key found for this signature in database
GPG Key ID: 269AD4F5325A22A3
2 changed files with 12 additions and 0 deletions

View File

@ -28,6 +28,7 @@ Features:
* Support Windows Service Pack version detection (Kernel, Windows)
* Support Debian point releases detection (OS, Linux)
* Add new module `NetIO` which prints network throughput (usage) of specified interface. Note this module costs about 1 second to finish.
* Use `lscpu` to detect CPU name for ARM CPUs (CPU, Linux)
Bugfixes:
* Fix fastfetch hanging in specific environment (#561)

View File

@ -1,5 +1,6 @@
#include "cpu.h"
#include "common/io/io.h"
#include "common/processing.h"
#include "common/properties.h"
#include "detection/temps/temps_linux.h"
#include "util/mallocHelper.h"
@ -50,6 +51,16 @@ static const char* parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer,
);
}
if (cpu->name.length == 0)
{
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
if (!ffProcessAppendStdOut(&buffer, (char *const[]) { "lscpu", NULL }))
{
ffParsePropLines(buffer.chars, "Model name:", &cpu->name);
if (ffStrbufEqualS(&cpu->name, "-")) ffStrbufClear(&cpu->name);
}
}
return NULL;
}