All of lore.kernel.org
 help / color / mirror / Atom feed
From: matthias.bgg@googlemail.com (Matthias Brugger)
To: kernelnewbies@lists.kernelnewbies.org
Subject: A confusion about invoking my syscall
Date: Tue, 19 Jun 2012 11:54:54 +0200	[thread overview]
Message-ID: <4FE04C6E.2040305@gmail.com> (raw)
In-Reply-To: <CAJrRU3WKMuawvEgiM9PkoFx5vqSgh8xWTpMN15Rg2S1Kh5dmAQ@mail.gmail.com>

On 06/19/2012 06:32 AM, ?? wrote:
>
>
> 2012/6/19 Jeff Haran <jharan at bytemobile.com <mailto:jharan@bytemobile.com>>
>
>     __ __
>
>     __ __
>
>     *From:*kernelnewbies-bounces at kernelnewbies.org
>     <mailto:kernelnewbies-bounces@kernelnewbies.org>
>     [mailto:kernelnewbies-bounces at kernelnewbies.org
>     <mailto:kernelnewbies-bounces@kernelnewbies.org>] *On Behalf Of *??
>     *Sent:* Monday, June 18, 2012 6:40 PM
>     *To:* kernelnewbies
>     *Subject:* A confusion about invoking my syscall____
>
>     __ __
>
>     Hello everyone:
>
>               I append a simple syscall in kernel. and the function is
>     as follows:
>
>        asmlinkage  long sys_mysyscall(long data)
>       {
>                printk("This is my syscall!\n");
>                return data;
>        }
>
>     and i test it sucessfully in user space . and the test program:
>
>         #include <linux/unistd.h>
>         #include <syscall.h>
>         #include <sys/types.h>
>         #include <stdio.h>
>
>
>
>         int main(void)
>         {
>         long n = 0,m = 0,pid1,pid2;
>         n = syscall(345,190);// #define __NR_mysyscall          345
>         printf("n = %ld\n",n);
>         pid1 = syscall(SYS_getpid);  //getpid
>         printf("pid = %ld\n",pid1);
>         pid2 = syscall(20);  //getpid
>         printf("pid = %ld\n",pid2);
>         return 0;
>        }
>     and the result:
>     n = 190
>     pid = 4097
>     pid = 4097
>
>     but if the test program is:
>     #include <linux/unistd.h>
>     #include <syscall.h>
>     #include <sys/types.h>
>     #include <stdio.h>
>
>
>
>     int main(void)
>     {
>       long n = 0,m = 0,pid1,pid2;
>       n = syscall(345,190);// #define __NR_mysyscall          345
>       printf("n = %ld\n",n);
>       m = syscall(SYS_mysyscall,190);
>       printf("m = %ld\n",m);
>       pid1 = syscall(SYS_getpid);  //getpid
>       printf("pid = %ld\n",pid1);
>       pid2 = syscall(20);  //getpid
>       printf("pid = %ld\n",pid2);
>       return 0;
>     }
>     and the result:
>     wanny at wanny-C-Notebook-XXXX:~/syscall/src$ gcc test1.c
>     test1.c: In function ?main?:
>     test1.c:13:14: error: ?SYS_mysyscall? undeclared (first use in this
>     function)
>     test1.c:13:14: note: each undeclared identifier is reported only
>     once for each function it appears in
>
>
>     why i can't invoke my syscall with "SYS_mysyscall"?
>
>     Thanks in advance!
>
>     Because it appears you never defined the symbol SYS_mysyscall.____
>
>     __ I think so,but where shoud i defne the __symbol SYS_mysyscall ?
>
>        and where is the symbol SYS_getpid defined?

Not sure, but I think the syscalls should be defined in syscall.h which 
is included by your program. I suppose that this file is part of libc, 
so there won't be your syscall definition in there.
The easiest way would be to define the syscall by yourself.

Remember that adding a syscall to the linux kernel is a bad idea.

Regards,
Matthias

>
>     Jeff Haran
>     ____
>
>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  parent reply	other threads:[~2012-06-19  9:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-19  1:39 A confusion about invoking my syscall 王哲
2012-06-19  1:58 ` Jeff Haran
2012-06-19  4:32   ` 王哲
2012-06-19  8:11     ` Baoquan He
2012-06-19  9:54     ` Matthias Brugger [this message]
2012-06-19 17:21     ` Jeff Haran
2012-06-20  8:15       ` 王哲
2012-06-20 16:58         ` Jeff Haran

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=4FE04C6E.2040305@gmail.com \
    --to=matthias.bgg@googlemail.com \
    --cc=kernelnewbies@lists.kernelnewbies.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.