I'm trying to add new (dummy) system call to linux kernel.
1) I added the system call code under linux-source/kernel/myfile.c and updated the Makefile accordingly.
2) Updated syscall.h, unistd.h and entry.S files to reflect the new system call (pedagogictime(int flag,struct timeval *time))
Then compiled the kernel and installed and rebooted the image.
When I run: cat /proc/kallsyms | grep "pedag"
, this is the output I'm getting
0000000000000000 T sys_pedagogictime 0000000000000000 d event_exit__pedagogictime 0000000000000000 d event_enter__pedagogictime 0000000000000000 d __syscall_meta_pedagogictime 0000000000000000 d types_pedagogictime 0000000000000000 d args__pedagogictime 0000000000000000 t trace_init_flags_enter__pedagogictime 0000000000000000 t trace_init_flags_exit__pedagogictime 0000000000000000 t __event_exit__pedagogictime 0000000000000000 t __event_enter__pedagogictime 0000000000000000 t __p_syscall_meta__pedagogictime 0000000000000000 t __initcall_trace_init_flags_exit__pedagogictimeearly 0000000000000000 t __initcall_trace_init_flags_enter__pedagogictimeearly
which means the system call is registered correctly.
In my user space program, I'm writing:
#define __NR_pedagogictime 1326 //1326 is my system call number
struct timeval *now = (struct timeval *)malloc(sizeof(struct timeval));
long ret = syscall(__NR_pedagogictime,0,now);
if(ret)
perror("syscall ");
But I'm getting the error:
"syscall : Function not implemented"
I would really appreciate any help about this. Thanks.
Edit:
Btw, the assembly code for the syscall() looks like this (if it helps):
movl $6, %esi
movl $1326, %edi
movl $0, %eax
call syscall
cltq