diff --git a/src/container.c b/src/container.c index a7029c4..d5efdb2 100644 --- a/src/container.c +++ b/src/container.c @@ -336,10 +336,10 @@ static int container_setup_workdir(struct hyper_container *container) { if (container->initialize) { // create workdir - hyper_mkdir(container->workdir); + hyper_mkdir(container->exec.workdir); } - if (container->workdir && chdir(container->workdir) < 0) { + if (container->exec.workdir && chdir(container->exec.workdir) < 0) { perror("change work directory failed"); return -1; } diff --git a/src/container.h b/src/container.h index f8f0144..5a43ac8 100644 --- a/src/container.h +++ b/src/container.h @@ -34,7 +34,6 @@ struct hyper_container { char *rootfs; char *image; char *scsiaddr; - char *workdir; char *fstype; struct volume *vols; struct env *envs; diff --git a/src/exec.h b/src/exec.h index d664976..7ab2068 100644 --- a/src/exec.h +++ b/src/exec.h @@ -9,12 +9,6 @@ struct hyper_exec { struct hyper_event stdinev; struct hyper_event stdoutev; struct hyper_event stderrev; - char *id; - char **argv; - int argc; - int tty; // use tty or not - uint64_t seq; - uint64_t errseq; int pid; int ptyno; int init; @@ -26,6 +20,15 @@ struct hyper_exec { uint8_t code; uint8_t exit; uint8_t ref; + + // configs + char *id; + char **argv; + int argc; + int tty; // use tty or not + uint64_t seq; + uint64_t errseq; + char *workdir; }; struct hyper_pod; diff --git a/src/parse.c b/src/parse.c index 9fc7866..d693ce1 100644 --- a/src/parse.c +++ b/src/parse.c @@ -164,6 +164,9 @@ static void container_cleanup_exec(struct hyper_exec *exec) free(exec->id); exec->id = NULL; + free(exec->workdir); + exec->workdir = NULL; + for (i = 0; i < exec->argc; i++) { free(exec->argv[i]); } @@ -441,9 +444,6 @@ void hyper_free_container(struct hyper_container *c) free(c->scsiaddr); c->scsiaddr = NULL; - free(c->workdir); - c->workdir = NULL; - free(c->fstype); c->fstype = NULL; @@ -524,8 +524,8 @@ static int hyper_parse_container(struct hyper_pod *pod, struct hyper_container * fprintf(stdout, "container stderr seq %" PRIu64 "\n", c->exec.errseq); i++; } else if (json_token_streq(json, t, "workdir") && t->size == 1) { - c->workdir = (json_token_str(json, &toks[++i])); - fprintf(stdout, "container workdir %s\n", c->workdir); + c->exec.workdir = (json_token_str(json, &toks[++i])); + fprintf(stdout, "container workdir %s\n", c->exec.workdir); i++; } else if (json_token_streq(json, t, "image") && t->size == 1) { c->image = (json_token_str(json, &toks[++i]));