title: Error: "device or resource busy" in removing proc module
body: <p>I wrote a linux module to creat a proc file and write and read the data from it. But I am unable to remove the module, its showing an error unable to remove saying "device or resource busy. here is my code. </p>
  
  <pre><code>#include&lt;linux/module.h&gt;
  #include&lt;linux/kernel.h&gt;
  #include&lt;linux/fs.h&gt; /*this is the file structure, file open read close */
  #include&lt;linux/cdev.h&gt; /* this is for character device, makes cdev avilable*/
  #include&lt;linux/semaphore.h&gt; /* this is for the semaphore*/
  #include&lt;linux/uaccess.h&gt; /*this is for copy_user vice vers*/
  #include&lt;linux/proc_fs.h&gt;
  
  #define MAX_LEN 1024
  int read_info(char *page, char **start, off_t off,  int count, int *eof, void *data);
  int write_info(struct file *filp, const char __user *buffer, unsigned long length, void *data);
  
  static struct proc_dir_entry *proc_entry;
  static char *info;
  static int write_index;
  static int read_index;
  
  int write_info(struct file *filp, const char __user *buffer, unsigned long length, void *data) {
      int capacity = (MAX_LEN - write_index) +1;
      if(length &gt; capacity) {
          printk(KERN_INFO "NO sapce to write into peoc file \n");
          return -1;
      }
      if(copy_from_user(&amp;info[write_index], buffer, length)) 
          return -2;
      write_index += length;
      printk(KERN_INFO " megharaj proc writing succesful, %d write \n", length);
      return length;
  }
  
  int read_info(char *page, char **start, off_t off, int count, int *eof, void *data) {
      int len;
      len = sprintf(page, "%s\n", &amp;info[read_index]);
      read_index += len;
      printk(KERN_INFO " megharaj proc reading succesful, %d read \n", len);
      return len;
  }
  
  
  int init_module(void) 
  {
      int ret = 0;
      info = (char *)vmalloc(MAX_LEN);
      memset(info, 0 , MAX_LEN);
  /*truct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
                                           struct proc_dir_entry *parent);*/
      proc_entry = create_proc_entry("megharaj_proc", 0666, NULL);
      if(proc_entry == NULL) {
          ret = -1;
          vfree(info);
          printk(KERN_INFO " megharaj proc not created \n");
      }
      else {
          write_index = 0;
          read_index = 0;
          proc_entry-&gt;read_proc = read_info;
          proc_entry-&gt;write_proc = write_info;
          printk(KERN_INFO " megharaj proc created \n");
      }
      return ret;
  }
  
  void clean_module(void) 
  {
      vfree(info);
      remove_proc_entry("megharaj_proc", NULL);
  
  }
  </code></pre>
  
  <p>also attaching the makefile,</p>
  
  <pre><code>obj-m   := proc.o
  
  KERNELDIR ?= /lib/modules/$(shell uname -r)/build
  PWD       := $(shell pwd)
  
  all:
      $(MAKE) -C $(KERNELDIR) M=$(PWD)
  
  clean:
      rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
  </code></pre>
  
  <p>echo and cat on proc file are working. Once work is done i am not able to remove the module by using sudo rmmod proc</p>
  
  <p>output from lsmod shows </p>
  
  <pre><code>proc                   12518  0 [permanent]
  </code></pre>
  
  <p>Now another question, what is this permanent ? Is this the problem. ?</p>