What is the difference between f_inode of the file object and d_inode of the dentry object in the Linux VFS?

118 Views Asked by At

I understand that when a file is opened, its inode is brought into memory.

I want to know whether the f_inode in the file object and the d_inode in the dentry object both point to the same in-memory inode for a given file.

1

There are 1 best solutions below

3
mbrain On

The key difference (as the characters d and f implies) is that f_inode points to the inode associated with a file, while d_inode points to the inode associated with a directory.

struct file *my_file;
struct dentry *my_dentry;  

struct inode *file_inode = my_file->f_inode;
struct inode *dir_inode = my_dentry->d_inode;