Re: regarding dentry

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Aditya-

I'm not the best person to answer these questions, so I'm copying the
Kernel Newbies list. I'll try to answer as best as I can:

> 1.
> does dentry contains full path name ???
> ( for a path /user/bin/usr1 there will be 4 dentries and d_name.name
> will be "/", "/user" /user/bin", "/user/bin/usr1" )
> is this correct or the d_name.name will be "/", "user", "bin" and
> "usr1" and they will be linked by parent pointers. ??

Your second guess is correct. Each dentry holds the name of just its
component of the path ("/", "usr", "bin", "usr1"). Each dentry has a
parent pointer and a linked list of child pointers. The parent pointer
of the root dentry of a filesystem points at itself.

> 2.
> if both /home and /temp are both mountpoints for the /dev/hda5, and I
> have opened many files on /home/mbr .. but not on /temp
> .
> I am not able to unmount the /home because there are open files. but i
> can umount /temp.
> 
> My question is how the VFS knows that there are open files at this
> particular mount point.

Because file structures point at both a dentry and a vfsmount structure.
Although the dentry tree is the same for both /home and /temp, each
mount has a separate vfsmount structure that points at the mountpoint's
dentry and vfsmount, as well as the root dentry of the mounted
filesystem. Because you're not using files under the /temp mountpoint,
its vfsmount structure is effectively unreferenced and can be unmounted.

Similarly, the current working directory and root directory information
for a task structure points at both dentries and vfsmounts.

> How VFS traverses back  to system root, when same file system is
> mounted at various mount point.

Take a look at the __d_path() function in fs/dcache.c (around line 940).
It takes a dentry and vfsmount, then walks back the chain to build a
pathname. This is the function used when you do a `ls -l
/proc/<pid>/fds` to see what files a process has open.

Hope this helps,

Brian Watson
OpenSSI Clustering project
OpenSSI.org
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux