Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I stumbled upon this very helpful page: <a href="http://kedar.dumpstack.com/pubs/al_vfsmounts.html" rel="nofollow noreferrer">http://kedar.dumpstack.com/pubs/al_vfsmounts.html</a></p> <p>(Also posted here in case that goes away): <a href="http://kerneltrap.org/node/3749" rel="nofollow noreferrer">http://kerneltrap.org/node/3749</a></p> <p>While short, this is valuable for anyone trying to begin to understand the workings of the vfs because it goes beyond describing the parts (superblock, inode, dentry, etc.) to describing how they work together to create the namespace users interact with.</p> <p>Anyway, if I'm reading this correctly, a tree of dentries are rooted from a super block corresponding to a file system, not a vfsmount. So I have to check to make sure that the d_parent and the dentry have the same vfs mount. The <code>mnt_root</code> check I mention below accomplishes this.</p> <p>So, it's not null I need to check at step 1 but these two things (I get this from the implementation of <code>__d_path</code> in <a href="http://lxr.free-electrons.com/ident?v=2.6.32;i=__d_path" rel="nofollow noreferrer">fs/dcache.c</a>):</p> <ol> <li><p><code>mnt_root</code>. If the f_dentry of f_child is the same as mnt_root of its f_vfsmnt, then I can't look at f_dentry->d_parent. We're at the root of the mount. If I want to go above that dentry, I have to move up the tree by looking at the dentry f_vfsmnt->mnt_mountpoint and the vfsmount f_vfsmnt->mnt_parent.</p></li> <li><p><code>IS_ROOT</code>. <code>IS_ROOT</code> takes a dentry, and if it returns true, then there is no point looking above that. We're at the root of the file system, which may not be the root of our namespace.</p></li> </ol> <p>Now that I understand some more, I realize that the post by J-16 SDiZ is helpful:</p> <p><a href="https://stackoverflow.com/questions/4622812/linux-kernel-dentry-and-inode">Linux Kernel dentry and inode</a></p> <p>He references the tomoyo implementation of getting a real path:</p> <p><a href="http://lxr.linux.no/linux+v2.6.37/security/tomoyo/realpath.c#L86" rel="nofollow noreferrer">http://lxr.linux.no/linux+v2.6.37/security/tomoyo/realpath.c#L86</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload