mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 15:45:25 +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:
23
Kernel/FileSystem/CustodyBase.cpp
Normal file
23
Kernel/FileSystem/CustodyBase.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2024, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <Kernel/FileSystem/CustodyBase.h>
|
||||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||
#include <Kernel/Library/KLexicalPath.h>
|
||||
#include <Kernel/Tasks/Process.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
ErrorOr<NonnullRefPtr<Custody>> CustodyBase::resolve() const
|
||||
{
|
||||
if (m_base)
|
||||
return *m_base;
|
||||
if (KLexicalPath::is_absolute(m_path))
|
||||
return VirtualFileSystem::the().root_custody();
|
||||
return Process::current().custody_for_dirfd({}, m_dirfd);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user