Directory.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <Kernel/FileSystem/SysFS/RootDirectory.h>
  7. #include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/BlockDevicesDirectory.h>
  8. #include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/CharacterDevicesDirectory.h>
  9. #include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/Directory.h>
  10. #include <Kernel/Sections.h>
  11. namespace Kernel {
  12. static SysFSDeviceIdentifiersDirectory* s_the { nullptr };
  13. SysFSDeviceIdentifiersDirectory& SysFSDeviceIdentifiersDirectory::the()
  14. {
  15. VERIFY(s_the);
  16. return *s_the;
  17. }
  18. UNMAP_AFTER_INIT NonnullRefPtr<SysFSDeviceIdentifiersDirectory> SysFSDeviceIdentifiersDirectory::must_create(SysFSRootDirectory const& root_directory)
  19. {
  20. auto devices_directory = adopt_ref_if_nonnull(new SysFSDeviceIdentifiersDirectory(root_directory)).release_nonnull();
  21. MUST(devices_directory->m_child_components.with([&](auto& list) -> ErrorOr<void> {
  22. list.append(SysFSBlockDevicesDirectory::must_create(*devices_directory));
  23. list.append(SysFSCharacterDevicesDirectory::must_create(*devices_directory));
  24. return {};
  25. }));
  26. s_the = devices_directory;
  27. return devices_directory;
  28. }
  29. SysFSDeviceIdentifiersDirectory::SysFSDeviceIdentifiersDirectory(SysFSRootDirectory const& root_directory)
  30. : SysFSDirectory(root_directory)
  31. {
  32. }
  33. }