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/RootDirectory.h>
|
2022-04-22 15:51:45 +03:00
|
|
|
#include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/BlockDevicesDirectory.h>
|
|
|
|
|
#include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/CharacterDevicesDirectory.h>
|
|
|
|
|
#include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/Directory.h>
|
2022-04-22 12:46:19 +03:00
|
|
|
#include <Kernel/Sections.h>
|
|
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
2022-04-23 11:48:40 +03:00
|
|
|
static SysFSDeviceIdentifiersDirectory* s_the { nullptr };
|
|
|
|
|
|
|
|
|
|
SysFSDeviceIdentifiersDirectory& SysFSDeviceIdentifiersDirectory::the()
|
|
|
|
|
{
|
|
|
|
|
VERIFY(s_the);
|
|
|
|
|
return *s_the;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-19 20:53:40 +02:00
|
|
|
UNMAP_AFTER_INIT NonnullLockRefPtr<SysFSDeviceIdentifiersDirectory> SysFSDeviceIdentifiersDirectory::must_create(SysFSRootDirectory const& root_directory)
|
2022-04-22 12:46:19 +03:00
|
|
|
{
|
2022-08-19 20:53:40 +02:00
|
|
|
auto devices_directory = adopt_lock_ref_if_nonnull(new SysFSDeviceIdentifiersDirectory(root_directory)).release_nonnull();
|
2022-04-23 01:06:37 +03:00
|
|
|
MUST(devices_directory->m_child_components.with([&](auto& list) -> ErrorOr<void> {
|
|
|
|
|
list.append(SysFSBlockDevicesDirectory::must_create(*devices_directory));
|
|
|
|
|
list.append(SysFSCharacterDevicesDirectory::must_create(*devices_directory));
|
|
|
|
|
return {};
|
|
|
|
|
}));
|
2022-04-23 11:48:40 +03:00
|
|
|
s_the = devices_directory;
|
2022-04-22 12:46:19 +03:00
|
|
|
return devices_directory;
|
|
|
|
|
}
|
2022-04-22 15:51:45 +03:00
|
|
|
SysFSDeviceIdentifiersDirectory::SysFSDeviceIdentifiersDirectory(SysFSRootDirectory const& root_directory)
|
2022-04-22 12:46:19 +03:00
|
|
|
: SysFSDirectory(root_directory)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|