mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-01 20:17:13 +02:00
Kernel/SysFS: Mark SysFSDirectory traverse and lookup methods as final
This enforces us to remove duplicated code across the SysFS code. This results in great simplification of how the SysFS works now, because we enforce one way to treat SysFSDirectory objects.
This commit is contained in:
Notes:
sideshowbarker
2024-07-17 16:23:55 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/70afa0b171 Pull-request: https://github.com/SerenityOS/serenity/pull/13779
@@ -28,31 +28,4 @@ SysFSBlockDevicesDirectory& SysFSBlockDevicesDirectory::the()
|
||||
return *s_the;
|
||||
}
|
||||
|
||||
ErrorOr<void> SysFSBlockDevicesDirectory::traverse_as_directory(FileSystemID fsid, Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)> callback) const
|
||||
{
|
||||
VERIFY(m_parent_directory);
|
||||
TRY(callback({ "."sv, { fsid, component_index() }, 0 }));
|
||||
TRY(callback({ ".."sv, { fsid, m_parent_directory->component_index() }, 0 }));
|
||||
|
||||
return m_devices_list.with([&](auto& list) -> ErrorOr<void> {
|
||||
for (auto& exposed_device : list) {
|
||||
VERIFY(exposed_device.is_block_device());
|
||||
TRY(callback({ exposed_device.name(), { fsid, exposed_device.component_index() }, 0 }));
|
||||
}
|
||||
return {};
|
||||
});
|
||||
}
|
||||
|
||||
RefPtr<SysFSComponent> SysFSBlockDevicesDirectory::lookup(StringView name)
|
||||
{
|
||||
return m_devices_list.with([&](auto& list) -> RefPtr<SysFSComponent> {
|
||||
for (auto& exposed_device : list) {
|
||||
VERIFY(exposed_device.is_block_device());
|
||||
if (exposed_device.name() == name)
|
||||
return exposed_device;
|
||||
}
|
||||
return nullptr;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user