Add a System Call

Submitted by weiwu
on February 22, 2009 - 4:09pm

I am trying to add a system under linux-2.6.28+.
I can successfully do this by adding the system call code to the kernel source tree.

But, since it will take a relative long time to compile the kernel,
I would like to put the real work into a loadable linux module.
Therefore, I am trying to do the following tricks:

----------------------------------------
long (*my_call_ptr) (int i) = NULL;
EXPORT_SYMBOL(my_call_ptr);

asmlinkage long sys_mycall(int i)
{
if (my_call_ptr)
return my_call_ptr(i);
else
return -ENOSYS;
}
----------------------------------------

However I get the following warnings:

warning: data definition has no type or storage class
warning: type defaults to ‘int’ in declaration of ‘EXPORT_SYMBOL’
warning: parameter names (without types) in function declaration

Does this mean that EXPORT_SYMBOL will not support pointer kinds of variables.
And anyone have any clues on how to pass the function pointer to a kernel
module so that I can don't have to recompile kernel whenever I make any changes
to my custom system call.

Thanks.

The warnings make it sound

Anonymous (not verified)
on
February 22, 2009 - 7:35pm

The warnings make it sound as though EXPORT_SYMBOLS has not been declared. Did you include the proper header file?

That is the problem.

weiwu
on
February 23, 2009 - 2:43am

Thank you so much for your reply.
The header file solved my problem.
I need to add "linux/module.h" to my source code to make the macro work correctly.
Now, I can get what I want.

Comment viewing options

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