Commit 013bd428 by Daniel Lezcano Committed by Daniel Lezcano

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: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 911324ef
...@@ -959,28 +959,32 @@ static inline int mount_entry_on_systemfs(struct mntent *mntent) ...@@ -959,28 +959,32 @@ static inline int mount_entry_on_systemfs(struct mntent *mntent)
} }
static int mount_entry_on_absolute_rootfs(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]; char path[MAXPATHLEN];
unsigned long mntflags; unsigned long mntflags;
char *mntdata; char *mntdata;
int ret; int ret = 0;
if (parse_mntopts(mntent->mnt_opts, &mntflags, &mntdata) < 0) { if (parse_mntopts(mntent->mnt_opts, &mntflags, &mntdata) < 0) {
ERROR("failed to parse mount option '%s'", mntent->mnt_opts); ERROR("failed to parse mount option '%s'", mntent->mnt_opts);
return -1; return -1;
} }
if (strncmp(mntent->mnt_dir, rootfs, strlen(rootfs))) aux = strstr(mntent->mnt_dir, rootfs->path);
WARN("mount target directory '%s' is outside " if (!aux) {
"container root", mntent->mnt_dir); WARN("ignoring mount point '%s'", mntent->mnt_dir);
else goto out;
WARN("mount target directory '%s' is not " }
"relative to container root", mntent->mnt_dir);
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); mntflags, mntdata);
out:
free(mntdata); free(mntdata);
return ret; return ret;
} }
...@@ -1030,7 +1034,7 @@ static int mount_file_entries(const struct lxc_rootfs *rootfs, FILE *file) ...@@ -1030,7 +1034,7 @@ static int mount_file_entries(const struct lxc_rootfs *rootfs, FILE *file)
continue; continue;
} }
if (mount_entry_on_absolute_rootfs(mntent, rootfs->path)) if (mount_entry_on_absolute_rootfs(mntent, rootfs))
goto out; goto out;
} }
......
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