Hi, Thanks for the help. Yah when I use current->pid and current->comm in the module, I am getting the process ID and name. I think i am having problem because I tried the module on Android and in there the process name is given as Binder Thread and not the application's name. I will post this question in Android forum to find out more.
Thanks and Regards, Perumal On Mar 22, 4:19 pm, Peter Teoh <[email protected]> wrote: > not sure how u wrote your module.....want to post your code here? > > From kernel/timer.c: > > 373 void __timer_stats_timer_set_start_info(struct timer_list *timer, > void *addr) > 374 { > 375 if (timer->start_site) > 376 return; > 377 > 378 timer->start_site = addr; > 379 memcpy(timer->start_comm, current->comm, TASK_COMM_LEN); > 380 timer->start_pid = current->pid; > 381 } > > the answer is obvious......i suspect u got your global variable > "current" wrongly. > > look into: > > ./arch/x86/kernel/cpu/common.c: > EXPORT_PER_CPU_SYMBOL(current_task); > > u can see that "current_task" is per-CPU and is exported, ie, > different CPU may be executing different task. > > so, from ./Documentation/uml/UserModeLinux-HOWTO.txt: > (gdb) p current_task.pid > (gdb) p current_task.prev_task.comm > (gdb) p current_task.prev_task.thread > > Or inside your kernel module....just do current_task->comm will do, as > the symbol is exported. > > But I cannot find EXPORT declaration for "current", so your kernel > module cannot access the global variable directly - roundabout way > needed. > > But if you compile your codes + kernel together, NOT USING KERNEL > MODULE, then access any global variable (eg, current) is possible. > > On Mar 22, 10:42 am, perumal316 <[email protected]> wrote: > > > Hi, > > > Is there any way to get the current process ID and the corresponding > > name of the application from the kernel module? > > > I have tried using task->comm ,task->pid, current->pid etc But I am > > not getting the correct process ID. > > > I want to printk the process ID and the application name each time a > > system call is called. System call should have a way to identify which > > process ID or application is calling it. > > > Any other way to printk the process ID and the application name? > > > Thanks In Advance, > > Perumal To unsubscribe from this group, send email to linuxkernelnewbies+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
