mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
Kernel: Use Userspace<T> in sys$get_dir_entries()
This commit is contained in:
parent
b5f32be577
commit
a1a82c1d95
Notes:
sideshowbarker
2024-07-18 21:48:49 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/a1a82c1d95e
@ -261,7 +261,7 @@ public:
|
|||||||
KResultOr<int> sys$purge(int mode);
|
KResultOr<int> sys$purge(int mode);
|
||||||
KResultOr<int> sys$select(const Syscall::SC_select_params*);
|
KResultOr<int> sys$select(const Syscall::SC_select_params*);
|
||||||
KResultOr<int> sys$poll(Userspace<const Syscall::SC_poll_params*>);
|
KResultOr<int> sys$poll(Userspace<const Syscall::SC_poll_params*>);
|
||||||
KResultOr<ssize_t> sys$get_dir_entries(int fd, void*, ssize_t);
|
KResultOr<ssize_t> sys$get_dir_entries(int fd, Userspace<void*>, ssize_t);
|
||||||
KResultOr<int> sys$getcwd(Userspace<char*>, size_t);
|
KResultOr<int> sys$getcwd(Userspace<char*>, size_t);
|
||||||
KResultOr<int> sys$chdir(Userspace<const char*>, size_t);
|
KResultOr<int> sys$chdir(Userspace<const char*>, size_t);
|
||||||
KResultOr<int> sys$fchdir(int fd);
|
KResultOr<int> sys$fchdir(int fd);
|
||||||
|
@ -29,18 +29,18 @@
|
|||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
KResultOr<ssize_t> Process::sys$get_dir_entries(int fd, void* buffer, ssize_t size)
|
KResultOr<ssize_t> Process::sys$get_dir_entries(int fd, Userspace<void*> user_buffer, ssize_t user_size)
|
||||||
{
|
{
|
||||||
REQUIRE_PROMISE(stdio);
|
REQUIRE_PROMISE(stdio);
|
||||||
if (size < 0)
|
if (user_size < 0)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
auto description = file_description(fd);
|
auto description = file_description(fd);
|
||||||
if (!description)
|
if (!description)
|
||||||
return EBADF;
|
return EBADF;
|
||||||
auto user_buffer = UserOrKernelBuffer::for_user_buffer((u8*)buffer, size);
|
auto buffer = UserOrKernelBuffer::for_user_buffer(user_buffer, static_cast<size_t>(user_size));
|
||||||
if (!user_buffer.has_value())
|
if (!buffer.has_value())
|
||||||
return EFAULT;
|
return EFAULT;
|
||||||
return description->get_dir_entries(user_buffer.value(), size);
|
return description->get_dir_entries(buffer.value(), user_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user