title: How do you get the struct file of the parent of another struct file in the Linux Kernel
body: <p>In the Linux Kernel: I have a file (ie, a 'struct file') of a directory.  Let's call it f_child.  I need a file reference for the parent directory.</p>
  
  <p>I'm currently retrieving this like so:</p>
  
  <p>1) Create a 'struct path' from the f_dentry->d_parent and f_vfsmnt of f_child.  I check, of course, that the d_parent is non-null.</p>
  
  <p>2) Get the path (ie, a string, not a struct path... a char *) of the parent of f_child using d_path, passing in the path we retrieved from step 1.</p>
  
  <p>3) Pass that string to filp_open, which returns the struct file * that I want.</p>
  
  <p>It seems to work.  I'm worried though about the assumption I'm making at step 1 that the vfs mount of the parent and child will be the same.  Will that bite me at some point?  Is there a better way of doing this?  Clearly, I don't understand the vfs mount structure well enough.  Do all dentries belonging to the same super block have the same vfs mount?</p>
  
  <p>btw: I anticipate, and a appreciate, the rebuke for opening a file in the Kernel, but what I'm doing really does require it. :)</p>
  
  <p>Thanks!</p>