From 8271242be97498b40f49ece9202bf392df21ac29 Mon Sep 17 00:00:00 2001
From: Miklos Szeredi <mszeredi@suse.cz>
Date: Thu, 30 Aug 2012 16:13:49 +0200
Subject: [PATCH 03/13] vfs: introduce clone_private_mount()
Patch-mainline: not yet
Overlayfs needs a private clone of the mount, so create a function for
this and export to modules.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
fs/namespace.c | 18 ++++++++++++++++++
include/linux/mount.h | 3 +++
2 files changed, 21 insertions(+)
Index: linux-3.6-rc7-master/fs/namespace.c
===================================================================
--- linux-3.6-rc7-master.orig/fs/namespace.c 2012-09-24 03:10:57.000000000 +0200
+++ linux-3.6-rc7-master/fs/namespace.c 2012-09-28 13:36:51.000000000 +0200
@@ -1387,6 +1387,24 @@ void drop_collected_mounts(struct vfsmou
namespace_unlock();
}
+struct vfsmount *clone_private_mount(struct path *path)
+{
+ struct mount *old_mnt = real_mount(path->mnt);
+ struct mount *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->mnt;
+}
+EXPORT_SYMBOL_GPL(clone_private_mount);
+
int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
struct vfsmount *root)
{
Index: linux-3.6-rc7-master/include/linux/mount.h
===================================================================
--- linux-3.6-rc7-master.orig/include/linux/mount.h 2012-09-24 03:10:57.000000000 +0200
+++ linux-3.6-rc7-master/include/linux/mount.h 2012-09-28 13:36:51.000000000 +0200
@@ -66,6 +66,9 @@ extern void mnt_pin(struct vfsmount *mnt
extern void mnt_unpin(struct vfsmount *mnt);
extern int __mnt_is_readonly(struct vfsmount *mnt);
+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,