mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-13 11:16:53 +00:00
Kernel: Ignore dirfd if absolute path is given in VFS-related syscalls
To be able to do this, we add a new class called CustodyBase, which can be resolved on-demand internally in the VirtualFileSystem resolving path code. When being resolved, CustodyBase will return a known custody if it was constructed with such, if that's not the case it will provide the root custody if the original path is absolute. Lastly, if that's not the case as well, it will resolve the given dirfd to provide a Custody object.
This commit is contained in:
@@ -16,10 +16,8 @@ ErrorOr<FlatPtr> Process::sys$chdir(Userspace<char const*> user_path, size_t pat
|
||||
VERIFY_NO_PROCESS_BIG_LOCK(this);
|
||||
TRY(require_promise(Pledge::rpath));
|
||||
auto path = TRY(get_syscall_path_argument(user_path, path_length));
|
||||
auto current_directory = m_current_directory.with([](auto& current_directory) -> NonnullRefPtr<Custody> {
|
||||
return *current_directory;
|
||||
});
|
||||
RefPtr<Custody> new_directory = TRY(VirtualFileSystem::the().open_directory(credentials(), path->view(), *current_directory));
|
||||
|
||||
RefPtr<Custody> new_directory = TRY(VirtualFileSystem::the().open_directory(credentials(), path->view(), current_directory()));
|
||||
m_current_directory.with([&](auto& current_directory) {
|
||||
// NOTE: We use swap() here to avoid manipulating the ref counts while holding the lock.
|
||||
swap(current_directory, new_directory);
|
||||
|
||||
Reference in New Issue
Block a user