From patchwork Tue Jan 3 21:30:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabian Frederick X-Patchwork-Id: 9495723 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0A0B5606B4 for ; Tue, 3 Jan 2017 21:32:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0B9027D13 for ; Tue, 3 Jan 2017 21:32:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E56ED27D4A; Tue, 3 Jan 2017 21:32:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A73E27D13 for ; Tue, 3 Jan 2017 21:32:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966367AbdACVbS (ORCPT ); Tue, 3 Jan 2017 16:31:18 -0500 Received: from mailrelay109.isp.belgacom.be ([195.238.20.136]:54450 "EHLO mailrelay109.isp.belgacom.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935165AbdACVas (ORCPT ); Tue, 3 Jan 2017 16:30:48 -0500 X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2AKBwDEFmxY/2ZisVteHQYMgzgBAQEBA?= =?us-ascii?q?R+Ba45Jk3oBkmWCD4IIhiKBTUETAQIBAQEBAQEBYiiFFi8jKSZLJBOIYxGxODq?= =?us-ascii?q?KXYZFi3MLgwoFjwaLd5E+ApBTkj0gATaBKoNCAU4cgV89NIhNAQEB?= X-IPAS-Result: =?us-ascii?q?A2AKBwDEFmxY/2ZisVteHQYMgzgBAQEBAR+Ba45Jk3oBkmW?= =?us-ascii?q?CD4IIhiKBTUETAQIBAQEBAQEBYiiFFi8jKSZLJBOIYxGxODqKXYZFi3MLgwoFj?= =?us-ascii?q?waLd5E+ApBTkj0gATaBKoNCAU4cgV89NIhNAQEB?= Received: from 102.98-177-91.adsl-dyn.isp.belgacom.be (HELO inkjet2.lan) ([91.177.98.102]) by relay.skynet.be with ESMTP; 03 Jan 2017 22:30:41 +0100 From: Fabian Frederick To: Andrew Morton Cc: Jan Kara , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, fabf@skynet.be Subject: [PATCH 3/6 linux-next] fs/affs: make affs exportable Date: Tue, 3 Jan 2017 22:30:39 +0100 Message-Id: <1483479039-5255-1-git-send-email-fabf@skynet.be> X-Mailer: git-send-email 2.7.4 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add standard functions making AFFS work with NFS. Functions based on ext4 implementation. Tested on loop device. Signed-off-by: Fabian Frederick --- fs/affs/affs.h | 1 + fs/affs/namei.c | 40 ++++++++++++++++++++++++++++++++++++++++ fs/affs/super.c | 1 + 3 files changed, 42 insertions(+) diff --git a/fs/affs/affs.h b/fs/affs/affs.h index efe6839..1b55428 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h @@ -162,6 +162,7 @@ extern void affs_free_bitmap(struct super_block *sb); /* namei.c */ +extern const struct export_operations affs_export_ops; extern int affs_hash_name(struct super_block *sb, const u8 *name, unsigned int len); extern struct dentry *affs_lookup(struct inode *dir, struct dentry *dentry, unsigned int); extern int affs_unlink(struct inode *dir, struct dentry *dentry); diff --git a/fs/affs/namei.c b/fs/affs/namei.c index 29186d2..04c3156f 100644 --- a/fs/affs/namei.c +++ b/fs/affs/namei.c @@ -9,6 +9,7 @@ */ #include "affs.h" +#include typedef int (*toupper_t)(int); @@ -465,3 +466,42 @@ affs_rename(struct inode *old_dir, struct dentry *old_dentry, affs_brelse(bh); return retval; } + +static struct inode *affs_nfs_get_inode(struct super_block *sb, u64 ino, + u32 generation) +{ + struct inode *inode; + + if (!affs_validblock(sb, ino)) + return ERR_PTR(-ESTALE); + + inode = affs_iget(sb, ino); + if (IS_ERR(inode)) + return ERR_CAST(inode); + + if (generation && inode->i_generation != generation) { + iput(inode); + return ERR_PTR(-ESTALE); + } + + return inode; +} + +static struct dentry *affs_fh_to_dentry(struct super_block *sb, struct fid *fid, + int fh_len, int fh_type) +{ + return generic_fh_to_dentry(sb, fid, fh_len, fh_type, + affs_nfs_get_inode); +} + +static struct dentry *affs_fh_to_parent(struct super_block *sb, struct fid *fid, + int fh_len, int fh_type) +{ + return generic_fh_to_parent(sb, fid, fh_len, fh_type, + affs_nfs_get_inode); +} + +const struct export_operations affs_export_ops = { + .fh_to_dentry = affs_fh_to_dentry, + .fh_to_parent = affs_fh_to_parent, +}; diff --git a/fs/affs/super.c b/fs/affs/super.c index d638486..98bd952 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c @@ -507,6 +507,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) return -ENOMEM; } + sb->s_export_op = &affs_export_ops; pr_debug("s_flags=%lX\n", sb->s_flags); return 0; }