diff options
author | Boaz Harrosh <bharrosh@panasas.com> | 2009-03-22 12:47:26 +0200 |
---|---|---|
committer | Boaz Harrosh <bharrosh@panasas.com> | 2009-03-31 19:44:36 +0300 |
commit | 8cf74b3936f5c65975b68333727f0540ec8350f4 (patch) | |
tree | 99eda92b32dc7869d6f3a28215f5b854675db6b1 /fs/exofs | |
parent | ba9e5e98ca2f808fe92b103a8e6ce5271b10cc89 (diff) | |
download | kernel_samsung_smdk4412-8cf74b3936f5c65975b68333727f0540ec8350f4.zip kernel_samsung_smdk4412-8cf74b3936f5c65975b68333727f0540ec8350f4.tar.gz kernel_samsung_smdk4412-8cf74b3936f5c65975b68333727f0540ec8350f4.tar.bz2 |
exofs: export_operations
implement export_operations and set in superblock.
It is now posible to export exofs via nfs
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Diffstat (limited to 'fs/exofs')
-rw-r--r-- | fs/exofs/dir.c | 15 | ||||
-rw-r--r-- | fs/exofs/exofs.h | 1 | ||||
-rw-r--r-- | fs/exofs/super.c | 53 |
3 files changed, 69 insertions, 0 deletions
diff --git a/fs/exofs/dir.c b/fs/exofs/dir.c index 6865605..65b0c8c 100644 --- a/fs/exofs/dir.c +++ b/fs/exofs/dir.c @@ -381,6 +381,21 @@ struct exofs_dir_entry *exofs_dotdot(struct inode *dir, struct page **p) return de; } +ino_t exofs_parent_ino(struct dentry *child) +{ + struct page *page; + struct exofs_dir_entry *de; + ino_t ino; + + de = exofs_dotdot(child->d_inode, &page); + if (!de) + return 0; + + ino = le64_to_cpu(de->inode_no); + exofs_put_page(page); + return ino; +} + ino_t exofs_inode_by_name(struct inode *dir, struct dentry *dentry) { ino_t res = 0; diff --git a/fs/exofs/exofs.h b/fs/exofs/exofs.h index 11e11d5..0fd4c785 100644 --- a/fs/exofs/exofs.h +++ b/fs/exofs/exofs.h @@ -152,6 +152,7 @@ struct exofs_dir_entry *exofs_find_entry(struct inode *, struct dentry *, struct page **); int exofs_empty_dir(struct inode *); struct exofs_dir_entry *exofs_dotdot(struct inode *, struct page **); +ino_t exofs_parent_ino(struct dentry *child); int exofs_set_link(struct inode *, struct exofs_dir_entry *, struct page *, struct inode *); diff --git a/fs/exofs/super.c b/fs/exofs/super.c index b736b11..9f1985e 100644 --- a/fs/exofs/super.c +++ b/fs/exofs/super.c @@ -37,6 +37,7 @@ #include <linux/parser.h> #include <linux/vfs.h> #include <linux/random.h> +#include <linux/exportfs.h> #include "exofs.h" @@ -194,6 +195,7 @@ static void destroy_inodecache(void) * SUPERBLOCK FUNCTIONS *****************************************************************************/ static const struct super_operations exofs_sops; +static const struct export_operations exofs_export_ops; /* * Write the superblock to the OSD @@ -358,6 +360,7 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent) /* set up operation vectors */ sb->s_op = &exofs_sops; + sb->s_export_op = &exofs_export_ops; root = exofs_iget(sb, EXOFS_ROOT_ID - EXOFS_OBJ_OFF); if (IS_ERR(root)) { EXOFS_ERR("ERROR: exofs_iget failed\n"); @@ -485,6 +488,56 @@ static const struct super_operations exofs_sops = { }; /****************************************************************************** + * EXPORT OPERATIONS + *****************************************************************************/ + +struct dentry *exofs_get_parent(struct dentry *child) +{ + unsigned long ino = exofs_parent_ino(child); + + if (!ino) + return NULL; + + return d_obtain_alias(exofs_iget(child->d_inode->i_sb, ino)); +} + +static struct inode *exofs_nfs_get_inode(struct super_block *sb, + u64 ino, u32 generation) +{ + struct inode *inode; + + inode = exofs_iget(sb, ino); + if (IS_ERR(inode)) + return ERR_CAST(inode); + if (generation && inode->i_generation != generation) { + /* we didn't find the right inode.. */ + iput(inode); + return ERR_PTR(-ESTALE); + } + return inode; +} + +static struct dentry *exofs_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, + exofs_nfs_get_inode); +} + +static struct dentry *exofs_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, + exofs_nfs_get_inode); +} + +static const struct export_operations exofs_export_ops = { + .fh_to_dentry = exofs_fh_to_dentry, + .fh_to_parent = exofs_fh_to_parent, + .get_parent = exofs_get_parent, +}; + +/****************************************************************************** * INSMOD/RMMOD *****************************************************************************/ |