mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 13:27:14 +02:00
Merge branch 'kernelcheck' of github.com:slsdetectorgroup/slsDetectorPackage into kernelcheck
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
#define _GNU_SOURCE // needed for strptime to be at the top
|
||||
#include "slsDetectorFunctionList.h"
|
||||
#include "ALTERA_PLL_CYCLONE10.h"
|
||||
#include "ASIC_Driver.h"
|
||||
@ -15,10 +14,10 @@
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h> // usleep
|
||||
#ifdef VIRTUAL
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
// Global variable from slsDetectorServer_funcs
|
||||
@ -182,45 +181,7 @@ int checkKernelVersion() {
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
|
||||
// extract kernel date string
|
||||
char output[256];
|
||||
memset(output, 0, 256);
|
||||
FILE *sysFile = popen("uname -a | cut -d ' ' -f5-10", "r");
|
||||
fgets(output, sizeof(output), sysFile);
|
||||
pclose(sysFile);
|
||||
// remove end line
|
||||
output[strlen(output) - 1] = '\0';
|
||||
|
||||
// convert kernel date string into time
|
||||
struct tm kernelDate;
|
||||
if (NULL == strptime(output, "%a %b %d %H:%M:%S %Z %Y", &kernelDate)) {
|
||||
LOG(logERROR, ("Could not parse retrieved kernel date, %s\n", output));
|
||||
return FAIL;
|
||||
}
|
||||
time_t t_kernelDate = mktime(&kernelDate);
|
||||
|
||||
// convert expected date into time
|
||||
struct tm expDate;
|
||||
if (NULL ==
|
||||
strptime(KERNEL_DATE_VRSN, "%a %b %d %H:%M:%S %Z %Y", &expDate)) {
|
||||
LOG(logERROR,
|
||||
("Could not parse expected kernel date, %s\n", KERNEL_DATE_VRSN));
|
||||
return FAIL;
|
||||
}
|
||||
time_t t_expDate = mktime(&expDate);
|
||||
|
||||
// compare if kernel time is older than expected time
|
||||
if (t_kernelDate < t_expDate) {
|
||||
LOG(logERROR,
|
||||
("Kernel Version Incompatible (too old)! Expected: %s, Got %s\n",
|
||||
KERNEL_DATE_VRSN, output));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
LOG(logINFOBLUE, ("Kernel Version Compatible: %s [min.: %s]\n", output,
|
||||
KERNEL_DATE_VRSN));
|
||||
return OK;
|
||||
return Nios_checkKernelVersion(KERNEL_DATE_VRSN);
|
||||
}
|
||||
|
||||
int checkType() {
|
||||
|
Reference in New Issue
Block a user