add mount option for filesystems

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
This commit is contained in:
Gao feng
2015-10-29 10:06:53 +08:00
parent 180339f16b
commit 19da0a2068
2 changed files with 9 additions and 9 deletions
+4 -4
View File
@@ -102,9 +102,9 @@ 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;
}
@@ -114,7 +114,7 @@ static int container_setup_mount(struct hyper_container *container)
return -1;
}
if (mount("tmpfs", "/dev/shm/", "tmpfs", 0, NULL) < 0) {
if (mount("tmpfs", "/dev/shm/", "tmpfs", MS_NOSUID| MS_NODEV, NULL) < 0) {
perror("mount shm failed");
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;
}