mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:47:35 +00:00
Kernel: Use non-locking {Nonnull,}RefPtr for OpenFileDescription
This patch switches away from {Nonnull,}LockRefPtr to the non-locking smart pointers throughout the kernel. I've looked at the handful of places where these were being persisted and I don't see any race situations. Note that the process file descriptor table (Process::m_fds) was already guarded via MutexProtected.
This commit is contained in:
parent
36b0ecfe9e
commit
d1371d66f7
34 changed files with 82 additions and 80 deletions
|
@ -38,7 +38,7 @@ ErrorOr<FlatPtr> Process::sys$anon_create(size_t size, int options)
|
|||
|
||||
return m_fds.with_exclusive([&](auto& fds) -> ErrorOr<FlatPtr> {
|
||||
auto new_fd = TRY(fds.allocate());
|
||||
fds[new_fd.fd].set(move(description), fd_flags);
|
||||
fds[new_fd.fd].set(description, fd_flags);
|
||||
return new_fd.fd;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -423,8 +423,8 @@ static ErrorOr<LoadResult> load_elf_object(NonnullOwnPtr<Memory::AddressSpace> n
|
|||
}
|
||||
|
||||
ErrorOr<LoadResult>
|
||||
Process::load(NonnullLockRefPtr<OpenFileDescription> main_program_description,
|
||||
LockRefPtr<OpenFileDescription> interpreter_description, const ElfW(Ehdr) & main_program_header)
|
||||
Process::load(NonnullRefPtr<OpenFileDescription> main_program_description,
|
||||
RefPtr<OpenFileDescription> interpreter_description, const ElfW(Ehdr) & main_program_header)
|
||||
{
|
||||
auto new_space = TRY(Memory::AddressSpace::try_create(nullptr));
|
||||
|
||||
|
@ -471,8 +471,8 @@ void Process::clear_signal_handlers_for_exec()
|
|||
}
|
||||
}
|
||||
|
||||
ErrorOr<void> Process::do_exec(NonnullLockRefPtr<OpenFileDescription> main_program_description, Vector<NonnullOwnPtr<KString>> arguments, Vector<NonnullOwnPtr<KString>> environment,
|
||||
LockRefPtr<OpenFileDescription> interpreter_description, Thread*& new_main_thread, InterruptsState& previous_interrupts_state, const ElfW(Ehdr) & main_program_header)
|
||||
ErrorOr<void> Process::do_exec(NonnullRefPtr<OpenFileDescription> main_program_description, Vector<NonnullOwnPtr<KString>> arguments, Vector<NonnullOwnPtr<KString>> environment,
|
||||
RefPtr<OpenFileDescription> interpreter_description, Thread*& new_main_thread, InterruptsState& previous_interrupts_state, const ElfW(Ehdr) & main_program_header)
|
||||
{
|
||||
VERIFY(is_user_process());
|
||||
VERIFY(!Processor::in_critical());
|
||||
|
@ -784,7 +784,7 @@ static ErrorOr<Vector<NonnullOwnPtr<KString>>> find_shebang_interpreter_for_exec
|
|||
return ENOEXEC;
|
||||
}
|
||||
|
||||
ErrorOr<LockRefPtr<OpenFileDescription>> Process::find_elf_interpreter_for_executable(StringView path, ElfW(Ehdr) const& main_executable_header, size_t main_executable_header_size, size_t file_size)
|
||||
ErrorOr<RefPtr<OpenFileDescription>> Process::find_elf_interpreter_for_executable(StringView path, ElfW(Ehdr) const& main_executable_header, size_t main_executable_header_size, size_t file_size)
|
||||
{
|
||||
// Not using ErrorOr here because we'll want to do the same thing in userspace in the RTLD
|
||||
StringBuilder interpreter_path_builder;
|
||||
|
|
|
@ -196,7 +196,7 @@ ErrorOr<FlatPtr> Process::sys$mmap(Userspace<Syscall::SC_mmap_params const*> use
|
|||
|
||||
Memory::Region* region = nullptr;
|
||||
|
||||
LockRefPtr<OpenFileDescription> description;
|
||||
RefPtr<OpenFileDescription> description;
|
||||
LockRefPtr<Memory::VMObject> vmobject;
|
||||
u64 used_offset = 0;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ ErrorOr<FlatPtr> Process::sys$poll(Userspace<Syscall::SC_poll_params const*> use
|
|||
TRY(m_fds.with_shared([&](auto& fds) -> ErrorOr<void> {
|
||||
for (size_t i = 0; i < params.nfds; i++) {
|
||||
auto& pfd = fds_copy[i];
|
||||
LockRefPtr<OpenFileDescription> description;
|
||||
RefPtr<OpenFileDescription> description;
|
||||
auto description_or_error = fds.open_file_description(pfd.fd);
|
||||
if (!description_or_error.is_error())
|
||||
description = description_or_error.release_value();
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Kernel {
|
|||
|
||||
using BlockFlags = Thread::FileBlocker::BlockFlags;
|
||||
|
||||
static ErrorOr<NonnullLockRefPtr<OpenFileDescription>> open_readable_file_description(auto& fds, int fd)
|
||||
static ErrorOr<NonnullRefPtr<OpenFileDescription>> open_readable_file_description(auto& fds, int fd)
|
||||
{
|
||||
auto description = TRY(fds.with_shared([&](auto& fds) { return fds.open_file_description(fd); }));
|
||||
if (!description->is_readable())
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Kernel {
|
|||
TRY(require_promise(Pledge::unix)); \
|
||||
} while (0)
|
||||
|
||||
static void setup_socket_fd(Process::OpenFileDescriptions& fds, int fd, NonnullLockRefPtr<OpenFileDescription> description, int type)
|
||||
static void setup_socket_fd(Process::OpenFileDescriptions& fds, int fd, NonnullRefPtr<OpenFileDescription> description, int type)
|
||||
{
|
||||
description->set_readable(true);
|
||||
description->set_writable(true);
|
||||
|
@ -94,7 +94,7 @@ ErrorOr<FlatPtr> Process::sys$accept4(Userspace<Syscall::SC_accept4_params const
|
|||
TRY(copy_from_user(&address_size, static_ptr_cast<socklen_t const*>(user_address_size)));
|
||||
|
||||
ScopedDescriptionAllocation fd_allocation;
|
||||
LockRefPtr<OpenFileDescription> accepting_socket_description;
|
||||
RefPtr<OpenFileDescription> accepting_socket_description;
|
||||
|
||||
TRY(m_fds.with_exclusive([&](auto& fds) -> ErrorOr<void> {
|
||||
fd_allocation = TRY(fds.allocate());
|
||||
|
|
|
@ -38,7 +38,7 @@ ErrorOr<FlatPtr> Process::sys$utimensat(Userspace<Syscall::SC_utimensat_params c
|
|||
}
|
||||
|
||||
OwnPtr<KString> path;
|
||||
LockRefPtr<OpenFileDescription> description;
|
||||
RefPtr<OpenFileDescription> description;
|
||||
RefPtr<Custody> base;
|
||||
|
||||
auto path_or_error = get_syscall_path_argument(params.path);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue