Hey guys. I am trying to implement a system call in linux kernel. I usually use ubutntu, but this I am doing on Fedora. I am using kernel 2.6. Here is what I did:
1. Added a line to arch/i386/kernel/syscall_table.S :
.long sys_foo
2. Added a line to linux/include/asm-i386/unistd.h:
#define __NR_foo 324
also incremented the call count by 1.
3. Added this code to sys.c
[code]
asmlinkage long sys_foo(void)
{
printk("Hello Kernel World");
return THREAD_SIZE;
}
[\code]
4. Wrote this user level client program to test my call:
Code:
#include <unistd.h>
#include <linux/unistd.h>
#define __NR_foo 324
__syscall0(long , foo)
int main()
{
foo();
return 0;
}
However, when I compile the user level program, I get the following error:
success.c:6: error: expected declaration specifiers or ‘...’ before ‘foo’
success.c: In function ‘__syscall0’:
success.c:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
success.c:6: error: parameter name omitted
success.c:13: error: expected ‘{’ at end of input
Anybody has any idea?
1. Added a line to arch/i386/kernel/syscall_table.S :
.long sys_foo
2. Added a line to linux/include/asm-i386/unistd.h:
#define __NR_foo 324
also incremented the call count by 1.
3. Added this code to sys.c
[code]
asmlinkage long sys_foo(void)
{
printk("Hello Kernel World");
return THREAD_SIZE;
}
[\code]
4. Wrote this user level client program to test my call:
Code:
#include <unistd.h>
#include <linux/unistd.h>
#define __NR_foo 324
__syscall0(long , foo)
int main()
{
foo();
return 0;
}
However, when I compile the user level program, I get the following error:
success.c:6: error: expected declaration specifiers or ‘...’ before ‘foo’
success.c: In function ‘__syscall0’:
success.c:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
success.c:6: error: parameter name omitted
success.c:13: error: expected ‘{’ at end of input
Anybody has any idea?
Comment