]> git.pld-linux.org Git - packages/kernel.git/blob - ovl04-vfs-introduce-clone_private_mount.patch
- 3.1.101
[packages/kernel.git] / ovl04-vfs-introduce-clone_private_mount.patch
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
6
7 Overlayfs needs a private clone of the mount, so create a function for
8 this and export to modules.
9
10 Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
11 ---
12  fs/namespace.c        |   27 +++++++++++++++++++++++++++
13  include/linux/mount.h |    3 +++
14  2 files changed, 30 insertions(+)
15
16 --- a/fs/namespace.c
17 +++ b/fs/namespace.c
18 @@ -1442,6 +1442,33 @@ void drop_collected_mounts(struct vfsmou
19         namespace_unlock();
20  }
21  
22 +/**
23 + * clone_private_mount - create a private clone of a path
24 + *
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).
28 + *
29 + * Release with mntput().
30 + */
31 +struct vfsmount *clone_private_mount(struct path *path)
32 +{
33 +       struct mount *old_mnt = real_mount(path->mnt);
34 +       struct mount *new_mnt;
35 +
36 +       if (IS_MNT_UNBINDABLE(old_mnt))
37 +               return ERR_PTR(-EINVAL);
38 +
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);
44 +
45 +       return &new_mnt->mnt;
46 +}
47 +EXPORT_SYMBOL_GPL(clone_private_mount);
48 +
49  int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
50                    struct vfsmount *root)
51  {
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);
57  
58 +struct path;
59 +extern struct vfsmount *clone_private_mount(struct path *path);
60 +
61  struct file_system_type;
62  extern struct vfsmount *vfs_kern_mount(struct file_system_type *type,
63                                       int flags, const char *name,
This page took 0.14702 seconds and 3 git commands to generate.