LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-28-2009, 08:25 AM   #1
HGaurav
LQ Newbie
 
Registered: Jul 2009
Posts: 7

Rep: Reputation: 1
Unhappy Problem in creating System call


Hi.
I am new to Linux. I just wanted to create a system call. I am using kernel 2.6.28.9.(Redhat) What I did to create a system call is:
1)I created a directory as /usr/src/linux-2.6.28.9/mycall.
2)I created a .c file as /usr/src/linux-2.6.28.9/mycall/mycall.c
SYSTEM_DEFINE1(mycall, int, i)
{
return i+10;
}
3)I created a Makefile file as /usr/src/linux-2.6.28.9/mycall/Makefile
obj-y := mycall.o

4) I edited /usr/src/linux-2.6.28.9/include/linux/syscalls.h
(original file)
asmlinkage long sys_mycall(void);
5) I edited /usr/src/linux-2.6.28.9/usr/include/asm/unistd_32.h
(original file)
#define __NR_mycall 333
6) I edited /usr/src/linux-2.6.28.9/arch/x86/kernel/syscall_table_32.S
(original file)
.long sys_mycall /* 333 */

But on make it gives me error after 10-12 mins.
Where am I wrong?
Please help me.
 
Old 07-28-2009, 02:26 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
What is the error exactly? Please paste the messages.
 
Old 07-29-2009, 12:35 AM   #3
HGaurav
LQ Newbie
 
Registered: Jul 2009
Posts: 7

Original Poster
Rep: Reputation: 1
Unhappy Problem in creating System Call

When i run make M=mycall/ inside source code dir it builds .o file for my system call. But when I run make, after a long time doing things it shows the following error:

MODPOST vmlinux.o
WARNING: modpost: Found 5 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
GEN .version
CHK include/linux/compile.h
UPD include/linux/compile.h
CC init/version.o
LD init/built-in.o
LD .tmp_vmlinux1
arch/x86/kernel/built-in.o: In function `sys_call_table':
(.rodata+0x934): undefined reference to `sys_mycall'
make: *** [.tmp_vmlinux1] Error 1

One thing that I want to tell is that I didnt find __NR_syscalls in my unistd_32.h that contains total number of sys calls.
also I dont have /usr/src/linux/arch/i386/kernel/syscall_table_32.c
but it is in /usr/src/linux/arch/x86/kernel/syscall_table_32.c
Is there any thing I have done wrong.
 
Old 07-30-2009, 12:26 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
OK, so it's not linking your file to the kernel. You compile your syscall fine, but the kernel must add the result to itself. It doesn't.

So, maybe just add a reference to your syscall in the main Makefile (linux/Makefile). Add your diretory to core-y somewhere and try again.
 
Old 07-31-2009, 01:03 AM   #5
HGaurav
LQ Newbie
 
Registered: Jul 2009
Posts: 7

Original Poster
Rep: Reputation: 1
Unhappy Still problem!

I have edited the Linux/Makefile already like:
core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ mycall/
Is there anything I have left or some wrong approch?
 
Old 07-31-2009, 01:10 AM   #6
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Rep: Reputation: 107Reputation: 107
Hi Gaurav,

I request you to put the coding thing in codes.


Code:
like this
 
Old 07-31-2009, 05:42 AM   #7
HGaurav
LQ Newbie
 
Registered: Jul 2009
Posts: 7

Original Poster
Rep: Reputation: 1
Ok I'll take care of this.
 
  


Reply


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
Problem in adding system call sid18 Linux - Kernel 2 10-22-2007 01:09 PM
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
problem when writing a new system call praveenchebolu Programming 3 03-25-2006 08:40 AM
Problem w/ 'read' system call - RH 7.3 buckles Linux - Newbie 3 05-07-2005 12:03 AM
help creating a system call drumlix18 Linux - Newbie 4 10-19-2004 07:14 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:29 PM.

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