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 | 18 ++++++++++++++++++
13 include/linux/mount.h | 3 +++
14 2 files changed, 21 insertions(+)
16 Index: linux-3.6-rc7-master/fs/namespace.c
17 ===================================================================
18 --- linux-3.6-rc7-master.orig/fs/namespace.c 2012-09-24 03:10:57.000000000 +0200
19 +++ linux-3.6-rc7-master/fs/namespace.c 2012-09-28 13:36:51.000000000 +0200
20 @@ -1387,6 +1387,24 @@ void drop_collected_mounts(struct vfsmou
21 release_mounts(&umount_list);
24 +struct vfsmount *clone_private_mount(struct path *path)
26 + struct mount *old_mnt = real_mount(path->mnt);
27 + struct mount *new_mnt;
29 + if (IS_MNT_UNBINDABLE(old_mnt))
30 + return ERR_PTR(-EINVAL);
32 + down_read(&namespace_sem);
33 + new_mnt = clone_mnt(old_mnt, path->dentry, CL_PRIVATE);
34 + up_read(&namespace_sem);
36 + return ERR_PTR(-ENOMEM);
38 + return &new_mnt->mnt;
40 +EXPORT_SYMBOL_GPL(clone_private_mount);
42 int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
43 struct vfsmount *root)
45 Index: linux-3.6-rc7-master/include/linux/mount.h
46 ===================================================================
47 --- linux-3.6-rc7-master.orig/include/linux/mount.h 2012-09-24 03:10:57.000000000 +0200
48 +++ linux-3.6-rc7-master/include/linux/mount.h 2012-09-28 13:36:51.000000000 +0200
49 @@ -66,6 +66,9 @@ extern void mnt_pin(struct vfsmount *mnt
50 extern void mnt_unpin(struct vfsmount *mnt);
51 extern int __mnt_is_readonly(struct vfsmount *mnt);
54 +extern struct vfsmount *clone_private_mount(struct path *path);
56 struct file_system_type;
57 extern struct vfsmount *vfs_kern_mount(struct file_system_type *type,
58 int flags, const char *name,