mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-14 03:53:18 +00:00
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:
parent
7e7f51d1b4
commit
fdc03323c2
@ -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"))
|
||||
|
Loading…
Reference in New Issue
Block a user