LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 09-27-2008, 08:52 AM   #1
Mr.J
Member
 
Registered: Jun 2008
Posts: 82

Rep: Reputation: 15
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
 
Old 09-29-2008, 12:15 AM   #2
ashok449
Member
 
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, 12:17 AM   #3
krishna_123
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, 12:20 AM   #4
krishna_123
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, 03:47 AM   #5
Mr.J
Member
 
Registered: Jun 2008
Posts: 82

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


Reply



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 07: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 12:07 AM
How can I script an autologin, automatically call kde(or simillar) and call an app aboaventura Slackware 8 02-03-2007 11:00 PM
Calling a system call from a system call? Loc_8 Programming 0 09-16-2006 04:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 02:42 AM.

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