where are the bug ?
Fan Yang
lljyangfan at gmail.com
Fri Oct 19 09:20:27 EDT 2012
HI ALL:
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:
1 #include<linux/module.h>
2 #include<linux/kernel.h>
3 #include<linux/init.h>
4 #include<linux/sched.h>
5
6 int input = 1;
7 module_param (input, int, S_IRUGO);
8
9 static int __init printvma_init (void)
10 {
11 struct vm_area_struct *p, *start;
12 int i;
13 struct task_struct
*thread;
14
15 thread = current;
16
17 while (1)
18 {
19 if (thread->pid == input)
20 break;
21 thread = list_entry (thread->tasks.next, struct task_struct,
tasks);
22 }
23 p = thread->mm->mmap;
24
25 do{
26 printk ("%lx\t%lx\t%s\n", p->vm_start,\
27 p->vm_end, p->vm_file->f_path.dentry->d_iname);
28 p = p->vm_next;
29 }while (p != NULL);
30
31 printk ("vm_file address is:%d\tf_path address is:%d\
32 \tname is:%s",& p->vm_file->f_path,\
33 p->vm_file->f_path.dentry->d_iname);
34
35 printk ("info from the kernel space:%s\n", thread->comm);
36 return 0;
37 }
38
39 static void __exit printvma_exit (void)
40 {
41 printk ("the module will leave the kernel space..\n");
42 }
43
44 module_init (printvma_init);
45 module_exit (printvma_exit);
46 MODULE_LICENSE ("GPL");
what's wrong?
thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20121019/449891ee/attachment.html
More information about the Kernelnewbies
mailing list