aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namespace.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/namespace.c')
-rw-r--r--fs/namespace.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index fbba8b17330d..5b66b2b3624d 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1686,6 +1686,33 @@ void drop_collected_mounts(struct vfsmount *mnt)
1686 namespace_unlock(); 1686 namespace_unlock();
1687} 1687}
1688 1688
1689/**
1690 * clone_private_mount - create a private clone of a path
1691 *
1692 * This creates a new vfsmount, which will be the clone of @path. The new will
1693 * not be attached anywhere in the namespace and will be private (i.e. changes
1694 * to the originating mount won't be propagated into this).
1695 *
1696 * Release with mntput().
1697 */
1698struct vfsmount *clone_private_mount(struct path *path)
1699{
1700 struct mount *old_mnt = real_mount(path->mnt);
1701 struct mount *new_mnt;
1702
1703 if (IS_MNT_UNBINDABLE(old_mnt))
1704 return ERR_PTR(-EINVAL);
1705
1706 down_read(&namespace_sem);
1707 new_mnt = clone_mnt(old_mnt, path->dentry, CL_PRIVATE);
1708 up_read(&namespace_sem);
1709 if (IS_ERR(new_mnt))
1710 return ERR_CAST(new_mnt);
1711
1712 return &new_mnt->mnt;
1713}
1714EXPORT_SYMBOL_GPL(clone_private_mount);
1715
1689int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg, 1716int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
1690 struct vfsmount *root) 1717 struct vfsmount *root)
1691{ 1718{