Skip to content

Commit ed4433d

Browse files
Fabian Fredericktorvalds
authored andcommitted
fs/affs: make affs exportable
Add standard functions making AFFS work with NFS. Functions based on ext4 implementation. Tested on loop device. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Fabian Frederick <[email protected]> Cc: Al Viro <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent d5de9fd commit ed4433d

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

fs/affs/affs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ extern void affs_free_bitmap(struct super_block *sb);
162162

163163
/* namei.c */
164164

165+
extern const struct export_operations affs_export_ops;
165166
extern int affs_hash_name(struct super_block *sb, const u8 *name, unsigned int len);
166167
extern struct dentry *affs_lookup(struct inode *dir, struct dentry *dentry, unsigned int);
167168
extern int affs_unlink(struct inode *dir, struct dentry *dentry);

fs/affs/namei.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
#include "affs.h"
12+
#include <linux/exportfs.h>
1213

1314
typedef int (*toupper_t)(int);
1415

@@ -465,3 +466,42 @@ affs_rename(struct inode *old_dir, struct dentry *old_dentry,
465466
affs_brelse(bh);
466467
return retval;
467468
}
469+
470+
static struct inode *affs_nfs_get_inode(struct super_block *sb, u64 ino,
471+
u32 generation)
472+
{
473+
struct inode *inode;
474+
475+
if (!affs_validblock(sb, ino))
476+
return ERR_PTR(-ESTALE);
477+
478+
inode = affs_iget(sb, ino);
479+
if (IS_ERR(inode))
480+
return ERR_CAST(inode);
481+
482+
if (generation && inode->i_generation != generation) {
483+
iput(inode);
484+
return ERR_PTR(-ESTALE);
485+
}
486+
487+
return inode;
488+
}
489+
490+
static struct dentry *affs_fh_to_dentry(struct super_block *sb, struct fid *fid,
491+
int fh_len, int fh_type)
492+
{
493+
return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
494+
affs_nfs_get_inode);
495+
}
496+
497+
static struct dentry *affs_fh_to_parent(struct super_block *sb, struct fid *fid,
498+
int fh_len, int fh_type)
499+
{
500+
return generic_fh_to_parent(sb, fid, fh_len, fh_type,
501+
affs_nfs_get_inode);
502+
}
503+
504+
const struct export_operations affs_export_ops = {
505+
.fh_to_dentry = affs_fh_to_dentry,
506+
.fh_to_parent = affs_fh_to_parent,
507+
};

fs/affs/super.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
507507
return -ENOMEM;
508508
}
509509

510+
sb->s_export_op = &affs_export_ops;
510511
pr_debug("s_flags=%lX\n", sb->s_flags);
511512
return 0;
512513
}

0 commit comments

Comments
 (0)