diff options
author | Daniel Lezcano <daniel.lezcano@free.fr> | 2011-01-13 16:25:14 +0100 |
---|---|---|
committer | Daniel Lezcano <dlezcano@fr.ibm.com> | 2011-01-13 16:25:14 +0100 |
commit | 013bd428482534e6de00b385b0a501c8c71c661b (patch) | |
tree | d6df441973eaf4f797225c4c0cb88f0346c1c057 | |
parent | encapsulate mount point code (diff) | |
download | lxc-013bd428482534e6de00b385b0a501c8c71c661b.tar.gz lxc-013bd428482534e6de00b385b0a501c8c71c661b.tar.bz2 lxc-013bd428482534e6de00b385b0a501c8c71c661b.zip |
substitute the absolute rootfs mount path
Change the mount point in the rootfs because we mount the rootfs
in ROOTFSDIR for the pivot. We have to substitute the real mount
path to the new path located in ROOTFSDIR.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
-rw-r--r-- | src/lxc/conf.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 345facd..df6f485 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -959,28 +959,32 @@ static inline int mount_entry_on_systemfs(struct mntent *mntent) } static int mount_entry_on_absolute_rootfs(struct mntent *mntent, - const char *rootfs) + const struct lxc_rootfs *rootfs) { + char *aux; char path[MAXPATHLEN]; unsigned long mntflags; char *mntdata; - int ret; + int ret = 0; if (parse_mntopts(mntent->mnt_opts, &mntflags, &mntdata) < 0) { ERROR("failed to parse mount option '%s'", mntent->mnt_opts); return -1; } - if (strncmp(mntent->mnt_dir, rootfs, strlen(rootfs))) - WARN("mount target directory '%s' is outside " - "container root", mntent->mnt_dir); - else - WARN("mount target directory '%s' is not " - "relative to container root", mntent->mnt_dir); + aux = strstr(mntent->mnt_dir, rootfs->path); + if (!aux) { + WARN("ignoring mount point '%s'", mntent->mnt_dir); + goto out; + } + + snprintf(path, MAXPATHLEN, "%s%s", rootfs->mount, + aux + strlen(rootfs->path)); - ret = mount_entry(mntent->mnt_fsname, mntent->mnt_dir, mntent->mnt_type, + ret = mount_entry(mntent->mnt_fsname, path, mntent->mnt_type, mntflags, mntdata); +out: free(mntdata); return ret; } @@ -1030,7 +1034,7 @@ static int mount_file_entries(const struct lxc_rootfs *rootfs, FILE *file) continue; } - if (mount_entry_on_absolute_rootfs(mntent, rootfs->path)) + if (mount_entry_on_absolute_rootfs(mntent, rootfs)) goto out; } |