Commit fdc03323 by Daniel Lezcano

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: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 7e7f51d1
...@@ -51,11 +51,14 @@ ...@@ -51,11 +51,14 @@
#include <lxc/lxc.h> #include <lxc/lxc.h>
#define MAXHWLEN 18 #define MAXHWLEN 18
#define MAXINDEXLEN 20 #define MAXINDEXLEN 20
#define MAXLINELEN 128 #define MAXLINELEN 128
#ifndef MS_REC
#define MS_REC 16384
#endif
typedef int (*instanciate_cb)(const char *directory, typedef int (*instanciate_cb)(const char *directory,
const char *file, pid_t pid); const char *file, pid_t pid);
...@@ -486,7 +489,7 @@ out: ...@@ -486,7 +489,7 @@ out:
static int configure_rootfs_dir_cb(const char *rootfs, const char *absrootfs, static int configure_rootfs_dir_cb(const char *rootfs, const char *absrootfs,
FILE *f) 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, static int configure_rootfs_blk_cb(const char *rootfs, const char *absrootfs,
...@@ -1036,6 +1039,8 @@ static int setup_mount(const char *name) ...@@ -1036,6 +1039,8 @@ static int setup_mount(const char *name)
if (hasmntopt(mntent, "bind")) if (hasmntopt(mntent, "bind"))
mntflags |= MS_BIND; mntflags |= MS_BIND;
if (hasmntopt(mntent, "rbind"))
mntflags |= MS_BIND|MS_REC;
if (hasmntopt(mntent, "ro")) if (hasmntopt(mntent, "ro"))
mntflags |= MS_RDONLY; mntflags |= MS_RDONLY;
if (hasmntopt(mntent, "noexec")) if (hasmntopt(mntent, "noexec"))
......
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