xfs
[Top] [All Lists]

XFS and nfsd_operations patch

To: linux-xfs@xxxxxxxxxxx
Subject: XFS and nfsd_operations patch
From: Jan Rekorajski <baggins@xxxxxxxxxxxxxxxxx>
Date: Mon, 7 May 2001 18:23:48 +0200
Sender: owner-linux-xfs@xxxxxxxxxxx
User-agent: Mutt/1.3.17i
Hi,
Some time ago Neil Brown made an nfsd_operations patch (available at
http://cgi.cse.unsw.edu.au/~neilb/patches/linux/) which needs a
find_parent method[1]. This patch is required for reiserfs to work
reliably with NFS and as I want both reiserfs and XFS to be servable
via NFS I made a small patch for XFS to work with nfsd_operations.

Could some XFS hacker please check the following code if it's correct?
I tested it, it Works For Me(tm) but I want to be on the safe side :)

[1] struct dentry * get_parent(struct dentry *child):
    get_parent should find the parent directory for the given child which is
    also a directory.  In the event that it cannot be found, or storage space
    cannot be allocated, a %ERR_PTR should be returned.


struct dentry * linvfs_get_parent(struct dentry *child)
{
        int             error;
        vnode_t         *vp, *cvp;
        pathname_t      pn;
        pathname_t      *pnp = &pn;
        struct inode    *ip = NULL;
        struct dentry   *parent;

        vp = LINVFS_GET_VP(child->d_inode);
        ASSERT(vp);

        /*
         * Initialize a pathname_t to pass down.
         */
        bzero(pnp, sizeof(pathname_t));
        pnp->pn_complen = 2;
        pnp->pn_path = "..";

        cvp = NULL;

        VOP_LOOKUP(vp, "..", &cvp, pnp, 0, NULL, NULL, error);
        if (!error) {
                ASSERT(cvp);
                ip = LINVFS_GET_IP(cvp);
                if (!ip) {
                        VN_RELE(cvp);
                        return ERR_PTR(-EACCES);
                }
                linvfs_set_inode_ops(ip);
                error = linvfs_revalidate_core(ip, ATTR_COMM);
        }

        parent = d_make_alias(ip);
        if (!parent) {
                VN_RELE(cvp);
                parent = ERR_PTR(-ENOMEM);
        }

        return parent;
}

Jan
-- 
Jan Rękorajski            |  ALL SUSPECTS ARE GUILTY. PERIOD!
baggins<at>mimuw.edu.pl   |  OTHERWISE THEY WOULDN'T BE SUSPECTS, WOULD THEY?
BOFH, MANIAC              |                   -- TROOPS by Kevin Rubio

<Prev in Thread] Current Thread [Next in Thread>
  • XFS and nfsd_operations patch, Jan Rekorajski <=