diff --git a/src/init.c b/src/init.c index 59d49c3..44e0369 100644 --- a/src/init.c +++ b/src/init.c @@ -620,6 +620,7 @@ static int hyper_start_pod(char *json, int length) if (pod->init_pid) fprintf(stdout, "pod init_pid exist %d\n", pod->init_pid); + hyper_sync_time_hctosys(); if (hyper_parse_pod(pod, json, length) < 0) { fprintf(stderr, "parse pod json failed\n"); return -1; diff --git a/src/util.c b/src/util.c index 94d87e3..7a2498d 100644 --- a/src/util.c +++ b/src/util.c @@ -99,6 +99,18 @@ int hyper_copy_dir(char *src, char *dest) { return -1; } +void hyper_sync_time_hctosys() { + int pid; + pid = fork(); + if (pid < 0) { + perror("fail to fork to copy directory"); + } else if (pid == 0) { + execlp("/busybox", "hwclock", "-s", NULL); + perror("exec hwclock -s command failed"); + exit(-1); + } +} + int hyper_find_sd(char *addr, char **dev) { struct dirent **list; struct dirent *dir; diff --git a/src/util.h b/src/util.h index 200365e..5be3327 100644 --- a/src/util.h +++ b/src/util.h @@ -19,6 +19,7 @@ int hyper_setup_env(struct env *envs, int num); int hyper_find_sd(char *addr, char **dev); int hyper_list_dir(char *path); int hyper_copy_dir(char *src, char *dst); +void hyper_sync_time_hctosys(); void online_cpu(void); void online_memory(void); int hyper_mkdir(char *path);