- 論壇徽章:
- 0
|
為什么我的copy_to_user函數(shù)實驗不成功....我用添加內(nèi)核模塊的方法添加了一個系統(tǒng)調(diào)用,然后在用戶程序中調(diào)用這個系統(tǒng)調(diào)用,同時把用戶buf地址傳入系統(tǒng)調(diào)用中,但是在內(nèi)核模塊中調(diào)用copy_to_user有問題,用戶態(tài)中的數(shù)據(jù)不對。幫我看看....
用戶態(tài)代碼:
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 }
內(nèi)核態(tài)代碼:
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 }
就這些.... |
|