1 From 8271242be97498b40f49ece9202bf392df21ac29 Mon Sep 17 00:00:00 2001
2 From: Miklos Szeredi <mszeredi@suse.cz>
3 Date: Thu, 30 Aug 2012 16:13:49 +0200
4 Subject: [PATCH 03/13] vfs: introduce clone_private_mount()
5 Patch-mainline: not yet
7 Overlayfs needs a private clone of the mount, so create a function for
8 this and export to modules.
10 Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
12 fs/namespace.c | 27 +++++++++++++++++++++++++++
13 include/linux/mount.h | 3 +++
14 2 files changed, 30 insertions(+)
18 @@ -1442,6 +1442,33 @@ void drop_collected_mounts(struct vfsmou
23 + * clone_private_mount - create a private clone of a path
25 + * This creates a new vfsmount, which will be the clone of @path. The new will
26 + * not be attached anywhere in the namespace and will be private (i.e. changes
27 + * to the originating mount won't be propagated into this).
29 + * Release with mntput().
31 +struct vfsmount *clone_private_mount(struct path *path)
33 + struct mount *old_mnt = real_mount(path->mnt);
34 + struct mount *new_mnt;
36 + if (IS_MNT_UNBINDABLE(old_mnt))
37 + return ERR_PTR(-EINVAL);
39 + down_read(&namespace_sem);
40 + new_mnt = clone_mnt(old_mnt, path->dentry, CL_PRIVATE);
41 + up_read(&namespace_sem);
42 + if (IS_ERR(new_mnt))
43 + return ERR_CAST(new_mnt);
45 + return &new_mnt->mnt;
47 +EXPORT_SYMBOL_GPL(clone_private_mount);
49 int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
50 struct vfsmount *root)
52 --- a/include/linux/mount.h
53 +++ b/include/linux/mount.h
54 @@ -68,6 +68,9 @@ extern void mnt_pin(struct vfsmount *mnt
55 extern void mnt_unpin(struct vfsmount *mnt);
56 extern int __mnt_is_readonly(struct vfsmount *mnt);
59 +extern struct vfsmount *clone_private_mount(struct path *path);
61 struct file_system_type;
62 extern struct vfsmount *vfs_kern_mount(struct file_system_type *type,
63 int flags, const char *name,