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 <dlezcano@fr.ibm.com>
This commit is contained in:
Daniel Lezcano 2009-03-11 10:20:05 +01:00
parent 7e7f51d1b4
commit fdc03323c2

View File

@ -51,11 +51,14 @@
#include <lxc/lxc.h>
#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"))