Getting "errno 38: function not implemented" on a system call

I am trying to write a system call in Linux. I modified unistd.h , syscall_32.tbl and sys.c as follows:

 /* #define __NR3264_fadvise64 223 __SC_COMP(__NR3264_fadvise64, sys_fadvise64_64, compat_sys_fadvise64_64) */ #define __NR_zslhello 223 __SYSCALL(__NR_zslhello, sys_zslhello) 

 223 i386 zslhello sys_zslhello 

 asmlinkage int sys_zslhello(int ret) { printk("Hello, my syscall!\n"); return ret; } 

After compiling the kernel, I use syscall(223, 10000); , the return value is -1 , and errno is 38 , i.e. function not implemented. Do you have any ideas about this?

+6
source share
1 answer

This is because syscall not implemented, as the name suggests. Probably in your case your machine is 64-bit. Therefore, you need to modify the syscall_64.tbl not syscall_32.tbl .

In the last line of the file where the common system calls are defined, add the line

 x common zslhello sys_zslhello 

Where x is 1 plus the last value in the common area. This is what a fragment of my syscall_64.tbl looks like.

 330 common pkey_alloc sys_pkey_alloc 331 common pkey_free sys_pkey_free # # x32-specific system call numbers start at 512 to avoid cache impact # for native 64-bit operation. # 512 x32 rt_sigaction compat_sys_rt_sigaction 513 x32 rt_sigreturn sys32_x32_rt_sigreturn 

In my case, x is 332. Greetings!

+3
source

All Articles