Adding a new system call within a module in 2.6 series

Submitted by Anonymous
on March 10, 2005 - 7:10am

Hi. For academic work, i have to add a dummy sytem call to the linux kernel. In classes they only explain how to do it for 2.4, but in 2.6 isn't the same, since the system call table isn't exported anymore.

I can (and in fact, I've already) add an in-kernel syscall (modifiying the entry.S for each arch, etc), but I'd like to be able to do it as a module, since recompiling and rebooting every change i made simply sux.

Any tips on how can i export the system call table and how can i add a syscall to it?

wrapper?

on
March 10, 2005 - 8:02am

Why don't you just make a wrapper syscall, i.e. put something like

long (*my_syscall)(args...) = NULL;
EXPORT_SYMBOL(my_syscall);

asmlinkage long sys_my_syscall(args...)
{
        return my_syscall ? my_syscall(args) : -ENOSYS;
}

into a builtin object and entry.S and assign the function pointer in the module? For debugging this seem adequate.

x)))

on
March 13, 2005 - 4:34pm

that seemed to work!! Thank you very much!!

How system call module really implement?

su (not verified)
on
October 10, 2005 - 6:24am

Apt-drink.. I ran into the same problem but I don't know how to start doing that. Please give me some suggestion.

Thank you

Hello,

on
September 15, 2006 - 10:31pm

Hello,

I am a newbie and I am supposed to do the same thing but I am not able to understand it. Can you please tell me if what I understand is right?

I modify syscall_table.S to add entry corresponding to 'wrapper' system call ('my_syscall'). And make a module which defines sys_my_syscall as you have shown.

long (*my_syscall)(args...) = NULL;

EXPORT_SYMBOL(my_syscall);

asmlinkage long sys_my_syscall(args...)
{
return my_syscall ? my_syscall(args) : -ENOSYS;
}

I define another module which implements system call say 'my_front_syscall' (which will be invoked from user space) and define sys_my_front_syscall such that it calls sys_my_syscall module, setting 'my_syscall' to address of function that does actual 'action-carrying' part defined in 'my_front_syscall'.

You got most of it right. Onl

Lohit Vijayarenu (not verified)
on
September 27, 2006 - 12:05am

You got most of it right. Only change is you just have to implement 'my_front_syscall' and assign my_syscall pointer to this function. From user space you still use my_syscall. you dont need sys_my_front_syscall.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.