Results 1 to 2 of 2
I have to add a system call in linux kernel that will print the process tree showing only the PIDs to user code. I have to use copy_to_user here. But ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 03-31-2011 #1
- Join Date
- Mar 2011
How to use 'copy_to_user'?
I have to add a system call in linux kernel that will print the process tree showing only the PIDs to user code. I have to use copy_to_user here. But I am not understanding the use of this function. Could any of u give an example of how it works, including the user-side code and added system code?.....Any easy/simple example would be great for me... Thanks.
- 04-01-2011 #2
- Join Date
- Apr 2011
view the manpage of copy_to_user.
Essentially it bridges the gap between kernel space and user space so you can copy data from kernel to user.
unsigned long copy_to_user (void __user * to, const void * from, unsigned long n);
Typically you would have a read function in your driver that passes in a pointer from user space and you would use that in the to argument. The from argument is just some pointer reference to data you have put data into on the driver side. The unsigned long n parameter is the number of bytes to copy from kernel to user.