mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:38:11 +00:00
Kernel/SysFS: Migrate components code from SysFS.cpp to the SysFS folder
This commit is contained in:
parent
4d05a41b30
commit
23c1c40e86
29 changed files with 496 additions and 286 deletions
42
Kernel/FileSystem/SysFS/RootDirectory.cpp
Normal file
42
Kernel/FileSystem/SysFS/RootDirectory.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <Kernel/FileSystem/SysFS/Registry.h>
|
||||
#include <Kernel/FileSystem/SysFS/RootDirectory.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Bus/Directory.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Devices/Directory.h>
|
||||
#include <Kernel/Sections.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
NonnullRefPtr<SysFSRootDirectory> SysFSRootDirectory::create()
|
||||
{
|
||||
return adopt_ref(*new (nothrow) SysFSRootDirectory);
|
||||
}
|
||||
|
||||
ErrorOr<void> SysFSRootDirectory::traverse_as_directory(FileSystemID fsid, Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)> callback) const
|
||||
{
|
||||
MutexLocker locker(SysFSComponentRegistry::the().get_lock());
|
||||
TRY(callback({ ".", { fsid, component_index() }, 0 }));
|
||||
TRY(callback({ "..", { fsid, 0 }, 0 }));
|
||||
|
||||
for (auto const& component : m_components) {
|
||||
InodeIdentifier identifier = { fsid, component.component_index() };
|
||||
TRY(callback({ component.name(), identifier, 0 }));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
SysFSRootDirectory::SysFSRootDirectory()
|
||||
{
|
||||
auto buses_directory = SysFSBusDirectory::must_create(*this);
|
||||
auto devices_directory = SysFSDevicesDirectory::must_create(*this);
|
||||
m_components.append(buses_directory);
|
||||
m_components.append(devices_directory);
|
||||
m_buses_directory = buses_directory;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue