Skip to content

Commit ac632f5

Browse files
committed
befs: add NFS export support
Implement mandatory export_operations, so it is possible to export befs via nfs. Signed-off-by: Luis de Bethencourt <[email protected]>
1 parent e60f749 commit ac632f5

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

fs/befs/linuxvfs.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/parser.h>
1919
#include <linux/namei.h>
2020
#include <linux/sched.h>
21+
#include <linux/exportfs.h>
2122

2223
#include "befs.h"
2324
#include "btree.h"
@@ -52,6 +53,10 @@ static void befs_put_super(struct super_block *);
5253
static int befs_remount(struct super_block *, int *, char *);
5354
static int befs_statfs(struct dentry *, struct kstatfs *);
5455
static int parse_options(char *, struct befs_mount_options *);
56+
static struct dentry *befs_fh_to_dentry(struct super_block *sb,
57+
struct fid *fid, int fh_len, int fh_type);
58+
static struct dentry *befs_fh_to_parent(struct super_block *sb,
59+
struct fid *fid, int fh_len, int fh_type);
5560

5661
static const struct super_operations befs_sops = {
5762
.alloc_inode = befs_alloc_inode, /* allocate a new inode */
@@ -84,6 +89,11 @@ static const struct address_space_operations befs_symlink_aops = {
8489
.readpage = befs_symlink_readpage,
8590
};
8691

92+
static const struct export_operations befs_export_operations = {
93+
.fh_to_dentry = befs_fh_to_dentry,
94+
.fh_to_parent = befs_fh_to_parent,
95+
};
96+
8797
/*
8898
* Called by generic_file_read() to read a page of data
8999
*
@@ -629,6 +639,33 @@ befs_nls2utf(struct super_block *sb, const char *in,
629639
return -EILSEQ;
630640
}
631641

642+
static struct inode *befs_nfs_get_inode(struct super_block *sb, uint64_t ino,
643+
uint32_t generation)
644+
{
645+
/* No need to handle i_generation */
646+
return befs_iget(sb, ino);
647+
}
648+
649+
/*
650+
* Map a NFS file handle to a corresponding dentry
651+
*/
652+
static struct dentry *befs_fh_to_dentry(struct super_block *sb,
653+
struct fid *fid, int fh_len, int fh_type)
654+
{
655+
return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
656+
befs_nfs_get_inode);
657+
}
658+
659+
/*
660+
* Find the parent for a file specified by NFS handle
661+
*/
662+
static struct dentry *befs_fh_to_parent(struct super_block *sb,
663+
struct fid *fid, int fh_len, int fh_type)
664+
{
665+
return generic_fh_to_parent(sb, fid, fh_len, fh_type,
666+
befs_nfs_get_inode);
667+
}
668+
632669
enum {
633670
Opt_uid, Opt_gid, Opt_charset, Opt_debug, Opt_err,
634671
};
@@ -829,6 +866,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
829866
/* Set real blocksize of fs */
830867
sb_set_blocksize(sb, (ulong) befs_sb->block_size);
831868
sb->s_op = &befs_sops;
869+
sb->s_export_op = &befs_export_operations;
832870
root = befs_iget(sb, iaddr2blockno(sb, &(befs_sb->root_dir)));
833871
if (IS_ERR(root)) {
834872
ret = PTR_ERR(root);

0 commit comments

Comments
 (0)