aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ntfs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2007-10-21 19:42:10 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-22 11:13:20 -0400
commita35132068a91907c29328abc3156d31e50673412 (patch)
tree2247cf3a16445a95355812b46b29d09b836412a7 /fs/ntfs
parentd425de704334dc2bad64ca6ea2ac20ef33c9e754 (diff)
ntfs: new export ops
Trivial switch over to the new generic helpers. Signed-off-by: Christoph Hellwig <hch@lst.de> Cc: Neil Brown <neilb@suse.de> Cc: "J. Bruce Fields" <bfields@fieldses.org> Cc: Anton Altaparmakov <aia21@cantab.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ntfs')
-rw-r--r--fs/ntfs/namei.c75
1 files changed, 28 insertions, 47 deletions
diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
index e93c6142b23c..887c5e131093 100644
--- a/fs/ntfs/namei.c
+++ b/fs/ntfs/namei.c
@@ -450,58 +450,40 @@ try_next:
450 return parent_dent; 450 return parent_dent;
451} 451}
452 452
453/** 453static struct inode *ntfs_nfs_get_inode(struct super_block *sb,
454 * ntfs_get_dentry - find a dentry for the inode from a file handle sub-fragment 454 u64 ino, u32 generation)
455 * @sb: super block identifying the mounted ntfs volume
456 * @fh: the file handle sub-fragment
457 *
458 * Find a dentry for the inode given a file handle sub-fragment. This function
459 * is called from fs/exportfs/expfs.c::find_exported_dentry() which in turn is
460 * called from the default ->decode_fh() which is export_decode_fh() in the
461 * same file. The code is closely based on the default ->get_dentry() helper
462 * fs/exportfs/expfs.c::get_object().
463 *
464 * The @fh contains two 32-bit unsigned values, the first one is the inode
465 * number and the second one is the inode generation.
466 *
467 * Return the dentry on success or the error code on error (IS_ERR() is true).
468 */
469static struct dentry *ntfs_get_dentry(struct super_block *sb, void *fh)
470{ 455{
471 struct inode *vi; 456 struct inode *inode;
472 struct dentry *dent;
473 unsigned long ino = ((u32 *)fh)[0];
474 u32 gen = ((u32 *)fh)[1];
475 457
476 ntfs_debug("Entering for inode 0x%lx, generation 0x%x.", ino, gen); 458 inode = ntfs_iget(sb, ino);
477 vi = ntfs_iget(sb, ino); 459 if (!IS_ERR(inode)) {
478 if (IS_ERR(vi)) { 460 if (is_bad_inode(inode) || inode->i_generation != generation) {
479 ntfs_error(sb, "Failed to get inode 0x%lx.", ino); 461 iput(inode);
480 return (struct dentry *)vi; 462 inode = ERR_PTR(-ESTALE);
481 } 463 }
482 if (unlikely(is_bad_inode(vi) || vi->i_generation != gen)) {
483 /* We didn't find the right inode. */
484 ntfs_error(sb, "Inode 0x%lx, bad count: %d %d or version 0x%x "
485 "0x%x.", vi->i_ino, vi->i_nlink,
486 atomic_read(&vi->i_count), vi->i_generation,
487 gen);
488 iput(vi);
489 return ERR_PTR(-ESTALE);
490 }
491 /* Now find a dentry. If possible, get a well-connected one. */
492 dent = d_alloc_anon(vi);
493 if (unlikely(!dent)) {
494 iput(vi);
495 return ERR_PTR(-ENOMEM);
496 } 464 }
497 ntfs_debug("Done for inode 0x%lx, generation 0x%x.", ino, gen); 465
498 return dent; 466 return inode;
467}
468
469static struct dentry *ntfs_fh_to_dentry(struct super_block *sb, struct fid *fid,
470 int fh_len, int fh_type)
471{
472 return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
473 ntfs_nfs_get_inode);
474}
475
476static struct dentry *ntfs_fh_to_parent(struct super_block *sb, struct fid *fid,
477 int fh_len, int fh_type)
478{
479 return generic_fh_to_parent(sb, fid, fh_len, fh_type,
480 ntfs_nfs_get_inode);
499} 481}
500 482
501/** 483/**
502 * Export operations allowing NFS exporting of mounted NTFS partitions. 484 * Export operations allowing NFS exporting of mounted NTFS partitions.
503 * 485 *
504 * We use the default ->decode_fh() and ->encode_fh() for now. Note that they 486 * We use the default ->encode_fh() for now. Note that they
505 * use 32 bits to store the inode number which is an unsigned long so on 64-bit 487 * use 32 bits to store the inode number which is an unsigned long so on 64-bit
506 * architectures is usually 64 bits so it would all fail horribly on huge 488 * architectures is usually 64 bits so it would all fail horribly on huge
507 * volumes. I guess we need to define our own encode and decode fh functions 489 * volumes. I guess we need to define our own encode and decode fh functions
@@ -520,7 +502,6 @@ static struct dentry *ntfs_get_dentry(struct super_block *sb, void *fh)
520struct export_operations ntfs_export_ops = { 502struct export_operations ntfs_export_ops = {
521 .get_parent = ntfs_get_parent, /* Find the parent of a given 503 .get_parent = ntfs_get_parent, /* Find the parent of a given
522 directory. */ 504 directory. */
523 .get_dentry = ntfs_get_dentry, /* Find a dentry for the inode 505 .fh_to_dentry = ntfs_fh_to_dentry,
524 given a file handle 506 .fh_to_parent = ntfs_fh_to_parent,
525 sub-fragment. */
526}; 507};