diff options
author | Luis de Bethencourt <luisbg@osg.samsung.com> | 2016-11-04 11:23:12 -0400 |
---|---|---|
committer | Luis de Bethencourt <luisbg@osg.samsung.com> | 2016-12-22 06:25:24 -0500 |
commit | ac632f5b6301c4beb19f9ea984ce0dc67b6e5874 (patch) | |
tree | d60b69e8c35b3179ffce65d113acf8bca5f31622 | |
parent | e60f749b60979e333764b8e9143aad7a7bdea0fa (diff) |
befs: add NFS export support
Implement mandatory export_operations, so it is possible to export befs via
nfs.
Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
-rw-r--r-- | fs/befs/linuxvfs.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 4cfead66decc..19407165f4aa 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/parser.h> | 18 | #include <linux/parser.h> |
19 | #include <linux/namei.h> | 19 | #include <linux/namei.h> |
20 | #include <linux/sched.h> | 20 | #include <linux/sched.h> |
21 | #include <linux/exportfs.h> | ||
21 | 22 | ||
22 | #include "befs.h" | 23 | #include "befs.h" |
23 | #include "btree.h" | 24 | #include "btree.h" |
@@ -52,6 +53,10 @@ static void befs_put_super(struct super_block *); | |||
52 | static int befs_remount(struct super_block *, int *, char *); | 53 | static int befs_remount(struct super_block *, int *, char *); |
53 | static int befs_statfs(struct dentry *, struct kstatfs *); | 54 | static int befs_statfs(struct dentry *, struct kstatfs *); |
54 | static int parse_options(char *, struct befs_mount_options *); | 55 | 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); | ||
55 | 60 | ||
56 | static const struct super_operations befs_sops = { | 61 | static const struct super_operations befs_sops = { |
57 | .alloc_inode = befs_alloc_inode, /* allocate a new inode */ | 62 | .alloc_inode = befs_alloc_inode, /* allocate a new inode */ |
@@ -84,6 +89,11 @@ static const struct address_space_operations befs_symlink_aops = { | |||
84 | .readpage = befs_symlink_readpage, | 89 | .readpage = befs_symlink_readpage, |
85 | }; | 90 | }; |
86 | 91 | ||
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 | |||
87 | /* | 97 | /* |
88 | * Called by generic_file_read() to read a page of data | 98 | * Called by generic_file_read() to read a page of data |
89 | * | 99 | * |
@@ -629,6 +639,33 @@ conv_err: | |||
629 | return -EILSEQ; | 639 | return -EILSEQ; |
630 | } | 640 | } |
631 | 641 | ||
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 | |||
632 | enum { | 669 | enum { |
633 | Opt_uid, Opt_gid, Opt_charset, Opt_debug, Opt_err, | 670 | Opt_uid, Opt_gid, Opt_charset, Opt_debug, Opt_err, |
634 | }; | 671 | }; |
@@ -829,6 +866,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent) | |||
829 | /* Set real blocksize of fs */ | 866 | /* Set real blocksize of fs */ |
830 | sb_set_blocksize(sb, (ulong) befs_sb->block_size); | 867 | sb_set_blocksize(sb, (ulong) befs_sb->block_size); |
831 | sb->s_op = &befs_sops; | 868 | sb->s_op = &befs_sops; |
869 | sb->s_export_op = &befs_export_operations; | ||
832 | root = befs_iget(sb, iaddr2blockno(sb, &(befs_sb->root_dir))); | 870 | root = befs_iget(sb, iaddr2blockno(sb, &(befs_sb->root_dir))); |
833 | if (IS_ERR(root)) { | 871 | if (IS_ERR(root)) { |
834 | ret = PTR_ERR(root); | 872 | ret = PTR_ERR(root); |