[BACK]Return to xfs_dm_fsops.c CVS log [TXT][DIR] Up to [Development] / xfs-linux / dmapi

File: [Development] / xfs-linux / dmapi / Attic / xfs_dm_fsops.c (download)

Revision 1.13, Tue Sep 11 06:12:43 2007 UTC (10 years, 1 month ago) by lachlan.longdrop.melbourne.sgi.com
Branch: MAIN
Changes since 1.12: +7 -7 lines

cleanup fid types mess

Currently XFs has three different fid types: struct fid, struct xfs_fid
and struct xfs_fid2 with hte latter two beeing identicaly and the first
one beeing the same size but an unstructured array with the same size.

This patch consolidates all this to alway uuse struct xfs_fid.

This patch is required for an upcoming patch series from me that revamps
the nfs exporting code and introduces a Linux-wide struct fid.


Note: the patch is ontop of Eric's inode/vnode tracing cleanup.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Merge of xfs-linux-melb:xfs-kern:29651a by kenmcd.

  cleanup fid types mess

/*
 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
 * All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms 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.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write the Free Software Foundation,
 * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
#include "xfs.h"
#include "xfs_fs.h"
#include "xfs_types.h"
#include "xfs_bit.h"
#include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_clnt.h"
#include "xfs_trans.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_dir2.h"
#include "xfs_alloc.h"
#include "xfs_dmapi.h"
#include "xfs_mount.h"
#include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h"
#include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h"
#include "xfs_inode.h"
#include "xfs_btree.h"
#include "xfs_ialloc.h"
#include "xfs_itable.h"
#include "xfs_bmap.h"
#include "xfs_rw.h"
#include "xfs_acl.h"
#include "xfs_attr.h"
#include "xfs_inode_item.h"
#include "xfs_vnodeops.h"
#include "xfs_vfsops.h"
#include <dmapi.h>
#include <dmapi_kern.h>
#include "xfs_dm.h"


STATIC const struct file_operations *
xfs_dm_get_invis_ops(
	struct inode *ip)
{
	return &xfs_invis_file_operations;
}

STATIC int
xfs_dm_fh_to_inode(
	struct super_block	*sb,
	struct inode		**ip,
	dm_fid_t		*dmfid)
{
	bhv_vnode_t	*vp = NULL;
	xfs_mount_t	*mp = XFS_M(sb);
	int		error;
	struct xfs_fid	xfid;

	/* Returns negative errors to DMAPI */

	*ip = NULL;
	memcpy(&xfid, dmfid, sizeof(*dmfid));
	if (xfid.fid_len) {	/* file object handle */
		error = xfs_vget(mp, &vp, &xfid);
	}
	else {			/* filesystem handle */
		error = xfs_root(mp, &vp);
	}
	if (vp && (error == 0))
		*ip = vn_to_inode(vp);
	return -error; /* Return negative error to DMAPI */
}

STATIC int
xfs_dm_inode_to_fh(
	struct inode		*inode,
	dm_fid_t		*dmfid,
	dm_fsid_t		*dmfsid)
{
	xfs_inode_t		*ip = XFS_I(inode);
	int			error;
	struct xfs_fid		xfid;

	/* Returns negative errors to DMAPI */

	if (ip->i_mount->m_fixedfsid == NULL)
		return -EINVAL;
	error = xfs_fid2(ip, &xfid);
	if (error)
		return -error; /* Return negative error to DMAPI */

	memcpy(dmfid, &xfid, sizeof(*dmfid));
	memcpy(dmfsid, ip->i_mount->m_fixedfsid, sizeof(*dmfsid));
	return 0;
}

STATIC int
xfs_dm_get_dmapiops(
	struct super_block	*sb,
	void			*addr)
{
	return -xfs_dm_get_fsys_vector(addr);
}

STATIC void
xfs_dm_get_fsid(
	struct super_block	*sb,
	dm_fsid_t		*fsid)
{
	memcpy(fsid, XFS_M(sb)->m_fixedfsid, sizeof(*fsid));
}

/*
 * Filesystem operations accessed by the DMAPI core.
 */
struct filesystem_dmapi_operations xfs_dmapiops = {
	.get_fsys_vector	= xfs_dm_get_dmapiops,
	.fh_to_inode		= xfs_dm_fh_to_inode,
	.get_invis_ops		= xfs_dm_get_invis_ops,
	.inode_to_fh		= xfs_dm_inode_to_fh,
	.get_fsid		= xfs_dm_get_fsid,
};