Patchwork [04/11] UBUNTU: ubuntu: overlayfs -- vfs: introduce clone_private_mount()

login
register
mail settings
Submitter Paolo Pisati
Date March 13, 2013, 9:50 a.m.
Message ID <1363168251-9374-5-git-send-email-paolo.pisati@canonical.com>
Download mbox | patch
Permalink /patch/227212/
State New
Headers show

Comments

Paolo Pisati - March 13, 2013, 9:50 a.m.
From: Miklos Szeredi <mszeredi@suse.cz>

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>
(cherry picked from commit d99f0ada379580408e06efaf2a22268bd63ec758)

BugLink: http://bugs.launchpad.net/bugs/1076317

Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
---
 fs/namespace.c        |   18 ++++++++++++++++++
 include/linux/mount.h |    3 +++
 2 files changed, 21 insertions(+)

Patch

diff --git a/fs/namespace.c b/fs/namespace.c
index 5e7f2e9..4d2f3e6 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1492,6 +1492,24 @@  void drop_collected_mounts(struct vfsmount *mnt)
 	release_mounts(&umount_list);
 }
 
+struct vfsmount *clone_private_mount(struct path *path)
+{
+	struct vfsmount *old_mnt = path->mnt;
+	struct vfsmount *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 33fe53d..ef49859 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -103,6 +103,9 @@  extern int __mnt_is_readonly(struct vfsmount *mnt);
 extern struct vfsmount *do_kern_mount(const char *fstype, int flags,
 				      const char *name, void *data);
 
+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,