>I'm reading the VFS implementation. The VFS has four primary object
types:
superblock, inode, dentry, file. A book says that " a dentry represents a component in path, which >might include a regular file. In other words, a dentry is not the same as a directory, but a directory is the same as a file.". I so confused about the difference dentry and >directory. Can anyone explain more about it? > Say a process is opening a file /mydir/test. then in the pathname lookup procedure the dentry object is created by the kernel for every component of a pathname. the dentry object associates the component to its corresponding inode. For example, when looking up the /mydir/test pathname, the kernel creates a dentry object for the "/" root directory, a second dentry object for the "mydir" entry of the root directory, and a third dentry object for the "test" entry of the /mydir directory. An individual dentry usually has a pointer to an inode. Inodes are the things that live on disc drives, and is a descriptor for a regular file, directory, FIFO or anyting else . Dentries live in RAM and are never saved to disc: they exist only for performance. on unix filesystems such as ext2/3 directories and files have same structure.. thats why its written that "............. a directory is the same as a file............." but on filesystems such as FAT /NTFS its not the same.. The most recently used dentry objects are contained in a disk cache named the dentry cache, which speeds up the translation from a file pathname to the inode of the last pathname component. regards lk
|