Files
fastfetch/src/detection/tpm/tpm_linux.c
T

25 lines
754 B
C
Raw Normal View History

2024-09-25 22:55:57 +08:00
#include "tpm.h"
2026-01-06 09:48:38 +08:00
#include "common/io.h"
2024-09-25 22:55:57 +08:00
2024-09-26 09:53:00 +08:00
const char* ffDetectTPM(FFTPMResult* result)
2024-09-25 22:55:57 +08:00
{
if (!ffPathExists("/sys/class/tpm/tpm0/", FF_PATHTYPE_DIRECTORY))
2024-09-26 09:53:00 +08:00
{
if (!ffPathExists("/sys/class/tpm/", FF_PATHTYPE_DIRECTORY))
2024-09-26 09:53:00 +08:00
return "TPM is not supported by kernel";
return "TPM device is not found";
}
2024-09-25 22:55:57 +08:00
if (ffReadFileBuffer("/sys/class/tpm/tpm0/tpm_version_major", &result->version))
{
ffStrbufTrimRightSpace(&result->version);
if (ffStrbufEqualS(&result->version, "2"))
ffStrbufSetStatic(&result->version, "2.0");
}
2024-09-26 09:53:00 +08:00
if (ffReadFileBuffer("/sys/class/tpm/tpm0/device/description", &result->description))
ffStrbufTrimRightSpace(&result->description);
2024-09-25 22:55:57 +08:00
2024-09-26 09:53:00 +08:00
return NULL;
2024-09-25 22:55:57 +08:00
}