mirror of
https://github.com/clearlinux/hyperstart.git
synced 2026-08-25 00:25:50 +00:00
move workdir to struct hyper_exec
Signed-off-by: Lai Jiangshan <jiangshanlai@gmail.com>
This commit is contained in:
+2
-2
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
@@ -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
@@ -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]));
|
||||
|
||||
Reference in New Issue
Block a user