title: cant open device
body: <p>I have a little problem. I install this module into my kernel and its written under /proc</p>
  
  <p>When I try to open() it from user mode I get the following message:</p>
  
  <blockquote>
    <p>"Can't open device file: my_dev"</p>
  </blockquote>
  
  <pre><code>static int module_permission(struct inode *inode, int op, struct nameidata *foo)
  {
   //if its write
   if ((op == 2)&amp;&amp;(writer == DOESNT_EXIST)){
    writer = EXIST ;
    return 0;
   }
   //if its read
   if (op == 4 ){
    numOfReaders++;
    return 0;
   }
   return -EACCES;
  }
  
  int procfs_open(struct inode *inode, struct file *file)
  {
   try_module_get(THIS_MODULE);
   return 0;
  }
  
  static struct file_operations File_Ops_4_Our_Proc_File = {
   .read   = procfs_read,
   .write   = procfs_write,
   .open   = procfs_open,
   .release = procfs_close,
  };
  
  static struct inode_operations Inode_Ops_4_Our_Proc_File = {
   .permission = module_permission, /* check for permissions */
  };
  
  int init_module()
  {
   /* create the /proc file */
   Our_Proc_File = create_proc_entry(PROC_ENTRY_FILENAME, 0644, NULL);
   /* check if the /proc file was created successfuly */
   if (Our_Proc_File == NULL){
    printk(KERN_ALERT "Error: Could not initialize /proc/%s\n",
           PROC_ENTRY_FILENAME);
    return -ENOMEM;
   }
  
   Our_Proc_File-&gt;owner = THIS_MODULE;
   Our_Proc_File-&gt;proc_iops = &amp;Inode_Ops_4_Our_Proc_File;
   Our_Proc_File-&gt;proc_fops = &amp;File_Ops_4_Our_Proc_File;
   Our_Proc_File-&gt;mode = S_IFREG | S_IRUGO | S_IWUSR;
   Our_Proc_File-&gt;uid = 0;
   Our_Proc_File-&gt;gid = 0;
   Our_Proc_File-&gt;size = 80;
  
   //i added init the writewr status
   writer = DOESNT_EXIST;
   numOfReaders = 0 ;
   printk(KERN_INFO "/proc/%s created\n", PROC_ENTRY_FILENAME);
   return 0;
  }
  </code></pre>