Retrieve information about the calling process from within a kernel module

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.