title: During a file creation, when does struct file_operations and struct file get connected?
body: <p>I am following the <strong>open()</strong> system call to find out when the <strong>struct file_operations</strong> and <strong>struct file</strong> get connected during a creation of file.</p>
  
  <p>The main path is as follows:</p>
  
  <pre><code>sys_open -&gt; do_sys_open -&gt; do_filp_open -&gt; nameidata_to_filp -&gt; __dentry_open
  </code></pre>
  
  <p>In __dentry_open</p>
  
  <pre><code> static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
                                       int flags, struct file *f,
                                       int (*open)(struct inode *, struct file *),
                                       const struct cred *cred)
  {
      struct inode *inode;
      int error;
  
      f-&gt;f_flags = flags;
      f-&gt;f_mode = ((flags+1) &amp; O_ACCMODE) | FMODE_LSEEK |
                              FMODE_PREAD | FMODE_PWRITE;
      inode = dentry-&gt;d_inode;
      if (f-&gt;f_mode &amp; FMODE_WRITE) {
              error = __get_file_write_access(inode, mnt);
              if (error)
                      goto cleanup_file;
              if (!special_file(inode-&gt;i_mode))
                      file_take_write(f);
      }
  
      f-&gt;f_mapping = inode-&gt;i_mapping;
      f-&gt;f_path.dentry = dentry;
      f-&gt;f_path.mnt = mnt;
      f-&gt;f_pos = 0;
      f-&gt;f_op = fops_get(inode-&gt;i_fop);//I think it is here that they get connected
      file_move(f, &amp;inode-&gt;i_sb-&gt;s_files);
  
      error = security_dentry_open(f);
  
      ...
  </code></pre>
  
  <p>But when and in which function that the i_fop in inode gets initialized?</p>