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?
What I mean by user defined function is, any function other than the kernel defined functions. Pointers to which is defined in struct file_operations
, as below.
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 *);
};
For eg. in my driver I've the following,
struct file_operations fops = {
.read = my_read,
.write = my_write,
};
and I can call these functions from user space application program using the calls read
and write
.
I also have a function named user_defined
in kernel source and my question is how do I call this from user space program?