Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions src/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static int container_populate_volume(char *src, char *dest)
return -1;
}

if (hyper_mkdir(dest, 0755) < 0) {
if (hyper_mkdir(dest, 0777) < 0) {
fprintf(stderr, "fail to create directroy %s\n", dest);
return -1;
}
Expand All @@ -61,10 +61,18 @@ static int container_check_file_volume(char *hyper_path, const char **filename)
*filename = NULL;
num = scandir(hyper_path, &list, NULL, NULL);
if (num < 0) {
/* No data in the volume yet, treat as non-file-volume */
if (errno == ENOENT) {
return 0;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

free list in error path.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed. Thanks.

perror("scan path failed");
return -1;
} else if (num != 3) {
fprintf(stdout, "%s has %d files/dirs\n", hyper_path, num - 2);
for (i = 0; i < num; i++) {
free(list[i]);
}
free(list);
return 0;
}

Expand Down Expand Up @@ -122,12 +130,6 @@ static int container_setup_volume(struct hyper_container *container)
}

sprintf(volume, "/%s/_data", path);
/* 0777 so that any user can write to new volumes */
if (hyper_mkdir(volume, 0777) < 0) {
fprintf(stderr, "fail to create directroy %s\n", volume);
return -1;
}

if (container_check_file_volume(volume, &filevolume) < 0)
return -1;

Expand All @@ -142,6 +144,10 @@ static int container_setup_volume(struct hyper_container *container)
fprintf(stderr, "fail to populate volume %s\n", mountpoint);
return -1;
}
} else if (hyper_mkdir(volume, 0777) < 0) {
/* First time mounting an empty volume */
perror("create _data dir failed");
return -1;
}
} else {
hyper_filize(mountpoint);
Expand All @@ -150,6 +156,11 @@ static int container_setup_volume(struct hyper_container *container)
return -1;
}
sprintf(volume, "/%s/_data/%s", path, filevolume);
/* 0777 so that any user can read/write the new file volume */
if (chmod(volume, 0777) < 0) {
fprintf(stderr, "fail to chmod directroy %s\n", volume);
return -1;
}
}

if (mount(volume, mountpoint, NULL, MS_BIND, NULL) < 0) {
Expand Down