1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00

Kernel: Add try_copy_kstring_from_user()

This is a convenience function that works the same as our old
copy_string_from_user(), but this returns a KString (and can fail!)
This commit is contained in:
Andreas Kling 2021-05-28 09:29:16 +02:00
parent 279383a8f3
commit 856f20f91f
3 changed files with 43 additions and 0 deletions

View file

@ -10,6 +10,8 @@
#include <AK/Forward.h>
#include <AK/Time.h>
#include <AK/Userspace.h>
#include <Kernel/KResult.h>
#include <Kernel/KString.h>
#include <Kernel/UnixTypes.h>
namespace Syscall {
@ -18,6 +20,8 @@ struct StringArgument;
[[nodiscard]] String copy_string_from_user(const char*, size_t);
[[nodiscard]] String copy_string_from_user(Userspace<const char*>, size_t);
[[nodiscard]] Kernel::KResultOr<NonnullOwnPtr<Kernel::KString>> try_copy_kstring_from_user(const char*, size_t);
[[nodiscard]] Kernel::KResultOr<NonnullOwnPtr<Kernel::KString>> try_copy_kstring_from_user(Userspace<const char*>, size_t);
[[nodiscard]] Optional<Time> copy_time_from_user(const timespec*);
[[nodiscard]] Optional<Time> copy_time_from_user(const timeval*);
template<typename T>