getting file pointer from dentry/inode
Hello All,
I want to find out how the file pointer from inode/dentry can be get. For example we can get inode pointer by using iget. In the struct file we can get inode/dentry (filp->f_dentry->d_inode) but how can we reversely get the struct file pointer from dentry/inode etc.
Secondly is this logically correct to get the file pointer from inode/dentry etc.
Thanks,
Uzair Lakhnai
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Quoted 2 lines
Secondly is this logically correct to get the file pointer from inode/dentry etc.
I don't think so. A single file on a disk (inode) can be opened concurrently, with different mode, with different read position, etc. Many file structures share the same inode then.
TH
Quoted 10 lines · --- Tomas Hruby
Quoted 2 lines
Secondly is this logically correct to get the file pointer from inode/dentry etc.
I don't think so. A single file on a disk (inode) can be opened concurrently,
with different mode, with different read position, etc. Many file structures
share the same inode then.TH
Hello All,
ok I agree that
"A single file on a disk (inode)
Quoted 4 lines
can be opened concurrently,
with different mode, with different read position, etc. Many file structures
share the same inode then."
but since I am getting the dentry so can I use the dentry_open function. If this is ok then additionally what is the purpose of dentry_open function.
Thanks,
Uzair Lakhani
Quoted 7 lines
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Quoted 14 lines · UZAIR LAKHANI
Quoted 9 lines · --- Tomas Hruby
Quoted 2 lines
Secondly is this logically correct to get the file pointer from inode/dentry etc.
I don't think so. A single file on a disk (inode) can be opened concurrently,
with different mode, with different read position, etc. Many file structures
share the same inode then.ok I agree that
"A single file on a disk (inode)
Quoted 9 lines
Quoted 4 lines
can be opened concurrently,
with different mode, with different read position, etc. Many file structures
share the same inode then."but since I am getting the dentry so can I use the
dentry_openfunction. If this is ok then additionally what is the purpose ofdentry_openfunction.
Ya, I think its ok to do so, as nfsd and others also do so (see
http://sosdg.org/~coywolf/lxr/source/fs/nfsd/vfs.c#L684). dentry_open actually gets a new filp and then fill it with the information got from dentry (many from dentry_d_inode) and returns that newly created filp see the code for it
(http://sosdg.org/~coywolf/lxr/source/fs/open.c#L784)
--
Fawad Lateef
Quoted 9 lines · UZAIR LAKHANI
Hello All,
I want to find out how the file pointer from inode/dentry can be get. For example we can get inode pointer by using iget. In the struct file we can get inode/dentry (
filp->f_dentry->d_inode) but how can we reversely get the struct file pointer from dentry/inode etc.
You can try to get the filp from filp->f_dentry->d_inode using the same way as list_entry macro in include/linux/list.h do and you have to do that list_entry kind of stuff two times to get to the filp from d_inode (as in one pass you can get f_dentry and then from f_dentry you can get to filp). I hope it will help but can't say that its a good way !
Quoted 3 lines
Secondly is this logically correct to get the file pointer from inode/dentry etc.
I can't say doing this is logically correct or not, but I can say if this really helps and you won't able to get the better way of accessing filp then you can do so or other people might give you some better idea but they probably need to know why and where you want to do this :)
--
Fawad Lateef