title: From struct file to struct super_block
body: <p>I just implemented a simple driver(<a href="http://code.google.com/p/ldd3/source/browse/trunk/scull/main.c?r=2#292" rel="nofollow">scull device</a>) following Linux Device Driver</p>
  
  <p>In the read function, I want to get the name of the file system. So I made some changes.</p>
  
  <pre><code>ssize_t scull_read(struct file *filp, char __user *buf, size_t count,
              loff_t *f_pos)
  {
      struct scull_dev *dev = filp-&gt;private_data; 
      struct scull_qset *dptr;        /* the first listitem */
      int quantum = dev-&gt;quantum, qset = dev-&gt;qset;
      int itemsize = quantum * qset; /* how many bytes in the listitem */
      int item, s_pos, q_pos, rest;
      ssize_t retval = 0;
  
  //start of change
  
      struct super_block *sp;
      const char *name;
  
      /** Get the super_block via struct inode, it works **/
      sp = flip-&gt;f_path.dentry-&gt;d_inode-&gt;i_sb;
      name = sp-&gt;s_type-&gt;name;
  
      /** Get the super_block via struct vfsmount, not works **/
      sp = flip-&gt;f_path.mnt-&gt;mnt_sb;
  
  //end of change
  
      if (down_interruptible(&amp;dev-&gt;sem))
              return -ERESTARTSYS;
      if (*f_pos &gt;= dev-&gt;size)
              goto out;
      if (*f_pos + count &gt; dev-&gt;size)
              count = dev-&gt;size - *f_pos;
      ....
  </code></pre>
  
  <p>To get the super_block via inode, everything works well.</p>
  
  <p>But while I am trying to get the super_block via vfsmount structure, I get error in compiling</p>
  
  <pre><code> error: dereferencing pointer to incomplete type
  </code></pre>
  
  <p>It seems like that the super_block in vfsmount structure is not initialized.</p>
  
  <p>To me, we should get the same super_block whatever the method we choose. But it's strange that the second method doesn't work.</p>
  
  <p>Please correct if I wrongly understand.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>The following are the content of header file</p>
  
  <pre><code>#include &lt;linux/module.h&gt;
  #include &lt;linux/cdev.h&gt;
  #include &lt;linux/moduleparam.h&gt;
  #include &lt;linux/types.h&gt;
  #include &lt;linux/init.h&gt;
  #include &lt;linux/kernel.h&gt;
  #include &lt;linux/fs.h&gt;
  #include &lt;linux/slab.h&gt;
  #include &lt;linux/semaphore.h&gt;
  #include &lt;linux/kernel.h&gt;
  #include &lt;asm/uaccess.h&gt;
  #include "scull.h"
  </code></pre>