From fdc03323c2ce83a5d80aeeba53b940b091dff838 Mon Sep 17 00:00:00 2001 From: Daniel Lezcano Date: Wed, 11 Mar 2009 10:20:05 +0100 Subject: [PATCH] Use the rbind mount for the rootfs The actual behavior is to mount bind the rootfs to a specific location and chroot to it. If someone did previously some bind mount in the rootfs they will be lost in the container. This fix makes the rootfs to have the submounts in the container. Signed-off-by: Daniel Lezcano --- src/lxc/lxc_conf.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index e5055e353..68eeaf205 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -51,11 +51,14 @@ #include - #define MAXHWLEN 18 #define MAXINDEXLEN 20 #define MAXLINELEN 128 +#ifndef MS_REC +#define MS_REC 16384 +#endif + typedef int (*instanciate_cb)(const char *directory, const char *file, pid_t pid); @@ -486,7 +489,7 @@ out: static int configure_rootfs_dir_cb(const char *rootfs, const char *absrootfs, FILE *f) { - return fprintf(f, "%s %s none bind 0 0\n", absrootfs, rootfs); + return fprintf(f, "%s %s none rbind 0 0\n", absrootfs, rootfs); } static int configure_rootfs_blk_cb(const char *rootfs, const char *absrootfs, @@ -1036,6 +1039,8 @@ static int setup_mount(const char *name) if (hasmntopt(mntent, "bind")) mntflags |= MS_BIND; + if (hasmntopt(mntent, "rbind")) + mntflags |= MS_BIND|MS_REC; if (hasmntopt(mntent, "ro")) mntflags |= MS_RDONLY; if (hasmntopt(mntent, "noexec"))