Hi guys.
I have downloaded kernel 2.6.38-5 to add a system call.
I did the following steps:
- 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 cal number in
<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);
- here is my system call
asmlinkage long sys_mycall(long input)
{return (input * 2);
}
- I have edited the Makfiles
Now after compilation when i use it via syscall() it gives me "BAD ADDRESS" with errno set to 14.
What should i do?
---------- Post updated 2011-05-15 at 04:06 AM ---------- Previous update was 2011-05-14 at 08:39 PM ----------
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.
According to this file
/usr/include/asm/unistd_32.h
the only system call number available is 251. so i changed my system call number to 251.
But this time it says: Function not implemented with errno = 38