Implement mnt_clone_direct() to just clone an existing vfsmount. Signed-off-by: Hannes Reinecke --- fs/namespace.c | 11 +++++++++++ include/linux/mount.h | 1 + 2 files changed, 12 insertions(+) diff --git a/fs/namespace.c b/fs/namespace.c index fe919abd2f01..dfde8e3c7131 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1477,6 +1477,17 @@ struct vfsmount *mnt_clone_internal(const struct path *path) return &p->mnt; } +struct vfsmount *mnt_clone_direct(struct vfsmount *mnt, struct dentry *dentry) +{ + struct mount *p; + + p = clone_mnt(real_mount(mnt), dentry, CL_SLAVE); + if (IS_ERR(p)) + return ERR_CAST(p); + p->mnt.mnt_flags |= MNT_INTERNAL; + return &p->mnt; +} + /* * Returns the mount which either has the specified mnt_id, or has the next * smallest id afer the specified one. diff --git a/include/linux/mount.h b/include/linux/mount.h index acfe7ef86a1b..7e7e7d66c302 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -75,6 +75,7 @@ extern void mnt_drop_write_file(struct file *file); extern void mntput(struct vfsmount *mnt); extern struct vfsmount *mntget(struct vfsmount *mnt); extern void mnt_make_shortterm(struct vfsmount *mnt); +extern struct vfsmount *mnt_clone_direct(struct vfsmount *mnt, struct dentry *dentry); extern struct vfsmount *mnt_clone_internal(const struct path *path); extern bool __mnt_is_readonly(const struct vfsmount *mnt); extern bool mnt_may_suid(struct vfsmount *mnt); -- 2.51.0