aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@free.fr>2010-10-03 23:09:35 +0200
committerDaniel Lezcano <dlezcano@fr.ibm.com>2010-10-03 23:09:35 +0200
commitac7787080cb77e0532c1ac27fe106873628f494f (patch)
treeb2fb9ad63d42cf776cd2e5393004f6339b7474b8 /src
parentimprove lxc-debian template to specify the suite (diff)
downloadlxc-ac7787080cb77e0532c1ac27fe106873628f494f.tar.gz
lxc-ac7787080cb77e0532c1ac27fe106873628f494f.tar.bz2
lxc-ac7787080cb77e0532c1ac27fe106873628f494f.zip
mount the rootfs to the mount directory first
Split the rootfs setup by mounting the rootfs to the mount point. This mount point will be used as the facto place where the rootfs is placed. Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/lxc/conf.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 8cb8e20..aae52f4 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -593,14 +593,11 @@ static int setup_rootfs_pivot_root(const char *rootfs, const char *pivotdir)
static int setup_rootfs(const struct lxc_rootfs *rootfs)
{
- char *mpath = LXCROOTFSMOUNT;
+ char *mpath = rootfs->mount ? rootfs->mount : LXCROOTFSMOUNT;
if (!rootfs->path)
return 0;
- if (rootfs->mount)
- mpath = rootfs->mount;
-
if (access(mpath, F_OK)) {
SYSERROR("failed to access to '%s', check it is present",
mpath);
@@ -614,11 +611,23 @@ static int setup_rootfs(const struct lxc_rootfs *rootfs)
DEBUG("mounted '%s' on '%s'", rootfs->path, mpath);
+ return 0;
+}
+
+int setup_pivot_root(const struct lxc_rootfs *rootfs)
+{
+ char *mpath = rootfs->mount ? rootfs->mount : LXCROOTFSMOUNT;
+
+ if (!rootfs->path)
+ return 0;
+
if (setup_rootfs_pivot_root(mpath, rootfs->pivot)) {
ERROR("failed to setup pivot root");
return -1;
}
+ DEBUG("pivot rooted to '%s'", mpath);
+
return 0;
}
@@ -1457,8 +1466,8 @@ int lxc_setup(const char *name, struct lxc_conf *lxc_conf)
return -1;
}
- if (setup_cgroup(name, &lxc_conf->cgroup)) {
- ERROR("failed to setup the cgroups for '%s'", name);
+ if (setup_rootfs(&lxc_conf->rootfs)) {
+ ERROR("failed to setup rootfs for '%s'", name);
return -1;
}
@@ -1472,6 +1481,11 @@ int lxc_setup(const char *name, struct lxc_conf *lxc_conf)
return -1;
}
+ if (setup_cgroup(name, &lxc_conf->cgroup)) {
+ ERROR("failed to setup the cgroups for '%s'", name);
+ return -1;
+ }
+
if (setup_console(&lxc_conf->rootfs, &lxc_conf->console)) {
ERROR("failed to setup the console for '%s'", name);
return -1;
@@ -1482,7 +1496,7 @@ int lxc_setup(const char *name, struct lxc_conf *lxc_conf)
return -1;
}
- if (setup_rootfs(&lxc_conf->rootfs)) {
+ if (setup_pivot_root(&lxc_conf->rootfs)) {
ERROR("failed to set rootfs for '%s'", name);
return -1;
}