* add a new system call
@ 2010-01-12 13:53 mojtaba
2010-01-12 15:52 ` Américo Wang
0 siblings, 1 reply; 2+ messages in thread
From: mojtaba @ 2010-01-12 13:53 UTC (permalink / raw)
To: linux-kernel
[please cc kernelppc@gmail.com in your replies]
Dear all,
I need to add a new system call to the linux kernel.
These are the linux information:
Linux ubuntu-desktop 2.6.32.3 #5 SMP Mon Jan 11 16:56:27 CET 2010 i686
GNU/Linux
I am working on kernel 2.6.32.
These are all the changes I did:
1- adding " .long sys_mycall" to the end of
"arch/x86/kernel/syscall_table_32.S"
2- adding
Code:
#define __NR_mycall 242
__SYSCALL(__NR_mycall, sys_mycall)
#undef __NR_syscalls
#define __NR_syscalls 243
to the "include/asm-generic/unistd.h"
3- adding
asmlinkage long sys_mycall(char * fname, void * params);
to the end of "/include/linux/syscalls.h"
4-modifying the linux Makefile
core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ mycall/
5- adding mycall folder to kernel source and mycall.c and the
corresponding Makefile in it:
Code:
#include <linux/kernel.h>
#include <linux/syscalls.h>
SYSCALL_DEFINE2(mycall, char __user *, fname,void __user *,params)
{
printk("I am here !!";
return 10;
}
Now after building and installing the new kernel, I want to test the
system call with this code:
Code:
#include<stdio.h>
#include <errno.h>
#include<linux/unistd.h>
#include <sys/syscall.h>
#define __NR_mycall 242
long mycall(char * fname, void * params )
{
return syscall(__NR_mycall, fname, params);
}
int main(void)
{
int tmp=10;
int er=0;
char * chp= (char *) &tmp;
void * vp= (void *) &tmp;
printf("%d\n", er=mycall(chp,vp));
if( er < 0 ) {
printf( "Error: %d, %s\n", errno, strerror( errno ) );
}
}
Unfortunately, the code prints this:
-1
Error: 3, No such process
And I have no idea what the problem is!
Is there any body who can help me?
Thank you and best regards,
Mojtaba
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: add a new system call
2010-01-12 13:53 add a new system call mojtaba
@ 2010-01-12 15:52 ` Américo Wang
0 siblings, 0 replies; 2+ messages in thread
From: Américo Wang @ 2010-01-12 15:52 UTC (permalink / raw)
To: mojtaba; +Cc: linux-kernel
On Tue, Jan 12, 2010 at 02:53:10PM +0100, mojtaba wrote:
>[please cc kernelppc@gmail.com in your replies]
>
>Dear all,
>
>I need to add a new system call to the linux kernel.
>
>These are the linux information:
>Linux ubuntu-desktop 2.6.32.3 #5 SMP Mon Jan 11 16:56:27 CET 2010 i686
>GNU/Linux
>
>I am working on kernel 2.6.32.
>
>These are all the changes I did:
>
>1- adding " .long sys_mycall" to the end of
>"arch/x86/kernel/syscall_table_32.S"
>
>2- adding
>Code:
>#define __NR_mycall 242
>__SYSCALL(__NR_mycall, sys_mycall)
>#undef __NR_syscalls
>#define __NR_syscalls 243
>to the "include/asm-generic/unistd.h"
>
>3- adding
>asmlinkage long sys_mycall(char * fname, void * params);
>to the end of "/include/linux/syscalls.h"
>
>4-modifying the linux Makefile
>core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ mycall/
>
>5- adding mycall folder to kernel source and mycall.c and the
>corresponding Makefile in it:
>Code:
>#include <linux/kernel.h>
>#include <linux/syscalls.h>
>SYSCALL_DEFINE2(mycall, char __user *, fname,void __user *,params)
>{
>printk("I am here !!";
>return 10;
>}
This is not what you did, you can't pass compiling here, since you are
missing ')'...
BTW, You can make a diff to show what you have changed.
>Now after building and installing the new kernel, I want to test the
>system call with this code:
>
>Code:
>#include<stdio.h>
>#include <errno.h>
>#include<linux/unistd.h>
>#include <sys/syscall.h>
>
>#define __NR_mycall 242
>
>long mycall(char * fname, void * params )
>{
>return syscall(__NR_mycall, fname, params);
>}
>
>int main(void)
>{
>int tmp=10;
>int er=0;
>char * chp= (char *) &tmp;
>void * vp= (void *) &tmp;
>printf("%d\n", er=mycall(chp,vp));
>if( er < 0 ) {
>printf( "Error: %d, %s\n", errno, strerror( errno ) );
>}
>}
>Unfortunately, the code prints this:
>-1
>Error: 3, No such process
>
>And I have no idea what the problem is!
>
>Is there any body who can help me?
>
>Thank you and best regards,
>Mojtaba
>--
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at http://www.tux.org/lkml/
--
Live like a child, think like the god.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-01-12 15:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-12 13:53 add a new system call mojtaba
2010-01-12 15:52 ` Américo Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox