From patchwork Wed Mar 13 09:50:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Pisati X-Patchwork-Id: 227212 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id A122B2C02A5 for ; Wed, 13 Mar 2013 20:51:09 +1100 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1UFiKo-0001dm-2X; Wed, 13 Mar 2013 09:50:58 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1UFiKl-0001bK-3T for kernel-team@lists.ubuntu.com; Wed, 13 Mar 2013 09:50:55 +0000 Received: from 2-230-238-136.ip204.fastwebnet.it ([2.230.238.136] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1UFiKl-0000tq-0S for kernel-team@lists.ubuntu.com; Wed, 13 Mar 2013 09:50:55 +0000 From: Paolo Pisati To: kernel-team@lists.ubuntu.com Subject: [PATCH 04/11] UBUNTU: ubuntu: overlayfs -- vfs: introduce clone_private_mount() Date: Wed, 13 Mar 2013 10:50:44 +0100 Message-Id: <1363168251-9374-5-git-send-email-paolo.pisati@canonical.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1363168251-9374-1-git-send-email-paolo.pisati@canonical.com> References: <1363168251-9374-1-git-send-email-paolo.pisati@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Miklos Szeredi 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 Signed-off-by: Andy Whitcroft (cherry picked from commit d99f0ada379580408e06efaf2a22268bd63ec758) BugLink: http://bugs.launchpad.net/bugs/1076317 Signed-off-by: Paolo Pisati --- fs/namespace.c | 18 ++++++++++++++++++ include/linux/mount.h | 3 +++ 2 files changed, 21 insertions(+) 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,