title: How to create a device in /dev automatically upon loading of the kernel module for a device driver?
body: <p>I am attempting to develop Linux device drivers and as my first attempt I am trying to develop a char device driver that has the following file options,  </p>
  
  <pre><code>struct file_operations fops{  
  .open=open_fun,  
  .release=release_fun,  
  .write=write_fun,  
  .read=read_fun,  
  };  
  </code></pre>
  
  <p>When I load the driver using <code>insmod</code>, I see that <code>/proc/devices</code> lists the driver under char devices but I can't find it in <code>/dev</code>. A Google search suggested use of <code>mknod</code> to create a deivce in <code>/dev</code> and associate it with the driver's major and minor. However, an attempt to do so resulted in "Permission denied" error even when done as a super user.</p>
  
  <p>What should I do to make the device appear in <code>/dev</code> when the kernel module is loaded? I tried both the older (<code>register_chrdev</code>) and the newer version (<code>cdev_init &amp; cdev_add</code>) of registering the device but none of them works.</p>
  
  <p>Thanks,<br>
  Mir</p>