Adding our system call Fedora 18 -new syscall

Hi,

I wanna add my own system call to Fedora 18 kernel 3.8.2.
From kernel 3.3 I heard there is a new system to add system calls.
So where i can find a guides ?

I wanna print this text: "Hello world!" in terminal, not dmesg.

What if you put at the end of your .profile config file:

echo 'Hello World!'

dude ....
not that
syscall...

Download the source of the kernel version to which you want to add the system cal.

Add your new syscall to arch/x86/syscalls (assuming you are using a kernel > 3.3.4). To add your system call move to the end of the file and add an entry at the end with the syntax same as previous lines. Next edit arch/x86/include/asm/unistd_32.h and add an appropriate #define for the your system call at the end of the file. Lets assume you wish to name your syscall "demo"

#define __NR_demo <your syscall number> 

Then add the following code to kernel/sys.c

int SYSCALL_DEFINE0(demo) { 
printk(KERN_INFO "Demo system call"); 
return 0;                                
}  

SYSCALL_DEFINE0 signifies that demo is a system call with zero arguments.

Compile and install your new kernel. Your new syscall is then ready for testing.

If i have 64 btis system then i have still to edit this file: "unistd_32.h"?

---------- Post updated at 03:51 PM ---------- Previous update was at 10:35 AM ----------

I must add syscall in Fedora 18 kernel 3.8.2 32 or 64. I take 32 on virtual box.
First i tried this:

"

  • Upzip it with command �tar xvfj XXX� to a folder For example : /root/kernel tar xvfj linux-3.3.1.tar.bz2
  • Edit file �/root/kernel/linux-3.3.1/arch/x86/syscalls/syscall_64.tbl� Add new line

312 64 husky1 sys_husky1

  • Eidt file �/root/kernel/linux-3.3.1/include/linux/syscalls.h� Add new function declaration

asmlinkage long sys_husky1(int fd);
before the line �#endif�

  • Add a new c file under �/root/kernel/linux-3.3.1/arch/x86/kernel� (I am using x86 CPU) Example :
  • Edit �/root/kernel/linux-3.3.1/arch/x86/kernel/Makefile� Add a new line �obj-y += husky.o�
  • goto /root/kernel/linux-3.3.1 folder and run command �make �j8� "

but after make menuconfig
and then make
I got this warning: "warning: function declaration isn't a prototype"

this is my demosys.c file:

#include <linux/linkage.h> 
#include <linux/kernel.h>  
asmlinkage long sys_democall()
 {     
                        printk ("Hello world\n");   
  
                        return 0; 
}

and this is my declaration in linux-3.8.2/include/linux/syscalls.h

asmlinkage long sys_democall(void);

and linux-3.3.1/arch/x86/syscalls/syscall_32.tbl
351 i386 democall sys_democall

Is this method good to add system call?
Did this erorr interferes with something?
after end of compilation my syscall will work?