views:

118

answers:

1

Hello Guys

i am tryin to add a new helloworld system call to a new version of the linux ubuntu kernel,

i have been looking through the web but i cannot find a consistent example to show me what files i will have to modify to enable a helloworld system call to be added to the kernel.

i have tried many and compile error have occured

so i know how to compile the kernel, but i just dont know where i add my c program system call, and where i add this call to the system call table and anything else i have to do

can some one please help me,

ps i am working on the newest linux ubuntu kernel

so i compiled the kernel with a new system call introduced, a simple call called mycall, now i am getting compile errors within the header file of my application that will test the call, below is my header file

#include<linux/unistd.h>

#define __NR_mycall 317

_syscall1(long, mycall, int, i)

this is the syntax error i am getting

stef@ubuntu:~$ gcc -o testmycall testmycall.c
In file included from testmycall.c:3:
testmycall.h:7: error: expected declaration specifiers or ‘...’ before ‘mycall’
testmycall.h:7: error: expected declaration specifiers or ‘...’ before ‘i’
testmycall.c: In function ‘_syscall1’:
testmycall.c:7: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
testmycall.h:7: error: parameter name omitted
testmycall.h:7: error: parameter name omitted
testmycall.c:11: error: expected ‘{’ at end of in

i got alot of help from the below link from Nikolai N Fetissov

any one got any ideas

A: 

The '_syscall1' macro that you are using is obsolete. Use syscall(2) instead.

Example:

#include <stdio.h>
#include <linux/unistd.h>
#include <sys/syscall.h>

#define __NR_mysyscall     317

int main(void)
{
        long return_value;

        return_value = syscall(__NR_syscall);

        printf("The return value is %ld.\n", return_value);

        return 0;
}
Oleksandr Kravchuk