mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:07:44 +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:
parent
48a0b31c47
commit
d7e5768763
1 changed files with 8 additions and 0 deletions
|
@ -167,3 +167,11 @@ template<typename T>
|
||||||
return EOVERFLOW;
|
return EOVERFLOW;
|
||||||
return copy_to_user(dest.unsafe_userspace_ptr(), src, size.value());
|
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;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue