sync hardware time to system time when start pod

Signed-off-by: Lai Jiangshan <jiangshanlai@gmail.com>
This commit is contained in:
Lai Jiangshan
2016-04-25 18:17:06 +08:00
parent 99319c29a6
commit c835eb9dfe
3 changed files with 14 additions and 0 deletions
+1
View File
@@ -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;
+12
View File
@@ -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;
+1
View File
@@ -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);