Hello every one,
I get something confused about unlink function of filesystem. I have dput function in my unlink function to destory the dentry, but after doing this, I get error message "Unable to handle kernel NULL pointer dereference at virtual address 00000080". Conversely, removing the dput function from my unlink function, it work well. Refering to Ramfs filesystem, I find it have dput in it's unlink function, simple_unlink. But looking into ext2 filesystem, the dput function is not in it's unlink function.
The bellow is the vfs_unlink code
int vfs_unlink(struct inode *dir, struct dentry *dentry){
.............
if (d_mountpoint(dentry))
error = -EBUSY;
else {
error = security_inode_unlink(dir, dentry);
if (!error)
error = dir->i_op->unlink(dir, dentry);
}
if (!error && !(dentry->d_flags & DCACHE_NFSFS_RENAMED)) {
d_delete(dentry);
}
return error;
}
I think the dentry will be destoried by my unlink function(dir->i_op->unlink) when I let dput in my unlink funcion. And d_delete will destory the dentry again, so I get the error message.
mmmmh~ Why the ramfs can work well with dput in the simple_unlink function?
Something must be wrong in my thought ><
Thank you,
Regards
re: filesystem unlink function problem
maybe, i find the answer.
vfs_unlink
If having dput function in my unlink function, the dentry is destroy at (a). so when d_delete being called at (b), it will err with the NULL point. But the ramfs have it's dentry pin in the memory, and it increase more one count at its dentry count. When meeting the point (a), it only decrease the dentry count, and really destroy it's dentry at (b).
--
One linux newbie is here. Ready to get knowledge and contribute something.