2020-07-30 21:38:15 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-07-30 21:38:15 +00:00
|
|
|
*/
|
|
|
|
|
2021-09-07 11:39:11 +00:00
|
|
|
#include <Kernel/FileSystem/OpenFileDescription.h>
|
2020-07-30 21:38:15 +00:00
|
|
|
#include <Kernel/Process.h>
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2021-11-07 23:51:39 +00:00
|
|
|
ErrorOr<FlatPtr> Process::sys$get_dir_entries(int fd, Userspace<void*> user_buffer, size_t user_size)
|
2020-07-30 21:38:15 +00:00
|
|
|
{
|
2021-07-18 18:20:12 +00:00
|
|
|
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this);
|
2021-12-29 09:11:45 +00:00
|
|
|
TRY(require_promise(Pledge::stdio));
|
2021-06-16 14:44:15 +00:00
|
|
|
if (user_size > NumericLimits<ssize_t>::max())
|
2021-03-01 12:49:16 +00:00
|
|
|
return EINVAL;
|
2022-01-29 00:22:28 +00:00
|
|
|
auto description = TRY(open_file_description(fd));
|
2021-11-21 11:24:32 +00:00
|
|
|
auto buffer = TRY(UserOrKernelBuffer::for_user_buffer(user_buffer, static_cast<size_t>(user_size)));
|
|
|
|
auto count = TRY(description->get_dir_entries(buffer, user_size));
|
2021-11-07 23:51:39 +00:00
|
|
|
return count;
|
2020-07-30 21:38:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|