From patchwork Fri Jun 29 18:57:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1133391 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id E8DD8DFF34 for ; Fri, 29 Jun 2012 19:03:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932603Ab2F2S6K (ORCPT ); Fri, 29 Jun 2012 14:58:10 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:41418 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932556Ab2F2S6J (ORCPT ); Fri, 29 Jun 2012 14:58:09 -0400 Received: by mail-yx0-f174.google.com with SMTP id l2so3038059yen.19 for ; Fri, 29 Jun 2012 11:58:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=44WFKOvymkTh0LCX16OnDJGb3hE2KNv2GkPAsXXsA9w=; b=oV9c5kwve6K/uXZCfHwiQO8++5weIWYaOaY16TBINfoeJXV0efETmFOsvQe2rFgOxS QpHasXWlUBGrQGEJg5zZ+TwLvtLwkQ1+z55AUWE7nbG+EJbOygGXF4Yi/AT5+KVZa2en 6rxWitlGVvyGlcl1y7xQ4yOlzs4kcWYhITzpqdlwfAZrTCPkzlg3H5HUKEPJskwd08Cz 7ApLxWp0pYhopQyE6HkLCGDMDxbsJzUBL31vrF74zIOtazt7K8AzoTZGP3YO6XUI6a2q Ugnm427mBa8yi1z/eLfi/NNX29GCSc9pvIZM8LNqbIFEP9nu6uigAUwyDw96yYk3bSfZ 0rGQ== Received: by 10.236.161.2 with SMTP id v2mr4590228yhk.26.1340996288806; Fri, 29 Jun 2012 11:58:08 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-076-182-054-194.nc.res.rr.com. [76.182.54.194]) by mx.google.com with ESMTPS id l13sm3936309ann.2.2012.06.29.11.58.07 (version=SSLv3 cipher=OTHER); Fri, 29 Jun 2012 11:58:08 -0700 (PDT) From: Jeff Layton To: viro@ZenIV.linux.org.uk Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, michael.brantley@deshaw.com, hch@infradead.org, miklos@szeredi.hu, pstaubach@exagrid.com Subject: [PATCH v3 02/17] vfs: add a kern_path_at function Date: Fri, 29 Jun 2012 14:57:45 -0400 Message-Id: <1340996280-27123-3-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1340996280-27123-1-git-send-email-jlayton@redhat.com> References: <1340996280-27123-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQn+o/+Bwnmt6386qRmsX87j8jJRLh8LJ4ZcVAbvWISfWpFhtBoiZXs3u7EC201IKMQXqoZM Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org This will function like user_path_at, but does not do the getname and putname, leaving that to the caller. Signed-off-by: Jeff Layton --- fs/namei.c | 27 +++++++++++++++++++-------- include/linux/namei.h | 1 + 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 196f039..3f46b2f 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1912,20 +1912,31 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len) return __lookup_hash(&this, base, NULL); } +int kern_path_at(int dfd, const char *name, unsigned flags, struct path *path) +{ + struct nameidata nd; + int err; + + BUG_ON(flags & LOOKUP_PARENT); + + err = do_path_lookup(dfd, name, flags, &nd); + if (!err) + *path = nd.path; + + return err; +} + int user_path_at_empty(int dfd, const char __user *name, unsigned flags, struct path *path, int *empty) { - struct nameidata nd; char *tmp = getname_flags(name, flags, empty); - int err = PTR_ERR(tmp); - if (!IS_ERR(tmp)) { - - BUG_ON(flags & LOOKUP_PARENT); + int err; - err = do_path_lookup(dfd, tmp, flags, &nd); + if (IS_ERR(tmp)) { + err = PTR_ERR(tmp); + } else { + err = kern_path_at(dfd, tmp, flags, path); putname(tmp); - if (!err) - *path = nd.path; } return err; } diff --git a/include/linux/namei.h b/include/linux/namei.h index ffc0213..cd95fcb 100644 --- a/include/linux/namei.h +++ b/include/linux/namei.h @@ -66,6 +66,7 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND}; #define LOOKUP_ROOT 0x2000 #define LOOKUP_EMPTY 0x4000 +extern int kern_path_at(int, const char *, unsigned, struct path *); extern int user_path_at(int, const char __user *, unsigned, struct path *); extern int user_path_at_empty(int, const char __user *, unsigned, struct path *, int *empty);