mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:38:12 +00:00
Kernel: Don't allocate Strings unnecessarily in process veil validation
Previously, Custody::absolute_path() was called for every call to validate_path_against_process_veil(). For processes that don't have a veil, the path is not used by the function. This means that it is unnecessarily generated. This introduces an overload to validate_path_against_process_veil(), which takes a Custody const& and only generates the absolute path if it there is actually a veil and it is thus needed. This patch results in a speed up of Assistant's file system cache building by around 16 percent.
This commit is contained in:
parent
557424a141
commit
3c0272126e
2 changed files with 10 additions and 2 deletions
|
@ -838,6 +838,13 @@ UnveilNode const& VFS::find_matching_unveiled_path(StringView path)
|
||||||
return unveil_root.traverse_until_last_accessible_node(path_parts.begin(), path_parts.end());
|
return unveil_root.traverse_until_last_accessible_node(path_parts.begin(), path_parts.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KResult VFS::validate_path_against_process_veil(Custody const& custody, int options)
|
||||||
|
{
|
||||||
|
if (Process::current()->veil_state() == VeilState::None)
|
||||||
|
return KSuccess;
|
||||||
|
return validate_path_against_process_veil(custody.absolute_path(), options);
|
||||||
|
}
|
||||||
|
|
||||||
KResult VFS::validate_path_against_process_veil(StringView path, int options)
|
KResult VFS::validate_path_against_process_veil(StringView path, int options)
|
||||||
{
|
{
|
||||||
if (Process::current()->veil_state() == VeilState::None)
|
if (Process::current()->veil_state() == VeilState::None)
|
||||||
|
@ -910,7 +917,7 @@ KResultOr<NonnullRefPtr<Custody>> VFS::resolve_path(StringView path, Custody& ba
|
||||||
return custody_or_error.error();
|
return custody_or_error.error();
|
||||||
|
|
||||||
auto& custody = custody_or_error.value();
|
auto& custody = custody_or_error.value();
|
||||||
if (auto result = validate_path_against_process_veil(custody->absolute_path(), options); result.is_error())
|
if (auto result = validate_path_against_process_veil(*custody, options); result.is_error())
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
return custody;
|
return custody;
|
||||||
|
@ -1009,7 +1016,7 @@ KResultOr<NonnullRefPtr<Custody>> VFS::resolve_path_without_veil(StringView path
|
||||||
if (!safe_to_follow_symlink(*child_inode, parent_metadata))
|
if (!safe_to_follow_symlink(*child_inode, parent_metadata))
|
||||||
return EACCES;
|
return EACCES;
|
||||||
|
|
||||||
if (auto result = validate_path_against_process_veil(custody->absolute_path(), options); result.is_error())
|
if (auto result = validate_path_against_process_veil(*custody, options); result.is_error())
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
auto symlink_target = child_inode->resolve_as_link(parent, out_parent, options, symlink_recursion_level + 1);
|
auto symlink_target = child_inode->resolve_as_link(parent, out_parent, options, symlink_recursion_level + 1);
|
||||||
|
|
|
@ -103,6 +103,7 @@ private:
|
||||||
friend class FileDescription;
|
friend class FileDescription;
|
||||||
|
|
||||||
UnveilNode const& find_matching_unveiled_path(StringView path);
|
UnveilNode const& find_matching_unveiled_path(StringView path);
|
||||||
|
KResult validate_path_against_process_veil(Custody const& path, int options);
|
||||||
KResult validate_path_against_process_veil(StringView path, int options);
|
KResult validate_path_against_process_veil(StringView path, int options);
|
||||||
|
|
||||||
bool is_vfs_root(InodeIdentifier) const;
|
bool is_vfs_root(InodeIdentifier) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue