UBUNTU: ubuntu: overlayfs -- vfs: introduce clone_private_mount()
authorMiklos Szeredi <mszeredi@suse.cz>
Wed, 21 Dec 2011 17:19:22 +0000 (18:19 +0100)
committerLeann Ogasawara <leann.ogasawara@canonical.com>
Mon, 2 Apr 2012 20:17:49 +0000 (13:17 -0700)
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>

fs/namespace.c
include/linux/mount.h

index 173d15a..aabfd30 100644 (file)
@@ -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)
 {
index 33fe53d..ef49859 100644 (file)
@@ -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,