1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:07:45 +00:00

Kernel: Add copy_typed_from_userspace<T>(Userspace<T const*>)

This allows easy retrieval of typed POD values from userspace with
implicit error propagation.
This commit is contained in:
Andreas Kling 2021-09-05 17:50:34 +02:00
parent 48a0b31c47
commit d7e5768763

View file

@ -167,3 +167,11 @@ template<typename T>
return EOVERFLOW;
return copy_to_user(dest.unsafe_userspace_ptr(), src, size.value());
}
template<typename T>
inline KResultOr<T> copy_typed_from_user(Userspace<T const*> user_data)
{
T data {};
TRY(copy_from_user(&data, user_data));
return data;
}