title: Calling a user defined function in kernel space from user space application program
body: <p>I have written a user defined function in my device driver and I want to call it from user space application program. How do I achieve this?</p>
  
  <p>What I mean by user defined function is, any function other than the kernel defined functions. Pointers to which is defined in <code>struct file_operations</code>, as below.</p>
  
  <pre><code>struct file_operations {
         struct module *owner;
         loff_t (*llseek) (struct file *, loff_t, int);
         ssize_t (*read) (struct file *, char *, size_t, loff_t *);
         ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
         int (*readdir) (struct file *, void *, filldir_t);
         unsigned int (*poll) (struct file *, struct poll_table_struct *);
         int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
         int (*mmap) (struct file *, struct vm_area_struct *);
         int (*open) (struct inode *, struct file *);
         int (*flush) (struct file *);
         int (*release) (struct inode *, struct file *);
         int (*fsync) (struct file *, struct dentry *, int datasync);
         int (*fasync) (int, struct file *, int);
         int (*lock) (struct file *, int, struct file_lock *);
           ssize_t (*readv) (struct file *, const struct iovec *, unsigned long,
            loff_t *);
           ssize_t (*writev) (struct file *, const struct iovec *, unsigned long,
            loff_t *);
      };
  </code></pre>
  
  <p>For eg. in my driver I've the following,</p>
  
  <pre><code>struct file_operations fops = {
  .read = my_read,
  .write = my_write,
  };
  </code></pre>
  
  <p>and I can call these functions from user space application program using the calls <code>read</code> and <code>write</code>. </p>
  
  <p>I also have a function named <code>user_defined</code> in kernel source and my question is how do I call this from user space program?</p>