Bios: try supporting FreeBSD

It prints nothing on my VM. Don't know if it works on a physical machine.
This commit is contained in:
李通洲
2022-12-29 20:12:14 +08:00
parent f0ec3cb9ec
commit 584d792f5a
3 changed files with 28 additions and 2 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ Notable Changes:
Features:
* Windows (7 and newer) is officially and fully supported
* FreeBSD support is improved greatly (Cpu Temp, Cpu Usage, Disk, Host, Processes, Swap, Terminal / Shell, Uptime)
* FreeBSD support is improved greatly (Bios, Cpu Temp, Cpu Usage, Disk, Host, Processes, Swap, Terminal / Shell, Uptime)
* Adds a new flag `--stat`, which prints time usage for individual modules
* Adds Wifi module which supports Windows and macOS
* Adds data source option for logo printing
+1 -1
View File
@@ -380,7 +380,7 @@ elseif(BSD)
src/common/processing_linux.c
src/common/sysctl.c
src/detection/battery/battery_nosupport.c
src/detection/bios/bios_nosupport.c
src/detection/bios/bios_bsd.c
src/detection/board/board_nosupport.c
src/detection/chassis/chassis_nosupport.c
src/detection/cpu/cpu_bsd.c
+26
View File
@@ -0,0 +1,26 @@
#include "bios.h"
#include <kenv.h>
static void kenvLookup(const char* name, FFstrbuf* result)
{
ffStrbufEnsureFree(result, 255);
int len = kenv(KENV_GET, name, result->chars, 256);
if(len > 0)
result->length = (uint32_t) len;
}
void ffDetectBios(FFBiosResult* bios)
{
ffStrbufInit(&bios->error);
ffStrbufInit(&bios->biosDate);
ffStrbufInit(&bios->biosRelease);
ffStrbufInit(&bios->biosVendor);
ffStrbufInit(&bios->biosVersion);
//https://wiki.ghostbsd.org/index.php/Kenv
kenvLookup("smbios.bios.reldate", &bios->biosDate);
kenvLookup("smbios.system.product", &bios->biosRelease);
kenvLookup("smbios.bios.vendor", &bios->biosVendor);
kenvLookup("smbios.bios.version", &bios->biosVersion);
}