fs/affs: make affs exportable
authorFabian Frederick <fabf@skynet.be>
Mon, 27 Feb 2017 22:27:49 +0000 (14:27 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 28 Feb 2017 02:43:45 +0000 (18:43 -0800)
Add standard functions making AFFS work with NFS.

Functions based on ext4 implementation.  Tested on loop device.

Link: http://lkml.kernel.org/r/20170109191208.6085-4-fabf@skynet.be
Signed-off-by: Fabian Frederick <fabf@skynet.be>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/affs/affs.h
fs/affs/namei.c
fs/affs/super.c

index efe683947df9d0b8de61f54248b4402f2d6bbfe0..1b5542818b2c0b2209974e23b7aa3dd014704c66 100644 (file)
@@ -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);
index 29186d29a3b611809f70b1ee7ba0cce4eb85d824..04c3156ff4119b4cc6b7cfde8cddbcacffc303c6 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include "affs.h"
+#include <linux/exportfs.h>
 
 typedef int (*toupper_t)(int);
 
@@ -465,3 +466,42 @@ done:
        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,
+};
index d6384863192ca5c47a3593680c59713dfff8ad29..98bd95291694552c33235b5ab20a6a479cd08025 100644 (file)
@@ -507,6 +507,7 @@ got_root:
                return -ENOMEM;
        }
 
+       sb->s_export_op = &affs_export_ops;
        pr_debug("s_flags=%lX\n", sb->s_flags);
        return 0;
 }