linux device driver - how to use get_user to copy data from user space to kernel space -
I want to copy an integer variable from the user space to the kernel location. Can anyone give me a simple example of how to do this? I came to know that we can use get_user but I do not know how.
check Pages <<>> << Code> copy_to_user and copy_from_user pages
Write a normal kernel module, read / write with operations, and register and four tools for them, something like
/ dev / sample .
An application write / read , but
fd opened by this application.
Now you need to implement the mechanism to move this data to the kernel space and read what you have returned.
- In the type you enter a
copy_from_user whether this check buffer is valid or not.
- In reading you do a
copy_to_user . Make sure that the status of the error is taken care of, and
open call implementation should be kept in mind that how many
opens are there, if you want to have many open implementations, And when this count decreases, the N app calls a
off to
FD .
Do you follow it?
Comments
Post a Comment