summaryrefslogtreecommitdiff
path: root/Kernel/StdLib.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-05-28 09:29:16 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-28 09:37:09 +0200
commit856f20f91f0558efb08a376a842c48ca183bb5be (patch)
tree6a34fbab8ec10e27a1a2bd8d878f812d45b31479 /Kernel/StdLib.h
parent279383a8f3cc9b9570a329ee7b0ed8844d26ba27 (diff)
downloadserenity-856f20f91f0558efb08a376a842c48ca183bb5be.zip
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!)
Diffstat (limited to 'Kernel/StdLib.h')
-rw-r--r--Kernel/StdLib.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/Kernel/StdLib.h b/Kernel/StdLib.h
index d0de84eef9..0a7a6ec00e 100644
--- a/Kernel/StdLib.h
+++ b/Kernel/StdLib.h
@@ -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>