Find the answer to your Linux question:
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.
  1. #1
    Just Joined!
    Join Date
    Mar 2011
    Posts
    1

    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.

  2. #2
    Just Joined!
    Join Date
    Apr 2011
    Posts
    1
    Quote Originally Posted by sh_me View Post
    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.

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •