linux kernel system call

G

gooch

This is not really a general c question but here goes anyway.

I am trying to add a system call to a kernel (redhat 2.4.18) for a
class I am taking and I have done the following.

in /usr/src/linux/include/asm/unistd.h
I added #define __NR_myfunctionname number

in /usr/src/linux/arch/i386/kernel/entry.S
I added .long SYMBOL_NAME(sys_myfunctionname)

and the next line is .rept NR_syscalls-(.-sys_call_table)/4

I then added to /usr/src/linux/kernel/sys.c

asmlinkage int sys_myfunctionname(int a)
{
return a*a;
}

I also added a symbolic link to /usr/include called asm which links to
/usr/src/linux/include/asm

I wrote a driver with a printf to output the function result and all I
get is
-1. I have tried it without arguments and simply tried to return a
value but that didn't seem to work either. I got instructions on how
to do this from a tutorial and have searched all the groups and the
web with no luck. I would appreciate any help someone might be able to
give.

Thanks
gooch
 
E

E. Robert Tisdale

gooch said:
This is not really a general c question but here goes anyway.

I am trying to add a system call to a kernel (redhat 2.4.18) for a
class I am taking and I have done the following.

in /usr/src/linux/include/asm/unistd.h
I added #define __NR_myfunctionname number

in /usr/src/linux/arch/i386/kernel/entry.S
I added .long SYMBOL_NAME(sys_myfunctionname)

and the next line is .rept NR_syscalls-(.-sys_call_table)/4

I then added to /usr/src/linux/kernel/sys.c

asmlinkage int sys_myfunctionname(int a) {
return a*a;
}

I also added a symbolic link to /usr/include called asm which links to
/usr/src/linux/include/asm

I wrote a driver with a printf to output the function result and all I
get is
-1. I have tried it without arguments and simply tried to return a
value but that didn't seem to work either. I got instructions on how
to do this from a tutorial and have searched all the groups and the
web with no luck. I would appreciate any help someone might be able to
give.

Try comp.os.linux
 
M

Mike Wahler

gooch said:
This is not really a general c question but here goes anyway.

I can't prevent you from posting off topic but here
goes anyway:

http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html
I am trying to add a system call to a kernel (redhat 2.4.18) for a
class I am taking and I have done the following.
I got instructions on how
to do this from a tutorial and have searched all the groups

I doubt *all*. Have you tried any of the groups listed
at: http://www.linux.org/docs/usenetlinux.html ?

(I located that link in three seconds with Google)

I suspect one or more of the groups enumerated therein
can give answers to your query and much more useful
Linux info.

-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top