diff options
| author | Christoph Hellwig <hch@sgi.com> | 2005-01-12 14:22:04 +1100 |
|---|---|---|
| committer | Nathan Scott <nathans@sgi.com> | 2005-01-12 14:22:04 +1100 |
| commit | ce13630941f6897813c8cbb7f7efd873b17ab82a (patch) | |
| tree | d08a9900e65d4ce72adea4d620cf873c56a64ee6 | |
| parent | 0c0695b0a777713dfd3a463780f00cbf2384c71e (diff) | |
[XFS] Move support code for NFS exporting to a conditionally built file
SGI-PV: 923968
SGI-Modid: xfs-linux:xfs-kern:185437a
Signed-off-by: Christoph Hellwig <hch@sgi.com>
Signed-off-by: Nathan Scott <nathans@sgi.com>
| -rw-r--r-- | fs/xfs/linux-2.6/xfs_export.c | 130 | ||||
| -rw-r--r-- | fs/xfs/linux-2.6/xfs_super.c | 100 | ||||
| -rw-r--r-- | fs/xfs/linux-2.6/xfs_super.h | 2 |
3 files changed, 134 insertions, 98 deletions
diff --git a/fs/xfs/linux-2.6/xfs_export.c b/fs/xfs/linux-2.6/xfs_export.c new file mode 100644 index 000000000000..772d216d8146 --- /dev/null +++ b/fs/xfs/linux-2.6/xfs_export.c @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Further, this software is distributed without any warranty that it is + * free of the rightful claim of any third person regarding infringement + * or the like. Any license provided herein, whether implied or + * otherwise, applies only to this software file. Patent licenses, if + * any, provided herein do not apply to combinations of this program with + * other software, or any other product whatsoever. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston MA 02111-1307, USA. + * + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, + * Mountain View, CA 94043, or: + * + * http://www.sgi.com + * + * For further information regarding this notice, see: + * + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ + */ + +#include "xfs.h" + + +STATIC struct dentry * +linvfs_decode_fh( + struct super_block *sb, + __u32 *fh, + int fh_len, + int fileid_type, + int (*acceptable)( + void *context, + struct dentry *de), + void *context) +{ + __u32 parent[2]; + parent[0] = parent[1] = 0; + + if (fh_len < 2 || fileid_type > 2) + return NULL; + + if (fileid_type == 2 && fh_len > 2) { + if (fh_len == 3) { + printk(KERN_WARNING + "XFS: detected filehandle without " + "parent inode generation information."); + return ERR_PTR(-ESTALE); + } + + parent[0] = fh[2]; + parent[1] = fh[3]; + } + + return find_exported_dentry(sb, fh, parent, acceptable, context); + +} + +STATIC struct dentry * +linvfs_get_dentry( + struct super_block *sb, + void *data) +{ + vnode_t *vp; + struct inode *inode; + struct dentry *result; + xfs_fid2_t xfid; + vfs_t *vfsp = LINVFS_GET_VFS(sb); + int error; + + xfid.fid_len = sizeof(xfs_fid2_t) - sizeof(xfid.fid_len); + xfid.fid_pad = 0; + xfid.fid_gen = ((__u32 *)data)[1]; + xfid.fid_ino = ((__u32 *)data)[0]; + + VFS_VGET(vfsp, &vp, (fid_t *)&xfid, error); + if (error || vp == NULL) + return ERR_PTR(-ESTALE) ; + + inode = LINVFS_GET_IP(vp); + result = d_alloc_anon(inode); + if (!result) { + iput(inode); + return ERR_PTR(-ENOMEM); + } + return result; +} + +STATIC struct dentry * +linvfs_get_parent( + struct dentry *child) +{ + int error; + vnode_t *vp, *cvp; + struct dentry *parent; + struct dentry dotdot; + + dotdot.d_name.name = ".."; + dotdot.d_name.len = 2; + dotdot.d_inode = NULL; + + cvp = NULL; + vp = LINVFS_GET_VP(child->d_inode); + VOP_LOOKUP(vp, &dotdot, &cvp, 0, NULL, NULL, error); + if (unlikely(error)) + return ERR_PTR(-error); + + parent = d_alloc_anon(LINVFS_GET_IP(cvp)); + if (unlikely(!parent)) { + VN_RELE(cvp); + return ERR_PTR(-ENOMEM); + } + return parent; +} + +struct export_operations linvfs_export_ops = { + .decode_fh = linvfs_decode_fh, + .get_parent = linvfs_get_parent, + .get_dentry = linvfs_get_dentry, +}; diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c index 0de349912654..10eeffc102df 100644 --- a/fs/xfs/linux-2.6/xfs_super.c +++ b/fs/xfs/linux-2.6/xfs_super.c @@ -76,7 +76,6 @@ STATIC struct quotactl_ops linvfs_qops; STATIC struct super_operations linvfs_sops; -STATIC struct export_operations linvfs_export_ops; STATIC kmem_zone_t *linvfs_inode_zone; STATIC kmem_shaker_t xfs_inode_shaker; @@ -661,96 +660,6 @@ linvfs_freeze_fs( VFS_FREEZE(LINVFS_GET_VFS(sb)); } -STATIC struct dentry * -linvfs_get_parent( - struct dentry *child) -{ - int error; - vnode_t *vp, *cvp; - struct dentry *parent; - struct dentry dotdot; - - dotdot.d_name.name = ".."; - dotdot.d_name.len = 2; - dotdot.d_inode = NULL; - - cvp = NULL; - vp = LINVFS_GET_VP(child->d_inode); - VOP_LOOKUP(vp, &dotdot, &cvp, 0, NULL, NULL, error); - if (unlikely(error)) - return ERR_PTR(-error); - - parent = d_alloc_anon(LINVFS_GET_IP(cvp)); - if (unlikely(!parent)) { - VN_RELE(cvp); - return ERR_PTR(-ENOMEM); - } - return parent; -} - -STATIC struct dentry * -linvfs_get_dentry( - struct super_block *sb, - void *data) -{ - vnode_t *vp; - struct inode *inode; - struct dentry *result; - xfs_fid2_t xfid; - vfs_t *vfsp = LINVFS_GET_VFS(sb); - int error; - - xfid.fid_len = sizeof(xfs_fid2_t) - sizeof(xfid.fid_len); - xfid.fid_pad = 0; - xfid.fid_gen = ((__u32 *)data)[1]; - xfid.fid_ino = ((__u32 *)data)[0]; - - VFS_VGET(vfsp, &vp, (fid_t *)&xfid, error); - if (error || vp == NULL) - return ERR_PTR(-ESTALE) ; - - inode = LINVFS_GET_IP(vp); - result = d_alloc_anon(inode); - if (!result) { - iput(inode); - return ERR_PTR(-ENOMEM); - } - return result; -} - -STATIC struct dentry * -linvfs_decode_fh( - struct super_block *sb, - __u32 *fh, - int fh_len, - int fileid_type, - int (*acceptable)( - void *context, - struct dentry *de), - void *context) -{ - __u32 parent[2]; - parent[0] = parent[1] = 0; - - if (fh_len < 2 || fileid_type > 2) - return NULL; - - if (fileid_type == 2 && fh_len > 2) { - if (fh_len == 3) { - printk(KERN_WARNING - "XFS: detected filehandle without " - "parent inode generation information."); - return ERR_PTR(-ESTALE); - } - - parent[0] = fh[2]; - parent[1] = fh[3]; - } - - return find_exported_dentry(sb, fh, parent, acceptable, context); - -} - STATIC int linvfs_show_options( struct seq_file *m, @@ -843,7 +752,9 @@ linvfs_fill_super( } sb_min_blocksize(sb, BBSIZE); +#ifdef CONFIG_EXPORTFS sb->s_export_op = &linvfs_export_ops; +#endif sb->s_qcop = &linvfs_qops; sb->s_op = &linvfs_sops; @@ -912,13 +823,6 @@ linvfs_get_sb( return get_sb_bdev(fs_type, flags, dev_name, data, linvfs_fill_super); } - -STATIC struct export_operations linvfs_export_ops = { - .decode_fh = linvfs_decode_fh, - .get_parent = linvfs_get_parent, - .get_dentry = linvfs_get_dentry, -}; - STATIC struct super_operations linvfs_sops = { .alloc_inode = linvfs_alloc_inode, .destroy_inode = linvfs_destroy_inode, diff --git a/fs/xfs/linux-2.6/xfs_super.h b/fs/xfs/linux-2.6/xfs_super.h index 866c7ad75f92..ec7e0035c731 100644 --- a/fs/xfs/linux-2.6/xfs_super.h +++ b/fs/xfs/linux-2.6/xfs_super.h @@ -133,4 +133,6 @@ extern int xfs_blkdev_get(struct xfs_mount *, const char *, struct block_device **); extern void xfs_blkdev_put(struct block_device *); +extern struct export_operations linvfs_export_ops; + #endif /* __XFS_SUPER_H__ */ |
