I have downloaded kernel 2.6.38-5 and want to add a system call. I did the following:
I have added my system call to system call table;
<src folder>/arc/x86/kernel/syscall_table_32.S
.long sys_mycall
I have added the system call number;
<src folder>/include/asm-generic/unistd.h
#define __NR_mycall 244
__SYSCALL(__NR_mycall, sys_mycall)
I have added the prototype to syscalls.h
;
<src follder>/include/linux/syscalls.h
asmlinkage long sys_mycall(long input);
And, here is my system call;
asmlinkage long sys_mycall(long input) {
return (input * 2);
}
I have edited the Makefiles too.
Now after compilation, when I use it via syscall()
it gives me BAD ADDRESS
with errno set to 14.
What should I do?
On x86, system call number 244 is already taken by get_thread_area(), which takes as first argument a pointer to a struct user_desc
:
int get_thread_area(struct user_desc *u_info);
You are passing a number instead of a pointer, the kernel is trying to interpret it as a pointer, it's determining that it points outside of your process, and returning -EFAULT
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With