<br><br><div class="gmail_quote">2012/10/19 Fan Yang <span dir="ltr"><<a href="mailto:lljyangfan@gmail.com" target="_blank">lljyangfan@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div><br><br>2012/10/19 Arun KS <<a href="mailto:getarunks@gmail.com" target="_blank">getarunks@gmail.com</a>><br>><br>> Hi Fan,<br>><br>> On Fri, Oct 19, 2012 at 6:50 PM, Fan Yang <<a href="mailto:lljyangfan@gmail.com" target="_blank">lljyangfan@gmail.com</a>> wrote:<br>
>><br>>> HI ALL:<br>>> I just run a module on my machine, but it can't work. When the module run the kernel will painc. I don't know where is wrong. This is my code:<br>>><br>>> 1 #include<linux/module.h><br>
>> 2 #include<linux/kernel.h><br>>> 3 #include<linux/init.h><br>>> 4 #include<linux/sched.h><br>>> 5<br>>> 6 int input = 1;<br>>> 7 module_param (input, int, S_IRUGO);<br>
>> 8<br>>> 9 static int __init printvma_init (void)<br>>> 10 {<br>>> 11 struct vm_area_struct *p, *start;<br>>> 12 int i;<br>>> 13 struct task_struct *thread; <br>
>> 14<br>>> 15 thread = current;<br>>> 16<br>>> 17 while (1)<br>>> 18 {<br>>> 19 if (thread->pid == input)<br>>> 20 break;<br>>> 21 thread = list_entry (thread->tasks.next, struct task_struct, tasks);<br>
>> 22 }<br>>> 23 p = thread->mm->mmap;<br>>> 24<br>>> 25 do{<br>>> 26 printk ("%lx\t%lx\t%s\n", p->vm_start,\<br>>> 27 p->vm_end, p->vm_file->f_path.dentry->d_iname);<br>
>> 28 p = p->vm_next;<br>>> 29 }while (p != NULL);<br>>> 30<br>>> 31 printk ("vm_file address is:%d\tf_path address is:%d\<br>>> 32 \tname is:%s",& p->vm_file->f_path,\<br>
>> 33 p->vm_file->f_path.dentry->d_iname);<br>>> 34<br>>> 35 printk ("info from the kernel space:%s\n", thread->comm);<br>>> 36 return 0;<br>>> 37 }<br>
>> 38<br>>> 39 static void __exit printvma_exit (void)<br>>> 40 {<br>>> 41 printk ("the module will leave the kernel space..\n");<br>>> 42 }<br>>> 43<br>>> 44 module_init (printvma_init);<br>
>> 45 module_exit (printvma_exit);<br>>> 46 MODULE_LICENSE ("GPL"); <br>>><br>>><br>>> what's wrong?<br>><br>><br>> It would be good if you paste your crash log here.<br>
><br>> Thanks,<br>> Arun<br>>><br>>><br>>> thanks<br>>><br>>> _______________________________________________<br>>> Kernelnewbies mailing list<br>>> <a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.org</a><br>
>> <a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>>><br>><br></div></div><div style="text-align:left">
The module run in a virtual machine, I can't control the machine when it crashed, so I just got a picture when the kernel panic.<br>
<br><br><img alt=""><br>
<br><br>Thanks</div></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="text-align:left"><span><font color="#888888"><br>
Fan</font></span></div></blockquote><div><br></div><div> </div><div>this is the pictiure:</div><div><br></div><div><img class="m-la-Kb-Z" alt="ÕÕƬ" src="https://lh6.googleusercontent.com/-WQaaCL8rECQ/UIFbRBoo8gI/AAAAAAAAAC0/_8HkycAjZz0/w718-h400-p-k/snapshot3.png" style="width: 718px; height: 400px; margin-left: 0px; margin-top: 0px; "></div>
</div>