mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +00:00
Kernel: Replace usage of LexicalPath with KLexicalPath
This replaces all uses of LexicalPath in the Kernel with the functions from KLexicalPath. This also allows the Kernel to stop including AK::LexicalPath.
This commit is contained in:
parent
87a62f4def
commit
ee342f5ec3
6 changed files with 21 additions and 25 deletions
|
@ -5,10 +5,10 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <Kernel/FileSystem/Custody.h>
|
||||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||
#include <Kernel/KLexicalPath.h>
|
||||
#include <Kernel/Process.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
@ -91,16 +91,16 @@ KResultOr<FlatPtr> Process::sys$unveil(Userspace<const Syscall::SC_unveil_params
|
|||
if (!custody_or_error.is_error()) {
|
||||
new_unveiled_path = custody_or_error.value()->absolute_path();
|
||||
} else if (custody_or_error.error() == -ENOENT && parent_custody && (new_permissions & UnveilAccess::CreateOrRemove)) {
|
||||
String basename = LexicalPath::basename(path.view());
|
||||
auto basename = KLexicalPath::basename(path.view());
|
||||
new_unveiled_path = String::formatted("{}/{}", parent_custody->absolute_path(), basename);
|
||||
} else {
|
||||
// FIXME Should this be EINVAL?
|
||||
return custody_or_error.error();
|
||||
}
|
||||
|
||||
LexicalPath lexical_path(new_unveiled_path);
|
||||
auto it = lexical_path.parts_view().begin();
|
||||
auto& matching_node = m_unveiled_paths.traverse_until_last_accessible_node(it, lexical_path.parts_view().end());
|
||||
auto path_parts = KLexicalPath::parts(new_unveiled_path);
|
||||
auto it = path_parts.begin();
|
||||
auto& matching_node = m_unveiled_paths.traverse_until_last_accessible_node(it, path_parts.end());
|
||||
if (it.is_end()) {
|
||||
// If the path has already been explicitly unveiled, do not allow elevating its permissions.
|
||||
if (matching_node.was_explicitly_unveiled()) {
|
||||
|
@ -122,10 +122,10 @@ KResultOr<FlatPtr> Process::sys$unveil(Userspace<const Syscall::SC_unveil_params
|
|||
|
||||
matching_node.insert(
|
||||
it,
|
||||
lexical_path.parts_view().end(),
|
||||
path_parts.end(),
|
||||
{ new_unveiled_path, (UnveilAccess)new_permissions, true },
|
||||
[](auto& parent, auto& it) -> Optional<UnveilMetadata> {
|
||||
auto path = LexicalPath::join(parent.path(), *it).string();
|
||||
auto path = String::formatted("{}/{}", parent.path(), *it);
|
||||
return UnveilMetadata { path, parent.permissions(), false };
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue