kvs: add working AP firmware version detection
This commit is contained in:
parent
31a49e632d
commit
42276cee4b
2
Makefile
2
Makefile
@ -1,4 +1,4 @@
|
|||||||
CC ?= gcc
|
CC := gcc
|
||||||
SHELL ?= /bin/sh
|
SHELL ?= /bin/sh
|
||||||
KVSFLIST := \
|
KVSFLIST := \
|
||||||
src/KVS/main.c \
|
src/KVS/main.c \
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
uint32_t convert_to_uint32(const char *str) {
|
uint32_t convert_to_uint32(const char *str) {
|
||||||
char *endptr;
|
char *endptr;
|
||||||
unsigned long ul_value = strtoul(str, &endptr, 0);
|
unsigned long ul_value = strtoul(str, &endptr, 0);
|
||||||
|
29
include/sysinfo.h
Normal file
29
include/sysinfo.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
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;
|
||||||
|
}
|
@ -1,11 +1,18 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
#include "sysinfo.h"
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
if (geteuid() != 0){
|
||||||
|
printf("Please run KVS as root!\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
// example values for testing
|
// example values for testing
|
||||||
char* fwver = "Google_Grunt.11031.149.0";
|
const char* fwver = getFirmwareVersion();
|
||||||
char* kernver = "0x00010001";
|
char* kernver = "0x00010001";
|
||||||
char* tpmver = "2.0";
|
char* tpmver = "2.0";
|
||||||
char* fwmp = "0x1";
|
char* fwmp = "0x1";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user