mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-02 11:23:41 +01:00
Bios (Linux): detect boot manager & secure boot
This commit is contained in:
+13
-7
@@ -4,7 +4,7 @@
|
||||
#include "modules/bios/bios.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_BIOS_NUM_FORMAT_ARGS 5
|
||||
#define FF_BIOS_NUM_FORMAT_ARGS 7
|
||||
|
||||
void ffPrintBios(FFBiosOptions* options)
|
||||
{
|
||||
@@ -14,6 +14,8 @@ void ffPrintBios(FFBiosOptions* options)
|
||||
ffStrbufInit(&bios.vendor);
|
||||
ffStrbufInit(&bios.version);
|
||||
ffStrbufInit(&bios.type);
|
||||
ffStrbufInit(&bios.bootmgr);
|
||||
bios.secureBoot = false;
|
||||
|
||||
const char* error = ffDetectBios(&bios);
|
||||
|
||||
@@ -65,6 +67,8 @@ void ffPrintBios(FFBiosOptions* options)
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.vendor},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.version},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.type},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.bootmgr},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &bios.secureBoot},
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -74,6 +78,7 @@ exit:
|
||||
ffStrbufDestroy(&bios.vendor);
|
||||
ffStrbufDestroy(&bios.version);
|
||||
ffStrbufDestroy(&bios.type);
|
||||
ffStrbufDestroy(&bios.bootmgr);
|
||||
}
|
||||
|
||||
bool ffParseBiosCommandOptions(FFBiosOptions* options, const char* key, const char* value)
|
||||
@@ -119,6 +124,8 @@ void ffGenerateBiosJsonResult(FF_MAYBE_UNUSED FFBiosOptions* options, yyjson_mut
|
||||
ffStrbufInit(&bios.vendor);
|
||||
ffStrbufInit(&bios.version);
|
||||
ffStrbufInit(&bios.type);
|
||||
ffStrbufInit(&bios.bootmgr);
|
||||
bios.secureBoot = false;
|
||||
|
||||
const char* error = ffDetectBios(&bios);
|
||||
|
||||
@@ -128,18 +135,14 @@ void ffGenerateBiosJsonResult(FF_MAYBE_UNUSED FFBiosOptions* options, yyjson_mut
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (bios.version.length == 0)
|
||||
{
|
||||
yyjson_mut_obj_add_str(doc, module, "error", "bios_version is not set.");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result");
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "date", &bios.date);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "release", &bios.release);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "vendor", &bios.vendor);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "version", &bios.version);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "type", &bios.type);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "bootmgr", &bios.bootmgr);
|
||||
yyjson_mut_obj_add_bool(doc, obj, "secureBoot", bios.secureBoot);
|
||||
|
||||
exit:
|
||||
ffStrbufDestroy(&bios.date);
|
||||
@@ -147,6 +150,7 @@ exit:
|
||||
ffStrbufDestroy(&bios.vendor);
|
||||
ffStrbufDestroy(&bios.version);
|
||||
ffStrbufDestroy(&bios.type);
|
||||
ffStrbufDestroy(&bios.bootmgr);
|
||||
}
|
||||
|
||||
void ffPrintBiosHelpFormat(void)
|
||||
@@ -157,6 +161,8 @@ void ffPrintBiosHelpFormat(void)
|
||||
"bios vendor",
|
||||
"bios version",
|
||||
"firmware type",
|
||||
"Boot manager used to boot the system",
|
||||
"Is secure boot enabled",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user