From within a kernel module you can get information about the currently executing process using the current variable. current is of type struct task_struct. When a system call is executing (such as open, read, write, ioctl) the current process will be the caller.
For example to display the process id from within a read function:
printk("%s: The calling process is \"%s\" (pid %i)\n",
__FUNCTION__, current->comm, current->pid);
References:
J. Corbet, A. Rubini, & G. Kroah-Hartman. (2005). Linux Device Drivers, 3rd Ed. (p. 20)
Advertisement