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
|