- 论坛徽章:
- 0
|
为什么我的copy_to_user函数实验不成功....我用添加内核模块的方法添加了一个系统调用,然后在用户程序中调用这个系统调用,同时把用户buf地址传入系统调用中,但是在内核模块中调用copy_to_user有问题,用户态中的数据不对。帮我看看....
用户态代码:
1 #include<stdio.h>
2 #include<sys/types.h>
3
4 struct user_buf
5 {
6 int pid;
7 };
8
9 main ()
10 {
11 struct user_buf user_data={0};
12 syscall (223, &user_data);
13 printf ("user pid is %d", user_data.pid);
14 }
内核态代码:
21 asmlinkage int my_syscall (struct kernel_buf *user_buf)
22 {
23 struct kernel_buf temp_buf;
24 printk ("the current process's pid is %d\n", current->pid);
25 copy_to_user (user_buf, &temp_buf, sizeof (temp_buf));
26 }
就这些.... |
|