mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
add check, if the cores are successfully booted
This commit is contained in:
parent
df5208ca7d
commit
dae879f222
1 changed files with 40 additions and 3 deletions
|
@ -70,6 +70,7 @@ static int init_env(void)
|
|||
char* str;
|
||||
FILE* file;
|
||||
char isle_path[MAX_PATH];
|
||||
char* result;
|
||||
|
||||
str = getenv("HERMIT_ISLE");
|
||||
if (str)
|
||||
|
@ -128,13 +129,49 @@ static int init_env(void)
|
|||
|
||||
str = getenv("HERMIT_CPUS");
|
||||
if (str)
|
||||
fprintf(file, "%s", str);
|
||||
ret = fprintf(file, "%s", str);
|
||||
else
|
||||
fprintf(file, "%s", "1");
|
||||
ret = fprintf(file, "%s", "1");
|
||||
|
||||
fclose(file);
|
||||
|
||||
//sleep(3);
|
||||
// check result
|
||||
file = fopen(isle_path, "r");
|
||||
if (!file) {
|
||||
perror("fopen");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (str)
|
||||
result = (char*) malloc(strlen(str)+128);
|
||||
else
|
||||
result = (char*) malloc(128);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
perror("malloc");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fscanf(file, "%s", result);
|
||||
|
||||
fclose(file);
|
||||
|
||||
if (str) {
|
||||
if (strcmp(result, str) != 0) {
|
||||
free(result);
|
||||
fprintf(stderr, "Unable to boot cores %s\n", str);
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
if (strcmp(result, "1") != 0) {
|
||||
free(result);
|
||||
fprintf(stderr, "Unable to boot core 1");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
free(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue