LinuxAnswers - the LQ Linux tutorial section.
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


  Search this Thread
Old 09-27-2008, 09:52 AM   #1
Registered: Jun 2008
Posts: 82

Rep: Reputation: 15
How to call system call from usb driver's code


I need to call one system call inside linux- .
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..

Old 09-29-2008, 01:15 AM   #2
Registered: Sep 2007
Location: noida
Distribution: suse
Posts: 63

Rep: Reputation: 16
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
Old 09-29-2008, 01:17 AM   #3
LQ Newbie
Registered: Jul 2008
Posts: 10

Rep: Reputation: 0
sys_getpid is not exported since there is no EXPORT_SYMBOL(sys_getpid) defined in the kernel source tree.
Old 09-29-2008, 01:20 AM   #4
LQ Newbie
Registered: Jul 2008
Posts: 10

Rep: Reputation: 0
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
Old 09-29-2008, 04:47 AM   #5
Registered: Jun 2008
Posts: 82

Original Poster
Rep: Reputation: 15
After exporting symbol, it worked.... Thanks for your help.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to add a system call into linux code base baran_6566 SUSE / openSUSE 2 10-20-2007 08:20 AM
How can i make centos 4.5's system call using vDSO(call *%gs:0x10) instead of int80 tclwp Red Hat 3 08-06-2007 01:07 AM
How can I script an autologin, automatically call kde(or simillar) and call an app aboaventura Slackware 8 02-04-2007 12:00 AM
Calling a system call from a system call? Loc_8 Programming 0 09-16-2006 05:21 PM

All times are GMT -5. The time now is 01:38 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration