static int
interceptor_proc_entry_fop_open(SshInterceptorProcEntry entry,
				struct file *file)
{
  /* Allow only one userspace application at a time. */
  write_lock(&entry->lock);
  if (entry->open == TRUE)
    {
      write_unlock(&entry->lock);
      return -EBUSY;
    }

  /* Check that engine initialization has been completed. */
  if (ssh_interceptor_context->engine_open == FALSE)
    {
      write_unlock(&entry->lock);
      return -EBUSY;
    }    

  /* Increment module ref to prohibit module unloading. */
  if (!ssh_linux_module_inc_use_count())
    {
      write_unlock(&entry->lock);
      return -EBUSY;
    }

  file->private_data = ssh_interceptor_context;
  entry->buf_len = 0;
  entry->open = TRUE;

  write_unlock(&entry->lock);

  return 0;
}
static int
interceptor_ipm_proc_entry_fop_open(struct inode *inode,
				    struct file *file)
{
  write_lock(&ssh_interceptor_context->ipm_proc_entry.lock);

  /* Allow only one read form userspace at a time. */
  if (ssh_interceptor_context->ipm_proc_entry.open)
    {
      write_unlock(&ssh_interceptor_context->ipm_proc_entry.lock);
      SSH_LINUX_PROCFS_DEBUG("interceptor_ipm_proc_entry_fop_open: -EBUSY\n");
      return -EBUSY;
    }

  /* Check that engine initialization has been completed. */
  if (ssh_interceptor_context->engine_open == FALSE)
    {
      write_unlock(&ssh_interceptor_context->ipm_proc_entry.lock);
      SSH_LINUX_PROCFS_DEBUG("interceptor_ipm_proc_entry_fop_open: -EBUSY\n");
      return -EBUSY;
    }    

  /* Increment module ref to prohibit module unloading. */
  if (!ssh_linux_module_inc_use_count())
    {
      write_unlock(&ssh_interceptor_context->ipm_proc_entry.lock);
      SSH_LINUX_PROCFS_DEBUG("interceptor_ipm_proc_entry_fop_open: -EBUSY\n");
      return -EBUSY;
    }
  
  file->private_data = ssh_interceptor_context;

  ssh_interceptor_context->ipm_proc_entry.open = TRUE;

  /* Clear receive buffer. */
  ssh_interceptor_context->ipm_proc_entry.recv_len = 0;
  
  write_unlock(&ssh_interceptor_context->ipm_proc_entry.lock);
  
  interceptor_ipm_open(ssh_interceptor_context);
  ssh_interceptor_notify_ipm_open(ssh_interceptor_context);
 
  return 0;
}