move workdir to struct hyper_exec

Signed-off-by: Lai Jiangshan <jiangshanlai@gmail.com>
This commit is contained in:
Lai Jiangshan
2016-04-06 14:19:15 +08:00
parent e487303205
commit 64cbfd2a0b
4 changed files with 16 additions and 14 deletions
+2 -2
View File
@@ -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;
}
-1
View File
@@ -34,7 +34,6 @@ struct hyper_container {
char *rootfs;
char *image;
char *scsiaddr;
char *workdir;
char *fstype;
struct volume *vols;
struct env *envs;
+9 -6
View File
@@ -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;
+5 -5
View File
@@ -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]));