xfs
[Top] [All Lists]

Re: [DMAPI] code error in dm_ip_to_handle()

To: Dean Roehrich <roehrich@xxxxxxx>
Subject: Re: [DMAPI] code error in dm_ip_to_handle()
From: Aurelien Degremont - Stagiaire <degremont@xxxxxxxxxxx>
Date: Mon, 16 May 2005 17:04:48 +0200
Cc: linux-xfs@xxxxxxxxxxx
In-reply-to: <20050516144914.4C3244FE8A@xxxxxxxxxxxxxxxxxxxxxxxx>
References: <20050516144914.4C3244FE8A@xxxxxxxxxxxxxxxxxxxxxxxx>
Sender: linux-xfs-bounce@xxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.2.1) Gecko/20030225
Dean Roehrich a écrit:
- fh_to_inode() must test the fid_len field and return the root inode number if its value is zero.


No.  fh_to_inode() doesn't have to modify the dm_fsfid at all.  It just needs
to check that it refers to a valid inode, and then it needs to return that
inode.

I'm sorry if I was unclear here.
I never said dmfsfid need to be modified. We just check its fid_len, return the root inode if null or return the file inode refers by the filehandle otherwise. When the inode number is known, try to get it with a iget(), if the iget succeeded, the inode was correct, else, return an error.
Here is my full function code, I think it agrees with your explanations :

static int
ext3_dm_fh_to_inode(
        struct super_block      *sb,
        struct inode            **ip,
        struct dm_fsfid         *dmfsfid)
{
        int error =     0;
        ino_t ino =     0;
        dm_fid_t fid;


        /*
* Read the inode number from the handle and fetch the corresponding
         * inode.
         */


        /* FS HANDLE */
        if (dmfsfid->fid_len == 0)
                ino = EXT3_ROOT_INO;
        /* Else FILE HANDLE */
        else
        {
                memcpy(&fid, dmfsfid, sizeof(fid));
                ino = fid.dm_fid_ino; /* memcpy() here ? */
        }


        *ip = iget(sb, ino);
        if (*ip == NULL)
                error = EIO;

        return -error; /* Return negative error to DMAPI */
}


Aurelien


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