Merge pull request #20 from gao-feng/mount

mount /dev/shm by default
This commit is contained in:
Gao feng
2015-11-03 15:26:09 +08:00
2 changed files with 18 additions and 8 deletions
+13 -3
View File
@@ -102,13 +102,23 @@ static int container_setup_mount(struct hyper_container *container)
hyper_mkdir("/sys");
hyper_mkdir("/dev");
if (mount("proc", "/proc", "proc", 0, NULL) < 0 ||
mount("sysfs", "/sys", "sysfs", 0, NULL) < 0 ||
mount("devtmpfs", "/dev", "devtmpfs", 0, NULL) < 0) {
if (mount("proc", "/proc", "proc", MS_NOSUID| MS_NODEV| MS_NOEXEC, NULL) < 0 ||
mount("sysfs", "/sys", "sysfs", MS_NOSUID| MS_NODEV| MS_NOEXEC, NULL) < 0 ||
mount("devtmpfs", "/dev", "devtmpfs", MS_NOSUID, NULL) < 0) {
perror("mount basic filesystem for container failed");
return -1;
}
if (hyper_mkdir("/dev/shm") < 0) {
fprintf(stderr, "create /dev/shm failed\n");
return -1;
}
if (mount("tmpfs", "/dev/shm/", "tmpfs", MS_NOSUID| MS_NODEV, NULL) < 0) {
perror("mount shm failed");
return -1;
}
if (hyper_mkdir("/dev/pts") < 0) {
fprintf(stderr, "create /dev/pts failed\n");
return -1;
+5 -5
View File
@@ -319,7 +319,7 @@ static int hyper_pod_init(void *data)
goto fail;
}
if (mount("proc", "/proc", "proc", 0, NULL) < 0) {
if (mount("proc", "/proc", "proc", MS_NOSUID| MS_NODEV| MS_NOEXEC, NULL) < 0) {
perror("mount proc filesystem failed\n");
goto fail;
}
@@ -1204,19 +1204,19 @@ int main(int argc, char *argv[])
return -1;
}
if (mount("proc", "/proc", "proc", 0, NULL) == -1) {
if (mount("proc", "/proc", "proc", MS_NOSUID| MS_NODEV| MS_NOEXEC, NULL) == -1) {
perror("mount proc failed");
return -1;
}
hyper_print_uptime();
if (mount("sysfs", "/sys", "sysfs", 0, NULL) == -1) {
if (mount("sysfs", "/sys", "sysfs", MS_NOSUID| MS_NODEV| MS_NOEXEC, NULL) == -1) {
perror("mount sysfs failed");
return -1;
}
if (mount("dev", "/dev", "devtmpfs", 0, NULL) == -1) {
if (mount("dev", "/dev", "devtmpfs", MS_NOSUID, NULL) == -1) {
perror("mount sysfs failed");
return -1;
}
@@ -1226,7 +1226,7 @@ int main(int argc, char *argv[])
return -1;
}
if (mount("devpts", "/dev/pts", "devpts", 0, NULL) == -1) {
if (mount("devpts", "/dev/pts", "devpts", MS_NOSUID| MS_NOEXEC, NULL) == -1) {
perror("mount devpts failed");
return -1;
}