|
@@ -23,22 +23,13 @@ KResultOr<FlatPtr> Process::sys$module_load(Userspace<const char*> user_path, si
|
|
|
|
|
|
REQUIRE_NO_PROMISES;
|
|
|
|
|
|
- auto path = get_syscall_path_argument(user_path, path_length);
|
|
|
- if (path.is_error())
|
|
|
- return path.error();
|
|
|
- auto description_or_error = VirtualFileSystem::the().open(path.value()->view(), O_RDONLY, 0, current_directory());
|
|
|
- if (description_or_error.is_error())
|
|
|
- return description_or_error.error();
|
|
|
- auto& description = description_or_error.value();
|
|
|
- auto payload_or_error = description->read_entire_file();
|
|
|
- if (payload_or_error.is_error())
|
|
|
- return payload_or_error.error();
|
|
|
-
|
|
|
- auto& payload = *payload_or_error.value();
|
|
|
- auto storage = KBuffer::try_create_with_size(payload.size());
|
|
|
+ auto path = TRY(get_syscall_path_argument(user_path, path_length));
|
|
|
+ auto description = TRY(VirtualFileSystem::the().open(path->view(), O_RDONLY, 0, current_directory()));
|
|
|
+ auto payload = TRY(description->read_entire_file());
|
|
|
+
|
|
|
+ auto storage = KBuffer::try_create_with_bytes(ReadonlyBytes { payload->data(), payload->size() });
|
|
|
if (!storage)
|
|
|
return ENOMEM;
|
|
|
- memcpy(storage->data(), payload.data(), payload.size());
|
|
|
|
|
|
auto elf_image = try_make<ELF::Image>(storage->data(), storage->size());
|
|
|
if (!elf_image)
|
|
@@ -155,11 +146,9 @@ KResultOr<FlatPtr> Process::sys$module_unload(Userspace<const char*> user_name,
|
|
|
|
|
|
REQUIRE_NO_PROMISES;
|
|
|
|
|
|
- auto module_name_or_error = try_copy_kstring_from_user(user_name, name_length);
|
|
|
- if (module_name_or_error.is_error())
|
|
|
- return module_name_or_error.error();
|
|
|
+ auto module_name = TRY(try_copy_kstring_from_user(user_name, name_length));
|
|
|
|
|
|
- auto it = g_modules->find(module_name_or_error.value()->view());
|
|
|
+ auto it = g_modules->find(module_name->view());
|
|
|
if (it == g_modules->end())
|
|
|
return ENOENT;
|
|
|
|