From mboxrd@z Thu Jan 1 00:00:00 1970 From: Valerie Aurora Subject: [PATCH 51/74] union-mount: Add do_lookup_union() wrapper for __lookup_union() Date: Tue, 22 Mar 2011 19:04:42 -0700 Message-ID: <1300845905-14433-8-git-send-email-valerie.aurora@gmail.com> References: <1300845905-14433-1-git-send-email-valerie.aurora@gmail.com> Cc: viro@zeniv.linux.org.uk, Valerie Aurora , Valerie Aurora To: linux-fsdevel@vger.kernel.org, linux@vger.kernel.org Return-path: Received: from mail-gw0-f46.google.com ([74.125.83.46]:54549 "EHLO mail-gw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751707Ab1CWCFj (ORCPT ); Tue, 22 Mar 2011 22:05:39 -0400 In-Reply-To: <1300845905-14433-1-git-send-email-valerie.aurora@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: From: Valerie Aurora do_lookup_union() locks the parent directory and follows the mount after lookup. It is appropriate for calling from do_lookup(). Signed-off-by: Valerie Aurora --- fs/namei.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 8257537..3fcb42c 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -909,6 +909,28 @@ static int lookup_union(struct nameidata *nd, struct qstr *name, } /* + * do_union_lookup - union mount-aware part of do_lookup + * + * do_lookup()-style wrapper for lookup_union(). Follows mounts. + */ + +static int do_lookup_union(struct nameidata *nd, struct qstr *name, + struct path *topmost) +{ + struct dentry *parent = nd->path.dentry; + struct inode *dir = parent->d_inode; + int err; + + mutex_lock(&dir->i_mutex); + err = lookup_union(nd, name, topmost); + mutex_unlock(&dir->i_mutex); + + __follow_mount(topmost); + + return err; +} + +/* * Allocate a dentry with name and parent, and perform a parent * directory ->lookup on it. Returns the new dentry, or ERR_PTR * on error. parent->d_inode->i_mutex must be held. d_lookup must -- 1.7.0.4