put_user & get_user

来源:互联网 发布:短篇小说 知乎 编辑:程序博客网 时间:2024/06/05 02:45

1. put_user

Name
put_user --    Write a simple value into user space.
Synopsis
put_user ( x, ptr);
Arguments
x

Value to copy to user space.

ptr

Destination address, in user space.

Context

User context only. This function may sleep.

Description

This macro copies a single simple value from kernel space to user space.It supports simple types like char and int, but not larger data types like structures or arrays.

ptr must have pointer-to-simple-variable type, and x must be assignable to the result of dereferencing ptr.

Returns zero on success, or -EFAULT on error.

2. get_user

Name
get_user --    Get a simple variable from user space.
Synopsis
get_user ( x, ptr);
Arguments
x

Variable to store result.

ptr

Source address, in user space.

Context

User context only. This function may sleep.


Description

This macro copies a single simple variable from user space to kernel space. It supports simple types like char and int, but not larger data types like structures or arrays.

ptr must have pointer-to-simple-variable type, and the result of dereferencing ptr must be assignable to x without a cast.

Returns zero on success, or -EFAULT on error. On error, the variable x is set to zero.


原创粉丝点击