xfs
[Top] [All Lists]

finding xfs_mount_t for specified device

To: linux-xfs@xxxxxxxxxxx
Subject: finding xfs_mount_t for specified device
From: Soon-Son Kwon <kss@xxxxxxxx>
Date: Thu, 17 Apr 2003 09:13:20 +0900
Organization: KLDP(Korean Linux Documentation Project)
Reply-to: kss@xxxxxxxx
Sender: linux-xfs-bounce@xxxxxxxxxxx
User-agent: Mutt/1.2.5i
Hi, I managed to make a very *primative* function 
that finds xfs_mount_t structure for a specified
device(e.g. /dev/hda2) from scratch but it does not 
work as I expected.

If anyone please take a look at my code and let me 
know where to modify, I'd appreciate it very much.


Thanks very much.
---
int xfssnap_findmp(const char *devname, xfs_mount_t *mp)
{
        int             fd, size;
        struct file     *file;
        struct inode    *inode;

        bhv_desc_t      *bdp;
        vn_bhv_head_t   *bhp;
        vnode_t         *vp; 
        xfs_inode_t     *ip;

        xfs_attr_multiop_t      *ops;
        xfs_fsop_attrmulti_handlereq_t  *am_hreq;

        size = sizeof(xfs_fsop_attrmulti_handlereq_t);
        am_hreq = (xfs_fsop_attrmulti_handlereq_t *)kmalloc(size, GFP_KERNEL);

        fd = open(devname, O_RDONLY, 0);
        file = fget(fd);
        inode = file->f_dentry->d_inode;
 
        vp = LINVFS_GET_VP(inode);
        bhp = VN_BHV_HEAD(vp);
        size = am_hreq->opcount * sizeof(attr_multiop_t);
        ops = (xfs_attr_multiop_t *)kmalloc(size, GFP_KERNEL);
        if(!ops)
        {
                VN_RELE(vp);
                return -XFS_ERROR(ENOMEM);
        }

        bdp = bhv_lookup(bhp, ops);

        vn_trace_entry(vp, "xfs_ioctl", (inst_t *)__return_address);

        ip = XFS_BHVTOI(bdp);
        mp = ip->i_mount;

        printk("xfssnap_findmp executed\n");

        kfree(am_hreq);
        kfree(ops);
        return 0;
}
-- 
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
           (o_             **WTFM**
(o_  (o_   //\
(/)_ (/)_  V_/_        http://kldp.org
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*     


<Prev in Thread] Current Thread [Next in Thread>