summaryrefslogtreecommitdiffstats
path: root/fs/namespace.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2014-10-24 04:52:55 +0200
committerAl Viro <viro@zeniv.linux.org.uk>2014-10-24 04:52:55 +0200
commit1be47b387a717a1d3edf29c80b6e7f3a72ab236e (patch)
tree5bd5f4b46b5266f5f583f601b8880211ee224c95 /fs/namespace.c
parentfix inode leaks on d_splice_alias() failure exits (diff)
parentfs: limit filesystem stacking depth (diff)
downloadlinux-1be47b387a717a1d3edf29c80b6e7f3a72ab236e.tar.xz
linux-1be47b387a717a1d3edf29c80b6e7f3a72ab236e.zip
Merge branch 'overlayfs.v25' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs into for-linus
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)
namespace_unlock();
}
+/**
+ * clone_private_mount - create a private clone of a path
+ *
+ * This creates a new vfsmount, which will be the clone of @path. The new will
+ * not be attached anywhere in the namespace and will be private (i.e. changes
+ * to the originating mount won't be propagated into this).
+ *
+ * Release with mntput().
+ */
+struct vfsmount *clone_private_mount(struct path *path)
+{
+ struct mount *old_mnt = real_mount(path->mnt);
+ struct mount *new_mnt;
+
+ if (IS_MNT_UNBINDABLE(old_mnt))
+ return ERR_PTR(-EINVAL);
+
+ down_read(&namespace_sem);
+ new_mnt = clone_mnt(old_mnt, path->dentry, CL_PRIVATE);
+ up_read(&namespace_sem);
+ if (IS_ERR(new_mnt))
+ return ERR_CAST(new_mnt);
+
+ return &new_mnt->mnt;
+}
+EXPORT_SYMBOL_GPL(clone_private_mount);
+
int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
struct vfsmount *root)
{