Bad Address when adding system call

Hi guys.

I have downloaded kernel 2.6.38-5 to add a system call.
I did the following steps:

  1. I have added my system call to system call table
<src folder>/arc/x86/kernel/syscall_table_32.S

.long sys_mycall
  1. i have added the system cal number in
<src folder>/include/asm-generic/unistd.h

#define __NR_mycall 244
__SYSCALL(__NR_mycall, sys_mycall)
  1. I have added the prototype to syscalls.h
<src follder>/include/linux/syscalls.h

asmlinkage long sys_mycall(long input);
  1. here is my system call
asmlinkage long sys_mycall(long input)
{return (input * 2);
}
  1. 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

I'm not sure we have too many kernel hackers on this forum. That being said, I don't see the step were you installed your new kernel. Also, as I understand it, the better way to add system calls is through the module interface, and better yet, not to add them at all.

It is for my Operating System course in university.
I have installed the new kernels like this:
How To Compile A Kernel - The Ubuntu Way | HowtoForge - Linux Howtos and Tutorials

Steps 7 & 8 - you followed those?

All steps except patching the kernel.

Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.