master ohmu/fastfetch-openbsd / src / detection / tpm / tpm_bsd.c
ohmu  ·  2026-10-15
 1#include "tpm.h"
 2#include "common/debug.h"
 3#include "common/sysctl.h"
 4#include "common/kmod.h"
 5
 6const char* ffDetectTPM(FFTPMResult* result) {
 7    if (ffSysctlGetString("dev.tpmcrb.0.%desc", &result->description) != nullptr) {
 8        if (!ffKmodLoaded("tpm")) {
 9            FF_DEBUG("`tpm` kernel module is not loaded");
10            return "`tpm` kernel module is not loaded";
11        }
12        FF_DEBUG("TPM device is not found");
13        return "TPM device is not found";
14    }
15
16    if (ffStrbufContainS(&result->description, "2.0")) {
17        ffStrbufSetStatic(&result->version, "2.0");
18    } else if (ffStrbufContainS(&result->description, "1.2")) {
19        ffStrbufSetStatic(&result->version, "1.2");
20    } else {
21        ffStrbufSetStatic(&result->version, "unknown");
22    }
23
24    return nullptr;
25}