mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: mojtaba <kernelppc@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: add a new system call
Date: Tue, 12 Jan 2010 14:53:10 +0100	[thread overview]
Message-ID: <1dec3f771001120553n61e281acjf82086f85e03425@mail.gmail.com> (raw)

[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

             reply	other threads:[~2010-01-12 13:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-12 13:53 mojtaba [this message]
2010-01-12 15:52 ` Américo Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1dec3f771001120553n61e281acjf82086f85e03425@mail.gmail.com \
    --to=kernelppc@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®