/* * get_user: - Get a simple variable from user space. * @x: Variable to store result. * @ptr: Source address, in user space. * * Context: User context only. This function may sleep if pagefaults are * enabled. * * 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.
*/ #define get_user(x, ptr) \
({ \ const __typeof__(*(ptr)) __user *__p = (ptr); \
\
might_fault(); \
access_ok(__p, sizeof(*__p)) ? __get_user((x), __p) : \
((x) = 0, -EFAULT); \
})
/* * put_user: - Write a simple value into user space. * @x: Value to copy to user space. * @ptr: Destination address, in user space. * * Context: User context only. This function may sleep if pagefaults are * enabled. * * 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.
*/ #define put_user(x, ptr) \
({ \
__typeof__(*(ptr)) __user *__p = (ptr); \
\
might_fault(); \
access_ok(__p, sizeof(*__p)) ? __put_user((x), __p) : -EFAULT; \
})
/* * __get_user: - Get a simple variable from user space, with less checking. * @x: Variable to store result. * @ptr: Source address, in user space. * * Context: User context only. This function may sleep if pagefaults are * enabled. * * 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. * * Caller must check the pointer with access_ok() before calling this * function. * * Returns zero on success, or -EFAULT on error. * On error, the variable @x is set to zero.
*/ #define __get_user(x, ptr) \
({ \ int __gu_err = 0; \
\
__chk_user_ptr(ptr); \
__get_user_common((x), sizeof(*(ptr)), ptr); \
__gu_err; \
})
/* * __put_user: - Write a simple value into user space, with less checking. * @x: Value to copy to user space. * @ptr: Destination address, in user space. * * Context: User context only. This function may sleep if pagefaults are * enabled. * * 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. * * Caller must check the pointer with access_ok() before calling this * function. * * Returns zero on success, or -EFAULT on error.
*/ #define __put_user(x, ptr) \
({ \ int __pu_err = 0; \
__typeof__(*(ptr)) __pu_val; \
\
__pu_val = (x); \
__chk_user_ptr(ptr); \
__put_user_common(ptr, sizeof(*(ptr))); \
__pu_err; \
})
/* * __clear_user: - Zero a block of memory in user space, with less checking. * @addr: Destination address, in user space. * @size: Number of bytes to zero. * * Zero a block of memory in user space. Caller must check * the specified block with access_ok() before calling this function. * * Returns number of bytes that could not be cleared. * On success, this will be zero.
*/ externunsignedlong __clear_user(void __user *addr, __kernel_size_t size);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.