KVS/include/sysinfo.h
2024-12-29 08:19:20 +00:00

42 lines
882 B
C

#ifndef SYSINFO_H
#define SYSINFO_H
#include <stdint.h>
#include <stddef.h>
#include "tpm.h"
void trim_newline(char* str) {
size_t len = strlen(str);
if (len > 0 && str[len - 1] == '\n') {
str[len - 1] = '\0';
}
}
const char* getFirmwareVersion(){
// note, may not work on all chromebooks
FILE *fptr;
char stupidfile[] = "/sys/class/dmi/id/bios_version";
fptr = fopen(stupidfile, "r");
static char firmwareVersion[1024];
if (fptr == NULL) {
printf("Error reading Firmware Version \n");
printf("Please report as a bug at https://github.com/kxtzownsu/KVS-private\n");
sleep(86400); // sleep for 1d if error
return "Error!";
}
fgets(firmwareVersion, 100, fptr);
fclose(fptr);
trim_newline(firmwareVersion);
return firmwareVersion;
}
// uint32_t getKernelVersion(){
// }
#endif