LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   How to call system call from usb driver's code (https://www.linuxquestions.org/questions/linux-kernel-70/how-to-call-system-call-from-usb-drivers-code-672727/)

Mr.J 09-27-2008 08:52 AM

How to call system call from usb driver's code
 
Hello,

I need to call one system call inside linux-2.6.22.14/drivers/usb/storage/usb.c .
I just included <linux/syscalls.h>
and called the api like (sys_getpid())...
but when I compiled the code, I got error ..undefined refence to sys_getpid....

If anybody has any idea on how to call system call within drivers code..
plz advise..

Mr.J

ashok449 09-29-2008 12:15 AM

I'm not sure but let me guess...


EXPORT_SYMBOL for the API you wanna use, and u can access in driver code


getpid() in kernel space ? you need to use process descriptor (struct task_struct) I guess ...



-- Ashok

krishna_123 09-29-2008 12:17 AM

sys_getpid is not exported since there is no EXPORT_SYMBOL(sys_getpid) defined in the kernel source tree.

krishna_123 09-29-2008 12:20 AM

u can get the pid of a process using the current pointer which is defined in linux/sched.h. current->pid will prints the pid of the user space program that invoked the driver

Mr.J 09-29-2008 03:47 AM

After exporting symbol, it worked.... Thanks for your help.


All times are GMT -5. The time now is 03:44 PM.