From patchwork Tue Feb 8 18:42:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A. Shutemov" X-Patchwork-Id: 541391 X-Patchwork-Delegate: Trond.Myklebust@netapp.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p18IiDqp021135 for ; Tue, 8 Feb 2011 18:44:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755569Ab1BHSng (ORCPT ); Tue, 8 Feb 2011 13:43:36 -0500 Received: from shutemov.name ([188.40.19.243]:48888 "EHLO shutemov.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755499Ab1BHSmM (ORCPT ); Tue, 8 Feb 2011 13:42:12 -0500 Received: by shutemov.name (Postfix, from userid 500) id 1F5FBD421F; Tue, 8 Feb 2011 20:42:09 +0200 (EET) From: "Kirill A. Shutemov" To: Trond Myklebust , "J. Bruce Fields" , Neil Brown Cc: Pavel Emelyanov , linux-nfs@vger.kernel.org, "David S. Miller" , Rob Landley , Al Viro , containers@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCH v3, RESEND 12/16] sunrpc: introduce get_rpc_pipefs() Date: Tue, 8 Feb 2011 20:42:03 +0200 Message-Id: <1297190527-19925-13-git-send-email-kas@openvz.org> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1297190527-19925-1-git-send-email-kas@openvz.org> References: <1297190527-19925-1-git-send-email-kas@openvz.org> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 08 Feb 2011 18:44:14 +0000 (UTC) diff --git a/include/linux/sunrpc/rpc_pipe_fs.h b/include/linux/sunrpc/rpc_pipe_fs.h index f5216f1..4a8830a 100644 --- a/include/linux/sunrpc/rpc_pipe_fs.h +++ b/include/linux/sunrpc/rpc_pipe_fs.h @@ -46,6 +46,7 @@ RPC_I(struct inode *inode) extern struct vfsmount *init_rpc_pipefs; +extern struct vfsmount *get_rpc_pipefs(const char *path); extern int rpc_pipefs_add_destroy_cb(struct super_block *sb, void (*destroy_cb)(void *data), void *data); diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 58312fa..1261f27 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c @@ -16,6 +16,9 @@ #include #include #include +#include +#include +#include #include #include @@ -939,6 +942,54 @@ static const struct super_operations s_ops = { #define RPCAUTH_GSSMAGIC 0x67596969 +static int check_rpc_pipefs(struct vfsmount *mnt, void *arg) +{ + struct vfsmount **rpcmount = arg; + struct path path = { + .mnt = mnt, + .dentry = mnt->mnt_root, + }; + + if (!mnt->mnt_sb) + return 0; + if (mnt->mnt_sb->s_magic != RPCAUTH_GSSMAGIC) + return 0; + + if (!path_is_under(&path, ¤t->fs->root)) + return 0; + + *rpcmount = mntget(mnt); + return 1; +} + +struct vfsmount *get_rpc_pipefs(const char *p) +{ + int error; + struct vfsmount *rpcmount = ERR_PTR(-EINVAL); + struct path path; + + if (!p) { + iterate_mounts(check_rpc_pipefs, &rpcmount, + current->nsproxy->mnt_ns->root); + + if (IS_ERR(rpcmount) && (current->nsproxy->mnt_ns == + init_task.nsproxy->mnt_ns)) + return mntget(init_rpc_pipefs); + + return rpcmount; + } + + error = kern_path(p, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &path); + if (error) + return ERR_PTR(error); + + check_rpc_pipefs(path.mnt, &rpcmount); + path_put(&path); + + return rpcmount; +} +EXPORT_SYMBOL_GPL(get_rpc_pipefs); + struct destroy_cb { struct list_head list; void (*callback)(void *data);