title: creating a shm file from kernel module
body: <p>I am trying to open a shm file for data sharing between kernel and user process.
  Below is my kernel module code.  Sys log output indicates that no errors were encountered.  Once the module is loaded, I don't see the file that I'm trying to create in /dev/shm.  What am I doing wrong?</p>
  
  <pre><code>#include &lt;linux/module.h&gt;
  #include &lt;linux/init.h&gt;
  #include &lt;linux/kernel.h&gt;
  #include &lt;linux/fs.h&gt;
  #include &lt;linux/shmem_fs.h&gt;
  
  static int __init moduleLoader(void) {
      struct file *shfile;
  
      printk(KERN_INFO "shkmod is loading...\n");
  
      shfile = shmem_file_setup("MyShmFile",sizeof(int),0);
      printk("shmem_file_setup returned %p\n",shfile);
      if (IS_ERR(shfile))
          printk("shmem_file_setup returned error.\n");
      printk("shfile is: %s\n", shfile-&gt;f_path.dentry-&gt;d_name.name);
  
      printk(KERN_INFO "shkmod is done loading.\n");
      return 0;
  }
  
  static void __exit moduleUnloader(void) {
      printk(KERN_INFO "shkmod was unloaded.\n");
      return;
  }
  
  module_init(moduleLoader);
  module_exit(moduleUnloader);
  
  MODULE_AUTHOR("Yaron Shragai");
  MODULE_LICENSE("GPL");
  MODULE_DESCRIPTION("Lorem ipsum dolor sit amet");
  </code></pre>
  
  <p>Here is the output in the sys log:</p>
  
  <pre><code>Jun  6 15:25:59 yaron-VirtualBox kernel: [457160.335482] shkmod is loading...
  Jun  6 15:25:59 yaron-VirtualBox kernel: [457160.335487] shmem_file_setup returned ffff8801fef53b00
  Jun  6 15:25:59 yaron-VirtualBox kernel: [457160.335488] shfile is: MyShmFile
  Jun  6 15:25:59 yaron-VirtualBox kernel: [457160.335488] shkmod is done loading.
  </code></pre>
  
  <p>$ uname -a<br>
  Linux yaron-VirtualBox 4.4.0-57-generic #78-Ubuntu SMP Fri Dec 9 23:50:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux</p>