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

25 lines
781 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
2026-03-29 09:28:49 +08:00
const char* ffDetectTPM(FFTPMResult* result) {
if (!ffPathExists("/sys/class/tpm/tpm0/", FF_PATHTYPE_DIRECTORY)) {
if (!ffPathExists("/sys/class/tpm/", FF_PATHTYPE_DIRECTORY)) {
2024-09-26 09:53:00 +08:00
return "TPM is not supported by kernel";
2026-03-29 09:28:49 +08:00
}
2024-09-26 09:53:00 +08:00
return "TPM device is not found";
}
2026-03-29 09:28:49 +08:00
if (ffReadFileBuffer("/sys/class/tpm/tpm0/tpm_version_major", &result->version)) {
2024-09-25 22:55:57 +08:00
ffStrbufTrimRightSpace(&result->version);
2026-03-29 09:28:49 +08:00
if (ffStrbufEqualS(&result->version, "2")) {
2024-09-25 22:55:57 +08:00
ffStrbufSetStatic(&result->version, "2.0");
2026-03-29 09:28:49 +08:00
}
2024-09-25 22:55:57 +08:00
}
2026-03-29 09:28:49 +08:00
if (ffReadFileBuffer("/sys/class/tpm/tpm0/device/description", &result->description)) {
2024-09-26 09:53:00 +08:00
ffStrbufTrimRightSpace(&result->description);
2026-03-29 09:28:49 +08:00
}
2024-09-25 22:55:57 +08:00
2026-07-10 18:08:04 +08:00
return nullptr;
2024-09-25 22:55:57 +08:00
}