First page Back Continue Last page Overview Graphics
Exchanging data with user-space (2)
A single value
- get_user(v, p);
The kernel variable v gets the value pointer by the user-space pointer p
- put_user(v, p);
The value pointed by the user-space pointer p is set to the contents of the kernel variable v.
A buffer
- unsigned long copy_to_user(void __user *to,
const void *from, unsigned long n);
- unsigned long copy_from_user(void *to,
const void __user *from, unsigned long n);
The return value must be checked. Zero on success, non-zero on failure. If non-zero, the convention is to return -EFAULT.