Commit 52914855 by Florian Klink Committed by Stéphane Graber

check whether rootfs is shared before running pre-mount hooks

this expands c597baa8 and 2c6f3fc9. Also move the block using detect_ramfs_rootfs() from setup_rootfs() to lxc_setup() Signed-off-by: 's avatarFlorian Klink <flokli@flokli.de> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent 91a3c828
...@@ -1506,18 +1506,6 @@ static int setup_rootfs(struct lxc_conf *conf) ...@@ -1506,18 +1506,6 @@ static int setup_rootfs(struct lxc_conf *conf)
return -1; return -1;
} }
if (detect_ramfs_rootfs()) {
if (chroot_into_slave(conf)) {
ERROR("Failed to chroot into slave /");
return -1;
}
} else if (detect_shared_rootfs()) {
if (mount("", "/", NULL, MS_SLAVE|MS_REC, 0)) {
SYSERROR("Failed to make / rslave");
return -1;
}
}
// First try mounting rootfs using a bdev // First try mounting rootfs using a bdev
struct bdev *bdev = bdev_init(rootfs->path, rootfs->mount, rootfs->options); struct bdev *bdev = bdev_init(rootfs->path, rootfs->mount, rootfs->options);
if (bdev && bdev->ops->mount(bdev) == 0) { if (bdev && bdev->ops->mount(bdev) == 0) {
...@@ -3712,6 +3700,19 @@ int lxc_setup(struct lxc_handler *handler) ...@@ -3712,6 +3700,19 @@ int lxc_setup(struct lxc_handler *handler)
const char *lxcpath = handler->lxcpath; const char *lxcpath = handler->lxcpath;
void *data = handler->data; void *data = handler->data;
if (detect_shared_rootfs()) {
if (mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL)) {
SYSERROR("Failed to make / rslave");
ERROR("Continuing...");
}
}
if (detect_ramfs_rootfs()) {
if (chroot_into_slave(lxc_conf)) {
ERROR("Failed to chroot into slave /");
return -1;
}
}
if (lxc_conf->inherit_ns_fd[LXC_NS_UTS] == -1) { if (lxc_conf->inherit_ns_fd[LXC_NS_UTS] == -1) {
if (setup_utsname(lxc_conf->utsname)) { if (setup_utsname(lxc_conf->utsname)) {
ERROR("failed to setup the utsname for '%s'", name); ERROR("failed to setup the utsname for '%s'", name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment