]> git.pld-linux.org Git - packages/kernel.git/blame - ovl04-vfs-introduce-clone_private_mount.patch
- 3.1.101
[packages/kernel.git] / ovl04-vfs-introduce-clone_private_mount.patch
CommitLineData
68184a5a
JR
1From 8271242be97498b40f49ece9202bf392df21ac29 Mon Sep 17 00:00:00 2001
2From: Miklos Szeredi <mszeredi@suse.cz>
3Date: Thu, 30 Aug 2012 16:13:49 +0200
4Subject: [PATCH 03/13] vfs: introduce clone_private_mount()
5Patch-mainline: not yet
6
7Overlayfs needs a private clone of the mount, so create a function for
8this and export to modules.
9
10Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
11---
c06a8ce3 12 fs/namespace.c | 27 +++++++++++++++++++++++++++
68184a5a 13 include/linux/mount.h | 3 +++
c06a8ce3 14 2 files changed, 30 insertions(+)
68184a5a 15
c06a8ce3
AM
16--- a/fs/namespace.c
17+++ b/fs/namespace.c
18@@ -1442,6 +1442,33 @@ void drop_collected_mounts(struct vfsmou
19 namespace_unlock();
68184a5a
JR
20 }
21
c06a8ce3
AM
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+ */
68184a5a
JR
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);
c06a8ce3
AM
42+ if (IS_ERR(new_mnt))
43+ return ERR_CAST(new_mnt);
68184a5a
JR
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 {
c06a8ce3
AM
52--- a/include/linux/mount.h
53+++ b/include/linux/mount.h
54@@ -68,6 +68,9 @@ extern void mnt_pin(struct vfsmount *mnt
68184a5a
JR
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.106038 seconds and 4 git commands to generate.