Welcome to the forums, adding a systemcall to the kernel shouldn't be that tricky a task.
- Download the kernel from http://www.kernel.org/
- Uncompress the tarball:
CODE
tar -zxvf linux-VERSION.tar.gz -C /usr/src
- Edit file /usr/src/linux-VERSION/arch/i386/kernel/syscall_table.S Adding .long sys_mysyscallnew after the last line of the file.
- Edit file /usr/src/linux-VERSION/arch/i386/kernel/Makefile Appending mysyscallnew.o at the end of the list of syscalls.
- Create a new file call mysyscallnew.c under /usr/src/linux-VERSION/arch/i386/kernel/ directory.
- Add your syscall in the file:
CODE
#include <linux/mysyscallnew.h>
#include <linux/init.h>
/* do something! */
asmlinkage int sys_mysyscallnew(int arg) {
cvalue += arg;
return (cvalue);
}
/* initialize */
void __init mysyscallnew_init(void) {
cvalue = 0;
}
- Create another file in /usr/src/linux-VERSION/include/linux/mysyscallnew.h
- Add this into the file:
CODE
#ifndef __LINUX_MYSYSCALLNEW_H
#define __LINUX_MYSYSCALLNEW_H
#include <linux/linkage.h>
int cvalue;
#endif
- Now edit the file Edit file /usr/src/linux-VERSION/include/asm-i386/unistd.h
- Add (this should be the current value of the __NR_syscalls !!:
CODE
#define __NR_mysyscallnew 318
- Modify:
CODE
#define __NR_syscalls 318
- To be
CODE
#define __NR_syscalls 319
- Now edit this file /usr/src/linux-VERSION/init/main.c and add (after extern void prepare_namespace(void);)
CODE
extern void mynewcall_init(void);
- In the same file, add (after acpi_early_init(); /* before LAPIC and SMP init */)
CODE
mysyscallnew_init();
OK! So at this point you should be able to build your kernel with its nice new syscall! If it builds first time I'd be stunned

So once its built, install it and reboot into the new kernel.
Now of course you want to test the magic new syscall.
- Create a file called /usr/include/linux/mysyscallnew-user.h
CODE
#include <linux/unistd.h>
#define __NR_mysyscallnew 318
_syscall1(int, mysyscallnew, int, arg);
- Create another file called testing.c (or whatever!)
CODE
#include <linux/mysyscallnew-user.h>
#include <stdio.h>
int main (int argc, char * argv[]) {
int val = 0;
val = mysyscallnew(10);
printf("currentvalue = %d\n", val);
return 0;
}
YES that's right, we have created a syscall that magically ADDs!

hehe.
I hope that my stuff here is good, you might want to check out some other sources to see what's what but I hope this gives you the jist. I found a
nice article )it is old though .. 1999!). I also spotted a shorter and less descriptive example
here but it does have a patch and C file example (NOTE its for the 2.4 kernel!).