<br><br><div class="gmail_quote">2012/6/20 Jeff Haran <span dir="ltr"><<a href="mailto:jharan@bytemobile.com" target="_blank">jharan@bytemobile.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div link="blue" vlink="purple" lang="EN-US">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">
</span><span style="font-size:10.0pt" lang="JA">ÍõÕÜ</span><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> [mailto:<a href="mailto:wangzhe5004@gmail.com" target="_blank">wangzhe5004@gmail.com</a>]
<br>
<b>Sent:</b> Monday, June 18, 2012 9:32 PM<br>
<b>To:</b> Jeff Haran<br>
<b>Cc:</b> kernelnewbies<br>
<b>Subject:</b> Re: A confusion about invoking my syscall<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><u></u> <u></u></p>
<div><div><div class="h5">
<p class="MsoNormal">2012/6/19 Jeff Haran <<a href="mailto:jharan@bytemobile.com" target="_blank">jharan@bytemobile.com</a>><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">
<a href="mailto:kernelnewbies-bounces@kernelnewbies.org" target="_blank">kernelnewbies-bounces@kernelnewbies.org</a> [mailto:<a href="mailto:kernelnewbies-bounces@kernelnewbies.org" target="_blank">kernelnewbies-bounces@kernelnewbies.org</a>]
<b>On Behalf Of </b>??<br>
<b>Sent:</b> Monday, June 18, 2012 6:40 PM<br>
<b>To:</b> kernelnewbies<br>
<b>Subject:</b> A confusion about invoking my syscall</span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hello everyone:<br>
<br>
I append a simple syscall in kernel. and the function is as follows:<br>
<br>
asmlinkage long sys_mysyscall(long data)<br>
{<br>
printk("This is my syscall!\n");<br>
return data;<br>
}<br>
<br>
and i test it sucessfully in user space . and the test program:<br>
<br>
#include <linux/unistd.h>
<br>
#include <syscall.h><br>
#include <sys/types.h><br>
#include <stdio.h><br>
<br>
<br>
<br>
int main(void)<br>
{<br>
long n = 0,m = 0,pid1,pid2;<br>
n = syscall(345,190);// #define __NR_mysyscall 345<br>
printf("n = %ld\n",n);<br>
pid1 = syscall(SYS_getpid); //getpid<br>
printf("pid = %ld\n",pid1);<br>
pid2 = syscall(20); //getpid<br>
printf("pid = %ld\n",pid2);<br>
return 0;<br>
}<br>
and the result:<br>
n = 190<br>
pid = 4097<br>
pid = 4097<br>
<br>
but if the test program is:<br>
#include <linux/unistd.h><br>
#include <syscall.h><br>
#include <sys/types.h><br>
#include <stdio.h><br>
<br>
<br>
<br>
int main(void)<br>
{<br>
long n = 0,m = 0,pid1,pid2;<br>
n = syscall(345,190);// #define __NR_mysyscall 345<br>
printf("n = %ld\n",n);<br>
m = syscall(SYS_mysyscall,190);<br>
printf("m = %ld\n",m);<br>
pid1 = syscall(SYS_getpid); //getpid<br>
printf("pid = %ld\n",pid1);<br>
pid2 = syscall(20); //getpid<br>
printf("pid = %ld\n",pid2);<br>
return 0;<br>
}<br>
and the result:<br>
wanny@wanny-C-Notebook-XXXX:~/syscall/src$ gcc test1.c <br>
test1.c: In function ‘main’:<br>
test1.c:13:14: error: ‘SYS_mysyscall’ undeclared (first use in this function)<br>
test1.c:13:14: note: each undeclared identifier is reported only once for each function it appears in<br>
<br>
<br>
why i can't invoke my syscall with "SYS_mysyscall"?<br>
<br>
Thanks in advance!<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><span style="color:#1f497d">Because it appears you never defined the symbol SYS_mysyscall.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d"> I think so,but where shoud i defne the symbol SYS_mysyscall ?</span><span style="color:#888888"> <u></u><u></u></span></p>
</div>
</div>
</div>
</div></div><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt"><div><div class="h5">
<p class="MsoNormal"><span style="color:#1f497d"> and where is the symbol </span><span style="color:#888888">SYS_getpid defined? <u></u><u></u></span></p>
</div></div><p class="MsoNormal"><span style="color:#1f497d">On my system /usr/include/bits/syscall.h, which is</span><span style="color:#1f497d"> </span><span style="color:#1f497d">being included in your program
because it includes syscall.h.</span></p></div></div></div></blockquote></div></div></div></div></blockquote><div> 83 #define SYS_getpid __NR_getpid £¬so SYS_getpid is replaced by __NR_getpid. and __NR_getpid was defined in the kernel(arch/x86/include/asm/unistd_32.h). and my syscall was also defined there.#define SYS_mysyscall __NR_mysyscall, i don't kown why it doesn't works.<br>
<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div link="blue" vlink="purple" lang="EN-US"><div><div style="border-width:medium medium medium 1.5pt;border-style:none none none solid;border-color:-moz-use-text-color -moz-use-text-color -moz-use-text-color blue;padding:0in 0in 0in 4pt">
<div><blockquote style="border-width:medium medium medium 1pt;border-style:none none none solid;border-color:-moz-use-text-color -moz-use-text-color -moz-use-text-color rgb(204,204,204);padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<div><div><div style="border-width:medium medium medium 1.5pt;border-style:none none none solid;border-color:-moz-use-text-color -moz-use-text-color -moz-use-text-color blue;padding:0in 0in 0in 4pt"><p class="MsoNormal"><span style="color:rgb(31,73,125)"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Jeff Haran<u></u><u></u></span></p>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
<font face="monospace"></font></div>
</blockquote></div><br>