2022-04-22 12:46:19 +03:00
|
|
|
/*
|
|
|
|
* 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>
|
2022-04-22 15:51:45 +03:00
|
|
|
#include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/Directory.h>
|
2022-04-22 12:46:19 +03:00
|
|
|
#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
|
|
|
|
{
|
2022-04-23 00:26:36 +03:00
|
|
|
MutexLocker locker(m_traverse_lock);
|
2022-07-11 20:32:29 +03:00
|
|
|
TRY(callback({ "."sv, { fsid, component_index() }, 0 }));
|
|
|
|
TRY(callback({ ".."sv, { fsid, 0 }, 0 }));
|
2022-04-22 12:46:19 +03:00
|
|
|
|
|
|
|
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);
|
2022-04-22 15:51:45 +03:00
|
|
|
auto device_identifiers_directory = SysFSDeviceIdentifiersDirectory::must_create(*this);
|
2022-04-22 12:46:19 +03:00
|
|
|
m_components.append(buses_directory);
|
2022-04-22 15:51:45 +03:00
|
|
|
m_components.append(device_identifiers_directory);
|
2022-04-22 12:46:19 +03:00
|
|
|
m_buses_directory = buses_directory;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|