Results 1 to 3 of 3
Hi.
I am new to Linux. I just wanted to create a system call. I am using kernel 2.6.28.9. What I did to create a system call is:
1)I created ...
- 07-28-2009 #1Just Joined!
- Join Date
- Jul 2009
- Posts
- 3
Writing a System Call
Hi.
I am new to Linux. I just wanted to create a system call. I am using kernel 2.6.28.9. 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
asmlinkage int 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 */
Now finally when I run the command:
[linux-2.6.28.9]$make M=mycall/
I get the output as :
CC mycall/mycall.o
mycall/mycall.c:3: error: expected ‘)’ before ‘int’
make[1]: *** [mycall/mycall.o] Error 1
make: *** [_module_mycall] Error 2
Where am I wrong?
I tried for the same system call without any argument then on make I got the result as:
CC mycall/mycall.o
mycall/mycall.c:4: warning: return type defaults to ‘int’
mycall/mycall.c:4: warning: function declaration isn’t a prototype
LD mycall/built-in.o
Building modules, stage 2.
MODPOST 0 modules
y is it so?
Is the procedure I adopted, wrong?
Please help me...
- 07-28-2009 #2
I haven't written my own syscall before, but I assume that you are following this guide:
Implementing a System Call on Linux 2.6 for i386
You forgot this line in your mycall.c:
As I suspect this is where asmlinkage is defined, including this file may solve your problem.Code:#include<linux/linkage.h>
DISTRO=Arch
Registered Linux User #388732
- 07-29-2009 #3Just Joined!
- Join Date
- Jul 2009
- Posts
- 3
Writing a system call
Hi. I included the header file but still its not working.
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.


Reply With Quote