aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2011-12-21 18:19:22 +0100
committerJohn Rigby <john.rigby@linaro.org>2012-03-17 17:04:57 -0600
commit3c3c605cdb5bd85f96fd6432880d26ff47a5b447 (patch)
tree228895a1596bd7a006abf402b96ed285bf16f25e
parenta1f123fda87abbc9a0d5ce0cf947d49119725572 (diff)
UBUNTU: ubuntu: overlayfs -- vfs: introduce clone_private_mount()
Overlayfs needs a private clone of the mount, so create a function for this and export to modules. [apw@canonical.com: backport to v3.2] Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Signed-off-by: Andy Whitcroft <apw@canonical.com>
-rw-r--r--fs/namespace.c18
-rw-r--r--include/linux/mount.h3
2 files changed, 21 insertions, 0 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index 38fcc2ec812..79153c60b8d 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1325,6 +1325,24 @@ void drop_collected_mounts(struct vfsmount *mnt)
release_mounts(&umount_list);
}
+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 (!new_mnt)
+ return ERR_PTR(-ENOMEM);
+
+ return new_mnt;
+}
+EXPORT_SYMBOL_GPL(clone_private_mount);
+
int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
struct vfsmount *root)
{
diff --git a/include/linux/mount.h b/include/linux/mount.h
index d7029f4a191..344a2623eb2 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -66,6 +66,9 @@ extern void mnt_pin(struct vfsmount *mnt);
extern void mnt_unpin(struct vfsmount *mnt);
extern int __mnt_is_readonly(struct vfsmount *mnt);
+struct path;
+extern struct vfsmount *clone_private_mount(struct path *path);
+
struct file_system_type;
extern struct vfsmount *vfs_kern_mount(struct file_system_type *type,
int flags, const char *name,