From patchwork Wed Aug 8 13:21:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1295851 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 A04FFDF223 for ; Wed, 8 Aug 2012 13:28:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758416Ab2HHNVw (ORCPT ); Wed, 8 Aug 2012 09:21:52 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:55556 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758392Ab2HHNVu (ORCPT ); Wed, 8 Aug 2012 09:21:50 -0400 Received: by mail-gh0-f174.google.com with SMTP id r11so730334ghr.19 for ; Wed, 08 Aug 2012 06:21:50 -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=jhQN/Nntrk2cBvNYLZuZ+3akruExFsXP40qrV9SSLZ0=; b=ilUuX6Ydi9rYggDirjFlElyfS8kN8P1UaCJknKyMAS85rl4RHP9rEkwyOlVf9r4vga McVFq6xZEUwWa32zzm4rNsZM4oCQJieaph68p/YpfWE8NI9JSIwImNTUwRC+/qRdh3vB k0kawGy/QvnWOrn0xbB+nd2VtSsmH6WqyA55TbwPd2ep6wlTXqh4kKoykAq5e/6wOa5V Rja0GdYCJD1mOA15XlDZSlvU9RKn1ecupDz5Qn89VAElkt7i8vVmK6I19/m8Muwye8Hh ge0dHHVrSlTjJZMJzK9DLE6IopAXbmts3K4t36BiMzqhGZbnt5PesSW/8x+7+JuaQHFH eqig== Received: by 10.236.200.167 with SMTP id z27mr270739yhn.131.1344432110301; Wed, 08 Aug 2012 06:21:50 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-069-134-145-027.nc.res.rr.com. [69.134.145.27]) by mx.google.com with ESMTPS id l1sm24418002yhm.19.2012.08.08.06.21.49 (version=SSLv3 cipher=OTHER); Wed, 08 Aug 2012 06:21:49 -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 v5 02/19] vfs: add a kern_path_at function Date: Wed, 8 Aug 2012 09:21:25 -0400 Message-Id: <1344432102-22312-3-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1344432102-22312-1-git-send-email-jlayton@redhat.com> References: <1344432102-22312-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQlFajRCFUjqCUSzB3aJmpXZwZsK05dPq/eh57r6RoHXm+oXoxsD/mYm23dwIC3P62Yd8xLP 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 dc792e5..83a6f46 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2092,20 +2092,31 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len) return __lookup_hash(&this, base, 0); } +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 4bf19d8..482f87f 100644 --- a/include/linux/namei.h +++ b/include/linux/namei.h @@ -55,6 +55,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);