summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCore
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-11-23 11:59:54 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-23 12:23:54 +0100
commit0ed5f84bd9575f71cb78b80eed1fb75f287f48de (patch)
treeeb7050d795d372ee4b83e61aac243e4d5f626227 /Userland/Libraries/LibCore
parent50416c286d098ee85c4d07a9f8d902b86fba8b25 (diff)
downloadserenity-0ed5f84bd9575f71cb78b80eed1fb75f287f48de.zip
LibCore: Use open() wrapper in Core::MappedFile :^)
Diffstat (limited to 'Userland/Libraries/LibCore')
-rw-r--r--Userland/Libraries/LibCore/MappedFile.cpp7
-rw-r--r--Userland/Libraries/LibCore/System.cpp2
2 files changed, 2 insertions, 7 deletions
diff --git a/Userland/Libraries/LibCore/MappedFile.cpp b/Userland/Libraries/LibCore/MappedFile.cpp
index 1fc28c7530..627b7d1a39 100644
--- a/Userland/Libraries/LibCore/MappedFile.cpp
+++ b/Userland/Libraries/LibCore/MappedFile.cpp
@@ -8,20 +8,15 @@
#include <AK/String.h>
#include <LibCore/MappedFile.h>
#include <LibCore/System.h>
-#include <errno.h>
#include <fcntl.h>
#include <sys/mman.h>
-#include <sys/stat.h>
#include <unistd.h>
namespace Core {
ErrorOr<NonnullRefPtr<MappedFile>> MappedFile::map(String const& path)
{
- int fd = open(path.characters(), O_RDONLY | O_CLOEXEC, 0);
- if (fd < 0)
- return Error::from_errno(errno);
-
+ auto fd = TRY(Core::System::open(path, O_RDONLY | O_CLOEXEC, 0));
return map_from_fd_and_close(fd, path);
}
diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp
index 37e1099b66..c1a66dac17 100644
--- a/Userland/Libraries/LibCore/System.cpp
+++ b/Userland/Libraries/LibCore/System.cpp
@@ -107,7 +107,7 @@ ErrorOr<int> open(StringView path, int options, ...)
HANDLE_SYSCALL_RETURN_VALUE("open"sv, rc, rc);
#else
// NOTE: We have to ensure that the path is null-terminated.
- String path_string;
+ String path_string = path;
int rc = ::open(path_string.characters(), options, mode);
if (rc < 0)
return Error::from_syscall("open"sv, -errno);